/* ============================================================
   CloudNote · 设计系统
   ============================================================ */

:root {
  --bg:            #f5f5fa;
  --bg-elev:       #ffffff;
  --bg-soft:       #eeeef7;
  --bg-hover:      rgba(99, 102, 241, .055);
  --bg-active:     #ffffff;

  --border:        rgba(24, 24, 60, .075);
  --border-strong: rgba(24, 24, 60, .13);

  --text:          #191926;
  --text-2:        #5a5a72;
  --text-3:        #9090a6;

  --accent:        #6366f1;
  --accent-2:      #a855f7;
  --accent-ink:    #4f46e5;
  --accent-soft:   rgba(99, 102, 241, .10);
  --accent-glow:   rgba(99, 102, 241, .28);

  --danger:        #ef4444;
  --danger-soft:   rgba(239, 68, 68, .10);
  --success:       #10b981;

  --shadow-xs: 0 1px 2px rgba(20, 20, 50, .05);
  --shadow-sm: 0 2px 8px -2px rgba(24, 24, 60, .10);
  --shadow:    0 10px 28px -12px rgba(24, 24, 60, .22);
  --shadow-lg: 0 24px 60px -20px rgba(24, 24, 60, .28);

  --r-sm: 8px;
  --r-md: 11px;
  --r-lg: 15px;
  --r-xl: 22px;

  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --mono: "SF Mono", "JetBrains Mono", ui-monospace, "Cascadia Code", Menlo, Consolas, monospace;

  --sidebar-w: 250px;
  --list-w: 330px;
}

[data-theme="dark"] {
  --bg:            #0d0d14;
  --bg-elev:       #15151f;
  --bg-soft:       #191922;
  --bg-hover:      rgba(255, 255, 255, .045);
  --bg-active:     #1e1e2b;

  --border:        rgba(255, 255, 255, .075);
  --border-strong: rgba(255, 255, 255, .14);

  --text:          #e9e9f2;
  --text-2:        #a2a2bb;
  --text-3:        #6b6b84;

  --accent:        #818cf8;
  --accent-2:      #c084fc;
  --accent-ink:    #a5b4fc;
  --accent-soft:   rgba(129, 140, 248, .16);
  --accent-glow:   rgba(129, 140, 248, .30);

  --danger:        #f87171;
  --danger-soft:   rgba(248, 113, 113, .14);

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, .35);
  --shadow-sm: 0 2px 10px -2px rgba(0, 0, 0, .45);
  --shadow:    0 12px 32px -14px rgba(0, 0, 0, .7);
  --shadow-lg: 0 28px 70px -24px rgba(0, 0, 0, .8);
}

* { box-sizing: border-box; }

/* 保证 hidden 属性始终生效（覆盖 class 上的 display） */
[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
  transition: background .3s ease, color .3s ease;
}

button, input, textarea, select { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; padding: 0; }
input, textarea { border: 0; background: none; outline: none; }
a { color: var(--accent-ink); }

::selection { background: var(--accent-soft); color: var(--text); }

.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.icon {
  width: 18px; height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
  display: block;
}
.icon.tiny { width: 13px; height: 13px; }

kbd {
  font-family: var(--sans);
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 5px;
  border-radius: 5px;
  background: var(--bg-hover);
  color: var(--text-3);
  border: 1px solid var(--border);
  letter-spacing: .02em;
}

