/* ==========================================================
   SEREN — Medical Evidence Research Platform
   Design: Bold editorial · Cream/Navy/Antique Brass palette
   ========================================================== */

@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@500;600;700&family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,300&display=swap');

:root {
  --cream:        #F5F0E8;
  --cream2:       #EDE8DC;
  --cream3:       #FAF7F2;
  --parchment:    #E8E0D0;

  --navy:         #0C1117;
  --navy2:        #1A2233;
  --navy3:        #243044;
  --navy-mid:     #2E3D52;

  --coffee:       #6A4C35;
  --coffee2:      #8B6347;
  --coffee-light: #C4956A;

  --brass:        #C9A87C;
  --brass2:       #B8935A;
  --brass-light:  #E8CFA0;

  --jungle:       #1A2A20;
  --sage:         #4A6741;
  --sage-light:   #7A9E6E;

  --bg:           var(--cream);
  --surface:      #FFFFFF;
  --surface2:     var(--cream3);
  --surface3:     var(--cream2);
  --text:         var(--navy);
  --text2:        var(--navy2);
  --muted:        #7A6E5F;
  --subtle:       #A09585;
  --line:         rgba(106, 76, 53, 0.12);
  --line2:        rgba(106, 76, 53, 0.08);

  --brand:        var(--navy2);
  --brand-mid:    var(--navy3);
  --accent:       var(--brass);
  --accent2:      var(--brass2);
  --accent-light: var(--brass-light);

  --good:         #3D7A4A;
  --warn:         #C4862A;
  --bad:          #B84040;

  --r-xs:   8px;
  --r-sm:   12px;
  --r:      18px;
  --r-lg:   24px;
  --r-xl:   32px;
  --r-pill: 999px;

  --shadow-xs:     0 1px 3px rgba(12,17,23,.06), 0 1px 2px rgba(12,17,23,.04);
  --shadow-sm:     0 4px 12px rgba(12,17,23,.07), 0 2px 4px rgba(12,17,23,.05);
  --shadow:        0 8px 28px rgba(12,17,23,.09), 0 3px 8px rgba(12,17,23,.06);
  --shadow-lg:     0 20px 56px rgba(12,17,23,.12), 0 8px 16px rgba(12,17,23,.07);
  --shadow-accent: 0 4px 20px rgba(201,168,124,.30);

  --sidebar-w:      88px;
  --sidebar-bg:     var(--navy);
  --side-icon:      rgba(255,255,255,.50);
  --side-icon-hover:rgba(255,255,255,.85);
  --side-active:    var(--brass);

  --font-display: 'Playfair Display', Georgia, serif;
  --font-body:    'DM Sans', ui-sans-serif, system-ui, sans-serif;
}

/* ══ Reset ══════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.025'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 9998;
  opacity: 0.4;
}

/* ══ Shell ══════════════════════════════════════════════════ */
.appShell {
  display: flex;
  min-height: 100vh;
  width: 100%;
  overflow-x: hidden;
}

/* ══ Sidebar ════════════════════════════════════════════════ */
.sidebar {
  background: var(--navy);
  width: var(--sidebar-w);
  position: fixed;
  top: 0; left: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 0 24px;
  z-index: 2000;
  border-right: 1px solid rgba(255,255,255,.05);
}

.sidebar::after {
  content: '';
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 1px;
  background: linear-gradient(180deg, transparent, rgba(201,168,124,.25) 40%, rgba(201,168,124,.25) 60%, transparent);
}

.brandMark {
  width: 48px;
  height: 48px;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 28px;
  background: linear-gradient(145deg, var(--navy3), var(--navy2));
  border: 1px solid rgba(201,168,124,.30);
  box-shadow: 0 4px 16px rgba(0,0,0,.3), inset 0 1px 0 rgba(255,255,255,.08);
  color: var(--brass);
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.5px;
  cursor: pointer;
  text-decoration: none;
}

.sideGroup {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  align-items: center;
}

.sideSpacer { flex: 1; }

.sideBtn {
  width: 52px;
  height: 52px;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: var(--side-icon);
  background: transparent;
  border: 1px solid transparent;
  transition: all .18s ease;
  position: relative;
  cursor: pointer;
}

.sideBtn:hover {
  color: var(--side-icon-hover);
  background: rgba(255,255,255,.06);
  border-color: rgba(255,255,255,.08);
}

