/* ============================================================
   mem-rs — "Warm Paper" Design System
   Aesthetic: editorial analog meets digital precision.
   Warm sepia/cream light theme, deep charcoal-indigo dark theme.
   Typography: Roboto throughout (display/body), Roboto Mono meta; CJK falls back to system fonts.
   ============================================================ */

/* ── Fonts（自托管可变字体，仅 latin 子集：英文走 Roboto，
   中文落到栈里的系统字体，保持原样）───────────────────── */
@font-face {
  font-family: 'Roboto';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/fonts/roboto-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Roboto Mono';
  font-style: normal;
  font-weight: 100 700;
  font-display: swap;
  src: url('/fonts/roboto-mono-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ── Tokens ──────────────────────────────────────────────── */
:root {
  /* Brand accent — a rich terracotta/rust ink */
  --accent:        #c0572a;
  --accent-dim:    #9c3e18;
  --accent-soft:   rgba(192, 87, 42, 0.12);
  --accent-glow:   rgba(192, 87, 42, 0.22);

  /* Light palette — warm paper */
  --bg:            #f7f3ee;
  --bg-card:       #fdf9f5;
  --bg-overlay:    rgba(247, 243, 238, 0.92);
  --bg-input:      #fff8f0;
  --surface:       #ede7de;
  --surface-2:     #e0d8cd;
  --border:        #cfc6ba;
  --border-subtle: #e4ddd5;

  /* Text */
  --text-primary:   #1e1a16;
  --text-secondary: #6b5e52;
  --text-tertiary:  #9c8e82;
  --text-inverse:   #fdf9f5;
  --text-accent:    #c0572a;

  /* Status */
  --status-ok:      #3a7c52;
  --status-ok-bg:   rgba(58, 124, 82, 0.10);
  --status-warn:    #b07d20;
  --status-warn-bg: rgba(176, 125, 32, 0.12);
  --status-fail:    #b03030;
  --status-fail-rgb: 176, 48, 48;
  --status-fail-bg: rgba(176, 48, 48, 0.10);
  --status-pulse:   #b07d20;

  /* Typography */
  --font-display: 'Roboto', 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body:    'Roboto', 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono:    'Roboto Mono', 'SF Mono', 'Cascadia Code', 'Fira Mono', 'Courier New', monospace;

  /* Scale (fluid) */
  --text-xs:   0.70rem;
  --text-sm:   0.825rem;
  --text-base: 1rem;
  --text-md:   1.125rem;
  --text-lg:   1.35rem;
  --text-xl:   1.7rem;
  --text-2xl:  2.1rem;
  --text-3xl:  2.8rem;

  /* Spacing */
  --sp-1: 0.25rem;
  --sp-2: 0.5rem;
  --sp-3: 0.75rem;
  --sp-4: 1rem;
  --sp-5: 1.25rem;
  --sp-6: 1.5rem;
  --sp-8: 2rem;
  --sp-10: 2.5rem;
  --sp-12: 3rem;
  --sp-16: 4rem;

  /* Radius */
  --r-sm:   4px;
  --r-md:   8px;
  --r-lg:   14px;
  --r-xl:   22px;
  --r-full: 9999px;

  /* Shadows — warm tinted */
  --shadow-sm: 0 1px 3px rgba(100, 70, 40, 0.10), 0 1px 2px rgba(100, 70, 40, 0.06);
  --shadow-md: 0 4px 12px rgba(100, 70, 40, 0.13), 0 2px 4px rgba(100, 70, 40, 0.08);
  --shadow-lg: 0 10px 32px rgba(100, 70, 40, 0.16), 0 4px 10px rgba(100, 70, 40, 0.10);
  --shadow-accent: 0 4px 18px rgba(192, 87, 42, 0.28);

  /* Transitions */
  --t-fast:   100ms ease;
  --t-base:   200ms ease;
  --t-smooth: 320ms cubic-bezier(0.22, 1, 0.36, 1);
  --t-spring: 400ms cubic-bezier(0.34, 1.56, 0.64, 1);

  /* Layout */
  --max-w:       680px;
  --appbar-h:    56px;
  --fab-size:    56px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top:    env(safe-area-inset-top, 0px);
}

/* (A) 显式深色 —— 现代靛蓝 */
:root[data-theme="dark"] {
  color-scheme: dark;
  --accent:        #7c93ff;
  --accent-dim:    #5f78f0;
  --accent-soft:   rgba(124, 147, 255, 0.14);
  --accent-glow:   rgba(124, 147, 255, 0.24);

  --bg:            #16181d;
  --bg-card:       #1d2026;
  --bg-overlay:    rgba(22, 24, 29, 0.94);
  --bg-input:      #222530;
  --surface:       #262a33;
  --surface-2:     #30343f;
  --border:        #2f333d;
  --border-subtle: #24272e;

  --text-primary:   #e8eaed;
  --text-secondary: #a3aab8;
  --text-tertiary:  #6b7280;
  --text-inverse:   #11131a;
  --text-accent:    #9aabff;

  --status-ok:      #5aaa74;
  --status-ok-bg:   rgba(90, 170, 116, 0.12);
  --status-warn:    #d4a040;
  --status-warn-bg: rgba(212, 160, 64, 0.14);
  --status-fail:    #e06b6b;
  --status-fail-rgb: 224, 107, 107;
  --status-fail-bg: rgba(224, 107, 107, 0.12);

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.40), 0 1px 2px rgba(0, 0, 0, 0.28);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.50), 0 2px 4px rgba(0, 0, 0, 0.32);
  --shadow-lg: 0 10px 36px rgba(0, 0, 0, 0.60), 0 4px 12px rgba(0, 0, 0, 0.38);
  --shadow-accent: 0 4px 22px rgba(124, 147, 255, 0.35);
}

/* (B) 系统深色,且未显式选择主题 —— 同一组令牌 */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) {
    color-scheme: dark;
    --accent:        #7c93ff;
    --accent-dim:    #5f78f0;
    --accent-soft:   rgba(124, 147, 255, 0.14);
    --accent-glow:   rgba(124, 147, 255, 0.24);

    --bg:            #16181d;
    --bg-card:       #1d2026;
    --bg-overlay:    rgba(22, 24, 29, 0.94);
    --bg-input:      #222530;
    --surface:       #262a33;
    --surface-2:     #30343f;
    --border:        #2f333d;
    --border-subtle: #24272e;

    --text-primary:   #e8eaed;
    --text-secondary: #a3aab8;
    --text-tertiary:  #6b7280;
    --text-inverse:   #11131a;
    --text-accent:    #9aabff;

    --status-ok:      #5aaa74;
    --status-ok-bg:   rgba(90, 170, 116, 0.12);
    --status-warn:    #d4a040;
    --status-warn-bg: rgba(212, 160, 64, 0.14);
    --status-fail:    #e06b6b;
    --status-fail-rgb: 224, 107, 107;
    --status-fail-bg: rgba(224, 107, 107, 0.12);

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.40), 0 1px 2px rgba(0, 0, 0, 0.28);
    --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.50), 0 2px 4px rgba(0, 0, 0, 0.32);
    --shadow-lg: 0 10px 36px rgba(0, 0, 0, 0.60), 0 4px 12px rgba(0, 0, 0, 0.38);
    --shadow-accent: 0 4px 22px rgba(124, 147, 255, 0.35);
  }
}