/* ---------- 滚动条 ---------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 10px;
  border: 3px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--text-3); background-clip: content-box; }

/* ============================================================
   通用按钮
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  border-radius: var(--r-md);
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: .01em;
  transition: transform .16s cubic-bezier(.34,1.56,.64,1), background .18s, box-shadow .18s, color .18s;
  white-space: nowrap;
}
.btn:active { transform: scale(.975); }

.btn-primary {
  color: #fff;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  box-shadow: 0 4px 14px -4px var(--accent-glow), inset 0 1px 0 rgba(255,255,255,.18);
}
.btn-primary:hover { box-shadow: 0 8px 22px -6px var(--accent-glow), inset 0 1px 0 rgba(255,255,255,.22); }

.btn-ghost {
  background: var(--bg-hover);
  color: var(--text-2);
}
.btn-ghost:hover { background: var(--border); color: var(--text); }

.btn-danger { background: var(--danger); color: #fff; }

.btn-block { width: 100%; height: 44px; }

.ghost-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px; height: 30px;
  border-radius: var(--r-sm);
  color: var(--text-3);
  transition: background .16s, color .16s, transform .16s;
}
.ghost-icon:hover { background: var(--bg-hover); color: var(--text); }
.ghost-icon:active { transform: scale(.92); }
.ghost-icon.sm { width: 24px; height: 24px; }
.ghost-icon.sm .icon { width: 15px; height: 15px; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  border-radius: var(--r-sm);
  color: var(--text-3);
  transition: background .16s, color .16s, transform .16s;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.icon-btn:active { transform: scale(.9); }
.icon-btn.is-on { color: var(--accent); background: var(--accent-soft); }
.icon-btn.is-on .icon { fill: currentColor; fill-opacity: .18; }
.icon-btn.danger:hover { color: var(--danger); background: var(--danger-soft); }

.divider-v {
  width: 1px; height: 18px;
  background: var(--border);
  margin: 0 6px;
  flex: none;
}

/* ============================================================
   登录页
   ============================================================ */
.auth {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-columns: 1.05fr .95fr;
  background: var(--bg);
  overflow: hidden;
  z-index: 40;
}
.auth-glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  pointer-events: none;
  opacity: .55;
}
.auth-glow.g1 {
  width: 620px; height: 620px;
  background: radial-gradient(circle, rgba(99,102,241,.30), transparent 68%);
  top: -220px; left: -160px;
}
.auth-glow.g2 {
  width: 560px; height: 560px;
  background: radial-gradient(circle, rgba(168,85,247,.24), transparent 68%);
  bottom: -240px; left: 20%;
}

.auth-visual {
  position: relative;
  padding: 56px 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.auth-visual > * { width: 100%; max-width: 500px; }

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 14px 0;
}
.auth-visual .brand { padding: 0 0 38px; }
.brand-mark {
  width: 38px; height: 38px;
  border-radius: 11px;
  display: grid; place-items: center;
  box-shadow: 0 8px 20px -8px var(--accent-glow);
  flex: none;
}
.brand-mark svg { width: 100%; height: 100%; display: block; }
.brand-mark.sm { width: 30px; height: 30px; border-radius: 9px; }
.brand-text {
  font-size: 16.5px;
  font-weight: 700;
  letter-spacing: -.02em;
  line-height: 1.1;
}
.brand-text small {
  display: block;
  font-size: 10.5px;
  font-weight: 500;
  color: var(--text-3);
  letter-spacing: .12em;
  margin-top: 2px;
}
.brand-lg .brand-text { font-size: 19px; }

.auth-visual h1 {
  font-size: 52px;
  line-height: 1.18;
  letter-spacing: -.035em;
  font-weight: 700;
  margin: 0 0 18px;
}
.grad-text {
  background: linear-gradient(110deg, var(--accent) 10%, var(--accent-2) 60%, #ec4899 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.auth-sub {
  font-size: 14.5px;
  line-height: 1.85;
  color: var(--text-2);
  margin: 0 0 34px;
}

.auth-points { list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 14px; }
.auth-points li { display: flex; align-items: flex-start; gap: 12px; }
.pt-ico {
  width: 34px; height: 34px;
  border-radius: 10px;
  display: grid; place-items: center;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--accent);
  box-shadow: var(--shadow-xs);
  flex: none;
}
.pt-ico .icon { width: 16px; height: 16px; }
.auth-points b { display: block; font-size: 13.5px; font-weight: 600; margin-bottom: 2px; }
.auth-points em { font-style: normal; font-size: 12.5px; color: var(--text-3); }