.sideBtn.active {
  color: var(--brass);
  background: rgba(201,168,124,.12);
  border-color: rgba(201,168,124,.25);
}

.sideBtn.active::before {
  content: '';
  position: absolute;
  left: -1px;
  top: 50%; transform: translateY(-50%);
  width: 3px;
  height: 22px;
  background: var(--brass);
  border-radius: 0 3px 3px 0;
}

.sideBtn .i { font-size: 17px; line-height: 1; }

.sideBtn[title]:hover::after {
  content: attr(title);
  position: absolute;
  left: calc(100% + 12px);
  top: 50%; transform: translateY(-50%);
  background: var(--navy2);
  color: var(--cream);
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 5px 10px;
  border-radius: var(--r-xs);
  white-space: nowrap;
  pointer-events: none;
  border: 1px solid rgba(255,255,255,.1);
  z-index: 3000;
  box-shadow: var(--shadow-sm);
}

/* ══ Main Area ══════════════════════════════════════════════ */
.mainArea {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 0;
  min-width: 0;
  width: calc(100vw - var(--sidebar-w));
  overflow-x: hidden;
}

/* ══ Topbar ══════════════════════════════════════════════════ */
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 28px;
  background: rgba(245,240,232,.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 100;
}

.topLeft { display: flex; align-items: center; gap: 12px; }

.pageTitle {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  color: var(--navy);
  letter-spacing: -0.02em;
}

.topSearch {
  flex: 1;
  max-width: 520px;
  min-width: 200px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  padding: 9px 16px;
  box-shadow: var(--shadow-xs);
  transition: border-color .15s, box-shadow .15s;
}

.topSearch:focus-within {
  border-color: rgba(201,168,124,.45);
  box-shadow: 0 0 0 3px rgba(201,168,124,.12), var(--shadow-xs);
}

.searchIcon { color: var(--subtle); font-size: 16px; flex-shrink: 0; }

.topSearch input {
  flex: 1;
  border: 0;
  outline: none;
  background: transparent;
  font-family: var(--font-body);
  font-size: 13.5px;
  color: var(--text);
  min-width: 0;
}

.topSearch input::placeholder { color: var(--subtle); }

.topRight {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

/* ── Pills ── */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  box-shadow: var(--shadow-xs);
  font-weight: 500;
}

.pill b { color: var(--navy2); font-weight: 600; }

.mono {
  font-family: 'SF Mono', ui-monospace, Menlo, monospace;
  font-size: 11px;
  color: var(--coffee2);
}

.dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--parchment);
  flex-shrink: 0;
}
.dot.ok   { background: var(--good); box-shadow: 0 0 0 2px rgba(61,122,74,.20); }
.dot.warn { background: var(--warn); box-shadow: 0 0 0 2px rgba(196,134,42,.20); }
.dot.bad  { background: var(--bad);  box-shadow: 0 0 0 2px rgba(184,64,64,.20); }

/* ══ Content ════════════════════════════════════════════════ */
.content {
  flex: 1;
  padding: 28px 28px 40px;
  min-width: 0;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.content > main,
.content main {
  padding: 0;
  width: 100%;
  max-width: none !important;
  min-width: 0;
  box-sizing: border-box;
}

.content main > *,
.content > main > * { min-width: 0; }

/* ══ Cards ══════════════════════════════════════════════════ */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow-sm);
  padding: 20px;
  margin-bottom: 18px;
}

.card--accent {
  border-color: rgba(201,168,124,.25);
  background: linear-gradient(135deg, var(--surface) 80%, rgba(201,168,124,.05));
}

/* ══ Typography ═════════════════════════════════════════════ */
h1, h2, h3, h4 { margin: 0 0 10px; font-family: var(--font-display); font-weight: 600; }

h1 { font-size: 28px; letter-spacing: -0.03em; }
h2 { font-size: 22px; letter-spacing: -0.02em; }
h3 { font-size: 17px; letter-spacing: -0.01em; }

.small { font-size: 12px; color: var(--muted); }
.muted { color: var(--muted); }

.hr {
  height: 1px;
  background: var(--line);
  border: none;
  margin: 16px 0;
}

.row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }

/* ══ Form Elements ══════════════════════════════════════════ */
label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}

input, select, textarea {
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--surface2);
  outline: none;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 13.5px;
  transition: border-color .15s, box-shadow .15s;
}