/* ── Reset & Base ────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.6;
  color: var(--text-primary);
  background-color: var(--bg);
  min-height: 100dvh;
  min-height: 100vh;
  overflow-x: hidden;
  /* Subtle warm paper texture via CSS */
  background-image:
    radial-gradient(circle at 20% 20%, rgba(192, 87, 42, 0.022) 0%, transparent 60%),
    radial-gradient(circle at 80% 80%, rgba(120, 90, 50, 0.018) 0%, transparent 60%);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Paper grain overlay — purely decorative, non-intrusive */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.022;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='400' height='400'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='400' height='400' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
  background-size: 200px 200px;
}

#app {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  min-height: 100vh;
}

/* ── Typography ──────────────────────────────────────────── */
h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

h1 { font-size: var(--text-2xl); }
h2 { font-size: var(--text-xl); }
h3 { font-size: var(--text-lg); }

p { color: var(--text-secondary); line-height: 1.7; }

a {
  color: var(--text-accent);
  text-decoration: none;
  transition: opacity var(--t-fast);
}
a:hover { opacity: 0.75; text-decoration: underline; }

code, kbd, samp {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--surface);
  padding: 0.1em 0.38em;
  border-radius: var(--r-sm);
  color: var(--text-accent);
}

/* ── Base Controls ───────────────────────────────────────── */
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1;
  cursor: pointer;
  border: 1.5px solid transparent;
  border-radius: var(--r-md);
  padding: var(--sp-3) var(--sp-5);
  min-height: 44px;
  transition:
    background var(--t-base),
    color var(--t-base),
    border-color var(--t-base),
    box-shadow var(--t-base),
    transform var(--t-fast);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
button:active { transform: scale(0.97); }
button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

/* Primary button */
button.primary,
.btn-save {
  background: var(--accent);
  color: var(--text-inverse);
  border-color: var(--accent-dim);
  box-shadow: var(--shadow-sm);
}
button.primary:hover,
.btn-save:hover {
  background: var(--accent-dim);
  box-shadow: var(--shadow-accent);
}

/* Ghost / outline button */
button.ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border);
}
button.ghost:hover {
  background: var(--surface);
  color: var(--text-primary);
  border-color: var(--border-subtle);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="url"],
input:not([type]),
textarea {
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--text-primary);
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--sp-3) var(--sp-4);
  width: 100%;
  line-height: 1.5;
  transition:
    border-color var(--t-base),
    box-shadow var(--t-base),
    background var(--t-base);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
input:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  background: var(--bg-card);
}
input::placeholder,
textarea::placeholder {
  color: var(--text-tertiary);
}

/* ── 下拉选择框：纳入控件体系，与输入框同高同风格 + 自定义箭头 ── */
select {
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--text-primary);
  background-color: var(--bg-input);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239c8e82' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--sp-4) center;
  background-size: 16px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--sp-3) var(--sp-4);
  padding-right: calc(var(--sp-4) * 2 + 16px);
  width: 100%;
  min-height: 44px;
  line-height: 1.5;
  cursor: pointer;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  transition:
    border-color var(--t-base),
    box-shadow var(--t-base),
    background-color var(--t-base);
}
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  background-color: var(--bg-card);
}
/* 深色主题：箭头改用偏亮的蓝灰，确保在靛蓝底上清晰 */
:root[data-theme="dark"] select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238b93a7' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}
/* 原生下拉项列表（Windows / 部分浏览器需显式给色才跟随主题）*/
select option { color: var(--text-primary); background: var(--bg-card); }

/* ── Layout Container ────────────────────────────────────── */
.container {
  width: 100%;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 var(--sp-4);
}


/* ── App Bar ─────────────────────────────────────────────── */
.appbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: calc(var(--appbar-h) + var(--safe-top));
  padding-top: var(--safe-top);
  background: var(--bg-overlay);
  border-bottom: 1px solid var(--border-subtle);
  backdrop-filter: blur(12px) saturate(1.4);
  -webkit-backdrop-filter: blur(12px) saturate(1.4);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding-left: var(--sp-4);
  padding-right: var(--sp-4);
}

.appbar__title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.appbar__title span.accent {
  color: var(--accent);
}

.appbar__actions {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-shrink: 0;
}

/* Appbar icon buttons */
.btn-back,
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  min-height: unset;
  padding: 0;
  border-radius: var(--r-full);
  background: transparent;
  border-color: transparent;
  color: var(--text-secondary);
  font-size: var(--text-base);
  font-weight: 600;
}
.btn-back:hover,
.btn-icon:hover {
  background: var(--surface);
  color: var(--text-primary);
}
.btn-back {
  /* back arrow visual */
  font-size: var(--text-md);
}


/* ── Notes View ──────────────────────────────────────────── */
.notes-view {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  min-height: 100vh;
  padding-bottom: calc(var(--sp-16) + var(--safe-bottom));
}

/* Toolbar: search + tag filter */
.toolbar {
  position: sticky;
  top: calc(var(--appbar-h) + var(--safe-top));
  z-index: 90;
  background: var(--bg-overlay);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-subtle);
  padding: var(--sp-3) var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.search {
  position: relative;
  display: flex;
  align-items: center;
}

.search input {
  padding-left: calc(var(--sp-4) + 1.4rem);
  font-size: var(--text-sm);
  min-height: 40px;
}

.search::before {
  content: '⌕';
  position: absolute;
  left: var(--sp-3);
  font-size: 1.1rem;
  color: var(--text-tertiary);
  pointer-events: none;
  z-index: 1;
  line-height: 1;
}

/* Tag filter row */
.tag-filter {
  display: flex;
  gap: var(--sp-2);
  overflow-x: auto;
  padding-bottom: var(--sp-1);
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.tag-filter::-webkit-scrollbar { display: none; }

/* Notes list */
.note-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: var(--sp-3) var(--sp-4);
}

.note-item {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  padding: var(--sp-4) var(--sp-4);
  background: var(--bg-card);
  border-radius: var(--r-lg);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  transition:
    transform var(--t-smooth),
    box-shadow var(--t-smooth),
    border-color var(--t-base),
    background var(--t-base);
  position: relative;
  overflow: hidden;
  margin-bottom: var(--sp-2);
  /* Ink rule — accent left-border on hover */
  --item-border-w: 0px;
}

.note-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--item-border-w);
  background: var(--accent);
  border-radius: var(--r-sm) 0 0 var(--r-sm);
  transition: width var(--t-smooth);
}

.note-item:hover {
  transform: translateX(3px);
  box-shadow: var(--shadow-md);
  border-color: var(--border);
  --item-border-w: 3px;
}

.note-item:active {
  transform: translateX(1px) scale(0.995);
}