.auth-cards {
  position: relative;
  height: 132px;
  margin-top: 4px;
}
.mini-card {
  position: absolute;
  width: 268px;
  padding: 14px 16px;
  border-radius: var(--r-lg);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  font-size: 11.5px;
  color: var(--text-2);
}
.mini-card .dot {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
  margin-right: 7px;
  vertical-align: middle;
}
.mini-card .dot.alt { background: var(--accent-2); }
.mini-card .line {
  height: 6px;
  border-radius: 3px;
  background: var(--bg-soft);
  margin-top: 9px;
}
.mini-card .w80 { width: 80%; }
.mini-card .w70 { width: 70%; }
.mini-card .w60 { width: 60%; }
.mini-card .w50 { width: 50%; }
.mini-card.c1 { top: 0; left: 0; transform: rotate(-2.2deg); }
.mini-card.c2 { top: 52px; left: 196px; transform: rotate(2.4deg); }

.auth-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  background: linear-gradient(160deg, rgba(99,102,241,.045), transparent 60%);
  border-left: 1px solid var(--border);
}
[data-theme="dark"] .auth-panel { background: linear-gradient(160deg, rgba(255,255,255,.03), transparent 55%); }

.auth-card {
  width: 100%;
  max-width: 400px;
  padding: 30px 32px 26px;
  border-radius: var(--r-xl);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  animation: rise .5s cubic-bezier(.22,1,.36,1) both;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(14px) scale(.985); }
  to   { opacity: 1; transform: none; }
}

.auth-tabs {
  position: relative;
  display: flex;
  padding: 4px;
  background: var(--bg-soft);
  border-radius: var(--r-md);
  margin-bottom: 26px;
}
.auth-tab {
  position: relative;
  z-index: 1;
  flex: 1;
  height: 34px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-3);
  border-radius: var(--r-sm);
  transition: color .2s;
}
.auth-tab.active { color: var(--text); }
.auth-tab-indicator {
  position: absolute;
  top: 4px; left: 4px;
  width: calc(50% - 4px);
  height: calc(100% - 8px);
  background: var(--bg-elev);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-xs);
  transition: transform .3s cubic-bezier(.4,0,.2,1);
}
.auth-tabs[data-active="register"] .auth-tab-indicator { transform: translateX(100%); }

.field { display: block; margin-bottom: 16px; }
.field-label {
  display: block;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-3);
  letter-spacing: .04em;
  margin-bottom: 7px;
}
.field-wrap {
  display: flex;
  align-items: center;
  gap: 9px;
  height: 44px;
  padding: 0 12px;
  border-radius: var(--r-md);
  background: var(--bg-soft);
  border: 1px solid transparent;
  transition: border-color .18s, background .18s, box-shadow .18s;
}
.field-wrap:focus-within {
  background: var(--bg-elev);
  border-color: var(--accent);
  box-shadow: 0 0 0 3.5px var(--accent-soft);
}
.field-wrap .icon { width: 16px; height: 16px; color: var(--text-3); }
.field-wrap input { flex: 1; min-width: 0; font-size: 13.5px; }
.field-wrap input::placeholder { color: var(--text-3); }
.field-wrap .ghost-icon { margin-right: -5px; }

.auth-error {
  font-size: 12.5px;
  color: var(--danger);
  background: var(--danger-soft);
  padding: 9px 12px;
  border-radius: var(--r-sm);
  margin: 0 0 14px;
}
.auth-foot {
  text-align: center;
  font-size: 12.5px;
  color: var(--text-3);
  margin: 18px 0 0;
}
.link-btn {
  color: var(--accent-ink);
  font-weight: 600;
  font-size: 12.5px;
}
.link-btn:hover { text-decoration: underline; }
.auth-note {
  position: absolute;
  bottom: 26px;
  font-size: 11.5px;
  color: var(--text-2);
  opacity: .75;
  margin: 0;
}

.btn.is-loading { pointer-events: none; opacity: .75; }
.btn.is-loading .icon { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   主应用骨架
   ============================================================ */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) var(--list-w) minmax(0, 1fr);
  height: 100dvh;
  overflow: hidden;
}