input:focus, select:focus, textarea:focus {
  border-color: rgba(201,168,124,.5);
  box-shadow: 0 0 0 3px rgba(201,168,124,.12);
  background: var(--surface);
}

textarea { min-height: 100px; resize: vertical; line-height: 1.6; }

/* ══ Buttons ════════════════════════════════════════════════ */
button, .btn, .navBtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text2);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-xs);
  transition: all .16s ease;
  text-decoration: none;
  white-space: nowrap;
  letter-spacing: 0.01em;
}

button:hover, .btn:hover {
  border-color: rgba(201,168,124,.35);
  background: var(--cream3);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

button:active, .btn:active {
  transform: translateY(0);
  box-shadow: var(--shadow-xs);
}

button:disabled {
  opacity: .5;
  cursor: not-allowed;
  transform: none;
  box-shadow: var(--shadow-xs);
}

button.primary, .btn.primary {
  background: var(--navy);
  color: var(--cream);
  border-color: var(--navy2);
  box-shadow: var(--shadow-sm), 0 2px 8px rgba(12,17,23,.2);
}
button.primary:hover, .btn.primary:hover {
  background: var(--navy2);
  border-color: var(--navy3);
}

button.accent, .btn.accent {
  background: linear-gradient(145deg, var(--brass), var(--brass2));
  color: var(--navy);
  border-color: var(--brass2);
  font-weight: 700;
  box-shadow: var(--shadow-accent);
}
button.accent:hover, .btn.accent:hover {
  background: linear-gradient(145deg, var(--brass-light), var(--brass));
  box-shadow: 0 6px 24px rgba(201,168,124,.40);
}

button.danger, .btn.danger {
  color: var(--bad);
  border-color: rgba(184,64,64,.2);
}
button.danger:hover, .btn.danger:hover {
  background: rgba(184,64,64,.06);
  border-color: rgba(184,64,64,.35);
}

button.ghost {
  background: transparent;
  box-shadow: none;
  border-color: transparent;
  color: var(--muted);
}
button.ghost:hover { color: var(--text); background: var(--surface3); border-color: var(--line); }

button.sm, .btn.sm { padding: 6px 12px; font-size: 12px; border-radius: var(--r-xs); }

/* ══ Lists / Items ═══════════════════════════════════════════ */
.list { display: flex; flex-direction: column; gap: 10px; }

.item {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 16px;
  transition: border-color .15s, box-shadow .15s, transform .15s;
}

.item:hover {
  border-color: rgba(201,168,124,.30);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.item.active {
  border-color: rgba(201,168,124,.45);
  background: linear-gradient(135deg, var(--surface) 85%, rgba(201,168,124,.06));
  box-shadow: var(--shadow-sm), inset 3px 0 0 var(--brass);
}

.itemTitle {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 15px;
  color: var(--navy);
  letter-spacing: -0.01em;
  line-height: 1.4;
}

.itemMeta {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.itemActions {
  margin-top: 12px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ══ Badges ═════════════════════════════════════════════════ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: var(--r-pill);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
  border: 1px solid;
}

.badge            { border-color: rgba(26,34,51,.12);    background: rgba(26,34,51,.06);    color: var(--navy2); }
.badge.brass      { border-color: rgba(201,168,124,.30); background: rgba(201,168,124,.12); color: var(--coffee); }
.badge.blue       { border-color: rgba(36,48,68,.18);    background: rgba(36,48,68,.08);    color: var(--navy3); }
.badge.green      { border-color: rgba(61,122,74,.20);   background: rgba(61,122,74,.08);   color: var(--good); }
.badge.warn       { border-color: rgba(196,134,42,.22);  background: rgba(196,134,42,.08);  color: var(--warn); }
.badge.red        { border-color: rgba(184,64,64,.20);   background: rgba(184,64,64,.08);   color: var(--bad); }
.badge.sage       { border-color: rgba(74,103,65,.20);   background: rgba(74,103,65,.08);   color: var(--sage); }
.badge.coffee     { border-color: rgba(106,76,53,.20);   background: rgba(106,76,53,.08);   color: var(--coffee); }

/* ══ Empty State ════════════════════════════════════════════ */
.empty {
  padding: 32px 20px;
  text-align: center;
  border: 1px dashed var(--parchment);
  border-radius: var(--r);
  color: var(--subtle);
  background: transparent;
  font-size: 13px;
}

/* ══ Paper Layout ═══════════════════════════════════════════ */
.split { display: grid; grid-template-columns: 1.25fr 1fr; gap: 20px; }

.split.drawerMode { grid-template-columns: 1fr; }
.split.drawerMode .paperRight {
  position: fixed;
  right: 20px;
  top: 80px;
  bottom: 20px;
  width: min(500px, calc(100vw - var(--sidebar-w) - 40px));
  z-index: 1200;
}
.split.drawerMode .paperRight .card { height: 100%; overflow: auto; }
.split.panelClosed .paperRight { display: none; }

.paperTitle {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  color: var(--navy);
  line-height: 1.35;
  letter-spacing: -0.02em;
}

.paperMetaLine { color: var(--muted); font-size: 12.5px; line-height: 1.6; }

/* Tabs */
.tabPills { display: flex; flex-wrap: wrap; gap: 6px; }

.tabPill {
  padding: 7px 14px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  background: var(--surface2);
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
  cursor: pointer;
  transition: all .14s ease;
  letter-spacing: 0.02em;
}

.tabPill:hover { border-color: rgba(201,168,124,.35); color: var(--text2); }

.tabPill.active {
  background: var(--navy);
  border-color: var(--navy);
  color: var(--cream);
}

/* ══ Toast ══════════════════════════════════════════════════ */
#toastHost { pointer-events: none; }
#toastHost * { pointer-events: auto; }

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 320px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow-lg);
  padding: 14px 16px;
  opacity: 0;
  transform: translateY(10px) scale(.98);
  pointer-events: none;
  transition: all .2s cubic-bezier(.34,1.56,.64,1);
  z-index: 9999;
}

.toast.show {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.toast::before {
  content: '';
  position: absolute;
  left: 0; top: 20%; bottom: 20%;
  width: 3px;
  border-radius: 3px;
  background: var(--brass);
}

.toastTitle { font-weight: 700; font-size: 13.5px; color: var(--navy); }
.toastBody  { color: var(--muted); font-size: 12.5px; margin-top: 3px; line-height: 1.5; }

/* ══ Confirm Modal ══════════════════════════════════════════ */
#meConfirmOverlay {
  position: fixed; inset: 0; display: none;
  place-items: center; z-index: 5000; pointer-events: none;
}
#meConfirmOverlay.show { display: grid; pointer-events: auto; }

.meConfirmBackdrop {
  position: absolute; inset: 0;
  background: rgba(12,17,23,.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.meConfirmCard {
  position: relative;
  width: min(480px, calc(100vw - 40px));
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  padding: 24px;
  animation: modalIn .2s cubic-bezier(.34,1.56,.64,1);
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(10px) scale(.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.meConfirmTitle { font-family: var(--font-display); font-size: 18px; font-weight: 600; margin-bottom: 8px; }
.meConfirmBody  { color: var(--muted); font-size: 13.5px; line-height: 1.5; }
.meConfirmActions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

/* ══ Prompt Modal ═══════════════════════════════════════════ */
#mePromptOverlay {
  position: fixed; inset: 0; display: none;
  place-items: center; z-index: 5000; pointer-events: none;
}
#mePromptOverlay.show { display: grid; pointer-events: auto; }

.mePromptBackdrop {
  position: absolute; inset: 0;
  background: rgba(12,17,23,.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.mePromptCard {
  position: relative;
  width: min(520px, calc(100vw - 40px));
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  padding: 24px;
  animation: modalIn .2s cubic-bezier(.34,1.56,.64,1);
}

.mePromptTitle { font-family: var(--font-display); font-size: 18px; font-weight: 600; margin-bottom: 6px; }
.mePromptBody  { color: var(--muted); font-size: 13px; margin-bottom: 14px; line-height: 1.5; }
.mePromptInput {
  width: 100%;
  padding: 11px 14px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--surface2);
  outline: none;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
}
.mePromptInput:focus {
  border-color: rgba(201,168,124,.5);
  box-shadow: 0 0 0 3px rgba(201,168,124,.12);
}
.mePromptActions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* ══ Auth Page ══════════════════════════════════════════════ */
.authBody { background: var(--cream); }

.authShell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.authCard {
  display: grid;
  grid-template-columns: 1fr 1.1fr;
  width: min(860px, 100%);
  border-radius: var(--r-xl);
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
}

@media (max-width: 680px) { .authCard { grid-template-columns: 1fr; } }

.authVisual {
  padding: 40px 32px;
  background: var(--navy);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}

.authVisual::before {
  content: '';
  position: absolute;
  top: -60px; right: -60px;
  width: 280px; height: 280px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(201,168,124,.20), transparent 70%);
}

.authVisual::after {
  content: '';
  position: absolute;
  bottom: -40px; left: -40px;
  width: 200px; height: 200px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(201,168,124,.12), transparent 70%);
}

.authLogo { display: flex; align-items: center; gap: 12px; position: relative; z-index: 1; }

.authLogoMark {
  width: 44px; height: 44px;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(201,168,124,.15);
  border: 1px solid rgba(201,168,124,.30);
  color: var(--brass);
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
}

.authLogoText {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  color: var(--cream);
  letter-spacing: 0.02em;
}

.authTagline {
  color: rgba(245,240,232,.55);
  font-size: 12px;
  line-height: 1.5;
  position: relative;
  z-index: 1;
  margin-top: 4px;
}

.authVisualQuote { position: relative; z-index: 1; }

.authVisualQuote p {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 500;
  color: var(--cream);
  line-height: 1.5;
  margin: 0 0 8px;
  font-style: italic;
  opacity: .9;
}

.authVisualQuote span {
  font-size: 12px;
  color: var(--brass);
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.authForm { padding: 36px 32px; }

.authTabs {
  display: flex; gap: 4px; padding: 4px;
  background: var(--surface2); border-radius: var(--r); margin-bottom: 24px;
}
.authTab {
  flex: 1; padding: 8px; border-radius: var(--r-sm);
  border: 1px solid transparent; background: transparent; box-shadow: none;
  font-size: 13px; font-weight: 600; color: var(--muted); text-align: center; cursor: pointer;
}
.authTab.active {
  background: var(--surface); border-color: var(--line); color: var(--navy); box-shadow: var(--shadow-xs);
}

.authFields { display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; }
.authPrimary { width: 100%; }
.authSecondary { width: 100%; background: transparent; box-shadow: none; border-color: var(--line); color: var(--muted); }
.authMsg { min-height: 18px; font-size: 12.5px; font-weight: 600; color: var(--bad); }

/* ══ Folder Chips ════════════════════════════════════════════ */
.folderChip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  background: var(--surface);
  cursor: pointer;
  transition: all .14s ease;
  box-shadow: var(--shadow-xs);
}

.folderChip:hover { border-color: rgba(201,168,124,.35); box-shadow: var(--shadow-sm); }

.folderChip.active {
  background: var(--navy);
  border-color: var(--navy);
}

.folderChip.active .folderChipName { color: var(--cream); }
.folderChip.active .folderDots { border-color: rgba(255,255,255,.2); background: rgba(255,255,255,.08); }
.folderChip.active .folderDots svg { stroke: var(--cream); }

.folderChipName { font-weight: 600; font-size: 12.5px; color: var(--text2); }

.folderDots {
  width: 26px; height: 26px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--line);
  background: var(--surface2);
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
  transition: all .13s ease;
}
.folderDots:hover { transform: translateY(-1px); border-color: rgba(201,168,124,.4); }

.folderMenu {
  position: absolute;
  min-width: 150px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow);
  padding: 5px;
  z-index: 3000;
}

.folderMenu button {
  width: 100%; text-align: left; background: transparent; border: 0; box-shadow: none;
  padding: 8px 10px; border-radius: var(--r-xs); font-size: 12.5px; color: var(--text2);
}
.folderMenu button:hover { background: var(--surface2); transform: none; }
.folderMenu .dangerItem { color: var(--bad); font-weight: 600; }

/* ══ AI Chat ════════════════════════════════════════════════ */
.aiShell { display: flex; flex-direction: column; min-height: 0; }

.aiFeedWrap {
  overflow-y: auto;
  padding: 4px 0;
  max-height: 420px;
  min-height: 0;
  display: flex;
  flex-direction: column;
  scroll-behavior: smooth;
}

.aiFeed { display: flex; flex-direction: column; gap: 14px; }

.aiEmpty {
  color: var(--subtle);
  font-size: 12.5px;
  text-align: center;
  padding: 24px 0;
  line-height: 1.7;
  font-style: italic;
}

.aiMsg { display: flex; gap: 8px; }
.aiMsg--user { justify-content: flex-end; }
.aiMsg--user .aiMsgBubble {
  background: var(--navy);
  color: var(--cream);
  border-radius: 18px 18px 4px 18px;
  padding: 10px 14px;
  font-size: 13px;
  max-width: 80%;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.55;
  box-shadow: var(--shadow-sm);
}

.aiMsg--ai { align-items: flex-start; }

.aiMsgAvatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--brass), var(--brass2));
  color: var(--navy);
  font-size: 10px;
  font-weight: 800;
  font-family: var(--font-display);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
  box-shadow: var(--shadow-accent);
}