.note-summary {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.note-meta {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-wrap: wrap;
}

.note-meta time {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  letter-spacing: 0.03em;
}

.note-meta .chips {
  display: flex;
  gap: var(--sp-1);
  flex-wrap: wrap;
}

/* Empty state */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-4);
  padding: var(--sp-16) var(--sp-8);
  text-align: center;
  color: var(--text-tertiary);
}

.empty__icon {
  font-size: 3rem;
  opacity: 0.35;
  /* Gentle float animation */
  animation: float 4s ease-in-out infinite;
}

.empty__title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  color: var(--text-secondary);
  font-style: italic;
}

.empty__hint {
  font-size: var(--text-sm);
  color: var(--text-tertiary);
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-8px); }
}

/* Floating Action Button */
.fab {
  position: fixed;
  bottom: calc(var(--sp-6) + var(--safe-bottom));
  right: var(--sp-5);
  z-index: 200;
  width: var(--fab-size);
  height: var(--fab-size);
  min-height: unset;
  padding: 0;
  border-radius: var(--r-full);
  background: var(--accent);
  color: var(--text-inverse);
  border-color: var(--accent-dim);
  box-shadow: var(--shadow-accent), var(--shadow-lg);
  font-size: 1.6rem;
  font-weight: 400;
  line-height: 1;
  transition:
    transform var(--t-spring),
    box-shadow var(--t-smooth),
    background var(--t-base);
}

.fab:hover {
  transform: scale(1.08) rotate(12deg);
  box-shadow: var(--shadow-accent), var(--shadow-lg);
  background: var(--accent-dim);
}

.fab:active {
  transform: scale(0.94);
}

/* 移动端有底栏：FAB 抬到底栏之上，否则盖住"我"tab 并拦截其点击 */
@media (max-width: 899px) {
  .fab { bottom: calc(var(--sp-6) + 52px + var(--safe-bottom)); }
}


/* ── Chips / Tags ────────────────────────────────────────── */
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  padding: var(--sp-1) var(--sp-3);
  font-size: var(--text-xs);
  font-weight: 600;
  font-family: var(--font-body);
  letter-spacing: 0.02em;
  text-transform: lowercase;
  background: var(--surface);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-full);
  cursor: pointer;
  white-space: nowrap;
  transition:
    background var(--t-base),
    color var(--t-base),
    border-color var(--t-base),
    transform var(--t-fast);
  -webkit-tap-highlight-color: transparent;
  min-height: 28px;
}

.chip:hover {
  background: var(--surface-2);
  color: var(--text-primary);
  border-color: var(--border);
  transform: translateY(-1px);
}

.chip.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
  font-weight: 700;
}

/* Inline add-tag form */
.chip-add {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
}

.chip-add input {
  width: 90px;
  font-size: var(--text-xs);
  padding: 2px var(--sp-2);
  min-height: 28px;
  border-radius: var(--r-full);
  background: var(--surface);
  border-color: var(--border);
}

.chip-add input:focus {
  width: 130px;
  transition: width var(--t-smooth), border-color var(--t-base), box-shadow var(--t-base);
}

.chip-add button {
  padding: 2px var(--sp-3);
  min-height: 28px;
  border-radius: var(--r-full);
  font-size: var(--text-xs);
  background: var(--accent-soft);
  color: var(--accent);
  border-color: transparent;
}
.chip-add button:hover {
  background: var(--accent);
  color: var(--text-inverse);
}

/* ── Status Badges ───────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  padding: 2px var(--sp-2);
  font-size: var(--text-xs);
  font-family: var(--font-mono);
  font-weight: 600;
  letter-spacing: 0.04em;
  border-radius: var(--r-full);
  line-height: 1.5;
}

.badge::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.badge-ready {
  background: var(--status-ok-bg);
  color: var(--status-ok);
}
.badge-ready::before {
  background: var(--status-ok);
}

.badge-transcribing {
  background: var(--status-warn-bg);
  color: var(--status-warn);
}
.badge-transcribing::before {
  background: var(--status-warn);
  animation: badge-pulse 1.2s ease-in-out infinite;
}

.badge-failed {
  background: var(--status-fail-bg);
  color: var(--status-fail);
}
.badge-failed::before {
  background: var(--status-fail);
}

@keyframes badge-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.3; transform: scale(0.7); }
}


/* ── Editor View ─────────────────────────────────────────── */
.save-ind { font-size: var(--text-xs); color: var(--text-tertiary); white-space: nowrap; }
.save-ind.err { color: var(--status-fail); }

.editor-view {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  min-height: 100vh;
  /* safe-bottom 由吸底的 .editor-bottom 自行处理，这里只留滚动余量 */
  padding-bottom: var(--sp-8);
}

/* Editor action bar (save, del, preview toggle, etc.) */
.editor-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-overlay);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  flex-wrap: wrap;
}

/* Textarea */
.editor-text {
  display: block;
  width: 100%;
  flex: 1;
  min-height: 320px;
  resize: vertical;
  padding: var(--sp-5) var(--sp-5);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  line-height: 1.8;
  color: var(--text-primary);
  background: var(--bg);
  border: none;
  border-bottom: 1px solid var(--border-subtle);
  border-radius: 0;
  outline: none;
  transition: background var(--t-base);
  -webkit-appearance: none;
  appearance: none;
  caret-color: var(--accent);
}
.editor-text:focus {
  background: var(--bg-card);
  box-shadow: none;
  border-color: var(--border-subtle);
}

/* Markdown preview */
.editor-preview {
  padding: var(--sp-5) var(--sp-5);
  background: var(--bg-card);
  line-height: 1.75;
  font-size: var(--text-base);
  color: var(--text-primary);
  border-top: 1px solid var(--border-subtle);
}

/* Prose styles inside preview */
.editor-preview h1,
.editor-preview h2,
.editor-preview h3,
.editor-preview h4,
.editor-preview h5,
.editor-preview h6 {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-top: 1.5em;
  margin-bottom: 0.5em;
  color: var(--text-primary);
}
.editor-preview h1 { font-size: var(--text-xl); border-bottom: 2px solid var(--border-subtle); padding-bottom: var(--sp-2); }
.editor-preview h2 { font-size: var(--text-lg); }
.editor-preview h3 { font-size: var(--text-md); }
.editor-preview h4, .editor-preview h5, .editor-preview h6 { font-size: var(--text-base); }

.editor-preview p {
  margin-bottom: 1em;
  color: var(--text-primary);
  line-height: 1.75;
}

.editor-preview ul,
.editor-preview ol {
  margin: 0.75em 0 1em 1.5em;
}
.editor-preview li {
  margin-bottom: 0.25em;
  color: var(--text-primary);
}
.editor-preview li::marker {
  color: var(--accent);
}

.editor-preview blockquote {
  margin: 1em 0;
  padding: var(--sp-3) var(--sp-5);
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  border-radius: 0 var(--r-md) var(--r-md) 0;
  font-style: italic;
  color: var(--text-secondary);
}
.editor-preview blockquote > p { color: var(--text-secondary); margin: 0; }