/* ---------- 侧边栏 ---------- */
.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 0 12px 12px;
  background: var(--bg-soft);
  border-right: 1px solid var(--border);
  position: relative;
}

.sidebar-close { display: none; margin-left: auto; }

.btn-new {
  margin: 16px 2px 14px;
  height: 40px;
  justify-content: flex-start;
  padding: 0 12px;
  gap: 9px;
  font-size: 13px;
}
.btn-new kbd {
  margin-left: auto;
  background: rgba(255,255,255,.18);
  border-color: transparent;
  color: rgba(255,255,255,.85);
}

.nav { display: flex; flex-direction: column; gap: 1px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 36px;
  padding: 0 10px;
  border-radius: var(--r-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  transition: background .15s, color .15s;
  position: relative;
}
.nav-item .icon { width: 17px; height: 17px; color: var(--text-3); transition: color .15s; }
.nav-item:hover { background: var(--bg-hover); color: var(--text); }
.nav-item:hover .icon { color: var(--text-2); }
.nav-item.active {
  background: var(--bg-elev);
  color: var(--text);
  font-weight: 600;
  box-shadow: var(--shadow-xs);
}
.nav-item.active .icon { color: var(--accent); }
.nav-item .badge {
  margin-left: auto;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-3);
  background: var(--bg-hover);
  padding: 1px 6px;
  border-radius: 20px;
  min-width: 20px;
  text-align: center;
}
.nav-item.active .badge { background: var(--accent-soft); color: var(--accent-ink); }

.section { margin-top: 22px; min-height: 0; display: flex; flex-direction: column; }
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px 6px 10px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-3);
}
.notebooks { overflow-y: auto; display: flex; flex-direction: column; gap: 1px; }

.nb-item {
  display: flex;
  align-items: center;
  gap: 9px;
  height: 34px;
  padding: 0 10px;
  border-radius: var(--r-sm);
  font-size: 12.5px;
  color: var(--text-2);
  cursor: pointer;
  transition: background .15s, color .15s;
  position: relative;
}
.nb-item:hover { background: var(--bg-hover); color: var(--text); }
.nb-item.active { background: var(--bg-elev); color: var(--text); font-weight: 600; box-shadow: var(--shadow-xs); }
.nb-dot {
  width: 8px; height: 8px;
  border-radius: 3px;
  flex: none;
}
.nb-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nb-count { font-size: 10.5px; color: var(--text-3); margin-left: 2px; }
.nb-item .nb-more { opacity: 0; }
.nb-item:hover .nb-more { opacity: 1; }

.sidebar-foot {
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.foot-btn {
  display: flex;
  align-items: center;
  gap: 9px;
  height: 32px;
  padding: 0 10px;
  border-radius: var(--r-sm);
  font-size: 12.5px;
  color: var(--text-2);
  transition: background .15s;
}
.foot-btn:hover { background: var(--bg-hover); color: var(--text); }
.foot-btn .icon { width: 16px; height: 16px; color: var(--text-3); }

.user-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 6px;
  padding: 8px 6px 8px 8px;
  border-radius: var(--r-md);
  transition: background .15s;
}
.user-chip:hover { background: var(--bg-hover); }
.avatar {
  width: 28px; height: 28px;
  border-radius: 9px;
  display: grid; place-items: center;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  flex: none;
}
.user-meta { flex: 1; min-width: 0; line-height: 1.25; }
.user-meta b { display: block; font-size: 12px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-meta em { display: block; font-style: normal; font-size: 10.5px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- 列表栏 ---------- */
.list-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--bg);
  border-right: 1px solid var(--border);
}