.aiMsgBody { display: flex; flex-direction: column; gap: 3px; max-width: 90%; }

.aiMsg--ai .aiMsgBubble {
  background: var(--surface2);
  border: 1px solid var(--line);
  border-radius: 4px 18px 18px 18px;
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.65;
  word-break: break-word;
}

.aiMsg--error { justify-content: center; }
.aiMsg--error .aiMsgBubble {
  background: rgba(184,64,64,.06);
  border: 1px solid rgba(184,64,64,.18);
  color: var(--bad);
  border-radius: var(--r-sm);
  padding: 8px 14px;
  font-size: 12.5px;
  font-weight: 600;
  max-width: 94%;
}

.aiMsgMeta { font-size: 11px; color: var(--subtle); padding: 0 4px; }
.aiMsg--user .aiMsgMeta { text-align: right; }

.aiHead { font-weight: 700; font-size: 13px; margin: 10px 0 4px; color: var(--navy2); }
.aiBullet { padding-left: 2px; margin: 3px 0; font-size: 12.5px; }

.aiTyping { display: flex; align-items: center; gap: 5px; padding: 6px 10px; }
.aiTyping span {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--brass);
  animation: aiDot 1.2s infinite;
}
.aiTyping span:nth-child(2) { animation-delay: .2s; }
.aiTyping span:nth-child(3) { animation-delay: .4s; }