.editor-preview pre {
  margin: 1em 0;
  padding: var(--sp-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  line-height: 1.7;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.editor-preview pre code {
  background: none;
  padding: 0;
  color: var(--text-primary);
  font-size: inherit;
}

.editor-preview code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--surface);
  color: var(--text-accent);
  padding: 0.1em 0.38em;
  border-radius: var(--r-sm);
}

.editor-preview hr {
  border: none;
  border-top: 2px solid var(--border-subtle);
  margin: 2em 0;
}

.editor-preview a {
  color: var(--text-accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.editor-preview table {
  width: 100%;
  border-collapse: collapse;
  margin: 1em 0;
  font-size: var(--text-sm);
}
.editor-preview th,
.editor-preview td {
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--border);
  text-align: left;
}
.editor-preview th {
  background: var(--surface);
  font-weight: 700;
  color: var(--text-primary);
}
.editor-preview td { color: var(--text-primary); }
.editor-preview tr:nth-child(even) td { background: var(--surface); }

.editor-preview img {
  max-width: 100%;
  border-radius: var(--r-md);
  box-shadow: var(--shadow-md);
}

/* Tag bar inside editor */
.tag-bar {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg);
}

.tag-bar__label {
  font-size: var(--text-xs);
  font-family: var(--font-mono);
  color: var(--text-tertiary);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}

/* Editor status bar */
.editor-status {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-4);
  background: var(--surface);
  border-top: 1px solid var(--border-subtle);
  font-size: var(--text-xs);
  font-family: var(--font-mono);
  color: var(--text-tertiary);
  letter-spacing: 0.04em;
}

/* Editor action buttons */
.btn-preview,
.btn-del {
  background: transparent;
  border-color: var(--border);
  color: var(--text-secondary);
  padding: var(--sp-2) var(--sp-4);
  min-height: 38px;
}
.btn-preview:hover { background: var(--surface); color: var(--text-primary); }
.btn-del {
  color: var(--status-fail);
  border-color: rgba(176, 48, 48, 0.25);
}
.btn-del:hover {
  background: var(--status-fail-bg);
  border-color: var(--status-fail);
}

/* Save button — inherits from .btn-save above */
.btn-save {
  padding: var(--sp-2) var(--sp-5);
  min-height: 38px;
  font-size: var(--text-sm);
}

/* Voice record button */
.btn-rec {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-4);
  min-height: 38px;
  border-radius: var(--r-full);
  background: var(--surface);
  color: var(--text-secondary);
  border-color: var(--border);
  font-size: var(--text-sm);
  font-weight: 600;
  position: relative;
  overflow: hidden;
  transition:
    background var(--t-base),
    color var(--t-base),
    box-shadow var(--t-smooth);
}

.btn-rec::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(circle, rgba(176, 48, 48, 0.12) 0%, transparent 70%);
  opacity: 0;
  transition: opacity var(--t-base);
}

.btn-rec:hover {
  background: var(--surface-2);
  color: var(--text-primary);
}

.btn-rec.recording {
  background: var(--status-fail-bg);
  color: var(--status-fail);
  border-color: var(--status-fail);
  box-shadow: 0 0 0 3px rgba(var(--status-fail-rgb), 0.18);
  animation: rec-pulse 1.5s ease-in-out infinite;
}
.btn-rec.recording::before { opacity: 1; }

@keyframes rec-pulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(var(--status-fail-rgb), 0.18); }
  50%       { box-shadow: 0 0 0 8px rgba(var(--status-fail-rgb), 0.06); }
}


/* ── Auth / Login ────────────────────────────────────────── */
.auth-form {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  padding: var(--sp-8) var(--sp-6);
}

/* Decorative backdrop for auth */
.auth-form::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(ellipse 80% 60% at 50% 0%, var(--accent-soft) 0%, transparent 70%),
    radial-gradient(ellipse 50% 40% at 80% 100%, var(--accent-glow) 0%, transparent 70%);
}

.auth-form > * { position: relative; z-index: 1; }

.auth-form__card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-xl);
  padding: var(--sp-8) var(--sp-8);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: var(--sp-5);
}

.auth-title {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text-primary);
  line-height: 1.1;
  text-align: center;
}

.auth-title span {
  color: var(--accent);
}

.auth-subtitle {
  font-size: var(--text-sm);
  color: var(--text-tertiary);
  text-align: center;
  margin-top: calc(-1 * var(--sp-3));
}

.auth-field {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.auth-field label {
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  font-family: var(--font-mono);
}

.auth-submit {
  width: 100%;
  padding: var(--sp-4);
  font-size: var(--text-base);
  font-weight: 700;
  background: var(--accent);
  color: var(--text-inverse);
  border-color: var(--accent-dim);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  letter-spacing: 0.02em;
  min-height: 52px;
}
.auth-submit:hover {
  background: var(--accent-dim);
  box-shadow: var(--shadow-accent);
  transform: translateY(-1px);
}
.auth-submit:active { transform: translateY(0); }

.auth-error {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4);
  background: var(--status-fail-bg);
  color: var(--status-fail);
  border: 1px solid rgba(176, 48, 48, 0.25);
  border-radius: var(--r-md);
  font-size: var(--text-sm);
  font-weight: 500;
  animation: shake 0.35s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

.auth-error::before {
  content: '✕';
  font-weight: 800;
  font-size: var(--text-xs);
  flex-shrink: 0;
  opacity: 0.8;
}

@keyframes shake {
  10%, 90%  { transform: translateX(-2px); }
  20%, 80%  { transform: translateX(3px); }
  30%, 50%, 70% { transform: translateX(-4px); }
  40%, 60%  { transform: translateX(4px); }
}

/* auth brand mark above the card */
.auth-brand {
  text-align: center;
  margin-bottom: var(--sp-4);
}

.auth-brand__logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: var(--r-lg);
  background: var(--accent);
  color: var(--text-inverse);
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 700;
  box-shadow: var(--shadow-accent);
  margin-bottom: var(--sp-3);
  /* subtle rotation for character */
  transform: rotate(-3deg);
}


/* ── Skeleton / Loading ──────────────────────────────────── */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--surface) 25%,
    var(--surface-2) 50%,
    var(--surface) 75%
  );
  background-size: 200% 100%;
  border-radius: var(--r-md);
  animation: skeleton-shimmer 1.4s ease-in-out infinite;
}

@keyframes skeleton-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}


/* ── Scroll & Misc Utilities ─────────────────────────────── */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

.text-muted   { color: var(--text-tertiary); }
.text-accent  { color: var(--accent); }
.text-mono    { font-family: var(--font-mono); }

.mt-auto { margin-top: auto; }
.ml-auto { margin-left: auto; }

/* Divider */
.divider {
  height: 1px;
  background: var(--border-subtle);
  margin: var(--sp-2) 0;
}

/* Thin scrollbars everywhere */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }


/* ── View transitions / page enter ──────────────────────── */
/* 仅初次挂载淡入一次,避免侧栏切换页时每次都"再淡入一次"造成的视觉闪烁。
   路由通过 staging-swap 实现原子换页,后续无需再播。 */
