:root {
  --bg: #0d0f12;
  --bg-2: #12151a;
  --panel: #171b21;
  --panel-2: #1d222a;
  --line: #262c36;
  --line-soft: #1e242e;
  --text: #e8ebf0;
  --text-2: #b6bdc7;
  --muted: #7f8896;
  --accent: #e8a33d;
  --accent-ink: #151008;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  background: var(--bg); color: var(--text);
  font-family: "Inter", -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 15px; line-height: 1.6; height: 100vh; overflow: hidden;
}
.hidden { display: none !important; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

/* ---------- login ---------- */
.login-screen { height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-card { text-align: center; max-width: 320px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
.brand-dot { width: 12px; height: 12px; border-radius: 4px; background: var(--accent); display: inline-block; }
.login-card p { color: var(--muted); margin: 10px 0 28px; }
.btn-primary {
  display: inline-block; background: var(--accent); color: var(--accent-ink);
  padding: 10px 22px; border-radius: 8px; font-weight: 600; border: none; cursor: pointer; font-size: 14.5px;
}
.btn-primary:hover { filter: brightness(1.1); }
.login-note { margin-top: 18px; font-size: 12.5px; }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: 264px 1fr; height: 100vh; }
.sidebar {
  background: var(--bg-2); border-right: 1px solid var(--line-soft);
  display: flex; flex-direction: column; padding: 14px 12px; gap: 10px; overflow: hidden;
}
.side-brand { font-size: 18px; font-weight: 700; display: flex; align-items: center; gap: 8px; padding: 2px 6px 8px; }
.new-btn {
  background: var(--accent); color: var(--accent-ink); border: none; border-radius: 7px;
  padding: 8px 12px; font-weight: 600; font-size: 13.5px; cursor: pointer; text-align: left;
}
.new-btn:hover { filter: brightness(1.1); }
.search-box {
  background: var(--panel); border: 1px solid var(--line); border-radius: 7px;
  color: var(--text); padding: 7px 10px; font-size: 13px; outline: none; width: 100%;
}
.search-box:focus { border-color: var(--accent); }
.search-results {
  background: var(--panel); border: 1px solid var(--line); border-radius: 7px;
  max-height: 240px; overflow-y: auto; position: absolute; z-index: 30; width: 228px;
}
.search-results a { display: block; padding: 7px 10px; font-size: 13px; color: var(--text-2); border-bottom: 1px solid var(--line-soft); }
.search-results a:hover { background: var(--panel-2); }
.tree { flex: 1; overflow-y: auto; font-size: 13.5px; }
.tree-item { display: flex; align-items: center; gap: 4px; padding: 5px 8px; border-radius: 6px; cursor: pointer; color: var(--text-2); white-space: nowrap; overflow: hidden; }
.tree-item:hover { background: var(--panel); }
.tree-item.active { background: var(--panel-2); color: var(--text); font-weight: 600; }
.tree-item .t-arrow { width: 14px; flex: none; font-size: 10px; color: var(--muted); cursor: pointer; }
.tree-item .t-title { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.tree-item .t-add { flex: none; opacity: 0; font-size: 13px; color: var(--muted); padding: 0 3px; }
.tree-item:hover .t-add { opacity: 1; }
.tree-empty { color: var(--muted); font-size: 13px; padding: 10px 8px; }
.side-footer { display: flex; flex-wrap: wrap; gap: 4px 12px; border-top: 1px solid var(--line-soft); padding-top: 10px; font-size: 12.5px; color: var(--muted); }
.side-footer a:hover { color: var(--text); }
.user-name { color: var(--accent); }

.main { display: flex; flex-direction: column; overflow: hidden; }
.editor-pane { display: flex; flex-direction: column; height: 100%; }
.topbar { display: flex; align-items: center; gap: 10px; padding: 10px 18px; border-bottom: 1px solid var(--line-soft); }
.icon-btn { display: none; background: none; border: none; color: var(--text); font-size: 18px; cursor: pointer; }
.title-input {
  flex: 1; background: none; border: none; color: var(--text); font-size: 20px; font-weight: 700;
  outline: none; letter-spacing: -.01em;
}
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.ghost-btn {
  background: var(--panel); border: 1px solid var(--line); color: var(--text-2);
  padding: 6px 12px; border-radius: 7px; font-size: 13px; cursor: pointer;
}
.ghost-btn:hover { color: var(--text); border-color: var(--muted); }
.save-indicator { font-size: 12px; color: var(--muted); min-width: 44px; text-align: right; }

.toolbar { display: flex; flex-wrap: wrap; gap: 3px; padding: 6px 14px; border-bottom: 1px solid var(--line-soft); background: var(--bg-2); }
.toolbar button {
  background: none; border: none; color: var(--text-2); min-width: 28px; height: 28px;
  border-radius: 5px; font-size: 12.5px; cursor: pointer; padding: 0 6px;
}
.toolbar button:hover { background: var(--panel-2); color: var(--text); }
.toolbar .sep { width: 1px; background: var(--line); margin: 3px 5px; }

.editor { flex: 1; overflow-y: auto; padding: 28px 8px 120px; }
.rote-prose { max-width: 760px; margin: 0 auto; outline: none; padding: 0 24px; }
.rote-prose p { margin: 8px 0; color: var(--text-2); }
.rote-prose h1, .rote-prose h2, .rote-prose h3 { margin: 22px 0 10px; letter-spacing: -.015em; }
.rote-prose h1 { font-size: 30px; } .rote-prose h2 { font-size: 24px; } .rote-prose h3 { font-size: 19px; }
.rote-prose ul, .rote-prose ol { padding-left: 24px; margin: 8px 0; color: var(--text-2); }
.rote-prose li { margin: 4px 0; }
.rote-prose li p { margin: 0; }
.rote-prose blockquote { border-left: 3px solid var(--accent); padding: 4px 14px; margin: 12px 0; color: var(--muted); background: var(--panel); border-radius: 0 6px 6px 0; }
.rote-prose code { background: var(--panel-2); border: 1px solid var(--line); border-radius: 4px; padding: 1px 6px; font-size: 13px; font-family: ui-monospace, Consolas, monospace; }
.rote-prose pre { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; margin: 12px 0; overflow-x: auto; }
.rote-prose pre code { background: none; border: none; padding: 0; }
.rote-prose mark { background: rgba(232,163,61,.3); color: var(--text); border-radius: 3px; padding: 0 2px; }
.rote-prose img { max-width: 100%; border-radius: 8px; border: 1px solid var(--line); }
.rote-prose table { border-collapse: collapse; margin: 14px 0; width: 100%; font-size: 14px; }
.rote-prose th, .rote-prose td { border: 1px solid var(--line); padding: 7px 12px; text-align: left; color: var(--text-2); }
.rote-prose th { background: var(--panel); color: var(--text); }
.rote-prose ul[data-type="taskList"] { list-style: none; padding-left: 6px; }
.rote-prose ul[data-type="taskList"] li { display: flex; gap: 8px; align-items: flex-start; }
.rote-prose a { color: var(--accent); text-decoration: underline; }
.rote-prose p.is-editor-empty:first-child::before {
  content: attr(data-placeholder); color: var(--muted); float: left; height: 0; pointer-events: none;
}

.empty-pane { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; color: var(--muted); }
.empty-pane h2 { font-size: 18px; color: var(--text-2); }
.trash-pane { flex: 1; overflow-y: auto; padding: 28px 40px; }
.trash-pane h2 { margin-bottom: 16px; }
.trash-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 8px; background: var(--panel); }
.trash-item .tt { flex: 1; font-size: 14px; }
.trash-item .td { font-size: 12px; color: var(--muted); }
.trash-item button { background: none; border: 1px solid var(--line); color: var(--text-2); border-radius: 6px; padding: 4px 10px; font-size: 12.5px; cursor: pointer; }
.trash-item button:hover { border-color: var(--muted); color: var(--text); }

/* ---------- modals ---------- */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 24px; width: 420px; max-width: 92vw; max-height: 80vh; overflow-y: auto; }
.modal-card h3 { margin-bottom: 14px; }
.modal-card label { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 12px; }
.modal-card input[type="text"], .modal-card input:not([type]) { width: 100%; background: var(--bg-2); border: 1px solid var(--line); border-radius: 7px; color: var(--text); padding: 8px 10px; font-size: 14px; margin-top: 4px; outline: none; }
.modal-card input[type="color"] { width: 100%; height: 36px; border: 1px solid var(--line); border-radius: 7px; background: none; margin-top: 4px; }
.modal-actions { display: flex; gap: 10px; margin-top: 18px; }
.share-row { display: flex; gap: 8px; margin: 14px 0; }
.share-row input { flex: 1; background: var(--bg-2); border: 1px solid var(--line); border-radius: 7px; color: var(--muted); padding: 8px 10px; font-size: 13px; }
.hist-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-bottom: 1px solid var(--line-soft); }
.hist-item .ht { flex: 1; font-size: 13.5px; }
.hist-item .hd { font-size: 12px; color: var(--muted); }
.hist-item button { background: none; border: 1px solid var(--line); color: var(--accent); border-radius: 6px; padding: 3px 10px; font-size: 12.5px; cursor: pointer; }

@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 40% 0 0; z-index: 60; transform: translateX(-105%); transition: transform .2s; }
  .sidebar.open { transform: none; }
  .icon-btn { display: block; }
  .search-results { width: auto; left: 12px; right: 12px; }
}