@keyframes aiDot {
  0%,80%,100% { opacity: .25; transform: scale(.8); }
  40%          { opacity: 1;   transform: scale(1.1); }
}

.aiInputRow {
  border-top: 1px solid var(--line);
  padding: 12px 0 4px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.aiInputRow textarea { min-height: 48px; max-height: 120px; resize: vertical; font-size: 13px; }

.aiActions { display: flex; gap: 8px; }

.aiFooter { font-size: 11px; color: var(--subtle); text-align: center; padding: 3px 0 0; }
.aiFooter a { color: var(--brass2); text-decoration: none; }
.aiFooter a:hover { text-decoration: underline; }

/* ══ Filter Bar ══════════════════════════════════════════════ */
.filterBar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow-xs);
  margin-top: 12px;
}

.filterGroup { display: flex; flex-direction: column; gap: 4px; min-width: 96px; }

.filterCheck {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-weight: 600;
  font-size: 12.5px;
  color: var(--muted);
}

.filterCheck input[type="checkbox"] {
  width: 15px; height: 15px; min-width: 15px;
  padding: 0; border-radius: 4px; cursor: pointer; accent-color: var(--navy);
}

/* ══ Divider ornament ════════════════════════════════════════ */
.ornament {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 20px 0;
  color: var(--subtle);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 600;
}
.ornament::before,
.ornament::after { content: ''; flex: 1; height: 1px; background: var(--line); }