#app > *.page-enter {
  animation: page-enter 220ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes page-enter {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ── v0.4 三栏下覆盖 v0.3 单列时代的居中约束 ───────────────────
   旧的 @media (min-width: 640px) 把 .editor-view max-width 锁到 680px 居中,
   桌面三栏里 detail 列宽通常 ≥ 1000px,导致编辑器被夹在中间出现大空白。 */
.notes-shell .editor-view,
.notes-shell .notes-view {
  max-width: none;
  margin: 0;
  border-left: none;
  border-right: none;
}

/* ── 统一图标 ────────────────────────────────────────────
   .ic 是包裹 svg 的容器,固定 20×20 居中;flex 父容器靠 align-items:center
   即可让图标与文字基线一致。.btn-ic 是"只显示图标的方形按钮"。 */
.ic {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  color: inherit;
}
.ic svg, .ic-svg { display: block; width: 100%; height: 100%; }

.btn-ic {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  min-height: 38px;
  padding: 0;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  color: var(--text-secondary);
}
.btn-ic:hover { background: var(--surface); color: var(--text-primary); border-color: var(--border-subtle); }
.btn-ic.btn-del { color: var(--status-fail); }
.btn-ic.btn-del:hover { background: var(--status-fail-bg); border-color: rgba(var(--status-fail-rgb), 0.35); }
.btn-ic.btn-rec.recording { color: var(--status-fail); background: var(--status-fail-bg); border-color: var(--status-fail); }

/* 侧栏 nav-item 用了 .ic + .nav-label,布局对齐 */
.sidebar .nav-item .nav-label {
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ── 侧栏底部:用户信息行 + 独立"退出登录"行 ─────────────
   用户信息只显示头像+用户名,不可点击;退出登录是独立的按钮,
   语义更清晰,长用户名也不会跟"登出"文字挤一起。 */
.sidebar .sidebar-footer {
  display: flex; flex-direction: column;
  gap: var(--sp-1);
  padding-top: var(--sp-2);
  border-top: 1px solid var(--border-subtle);
}
.sidebar .sidebar-user {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  min-width: 0;
}
.sidebar .user-avatar {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  background: var(--accent); color: var(--text-inverse);
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-size: var(--text-xs); font-weight: 700;
}
.sidebar .user-name {
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* 退出登录与设置/用户管理同为 nav-item，仅 hover 提示破坏性 */
.sidebar .nav-logout { cursor: pointer; }
.sidebar .nav-logout:hover { background: var(--status-fail-bg); color: var(--status-fail); }
/* 桌面端侧栏已有退出入口，设置页的退出组只在移动端显示 */
@media (min-width: 900px) {
  .set-group--logout { display: none; }
}
/* 整行可点的设置行（如退出登录） */
.set-row--action { cursor: pointer; }
.set-row--action:active { background: var(--surface); }

/* ── 居中确认弹窗 ─────────────────────────────── */
.dlg-overlay {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  padding: var(--sp-5);
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(2px);
  animation: dlg-fade 0.15s ease;
}
.dlg {
  width: 100%; max-width: 320px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
  box-shadow: var(--shadow-lg);
  animation: dlg-pop 0.18s ease;
}
.dlg__title { margin: 0 0 var(--sp-2); font-family: var(--font-display); font-size: var(--text-md); color: var(--text-primary); }
.dlg__msg { margin: 0 0 var(--sp-4); font-size: var(--text-sm); color: var(--text-secondary); line-height: 1.6; }
.dlg__actions { display: flex; gap: var(--sp-2); }
.dlg__actions button { flex: 1; min-height: 40px; }
@keyframes dlg-fade { from { opacity: 0; } }
@keyframes dlg-pop { from { transform: scale(0.95); opacity: 0; } }

/* ── 列表卡片上下文菜单（右键 / 长按） ─────────── */
.ctx-menu {
  position: fixed; z-index: 1000;
  min-width: 140px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  padding: var(--sp-1);
  animation: dlg-pop 0.12s ease;
}
.ctx-menu__item {
  display: flex; align-items: center; gap: var(--sp-2);
  width: 100%; min-height: 36px;
  padding: 0 var(--sp-3);
  border: none; background: none; border-radius: var(--r-sm);
  font-size: var(--text-sm); font-family: var(--font-body);
  color: var(--text-primary); cursor: pointer; text-align: left;
}
.ctx-menu__item:hover { background: var(--surface); }
.ctx-menu__item--danger { color: var(--status-fail); }
.ctx-menu__item--danger:hover { background: var(--status-fail-bg); }

/* btn-save 既有图标也有文字 */
.btn-save { gap: var(--sp-2); }
.btn-save .ic { color: currentColor; }

/* ── 编辑器底部:标签 + 录音按钮同一行 ──────────────────── */
/* 底栏+状态条包一层 sticky 容器：长文滚动时钉在视口底部，录音/加标签随时可点 */
.editor-bottom {
  position: sticky;
  bottom: 0;
  z-index: 90;
  background: var(--bg);
  border-top: 1px solid var(--border-subtle);
  padding-bottom: var(--safe-bottom);
}
.editor-bottom-bar {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-4);
  background: var(--bg);
  border-bottom: 1px solid var(--border-subtle);
}
/* 内嵌的 tag-bar 去掉自身的 padding/border/bg,让外层底栏统一控制 */
.editor-bottom-bar .tag-bar {
  flex: 1;
  padding: 0;
  background: transparent;
  border-bottom: none;
}
/* 录音按钮放在最左边,但用一条细分隔线 + 透明背景跟标签 chip 区分开,
   让它"显眼但不突兀"。视觉上像工具栏左侧的辅助操作。
   注意:padding 必须保持 0(继承自 .btn-ic),否则图标会偏离 38×38 容器中心。 */
.editor-bottom-bar > .btn-rec {
  flex-shrink: 0;
  border: 1px solid var(--border-subtle);
  margin-right: var(--sp-2);
}
.editor-bottom-bar > .btn-rec:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}
.editor-bottom-bar > .btn-rec.recording {
  border-color: var(--status-fail);
  color: var(--status-fail);
  background: var(--status-fail-bg);
}

/* ── 标签 chip 内的 × 移除按钮: 跟随 chip 尺寸,不继承全站 button 默认 44px ── */
.chip > button {
  min-height: unset;
  padding: 0;
  width: 16px;
  height: 16px;
  background: transparent;
  border: none;
  color: inherit;
  font-size: var(--text-md);
  font-weight: 600;
  line-height: 1;
  border-radius: 50%;
  opacity: 0.55;
  margin-left: 2px;
}
.chip > button:hover {
  opacity: 1;
  background: rgba(0, 0, 0, 0.08);
}


/* ── Desktop adaptation ──────────────────────────────────── */
@media (min-width: 640px) {
  :root {
    --appbar-h: 62px;
    --text-base: 1.0125rem;
  }

  .notes-view,
  .editor-view {
    max-width: var(--max-w);
    margin: 0 auto;
    border-left: 1px solid var(--border-subtle);
    border-right: 1px solid var(--border-subtle);
    min-height: 100vh;
  }

  /* appbar/toolbar are sticky inside the already-centered .notes-view/.editor-view
     column, so they inherit its width; only the side borders are added for continuity. */
  .appbar {
    border-left: 1px solid var(--border-subtle);
    border-right: 1px solid var(--border-subtle);
    border-bottom: 1px solid var(--border-subtle);
  }

  .toolbar {
    border-left: 1px solid var(--border-subtle);
    border-right: 1px solid var(--border-subtle);
  }

  /* 编辑器吸顶工具栏与 appbar 侧边线对齐 */
  .editor-top,
  .editor-bottom {
    border-left: 1px solid var(--border-subtle);
    border-right: 1px solid var(--border-subtle);
  }

  /* （FAB 容器对齐规则移到下方独立 media 块：仅平板单列区间适用） */

  .auth-form__card {
    padding: var(--sp-10) var(--sp-10);
  }
}

@media (min-width: 1024px) {
  .editor-text {
    font-size: var(--text-base);
  }
}

/* FAB 对齐限宽容器右缘：仅平板单列（640-899）适用；
   ≥900 桌面三栏不限宽，FAB 贴视口右下角（默认 right） */
@media (min-width: 640px) and (max-width: 899px) {
  .fab {
    right: calc(50% - var(--max-w) / 2 + var(--sp-5));
  }
}


/* ── Focus-visible (accessibility) ──────────────────────── */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

button:focus-visible,
.chip:focus-visible {
  outline-offset: 3px;
}

/* ── Reduced motion ──────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ── 分组卡片(设置 / 用户管理通用)──────────────── */
.settings-view { display:flex; flex-direction:column; min-height:100dvh; padding-bottom: calc(var(--sp-12) + var(--safe-bottom)); }
/* 桌面全屏路由下限宽居中，避免输入框铺满整屏被拉长 */
.set-scroll { padding: var(--sp-2) var(--sp-4) var(--sp-8); width: 100%; max-width: 640px; margin: 0 auto; }

.set-group { margin-top: var(--sp-5); }
.set-group__label {
  display:flex; align-items:center; gap: var(--sp-2);
  font-family: var(--font-mono); font-size: var(--text-xs);
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-tertiary); padding: 0 var(--sp-2) var(--sp-2);
}
.set-group__flag { font-family: var(--font-body); letter-spacing:0; text-transform:none;
  font-size: var(--text-xs); padding: 1px var(--sp-2); border-radius: var(--r-full);
  background: var(--accent); color: var(--text-inverse); }
