.history-overlay {
  position: absolute;
  top: 48px;
  left: 80px;
  min-width: 320px;
  max-width: 480px;
  max-height: 70vh;
  overflow-y: auto;
  background: var(--panel2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.18);
  padding: 18px 20px 14px 20px;
  z-index: 1001;
  font-size: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.history-overlay strong { font-size: 15px; }
.history-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.history-version {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 9px 10px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 3px 10px;
  background: rgba(255,255,255,.025);
  color: var(--text);
  text-align: left;
}
.history-version:hover {
  border-color: var(--accent);
  background: rgba(110,168,254,.1);
}
.history-version.autosave {
  border-color: rgba(147,160,178,.28);
  background: rgba(255,255,255,.015);
  color: rgba(238,242,248,.78);
}
.history-version.autosave:hover {
  border-color: rgba(110,168,254,.5);
  background: rgba(110,168,254,.07);
}
.history-version-date {
  font-size: 13px;
  font-weight: 700;
}
.history-version-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}
.history-badge {
  border: 1px solid rgba(147,160,178,.35);
  border-radius: 999px;
  padding: 1px 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}
.history-version-excerpt {
  min-width: 0;
  grid-column: 1 / -1;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.history-empty {
  color: var(--muted);
}
.history-autosaves {
  border-top: 1px solid var(--border);
  padding-top: 8px;
}
.history-autosaves summary {
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
}
.history-autosaves .history-list {
  margin-top: 8px;
}
.history-overlay .close-btn {
  position: absolute;
  top: 6px;
  right: 10px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 18px;
  cursor: pointer;
}
.history-overlay[hidden] { display: none !important; }
:root {
  --bg: #10131a;
  --panel: #151a23;
  --panel2: #1d2430;
  --text: #eef2f8;
  --muted: #93a0b2;
  --border: #2d3748;
  --accent: #6ea8fe;
  --danger: #ff6b6b;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
* {
  scrollbar-width: thin;
  scrollbar-color: #506078 transparent;
}
*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
*::-webkit-scrollbar-track {
  background: transparent;
}
*::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 999px;
  background: #506078;
  background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover {
  background: #6a7b96;
  background-clip: padding-box;
}
*::-webkit-scrollbar-corner {
  background: transparent;
}
body { margin: 0; font-family: Inter, system-ui, Segoe UI, Arial, sans-serif; background: var(--bg); color: var(--text); }
.app { display: grid; grid-template-columns: 330px 1fr; min-height: 100vh; }
.sidebar { background: var(--panel); border-right: 1px solid var(--border); padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.brand {
  width: 100%;
  line-height: 0;
}
.brand img {
  display: block;
  width: min(100%, 280px);
  height: auto;
}
.search, input, select { width: 100%; background: var(--panel2); color: var(--text); border: 1px solid var(--border); border-radius: 10px; padding: 11px 12px; outline: none; }
.search:focus, input:focus, select:focus { border-color: var(--accent); }
input[readonly] { color: var(--muted); cursor: default; }
button { border: 0; border-radius: 10px; padding: 11px 14px; cursor: pointer; font-weight: 700; color: var(--text); background: var(--panel2); }
button.primary { background: var(--accent); color: #08111f; }
button.danger { background: transparent; color: var(--danger); border: 1px solid rgba(255,107,107,.4); }
.article-list { overflow: auto; display: flex; flex-direction: column; gap: 2px; padding-right: 4px; }
.article-card { border: 1px solid var(--border); border-radius: 14px; padding: 12px; background: rgba(255,255,255,.025); cursor: pointer; }
.article-card:hover, .article-card.active { border-color: var(--accent); background: rgba(110,168,254,.08); }
.article-title { font-weight: 800; margin-bottom: 5px; }
.article-meta { color: var(--muted); font-size: 12px; display: flex; gap: 8px; flex-wrap: wrap; }
.tree-row {
  width: 100%;
  min-height: 30px;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 4px 8px 4px calc(8px + (var(--depth) * 18px));
  display: grid;
  grid-template-columns: 14px 18px minmax(0, 1fr);
  align-items: center;
  gap: 5px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  text-align: left;
}
.tree-row:hover,
.tree-row.active {
  border-color: rgba(110,168,254,.45);
  background: rgba(110,168,254,.11);
}
.tree-row:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.tree-folder {
  color: #dfe8f6;
}
.tree-file {
  min-height: 38px;
}
.tree-caret::before {
  content: "";
  display: block;
  width: 0;
  height: 0;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  border-left: 5px solid var(--muted);
  color: var(--muted);
  margin-left: 3px;
}
.tree-folder.open .tree-caret::before {
  transform: rotate(90deg);
}
.tree-icon {
  position: relative;
  width: 16px;
  height: 14px;
  display: block;
}
.tree-folder .tree-icon::before,
.tree-folder .tree-icon::after,
.tree-file .tree-icon::before,
.tree-file .tree-icon::after {
  content: "";
  position: absolute;
  display: block;
}
.tree-folder .tree-icon::before {
  left: 1px;
  top: 2px;
  width: 7px;
  height: 4px;
  border-radius: 2px 2px 0 0;
  background: #86b7ff;
}
.tree-folder .tree-icon::after {
  left: 0;
  top: 5px;
  width: 16px;
  height: 10px;
  border: 1px solid rgba(134,183,255,.85);
  border-radius: 2px;
  background: rgba(134,183,255,.18);
}
.tree-file .tree-icon::before {
  left: 3px;
  top: 0;
  width: 10px;
  height: 14px;
  border: 1px solid rgba(238,242,248,.68);
  border-radius: 2px;
  background: rgba(238,242,248,.08);
}
.tree-file .tree-icon::after {
  right: 3px;
  top: 1px;
  width: 4px;
  height: 4px;
  border-left: 1px solid rgba(238,242,248,.55);
  border-bottom: 1px solid rgba(238,242,248,.55);
  background: var(--panel);
}
.tree-content {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.tree-label,
.tree-meta {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tree-label {
  font-weight: 650;
}
.tree-meta {
  color: var(--muted);
  font-size: 11px;
  font-weight: 400;
}
.tree-empty {
  color: var(--muted);
  font-size: 13px;
  padding: 12px 8px;
}
.main { min-width: 0; display: flex; flex-direction: column; }
.toolbar { position: relative; z-index: 20; padding: 28px 24px 20px 24px; border-bottom: 1px solid var(--border); background: rgba(21,26,35,.85); backdrop-filter: blur(10px); display: flex; flex-direction: column; gap: 22px; }
.title { font-size: 18px; font-weight: 800; letter-spacing: -0.04em; margin-bottom: 14px; }
.read-toolbar { position: relative; display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.read-heading {
  display: flex;
  align-items: center;
  gap: 8px;
}
.read-title { margin: 0 0 4px; font-size: 26px; font-weight: 800; letter-spacing: 0; line-height: 1.2; }
.read-meta { color: var(--muted); font-size: 13px; }
.read-icon-btn {
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: none;
  color: var(--muted);
  font-size: 20px;
  font-weight: 400;
  line-height: 1;
}
.read-icon-btn:hover {
  background: rgba(110,168,254,.12);
  color: var(--text);
}
.meta-info-overlay {
  position: absolute;
  top: 48px;
  left: 32px;
  min-width: 220px;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 20px 14px 20px;
  box-shadow: 0 4px 24px 4px #222b38, 0 4px 24px rgba(0,0,0,0.18);
  background: #222b38;
  background-color: #222b38;
  backdrop-filter: none;
  pointer-events: auto;
  isolation: isolate;
  z-index: 2000;
  font-size: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.meta-info-overlay strong { font-size: 15px; }
.meta-info-overlay .meta-row { display: flex; gap: 8px; font-size: 13px; }
.meta-info-overlay .close-btn {
  position: absolute;
  top: 6px;
  right: 10px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 18px;
  cursor: pointer;
}
.meta-info-overlay[hidden] { display: none !important; }
.meta-row { display: grid; grid-template-columns: 1fr 1fr 1.4fr; gap: 18px; margin-bottom: 10px; }
.actions { display: flex; justify-content: flex-end; align-items: center; gap: 10px; }
#status { margin-right: auto; color: var(--muted); font-size: 13px; }
#editor { height: calc(100vh - 168px); background: var(--bg); color: var(--text); }
.reader-shell {
  position: relative;
  z-index: 0;
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: 2px;
  justify-content: stretch;
  height: calc(100vh - 86px);
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
}
.viewer {
  min-width: 0;
  overflow: auto;
  padding: 32px 24px 32px min(56px, 6vw);
  background: #111722;
}
.viewer .toastui-editor-contents {
  max-width: none;
  font-size: 16px;
  background: transparent !important;
}
.outline {
  overflow: auto;
  padding: 24px 16px 24px 12px;
  border-left: 1px solid var(--border);
  background: var(--bg);
}
.outline-link {
  width: 100%;
  border-radius: 4px;
  padding: 7px 8px 7px calc(8px + (var(--level) * 12px));
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  text-align: left;
}
.outline-link:hover {
  background: rgba(110,168,254,.12);
  color: var(--text);
}
.outline-empty {
  color: var(--muted);
  font-size: 13px;
  padding: 8px;
}
.toastui-editor-defaultUI {
  border: 0 !important;
  background: var(--bg) !important;
  color: var(--text) !important;
}
.toastui-editor-defaultUI-toolbar,
.toastui-editor-toolbar,
.toastui-editor-md-tab-container,
.toastui-editor-mode-switch {
  border-color: var(--border) !important;
  background: var(--panel) !important;
}
.toastui-editor-defaultUI-toolbar button,
.toastui-editor-toolbar button,
.toastui-editor-mode-switch .tab-item {
  border-color: transparent !important;
  background-color: transparent !important;
  color: var(--text) !important;
}
.toastui-editor-defaultUI-toolbar button:hover,
.toastui-editor-toolbar button:hover,
.toastui-editor-mode-switch .tab-item:hover,
.toastui-editor-mode-switch .tab-item.active {
  border-color: rgba(110,168,254,.45) !important;
  background-color: rgba(110,168,254,.12) !important;
}
.toastui-editor-defaultUI-toolbar button::after,
.toastui-editor-toolbar button::after {
  filter: invert(1) opacity(.9);
}
#editor .toastui-editor-main,
#editor .toastui-editor-md-container,
#editor .toastui-editor-md-preview,
#editor .toastui-editor-ww-container,
#editor .toastui-editor-contents,
#editor .toastui-editor-md-splitter {
  border-color: var(--border) !important;
  background: var(--bg) !important;
  color: var(--text) !important;
}
#editor .toastui-editor-md-preview,
#editor .toastui-editor-ww-container {
  background: #111722 !important;
}
#editor .toastui-editor-md-preview .toastui-editor-contents,
#editor .toastui-editor-ww-container .toastui-editor-contents,
.viewer .toastui-editor-contents {
  background: transparent !important;
}
#editor .toastui-editor-md-container .toastui-editor,
#editor .toastui-editor-md-container .ProseMirror,
#editor .toastui-editor-ww-container .ProseMirror {
  background: var(--bg) !important;
  color: var(--text) !important;
  height: calc(100% - 0px) !important;
}
#editor .toastui-editor-md-container .toastui-editor textarea,
#editor .toastui-editor-md-container .toastui-editor .toastui-editor-md-code,
#editor .toastui-editor-md-container .toastui-editor .toastui-editor-md-code-block-line-background,
#editor .toastui-editor-md-container .toastui-editor .toastui-editor-md-line {
  background: var(--bg) !important;
  color: var(--text) !important;
}
#editor .toastui-editor-md-container .toastui-editor .toastui-editor-md-code-block-line-background {
  background: var(--panel2) !important;
}
#editor .toastui-editor-md-container .toastui-editor .toastui-editor-md-marked-text,
#editor .toastui-editor-md-container .toastui-editor .toastui-editor-md-link,
#editor .toastui-editor-md-container .toastui-editor .toastui-editor-md-html {
  color: #a7d5ff !important;
}
#editor .toastui-editor-md-container .toastui-editor .toastui-editor-md-delimiter,
#editor .toastui-editor-md-container .toastui-editor .toastui-editor-md-list-marker {
  color: var(--muted) !important;
}
#editor .toastui-editor-md-container .toastui-editor .placeholder {
  color: var(--muted) !important;
}
#editor .toastui-editor-md-container .toastui-editor .toastui-editor-md-code,
#editor .toastui-editor-md-container .toastui-editor .toastui-editor-md-code-block {
  caret-color: var(--text);
}
#editor .toastui-editor-contents h1,
#editor .toastui-editor-contents h2,
#editor .toastui-editor-contents h3,
#editor .toastui-editor-contents h4,
#editor .toastui-editor-contents h5,
#editor .toastui-editor-contents h6,
#editor .toastui-editor-contents p,
#editor .toastui-editor-contents li,
#editor .toastui-editor-contents blockquote,
#editor .toastui-editor-contents table,
.viewer .toastui-editor-contents h1,
.viewer .toastui-editor-contents h2,
.viewer .toastui-editor-contents h3,
.viewer .toastui-editor-contents h4,
.viewer .toastui-editor-contents h5,
.viewer .toastui-editor-contents h6,
.viewer .toastui-editor-contents p,
.viewer .toastui-editor-contents li,
.viewer .toastui-editor-contents blockquote,
.viewer .toastui-editor-contents table {
  color: var(--text) !important;
}
#editor .toastui-editor-contents a,
.viewer .toastui-editor-contents a {
  color: var(--accent) !important;
}
#editor .toastui-editor-contents code,
#editor .toastui-editor-contents pre,
.viewer .toastui-editor-contents code,
.viewer .toastui-editor-contents pre {
  border-color: var(--border) !important;
  background: var(--panel2) !important;
  color: #f8fafc !important;
}
#editor .toastui-editor-contents blockquote,
.viewer .toastui-editor-contents blockquote {
  border-color: var(--accent) !important;
  background: rgba(110,168,254,.08) !important;
}
#editor .toastui-editor-contents th,
#editor .toastui-editor-contents td,
.viewer .toastui-editor-contents th,
.viewer .toastui-editor-contents td {
  border-color: var(--border) !important;
}
#editor .toastui-editor-contents th,
.viewer .toastui-editor-contents th {
  background: var(--panel2) !important;
}
#editor .toastui-editor-contents hr,
.viewer .toastui-editor-contents hr {
  border-color: var(--border) !important;
}
.toastui-editor-popup,
.toastui-editor-context-menu {
  border-color: var(--border) !important;
  background: var(--panel) !important;
  color: var(--text) !important;
}
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { min-height: 320px; border-right: 0; border-bottom: 1px solid var(--border); }
  .meta-row { grid-template-columns: 1fr; }
  .read-toolbar { align-items: flex-start; flex-direction: column; }
  .reader-shell { grid-template-columns: 1fr; height: 70vh; }
  .outline { display: none; }
  #editor { height: 70vh; }
}