/* ══ Section headers ═════════════════════════════════════════ */
.sectionHead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 10px;
}

.sectionHead h2 {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  margin: 0;
  color: var(--navy);
}

/* ══ Stats / KPI cards ═══════════════════════════════════════ */
.statCard {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 18px 20px;
  box-shadow: var(--shadow-xs);
}

.statNum {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 700;
  color: var(--navy);
  line-height: 1;
}

.statLabel {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--subtle);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-top: 4px;
}

/* ══ Page transitions ════════════════════════════════════════ */
.content > * { animation: fadeUp .25s ease; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ══ Scrollbar styling ═══════════════════════════════════════ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--parchment); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--brass-light); }

/* ══ Phase 3: Reading Status Chips ══════════════════════════ */
.statusChip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  border-radius: var(--r-pill);
  border: 1.5px solid;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: all .15s ease;
  text-transform: uppercase;
  user-select: none;
}

.statusChip[data-status="unread"]  { border-color: var(--line);              background: transparent;              color: var(--subtle); }
.statusChip[data-status="reading"] { border-color: rgba(196,134,42,.35);     background: rgba(196,134,42,.10);     color: var(--warn); }
.statusChip[data-status="done"]    { border-color: rgba(61,122,74,.30);      background: rgba(61,122,74,.10);      color: var(--good); }
.statusChip[data-status="flagged"] { border-color: rgba(184,64,64,.30);      background: rgba(184,64,64,.10);      color: var(--bad); }