.set-group__flag.new { background: var(--status-ok); }

.set-card { background: var(--bg-card); border: 1px solid var(--border-subtle);
  border-radius: var(--r-lg); overflow: hidden; }
.set-row { display:flex; align-items:center; gap: var(--sp-3);
  padding: var(--sp-4); border-bottom: 1px solid var(--border-subtle); }
.set-row:last-child { border-bottom: none; }
.set-row__main { min-width:0; }
.set-row__title { font-size: var(--text-sm); font-weight: 600; color: var(--text-primary); }
.set-row__sub { font-size: var(--text-xs); color: var(--text-tertiary); margin-top: 2px; }
.set-row__right { margin-left: auto; display:flex; align-items:center; gap: var(--sp-2); flex-shrink:0; }

.set-avatar { width:40px; height:40px; border-radius: var(--r-md); background: var(--accent);
  color: var(--text-inverse); display:flex; align-items:center; justify-content:center;
  font-family: var(--font-display); font-weight: 700; font-size: var(--text-lg); flex-shrink:0; }

.role-badge { font-size: var(--text-xs); font-family: var(--font-mono);
  padding: 2px var(--sp-2); border-radius: var(--r-full); background: var(--surface); color: var(--text-secondary); }
.role-badge.admin { background: var(--accent); color: var(--text-inverse); }

/* ── 段控(主题三选)──────────────────────────── */
.segctl { display:inline-flex; border:1px solid var(--border); border-radius: var(--r-md); overflow:hidden; }
.segctl button { min-height: 34px; padding: var(--sp-2) var(--sp-3); font-size: var(--text-xs);
  border:none; border-radius:0; background: transparent; color: var(--text-secondary); }
.segctl button[aria-pressed="true"] { background: var(--accent); color: var(--text-inverse); }