.list-head { padding: 18px 18px 10px; flex: none; }
.list-title-row { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.list-title-row h2 {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -.02em;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.list-title-row .ghost-icon:last-child { margin-left: auto; }
.pill {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-3);
  background: var(--bg-soft);
  border-radius: 20px;
  padding: 2px 8px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 10px;
  border-radius: var(--r-md);
  background: var(--bg-soft);
  border: 1px solid transparent;
  transition: background .18s, border-color .18s, box-shadow .18s;
}
.search-box:focus-within {
  background: var(--bg-elev);
  border-color: var(--accent);
  box-shadow: 0 0 0 3.5px var(--accent-soft);
}
.search-box .icon { width: 15px; height: 15px; color: var(--text-3); }
.search-box input { flex: 1; min-width: 0; font-size: 12.5px; }
.search-box input::placeholder { color: var(--text-3); }
.search-box kbd { flex: none; }

.list-sort { display: flex; gap: 6px; margin-top: 10px; }
.chip {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-3);
  padding: 4px 10px;
  border-radius: 20px;
  transition: background .15s, color .15s;
}
.chip:hover { background: var(--bg-hover); color: var(--text-2); }
.chip.active { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }

.note-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 10px 20px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.note-card {
  position: relative;
  padding: 12px 12px 11px;
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background .15s, box-shadow .18s, transform .18s;
  border: 1px solid transparent;
}
.note-card:hover { background: var(--bg-hover); }
.note-card.active {
  background: var(--bg-elev);
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}
.note-card-head { display: flex; align-items: center; gap: 6px; margin-bottom: 3px; }
.note-card-title {
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: -.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}
.note-card.untitled .note-card-title { color: var(--text-3); font-weight: 500; }
.note-flag { color: var(--accent); display: flex; }
.note-flag .icon { width: 12px; height: 12px; }
.note-flag.star .icon { fill: currentColor; fill-opacity: .25; }
.note-card-excerpt {
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-3);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 0;
}
.note-card-foot {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 7px;
  font-size: 10.5px;
  color: var(--text-3);
}
.note-card-foot .sep { opacity: .5; }
.note-card-foot .nb-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.note-card-foot .nb-tag i {
  width: 6px; height: 6px;
  border-radius: 2px;
  flex: none;
}
.note-card-del {
  position: absolute;
  right: 8px; bottom: 8px;
  opacity: 0;
  display: flex;
  gap: 2px;
  transition: opacity .15s;
}
.note-card:hover .note-card-del { opacity: 1; }
.tiny-btn {
  width: 24px; height: 24px;
  border-radius: 6px;
  display: grid; place-items: center;
  color: var(--text-3);
  transition: background .15s, color .15s;
}
.tiny-btn:hover { background: var(--bg-soft); color: var(--text); }
.tiny-btn.danger:hover { color: var(--danger); background: var(--danger-soft); }
.tiny-btn .icon { width: 13px; height: 13px; }

/* ---------- 空状态 ---------- */
.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text-3);
  padding: 40px;
  text-align: center;
}
.empty-art { width: 110px; height: 110px; color: var(--text-3); opacity: .9; margin-bottom: 6px; }
.empty-art svg { width: 100%; height: 100%; display: block; }
.empty-art.lg { width: 150px; height: 132px; }
.empty-state p { margin: 0; font-size: 13.5px; font-weight: 600; color: var(--text-2); }
.empty-state small { font-size: 12px; }

/* ---------- 编辑器 ---------- */
.editor-pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--bg-elev);
  position: relative;
}
.editor-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--text-3);
}
.editor-empty h3 { font-size: 15px; font-weight: 600; color: var(--text-2); margin: 0; }
.editor-empty p { font-size: 12.5px; margin: 0; }

.editor { display: flex; flex-direction: column; height: 100%; min-height: 0; }

.editor-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 18px 4px;
  flex: none;
}
.title-input {
  flex: 1;
  min-width: 0;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -.03em;
  line-height: 1.3;
  padding: 2px 4px;
  border-radius: 6px;
  transition: background .15s;
}
.title-input::placeholder { color: var(--text-3); opacity: .55; font-weight: 600; }
.title-input:focus { background: var(--bg-hover); }

.editor-actions { display: flex; align-items: center; gap: 2px; flex: none; }