.statusChip.active[data-status="unread"]  { background: rgba(26,34,51,.08); }
.statusChip.active[data-status="reading"] { background: rgba(196,134,42,.18); }
.statusChip.active[data-status="done"]    { background: rgba(61,122,74,.18); }
.statusChip.active[data-status="flagged"] { background: rgba(184,64,64,.18); }

.statusChip:hover { transform: translateY(-1px); box-shadow: var(--shadow-xs); }

/* ══ Phase 3: Evidence Panel ════════════════════════════════ */
.evidenceGrid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}

.evidenceCell {
  background: var(--surface2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 12px 14px;
}

.evidenceCellLabel {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--subtle);
  margin-bottom: 5px;
}

.evidenceCellValue {
  font-size: 13px;
  color: var(--text2);
  line-height: 1.5;
}

.evidenceCellValue.empty {
  color: var(--subtle);
  font-style: italic;
  font-size: 12px;
}

.strengthBar {
  display: flex;
  gap: 4px;
  align-items: center;
  margin-top: 4px;
}

.strengthDot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--parchment);
  transition: background .2s;
}

.strengthDot.filled        { background: var(--brass); }
.strengthDot.filled.strong { background: var(--good); }
.strengthDot.filled.weak   { background: var(--warn); }

.biasTag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: var(--r-pill);
  font-size: 11px;
  font-weight: 700;
}

.biasTag.low      { background: rgba(61,122,74,.12);  color: var(--good); border: 1px solid rgba(61,122,74,.25); }
.biasTag.moderate { background: rgba(196,134,42,.12); color: var(--warn); border: 1px solid rgba(196,134,42,.25); }
.biasTag.high     { background: rgba(184,64,64,.12);  color: var(--bad);  border: 1px solid rgba(184,64,64,.25); }

/* ══ Phase 3: Audience Rewrite Toggle ═══════════════════════ */
.audienceToggle {
  display: flex;
  gap: 4px;
  background: var(--surface2);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  padding: 3px;
  margin-bottom: 12px;
}

.audienceBtn {
  flex: 1;
  padding: 6px 10px;
  border-radius: var(--r-pill);
  border: none;
  background: transparent;
  box-shadow: none;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--muted);
  cursor: pointer;
  transition: all .14s ease;
  text-transform: uppercase;
}

.audienceBtn:hover { color: var(--text2); transform: none; }

.audienceBtn.active {
  background: var(--navy);
  color: var(--cream);
  box-shadow: var(--shadow-xs);
}

.audienceContent {
  font-size: 13px;
  line-height: 1.75;
  color: var(--text2);
}

/* ══ Streaming cursor blink ══════════════════════════════════ */
.streamCursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  background: var(--brass);
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: blink .7s step-end infinite;
}

@keyframes blink {
  0%,100% { opacity: 1; }
  50%      { opacity: 0; }
}

/* ══ Bold editorial title (library + other pages) ════════════ */
.pageTitleLarge {
  font-family: var(--font-display);
  font-size: 36px;
  font-weight: 700;
  color: var(--navy);
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.pageTitleLarge .accent { color: var(--brass2); }

/* ══ Paper card status stripe ════════════════════════════════ */
.paperCard[data-status="reading"] { border-left: 3px solid var(--warn); }
.paperCard[data-status="done"]    { border-left: 3px solid var(--good); }
.paperCard[data-status="flagged"] { border-left: 3px solid var(--bad); }

/* ══ Responsive ═════════════════════════════════════════════ */
@media (max-width: 980px) {
  :root { --sidebar-w: 72px; }
  .split { grid-template-columns: 1fr; }
  .topRight .pill { display: none; }
  .content { padding: 18px 16px 28px; }
}

@media (max-width: 640px) {
  .topbar { padding: 12px 16px; }
  .topSearch { min-width: 140px; }
  .authCard { grid-template-columns: 1fr; }
  .authVisual { display: none; }
}

/* ══ Selection ══════════════════════════════════════════════ */
::selection { background: rgba(201,168,124,.25); color: var(--navy); }