/* ── 危险按钮 ─────────────────────────────────── */
.btn-danger { background: var(--status-fail); color:#fff; border-color: transparent; }
.btn-danger:hover { filter: brightness(0.94); }
.set-row__del { width:34px; height:34px; min-height:unset; padding:0; border-radius: var(--r-full);
  background:transparent; border-color:transparent; color: var(--status-fail); }
.set-row__del:hover { background: var(--status-fail-bg); }

/* ── OTP 6 格输入 ─────────────────────────────── */
.otp { display:flex; gap: var(--sp-2); justify-content:center; }
.otp input {
  width: 44px; height: 54px; text-align:center; font-size: var(--text-xl);
  font-family: var(--font-mono); font-weight: 700; padding: 0;
  border: 1.5px solid var(--border); border-radius: var(--r-md); background: var(--bg-input);
}
.otp input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.otp.error input { border-color: var(--status-fail); color: var(--status-fail);
  background: var(--status-fail-bg); animation: shake 0.35s cubic-bezier(0.36,0.07,0.19,0.97) both; }

/* ── 内嵌表单小标题 ───────────────────────────── */
.set-form { display:flex; flex-direction:column; gap: var(--sp-3); padding: var(--sp-4); }
/* 全站兜底:HTML hidden 属性优先级最高,避免被组件 display:flex 覆盖 */
[hidden] { display: none !important; }
.set-form label { display:flex; flex-direction:column; gap: var(--sp-1);
  font-size: var(--text-xs); color: var(--text-tertiary); font-family: var(--font-mono);
  letter-spacing: 0.04em; text-transform: uppercase; }
/* 设置面板里输入框统一紧凑高度（全局 padding 对全屏表单偏高） */
.set-form input:not([type="checkbox"]) { padding: var(--sp-2) var(--sp-3); font-size: var(--text-sm); }
/* 下拉框同样收紧到与输入框一致的高度，箭头留白随之缩小 */
.set-form select {
  padding: var(--sp-2) var(--sp-3);
  padding-right: calc(var(--sp-3) * 2 + 16px);
  font-size: var(--text-sm);
  min-height: 38px;
  background-position: right var(--sp-3) center;
}
/* 复选框行：横排垂直居中，恢复正文字体（不继承 label 的 mono 大写小字） */
.set-form label:has(> input[type="checkbox"]) {
  flex-direction: row; align-items: center; gap: var(--sp-2);
  font-family: var(--font-body); font-size: var(--text-sm); color: var(--text-primary);
  letter-spacing: 0; text-transform: none;
}
.set-form input[type="checkbox"] { width: 18px; height: 18px; flex: none; accent-color: var(--accent); margin: 0; }
/* 操作按钮排成一行 */
.set-actions { display: flex; gap: var(--sp-2); }
.set-actions button { flex: 1; }
.set-msg { font-size: var(--text-sm); margin:0; }
.set-msg.ok { color: var(--status-ok); }
.set-msg.err { color: var(--status-fail); }
.provisioning { font-family: var(--font-mono); font-size: var(--text-xs); word-break: break-all;
  background: var(--surface); padding: var(--sp-2) var(--sp-3); border-radius: var(--r-sm); color: var(--text-secondary); }

/* ── 离线横幅(纳入设计系统)──────────────────── */
.offline-banner { background: var(--accent); color: var(--text-inverse); text-align:center;
  padding: 6px 12px; font-size: var(--text-sm); }
.badge-dirty { background: var(--surface-2); color: var(--text-secondary); }
.badge-pending { background: var(--accent); color: var(--text-inverse); }

/* ── Voice placeholder ──────────────────────────────────── */
.voice-placeholder {
  background: var(--status-warn-bg);
  color: var(--status-warn);
  border-radius: var(--r-sm);
  padding: 1px 6px;
  font-family: var(--font-mono);
  font-size: 0.92em;
  font-weight: 600;
  white-space: nowrap;
  animation: voice-pulse 1.4s ease-in-out infinite;
}
.voice-placeholder[data-state="failed"] {
  background: var(--status-fail-bg);
  color: var(--status-fail);
  animation: none;
  transition: opacity 600ms ease;
}
.voice-placeholder[data-state="live"] {
  background: transparent;
  color: var(--text-tertiary);    /* 弱化灰，表"识别中"；录完精修去 mark 转正常色 */
  font-family: var(--font-body);  /* 长文本用正文字体，不用 mono */
  font-weight: 400;
  white-space: normal;            /* 覆盖默认 nowrap：实时长文本要换行 */
  animation: none;
}
@keyframes voice-pulse { 50% { opacity: 0.55; } }

/* ── Editor segmented control (富文本/源码) ──────────── */
.editor-mode {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
}
.editor-mode button {
  min-height: 32px;
  padding: var(--sp-1) var(--sp-3);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: var(--text-sm);
  border-radius: 0;
}
.editor-mode button[aria-pressed="true"] { background: var(--accent); color: var(--text-inverse); }

/* ── Editor split (source mode, desktop) ─────────────── */
/* flex:1 + min-height:0：编辑区占满剩余高度，把底部标签栏推到视图最底；
   长文在 split 内部滚动而不是把底栏顶出视口 */
.editor-split { display: grid; grid-template-columns: 1fr; gap: 0; flex: 1; min-height: 0; overflow-y: auto; }
@media (min-width: 900px) {
  .editor-split.source { grid-template-columns: 1fr 1fr; }
  .editor-split.source > .editor-preview { border-left: 1px solid var(--border-subtle); border-top: none; }
}

/* ── 编辑器工具栏 ── */
/* 工具栏+链接条包一层 sticky 容器：长文滚动时钉在 appbar 下方，随时可操作 */
.editor-top {
  position: sticky;
  top: calc(var(--appbar-h) + var(--safe-top));
  z-index: 90;
  background: var(--bg);
}
.editor-toolbar { display: flex; align-items: center; gap: 2px; flex: none; overflow-x: auto; scrollbar-width: none; padding: var(--sp-1) var(--sp-2); border-bottom: 1px solid var(--border-subtle); background: var(--bg); }
.editor-toolbar::-webkit-scrollbar { display: none; }
.editor-toolbar[hidden] { display: none; }
.editor-toolbar button { flex: none; min-width: 34px; height: 34px; padding: 0 var(--sp-1); border: none; background: none; border-radius: 8px; color: var(--text-secondary); font-size: var(--text-sm); font-weight: 700; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.editor-toolbar button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }
.editor-toolbar button:disabled { opacity: .35; cursor: default; }
.editor-toolbar .tb-sep { flex: none; width: 1px; height: 18px; background: var(--border-subtle); margin: 0 var(--sp-1); }
/* 移动端：按钮自动换行全部可见（横滑被隐藏滚动条遮蔽，用户以为显示不全） */
@media (max-width: 899px) {
  .editor-toolbar { flex-wrap: wrap; overflow-x: visible; row-gap: 2px; }
}
.editor-linkbar { display: flex; gap: var(--sp-2); align-items: center; padding: var(--sp-2); border-bottom: 1px solid var(--border-subtle); }
.editor-linkbar[hidden] { display: none; }
.editor-linkbar input { flex: 1; min-width: 0; padding: var(--sp-1) var(--sp-2); font-size: var(--text-sm); }
.tiptap img, .editor-preview img { max-width: 100%; height: auto; border-radius: 8px; display: block; margin: 0.6em 0; }
.tiptap img.ProseMirror-selectednode { outline: 2px solid var(--accent); }
/* 可缩放图片 NodeView：选中/悬停时露出右下角拖拽手柄 */
.tiptap .img-resize-wrap { position: relative; display: inline-block; max-width: 100%; }
.tiptap .img-resize-wrap img { margin: 0.6em 0; }
.tiptap .img-resize-handle {
  position: absolute; right: -6px; bottom: 4px; width: 14px; height: 14px;
  border-radius: 4px; background: var(--accent); border: 2px solid var(--bg-card);
  cursor: nwse-resize; opacity: 0; transition: opacity var(--t-base);
  touch-action: none; /* 触屏拖拽不滚动页面 */
}
.tiptap .img-resize-wrap:hover .img-resize-handle,
.tiptap .img-resize-wrap.ProseMirror-selectednode .img-resize-handle { opacity: 1; }
.tiptap .img-resize-wrap.ProseMirror-selectednode img { outline: 2px solid var(--accent); }

/* tiptap content baseline */
.tiptap { outline: none; padding: var(--sp-5); min-height: 320px; font-family: var(--font-body); font-size: var(--text-base); line-height: 1.75; color: var(--text-primary); }
.tiptap h1, .tiptap h2, .tiptap h3 { font-family: var(--font-display); font-weight: 700; letter-spacing: -0.02em; margin: 1em 0 0.4em; }
.tiptap h1 { font-size: var(--text-xl); }
.tiptap h2 { font-size: var(--text-lg); }
.tiptap p { margin-bottom: 0.6em; }
.tiptap ul, .tiptap ol { margin: 0.4em 0 0.6em 1.5em; }
.tiptap blockquote { border-left: 3px solid var(--accent); background: var(--accent-soft); padding: 4px var(--sp-4); margin: 0.6em 0; font-style: italic; color: var(--text-secondary); }
.tiptap code { background: var(--surface); color: var(--text-accent); padding: 0.1em 0.38em; border-radius: var(--r-sm); font-family: var(--font-mono); font-size: 0.88em; }
/* 代码块：块级容器样式（与 .editor-preview pre 一致），并重置内部 code 的行内样式，
   否则代码块和行内代码看起来没有区别 */
.tiptap pre {
  margin: 0.8em 0;
  padding: var(--sp-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  line-height: 1.7;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.tiptap pre code {
  background: none;
  padding: 0;
  border-radius: 0;
  color: var(--text-primary);
  font-size: inherit;
}
.tiptap .is-editor-empty:first-child::before {
  content: attr(data-placeholder); color: var(--text-tertiary); float: left; height: 0; pointer-events: none;
}

/* ============================================================
   NotesShell — 桌面三栏 / 移动单列
   ============================================================ */

.notes-shell {
  display: grid;
  min-height: 100dvh;
  grid-template-columns: 1fr;
  grid-template-rows: auto 1fr auto;
  grid-template-areas:
    "topbar"
    "list"
    "bottomnav";
}

/* 移动单列：默认隐藏侧栏与详情列 */
.notes-shell .sidebar { display: none; }
.notes-shell .detail  { display: none; }
.notes-shell .bottom-nav { grid-area: bottomnav; }
.notes-shell .topbar  { grid-area: topbar; }
.notes-shell .list    { grid-area: list; overflow-y: auto; }

/* 桌面三栏 */
@media (min-width: 900px) {
  .notes-shell {
    grid-template-columns: 220px 320px 1fr;
    grid-template-rows: 56px 1fr;
    grid-template-areas:
      "sidebar topbar topbar"
      "sidebar list    detail";
  }
  .notes-shell .sidebar     { display: flex; flex-direction: column; grid-area: sidebar;
                              border-right: 1px solid var(--border-subtle); padding: var(--sp-3); }
  .notes-shell .detail      { display: block; grid-area: detail; overflow-y: auto; }
  .notes-shell .list        { border-right: 1px solid var(--border-subtle); }
  .notes-shell .bottom-nav  { display: none; }
}

.topbar {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4);
  background: var(--bg-overlay);
  border-bottom: 1px solid var(--border-subtle);
  backdrop-filter: blur(12px) saturate(1.4);
}
.topbar .search { flex: 1; }
.topbar .search input { min-height: 38px; }
.topbar .kbd { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--text-tertiary);
               padding: 2px 6px; border: 1px solid var(--border); border-radius: var(--r-sm); }

.sidebar h1 { font-family: var(--font-display); font-size: var(--text-md); margin-bottom: var(--sp-3); }
.sidebar .nav-item { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-2) var(--sp-3);
                     border-radius: var(--r-md); color: var(--text-secondary); cursor: pointer;
                     font-size: var(--text-sm); text-decoration: none; }