.editor-meta {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 22px 12px;
  font-size: 11.5px;
  color: var(--text-3);
  flex: none;
  flex-wrap: wrap;
}
.meta-item { display: inline-flex; align-items: center; gap: 5px; }
.meta-item .icon { width: 12px; height: 12px; }
.meta-dot { opacity: .5; }
.meta-notebook {
  padding: 2px 7px;
  border-radius: 6px;
  transition: background .15s, color .15s;
}
.meta-notebook:hover { background: var(--bg-hover); color: var(--text-2); }

.toolbar {
  display: flex;
  align-items: center;
  gap: 1px;
  padding: 7px 18px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  flex: none;
  background: var(--bg-elev);
}
.tool {
  width: 30px; height: 30px;
  border-radius: 7px;
  display: grid; place-items: center;
  color: var(--text-3);
  transition: background .15s, color .15s, transform .15s;
}
.tool:hover { background: var(--bg-hover); color: var(--text); }
.tool:active { transform: scale(.9); }
.tool .icon { width: 16px; height: 16px; }
.toolbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.mode-switch {
  display: flex;
  padding: 3px;
  background: var(--bg-soft);
  border-radius: 8px;
}
.mode {
  width: 28px; height: 24px;
  border-radius: 6px;
  display: grid; place-items: center;
  color: var(--text-3);
  transition: background .15s, color .15s;
}
.mode .icon { width: 14px; height: 14px; }
.mode:hover { color: var(--text-2); }
.mode.active { background: var(--bg-elev); color: var(--accent); box-shadow: var(--shadow-xs); }

.editor-body {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}
.editor-body.mode-edit { grid-template-columns: minmax(0, 1fr); }
.editor-body.mode-edit .preview { display: none; }
.editor-body.mode-preview { grid-template-columns: minmax(0, 1fr); }
.editor-body.mode-preview .editor-input { display: none; }

.editor-input {
  width: 100%;
  height: 100%;
  resize: none;
  padding: 20px 24px 60px;
  font-family: var(--mono);
  font-size: 13.5px;
  line-height: 1.85;
  color: var(--text-2);
  overflow-y: auto;
  tab-size: 2;
}
.editor-input::placeholder { color: var(--text-3); opacity: .7; }

.preview {
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px 30px 80px;
  border-left: 1px solid var(--border);
  min-width: 0;
}

.editor-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 34px;
  padding: 0 20px;
  border-top: 1px solid var(--border);
  font-size: 10.5px;
  color: var(--text-3);
  flex: none;
  background: var(--bg-elev);
}
.save-state { display: inline-flex; align-items: center; gap: 5px; }
.save-state .icon { width: 13px; height: 13px; color: var(--success); }
.save-state.saving .icon { color: var(--text-3); animation: spin .9s linear infinite; }
.save-state.dirty .icon { color: #f59e0b; }
.foot-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.tags { display: flex; gap: 5px; }
.tag-pill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 7px;
  border-radius: 20px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 10px;
  font-weight: 600;
}
.tag-pill .icon { width: 9px; height: 9px; }

/* ---------- Markdown 预览 ---------- */
.markdown-body {
  font-size: 14px;
  line-height: 1.85;
  color: var(--text-2);
  word-wrap: break-word;
}
.markdown-body > *:first-child { margin-top: 0; }
.markdown-body h1, .markdown-body h2, .markdown-body h3, .markdown-body h4 {
  color: var(--text);
  font-weight: 700;
  letter-spacing: -.02em;
  line-height: 1.35;
  margin: 1.6em 0 .6em;
}
.markdown-body h1 { font-size: 24px; }
.markdown-body h2 {
  font-size: 19px;
  padding-bottom: .3em;
  border-bottom: 1px solid var(--border);
}
.markdown-body h3 { font-size: 16px; }
.markdown-body h4 { font-size: 14.5px; }
.markdown-body p { margin: 0 0 1em; }
.markdown-body strong { color: var(--text); font-weight: 650; }
.markdown-body em { font-style: italic; }
.markdown-body del { color: var(--text-3); }
.markdown-body a { color: var(--accent-ink); text-decoration: none; border-bottom: 1px solid var(--accent-soft); }
.markdown-body a:hover { border-bottom-color: var(--accent); }
.markdown-body ul, .markdown-body ol { padding-left: 1.4em; margin: 0 0 1em; }
.markdown-body li { margin: .25em 0; }
.markdown-body li::marker { color: var(--text-3); }
.markdown-body input[type="checkbox"] {
  margin-right: 6px;
  accent-color: var(--accent);
  width: 13px; height: 13px;
}
.markdown-body blockquote {
  margin: 0 0 1em;
  padding: 2px 0 2px 14px;
  border-left: 3px solid var(--accent);
  color: var(--text-3);
  background: linear-gradient(90deg, var(--accent-soft), transparent 70%);
  border-radius: 0 6px 6px 0;
}
.markdown-body blockquote p:last-child { margin-bottom: 0; }
.markdown-body code {
  font-family: var(--mono);
  font-size: .88em;
  padding: .15em .4em;
  border-radius: 5px;
  background: var(--bg-soft);
  color: var(--accent-ink);
}
.markdown-body pre {
  max-width: 100%;
  margin: 0 0 1.2em;
  padding: 14px 16px;
  border-radius: var(--r-md);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  overflow-x: auto;
  line-height: 1.65;
}
.markdown-body pre code {
  background: none;
  padding: 0;
  color: var(--text-2);
  font-size: 12.5px;
}
.markdown-body hr {
  border: 0;
  height: 1px;
  background: var(--border);
  margin: 2em 0;
}
.markdown-body img { max-width: 100%; border-radius: var(--r-md); }
.markdown-body table {
  width: 100%;
  max-width: 100%;
  table-layout: fixed;
  word-break: break-word;
  border-collapse: collapse;
  margin: 0 0 1.2em;
  font-size: 13px;
}
.markdown-body th, .markdown-body td {
  border: 1px solid var(--border);
  padding: 7px 11px;
  text-align: left;
}
.markdown-body th { background: var(--bg-soft); font-weight: 600; color: var(--text); }
.markdown-body .task-list { list-style: none; padding-left: .2em; }

/* ============================================================
   弹层 / 菜单 / Toast
   ============================================================ */
.popover {
  position: fixed;
  z-index: 60;
  min-width: 190px;
  padding: 6px;
  border-radius: var(--r-md);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  animation: pop .16s cubic-bezier(.22,1,.36,1) both;
}
@keyframes pop {
  from { opacity: 0; transform: translateY(-5px) scale(.97); }
  to   { opacity: 1; transform: none; }
}
.menu-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  height: 32px;
  padding: 0 9px;
  border-radius: 7px;
  font-size: 12.5px;
  color: var(--text-2);
  text-align: left;
  transition: background .12s, color .12s;
}
.menu-item:hover { background: var(--bg-hover); color: var(--text); }
.menu-item .icon { width: 15px; height: 15px; color: var(--text-3); }
.menu-item.danger { color: var(--danger); }
.menu-item.danger .icon { color: var(--danger); }
.menu-item.danger:hover { background: var(--danger-soft); }
.menu-sep { height: 1px; background: var(--border); margin: 5px 4px; }
.menu-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .08em;
  color: var(--text-3);
  padding: 6px 9px 4px;
  text-transform: uppercase;
}
.color-row { display: flex; gap: 7px; padding: 6px 9px 8px; }
.color-dot {
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 2px solid transparent;
  transition: transform .15s;
}
.color-dot:hover { transform: scale(1.15); }
.color-dot.on { border-color: var(--text-2); }

.toast-wrap {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 90;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 15px;
  border-radius: 100px;
  background: var(--text);
  color: var(--bg-elev);
  font-size: 12.5px;
  font-weight: 500;
  box-shadow: var(--shadow);
  animation: toastIn .26s cubic-bezier(.22,1,.36,1) both;
}
[data-theme="dark"] .toast { background: var(--bg-elev); color: var(--text); border: 1px solid var(--border-strong); }
.toast .icon { width: 14px; height: 14px; }
.toast.out { animation: toastOut .2s ease forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px) scale(.95); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(6px) scale(.96); } }