.sidebar .nav-item:hover { background: var(--surface); color: var(--text-primary); text-decoration: none; }
.sidebar .nav-item:focus,
.sidebar .nav-item:active { text-decoration: none; outline: none; }
.sidebar .nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.sidebar .nav-item .count { margin-left: auto; font-family: var(--font-mono); font-size: var(--text-xs);
                            background: var(--surface); padding: 1px 6px; border-radius: var(--r-full); }
.sidebar .nav-item.active .count { background: var(--accent); color: var(--text-inverse); }
.sidebar .nav-divider { height: 1px; background: var(--border-subtle); margin: var(--sp-3) 0; }
.sidebar .nav-spacer { flex: 1; }

.bottom-nav {
  display: flex; justify-content: space-around;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-overlay);
  padding: var(--sp-2) 0 calc(var(--sp-2) + var(--safe-bottom));
}
.bottom-nav .tab {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: var(--sp-1) var(--sp-3);
  color: var(--text-tertiary); font-size: var(--text-xs);
  cursor: pointer; border: none; background: transparent;
}
.bottom-nav .tab .ic { font-size: 18px; }
.bottom-nav .tab.active { color: var(--accent); font-weight: 700; }

/* B1 list card */
.list-card {
  display: flex; flex-direction: column; gap: var(--sp-1);
  padding: var(--sp-4);
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer; position: relative; transition: background var(--t-fast);
}
.list-card:hover { background: var(--surface); }
.list-card.active { background: var(--accent-soft); }
.list-card.active::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0;
  width: 3px; background: var(--accent);
}
.list-card__title { font-family: var(--font-display); font-weight: 700; font-size: var(--text-base);
                    color: var(--text-primary); }
.list-card__summary {
  color: var(--text-secondary); font-size: var(--text-sm); line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.list-card__meta {
  display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap;
  font-family: var(--font-mono); font-size: var(--text-xs); color: var(--text-tertiary);
  margin-top: var(--sp-1);
}

/* ── Command palette ───────────────────────────────────── */
.cmdk-backdrop {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,0.32);
  backdrop-filter: blur(2px);
  display: flex; align-items: flex-start; justify-content: center;
  padding-top: 12vh;
}
.cmdk {
  width: min(560px, 92vw); background: var(--bg-card);
  border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg); overflow: hidden;
  display: flex; flex-direction: column;
}
.cmdk input { border: none; border-bottom: 1px solid var(--border-subtle); border-radius: 0;
              padding: var(--sp-4); font-size: var(--text-md); background: transparent; }
.cmdk input:focus { box-shadow: none; }
.cmdk ul { list-style: none; max-height: 50vh; overflow-y: auto; }
.cmdk li { padding: var(--sp-3) var(--sp-4); cursor: pointer; display: flex; align-items: center; gap: var(--sp-2);
           border-bottom: 1px solid var(--border-subtle); }
.cmdk li:last-child { border-bottom: none; }
.cmdk li.active { background: var(--accent-soft); color: var(--accent); }
.cmdk .cmdk-section { padding: var(--sp-2) var(--sp-4); font-family: var(--font-mono); font-size: var(--text-xs);
                      color: var(--text-tertiary); letter-spacing: 0.08em; text-transform: uppercase;
                      background: var(--surface); }

.fab-rec-popover {
  position: fixed; z-index: 300;
  bottom: calc(var(--sp-6) + var(--fab-size) + 8px + var(--safe-bottom));
  right: var(--sp-5);
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: var(--sp-3) var(--sp-4); box-shadow: var(--shadow-lg);
  display: flex; align-items: center; flex-wrap: wrap; gap: var(--sp-3); font-family: var(--font-mono);
  max-width: min(360px, calc(100vw - 2 * var(--sp-5)));
}
.fab-rec-popover .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--status-fail); animation: badge-pulse 1.2s infinite; }
.fab-rec-popover button { min-height: 32px; padding: var(--sp-1) var(--sp-3); font-size: var(--text-sm); }
/* 实时字幕区：整行占满，已确认文本正常色、识别中文本灰显。 */
.fab-rec-popover .rec-caption {
  flex-basis: 100%; max-height: 6.5em; overflow-y: auto;
  font-family: var(--font-sans); font-size: var(--text-sm); line-height: 1.45;
  color: var(--text); border-top: 1px solid var(--border); padding-top: var(--sp-2);
  word-break: break-word;
}
.fab-rec-popover .rec-caption .cap-final { color: var(--text); }
.fab-rec-popover .rec-caption .cap-partial { color: var(--text-muted); }