.modal {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  background: rgba(16, 16, 32, .42);
  backdrop-filter: blur(3px);
  animation: fade .18s ease both;
  padding: 20px;
}
@keyframes fade { from { opacity: 0; } }
.modal-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  animation: rise .26s cubic-bezier(.22,1,.36,1) both;
  overflow: hidden;
}
.modal-head {
  display: flex;
  align-items: center;
  padding: 16px 18px 4px;
}
.modal-head h3 { margin: 0; font-size: 15px; font-weight: 650; flex: 1; }
.modal-body { padding: 12px 18px 4px; }
.modal-body p { margin: 0 0 12px; font-size: 13px; color: var(--text-2); line-height: 1.7; }
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 18px 18px;
}
.modal-foot .btn { height: 36px; padding: 0 14px; font-size: 12.5px; }
.modal-input {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border-radius: var(--r-sm);
  background: var(--bg-soft);
  border: 1px solid transparent;
  font-size: 13px;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.modal-input:focus {
  background: var(--bg-elev);
  border-color: var(--accent);
  box-shadow: 0 0 0 3.5px var(--accent-soft);
}

.scrim { display: none; }
.only-mobile { display: none; }

/* ============================================================
   响应式
   ============================================================ */
@media (max-width: 1180px) {
  :root { --sidebar-w: 226px; --list-w: 300px; }
  .auth-visual { padding: 40px 40px 30px; }
  .auth-visual h1 { font-size: 38px; }
}

@media (max-width: 980px) {
  .app { grid-template-columns: var(--list-w) minmax(0, 1fr); }
  .sidebar {
    position: fixed;
    top: 0; bottom: 0; left: 0;
    width: 268px;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform .28s cubic-bezier(.4,0,.2,1);
    box-shadow: var(--shadow-lg);
  }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .scrim {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(16,16,32,.36);
    z-index: 45;
    animation: fade .2s both;
  }
  .sidebar-close { display: inline-flex; }
  .only-mobile { display: inline-flex; }

  .auth { grid-template-columns: 1fr; }
  .auth-visual { display: none; }
  .auth-panel { padding: 24px; }
}

@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .list-pane { border-right: 0; }
  .editor-pane {
    position: fixed;
    inset: 0;
    z-index: 30;
    transform: translateX(100%);
    transition: transform .3s cubic-bezier(.32,.72,0,1);
  }
  body.editor-open .editor-pane { transform: none; }
  .editor-body { grid-template-columns: 1fr; }
  .editor-body:not(.mode-preview) .preview { display: none; }
  .editor-body.mode-preview .preview { border-left: 0; }
  .title-input { font-size: 19px; }
  .act-pin, .act-archive, .act-delete, .act-div { display: none; }
  .editor-head { padding: 12px 12px 2px; gap: 4px; }
  .search-box kbd { display: none; }
  #mode-switch .mode[data-mode="split"] { display: none; }
  .note-card { padding: 11px 12px 10px; }
  .note-list { gap: 0; }
  .note-card + .note-card { border-top: 1px solid var(--border); border-radius: 0; }
  .note-card.active { border-color: transparent; border-radius: var(--r-md); }
  .list-sort { overflow-x: auto; }
  .editor-input { padding: 16px 18px 60px; }
  .preview { padding: 16px 20px 60px; }
  .foot-hint { display: none; }
  .list-head { padding: 14px 14px 8px; }
  .note-list { padding: 4px 6px 20px; }
}

@media (max-width: 420px) {
  .auth-card { padding: 24px 20px 20px; border-radius: 18px; }
  .editor-actions .icon-btn:nth-child(3) { display: none; }
}

@media (hover: none) {
  .note-card-del { opacity: 1; }
  .nb-item .nb-more { opacity: 1; }
  .note-card:hover { background: transparent; }
  .note-card.active:hover { background: var(--bg-elev); }
  .sidebar { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
