/* =========================================================================
   Literature Assistant - design system
   A clean, modern academic/AI aesthetic: indigo accent, deep navy sidebar,
   generous spacing, soft shadows, fully responsive.
   ========================================================================= */

:root {
  /* brand - UC Berkeley */
  --brand:        #003262;   /* Berkeley Blue */
  --brand-600:    #00264d;   /* darker - hover & links */
  --brand-700:    #001a33;
  --brand-50:     #e7eef3;   /* light Berkeley-blue tint */
  --brand-100:    #c9dbe8;

  /* California Gold accent */
  --gold:         #fdb515;
  --gold-600:     #c4820e;   /* Medalist */
  --gold-50:      #fff6e1;
  --gold-100:     #fce7b8;
  --founders:     #3b7ea1;   /* Founder's Rock - medium blue */

  /* neutrals */
  --bg:           #f5f6f8;
  --surface:      #ffffff;
  --surface-2:    #fbfbfd;
  --border:       #e5e7eb;
  --border-strong:#d1d5db;
  --text:         #0f172a;
  --text-muted:   #64748b;
  --text-faint:   #94a3b8;

  /* sidebar */
  --side-bg:      #003262;   /* Berkeley Blue */
  --side-bg-2:    #00264d;
  --side-text:    #cdd9e3;
  --side-text-dim:#8fa9bd;
  --side-active:  #fdb515;   /* California Gold */

  /* status */
  --green:    #16a34a;  --green-bg:  #dcfce7;  --green-border:#bbf7d0;
  --red:      #dc2626;  --red-bg:    #fee2e2;  --red-border:  #fecaca;
  --amber:    #b45309;  --amber-bg:  #fef3c7;  --amber-border:#fde68a;
  --blue:     #2563eb;  --blue-bg:   #dbeafe;  --blue-border: #bfdbfe;

  /* shape */
  --radius:    12px;
  --radius-sm: 8px;
  --radius-lg: 18px;
  --shadow-sm: 0 1px 2px rgba(15,23,42,.06), 0 1px 3px rgba(15,23,42,.05);
  --shadow:    0 4px 12px rgba(15,23,42,.07), 0 2px 4px rgba(15,23,42,.05);
  --shadow-lg: 0 18px 40px rgba(15,23,42,.14);

  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
          Helvetica, Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --sidebar-w: 264px;
  --topbar-h: 64px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 { line-height: 1.25; color: var(--text); margin: 0 0 .5em; font-weight: 700; letter-spacing: -.01em; }
h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.2rem; }
h4 { font-size: 1.02rem; }
p  { margin: 0 0 1rem; }
a  { color: var(--brand-600); text-decoration: none; }
a:hover { text-decoration: underline; }
small { font-size: .82rem; }
hr { border: none; border-top: 1px solid var(--border); margin: 1.5rem 0; }

.muted   { color: var(--text-muted); }
.faint   { color: var(--text-faint); }
.center  { text-align: center; }
.nowrap  { white-space: nowrap; }
.mono    { font-family: var(--mono); }

/* ---------- layout: app shell ------------------------------------------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: linear-gradient(180deg, var(--side-bg) 0%, #00233f 100%);
  color: var(--side-text);
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
  overflow-y: auto;
}

.sidebar .brand {
  display: flex; align-items: center; gap: .7rem;
  padding: 1.25rem 1.25rem 1rem;
  color: #fff; font-weight: 700; font-size: 1.06rem; letter-spacing: -.01em;
}
.sidebar .brand .logo {
  width: 34px; height: 34px; border-radius: 9px; flex: 0 0 34px;
  background: var(--gold); font-weight: 800;
  display: grid; place-items: center; color: var(--brand); box-shadow: var(--shadow-sm);
}
.sidebar .brand small { display:block; color: var(--side-text-dim); font-weight: 500; font-size:.72rem; }

.nav { padding: .5rem .75rem 1rem; flex: 1; }
.nav-label {
  text-transform: uppercase; font-size: .68rem; letter-spacing: .09em;
  color: var(--side-text-dim); padding: 1rem .75rem .4rem; font-weight: 600;
}
.nav-link {
  display: flex; align-items: center; gap: .7rem;
  padding: .56rem .75rem; margin: 2px 0;
  border-radius: var(--radius-sm); color: var(--side-text);
  font-weight: 500; font-size: .92rem; cursor: pointer; transition: background .15s, color .15s;
}
.nav-link:hover { background: rgba(148,163,184,.12); color: #fff; text-decoration: none; }
.nav-link.active { background: var(--side-active); color: var(--brand); font-weight: 700; box-shadow: var(--shadow-sm); }
.nav-link.active .ico { opacity: 1; }
.nav-link .ico { width: 18px; height: 18px; flex: 0 0 18px; opacity: .9; }

.sidebar .side-foot {
  border-top: 1px solid rgba(148,163,184,.15);
  padding: .9rem 1rem; font-size: .8rem; color: var(--side-text-dim);
}

.main {
  flex: 1; min-width: 0;
  margin-left: var(--sidebar-w);
  display: flex; flex-direction: column;
}

.topbar {
  height: var(--topbar-h);
  background: rgba(255,255,255,.85);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 1rem;
  padding: 0 1.5rem; position: sticky; top: 0; z-index: 30;
}
.topbar .hamburger { display: none; }
.topbar .spacer { flex: 1; }
.topbar .topbar-title { font-weight: 700; font-size: 1.05rem; }
.topbar .topbar-title small { display:block; font-weight:500; color: var(--text-muted); font-size:.78rem; }

.content { padding: 1.75rem; max-width: 1180px; width: 100%; margin: 0 auto; }
.content.narrow { max-width: 820px; }

.page-head { margin-bottom: 1.4rem; }
.page-head h1 { margin-bottom: .25rem; }
.page-head .lead { color: var(--text-muted); font-size: 1.02rem; margin: 0; }

/* ---------- user menu ---------------------------------------------------- */
.usermenu { position: relative; }
.usermenu summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: .55rem;
  padding: .35rem .55rem; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface);
}
.usermenu summary::-webkit-details-marker { display: none; }
.avatar {
  width: 30px; height: 30px; border-radius: 999px; flex:0 0 30px;
  background: var(--brand); color: var(--gold);
  display: grid; place-items: center; font-weight: 700; font-size: .85rem;
}
.usermenu .menu {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 220px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: .5rem; z-index: 50;
}
.usermenu .menu a, .usermenu .menu button {
  display: flex; width: 100%; text-align: left; gap: .5rem; align-items: center;
  padding: .5rem .6rem; border-radius: var(--radius-sm); color: var(--text);
  background: none; border: none; font: inherit; cursor: pointer;
}
.usermenu .menu a:hover, .usermenu .menu button:hover { background: var(--brand-50); text-decoration: none; }
.usermenu .menu .sep { border-top: 1px solid var(--border); margin: .4rem 0; }

/* ---------- cards -------------------------------------------------------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm); margin-bottom: 1.25rem;
}
.card.flat { box-shadow: none; }
.card-header { padding: 1.1rem 1.25rem; border-bottom: 1px solid var(--border); }
.card-header h2, .card-header h3 { margin: 0; }
.card-header .sub { color: var(--text-muted); font-size: .9rem; margin-top: .25rem; }
.card-body { padding: 1.25rem; }
.card-body > :last-child { margin-bottom: 0; }

.grid { display: grid; gap: 1.25rem; }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }

/* ---------- metrics ------------------------------------------------------ */
.metric-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.metric {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.1rem 1.25rem; box-shadow: var(--shadow-sm);
}
.metric .value { font-size: 1.9rem; font-weight: 800; letter-spacing: -.02em; }
.metric .label { color: var(--text-muted); font-size: .85rem; font-weight: 500; }
.metric.accent { background: linear-gradient(135deg, var(--brand-50), #fff); border-color: var(--brand-100); }

/* ---------- buttons ------------------------------------------------------ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  font: inherit; font-weight: 600; font-size: .92rem; line-height: 1;
  padding: .62rem 1rem; border-radius: var(--radius-sm); cursor: pointer;
  border: 1px solid transparent; background: var(--surface); color: var(--text);
  transition: background .15s, border-color .15s, box-shadow .15s, transform .04s;
  text-decoration: none; white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--brand-600); }
.btn-secondary { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.btn-secondary:hover { background: var(--surface-2); border-color: var(--text-faint); }
.btn-ghost { background: transparent; color: var(--brand-600); }
.btn-ghost:hover { background: var(--brand-50); }
.btn-success { background: var(--green); color: #fff; }
.btn-success:hover { filter: brightness(.95); }
.btn-danger { background: var(--surface); color: var(--red); border-color: var(--red-border); }
.btn-danger:hover { background: var(--red-bg); }
.btn-danger.solid { background: var(--red); color: #fff; border-color: var(--red); }
.btn-sm { padding: .42rem .7rem; font-size: .84rem; }
.btn-lg { padding: .8rem 1.4rem; font-size: 1rem; }
.btn-block { width: 100%; }
.btn .spin { display: none; }
.btn.loading .spin { display: inline-block; }
.btn.loading .label { opacity: .7; }

.btn-row { display: flex; flex-wrap: wrap; gap: .6rem; }
.btn-row.end { justify-content: flex-end; }

/* ---------- forms -------------------------------------------------------- */
.form-group { margin-bottom: 1.1rem; }
.form-group label, .form-label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .35rem; }
.form-hint { color: var(--text-muted); font-size: .83rem; margin-top: .35rem; }
input[type=text], input[type=password], input[type=email], input[type=number],
input[type=search], select, textarea {
  width: 100%; font: inherit; color: var(--text);
  padding: .6rem .75rem; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); background: var(--surface); transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-100);
}
textarea { resize: vertical; min-height: 90px; }
.checkbox { display: flex; align-items: flex-start; gap: .55rem; font-weight: 500; cursor: pointer; }
.checkbox input { width: auto; margin-top: .2rem; }
.inline-form { display: flex; gap: .6rem; align-items: flex-end; flex-wrap: wrap; }
.inline-form .form-group { margin-bottom: 0; flex: 1; min-width: 160px; }
fieldset { border: none; padding: 0; margin: 0; }

/* segmented control (mode / filters) */
.segmented { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 3px; gap: 3px; }
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span {
  display: block; padding: .42rem .9rem; border-radius: 999px; font-size: .88rem;
  font-weight: 600; color: var(--text-muted); cursor: pointer; white-space: nowrap;
}
.segmented input:checked + span { background: var(--brand); color: #fff; box-shadow: var(--shadow-sm); }

/* ---------- badges & chips ---------------------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: .3rem; padding: .18rem .55rem;
  border-radius: 999px; font-size: .76rem; font-weight: 600; line-height: 1.4;
  background: #f1f5f9; color: var(--text-muted); border: 1px solid var(--border);
}
.badge.green { background: var(--green-bg); color: var(--green); border-color: var(--green-border); }
.badge.red   { background: var(--red-bg);   color: var(--red);   border-color: var(--red-border); }
.badge.amber { background: var(--amber-bg); color: var(--amber); border-color: var(--amber-border); }
.badge.blue  { background: var(--blue-bg);  color: var(--blue);  border-color: var(--blue-border); }
.badge.brand { background: var(--brand-50); color: var(--brand-600); border-color: var(--brand-100); }
.chip { display: inline-block; padding: .2rem .6rem; border-radius: 999px; background: var(--brand-50); color: var(--brand-700); font-size: .8rem; font-weight: 600; margin: 0 .3rem .3rem 0; }

/* ---------- tabs --------------------------------------------------------- */
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); margin-bottom: 1.4rem; overflow-x: auto; }
.tab {
  padding: .7rem 1rem; font-weight: 600; font-size: .92rem; color: var(--text-muted);
  border: none; background: none; cursor: pointer; border-bottom: 2px solid transparent;
  white-space: nowrap; margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--brand); border-bottom-color: var(--gold); }
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---------- tables ------------------------------------------------------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
table.table { width: 100%; border-collapse: collapse; font-size: .9rem; background: var(--surface); }
table.table th, table.table td { padding: .65rem .8rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
table.table thead th { background: var(--surface-2); font-weight: 700; color: var(--text-muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; position: sticky; top: 0; }
table.table tbody tr:hover { background: var(--brand-50); }
table.table tbody tr:last-child td { border-bottom: none; }
table.table td.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- paper accordion --------------------------------------------- */
.paper {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); margin-bottom: .75rem; box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.paper > summary {
  list-style: none; cursor: pointer; padding: .9rem 1.1rem;
  display: flex; align-items: flex-start; gap: .75rem; font-weight: 600;
}
.paper > summary::-webkit-details-marker { display: none; }
.paper > summary::after {
  content: "⌄"; margin-left: auto; color: var(--text-faint); font-size: 1.2rem;
  transition: transform .2s; line-height: 1;
}
.paper[open] > summary::after { transform: rotate(180deg); }
.paper > summary:hover { background: var(--surface-2); }
.paper .rank { color: var(--text-faint); font-weight: 700; flex: 0 0 auto; }
.paper .ptitle { flex: 1; min-width: 0; }
.paper .pbody { padding: 0 1.1rem 1.1rem; border-top: 1px solid var(--border); }
.paper .pbody .meta { color: var(--text-muted); font-size: .85rem; margin: .8rem 0 .4rem; }
.paper .abstract { color: #334155; margin: .6rem 0 1rem; }
.paper .actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }

/* ---------- alerts / flash ---------------------------------------------- */
.alert {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: .85rem 1.1rem; margin-bottom: 1rem; display: flex; gap: .65rem; align-items: flex-start;
  background: var(--surface);
}
.alert.success { background: var(--green-bg); border-color: var(--green-border); color: #14532d; }
.alert.error   { background: var(--red-bg);   border-color: var(--red-border);   color: #7f1d1d; }
.alert.info    { background: var(--blue-bg);  border-color: var(--blue-border);   color: #1e3a8a; }
.alert.warning { background: var(--amber-bg); border-color: var(--amber-border);  color: #78350f; }

.empty {
  text-align: center; padding: 3rem 1.5rem; color: var(--text-muted);
  border: 1px dashed var(--border-strong); border-radius: var(--radius); background: var(--surface-2);
}
.empty .ico { font-size: 2rem; opacity: .5; margin-bottom: .5rem; }

/* ---------- progress ----------------------------------------------------- */
.progress { height: 10px; background: #e9ecf3; border-radius: 999px; overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: linear-gradient(90deg, var(--brand), var(--gold)); border-radius: 999px; transition: width .4s ease; }

/* spinner */
.spin { width: 1em; height: 1em; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .6s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-block { display: flex; align-items: center; gap: .6rem; color: var(--text-muted); padding: 1rem 0; }

/* ---------- toasts ------------------------------------------------------- */
.toast-wrap { position: fixed; right: 1.25rem; bottom: 1.25rem; z-index: 100; display: flex; flex-direction: column; gap: .6rem; }
.toast {
  background: var(--text); color: #fff; padding: .8rem 1.1rem; border-radius: var(--radius);
  box-shadow: var(--shadow-lg); font-weight: 500; max-width: 360px; animation: toastin .25s ease;
}
.toast.success { background: #14532d; }
.toast.error { background: #7f1d1d; }
@keyframes toastin { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* ---------- code / reports ---------------------------------------------- */
.report pre, pre {
  background: #0f172a; color: #e2e8f0; padding: 1rem 1.1rem; border-radius: var(--radius);
  overflow-x: auto; font-family: var(--mono); font-size: .82rem; line-height: 1.5;
}
.report code, code { font-family: var(--mono); font-size: .85em; }
.report :not(pre) > code { background: var(--brand-50); color: var(--brand-700); padding: .1rem .35rem; border-radius: 5px; }
.report h1 { font-size: 1.4rem; } .report h2 { font-size: 1.15rem; margin-top: 1.4rem; }
.report table { border-collapse: collapse; width: 100%; margin: 1rem 0; }
.report th, .report td { border: 1px solid var(--border); padding: .5rem .7rem; text-align: left; }
.report blockquote { border-left: 4px solid var(--amber); background: var(--amber-bg); padding: .6rem 1rem; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; color: #78350f; margin: 1rem 0; }

/* ---------- popover / details helper ------------------------------------ */
.popover { display: inline-block; position: relative; }
.popover > summary { list-style: none; cursor: pointer; }
.popover > summary::-webkit-details-marker { display: none; }
.popover .pop {
  position: absolute; z-index: 50; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 1rem; min-width: 260px; margin-top: .4rem;
}

/* ---------- public / marketing ------------------------------------------ */
.public-nav {
  display: flex; align-items: center; gap: 1rem; padding: 1rem 1.5rem;
  max-width: 1120px; margin: 0 auto;
}
.public-nav .brand { display: flex; align-items: center; gap: .6rem; font-weight: 700; font-size: 1.1rem; color: var(--text); }
.public-nav .brand .logo { width: 34px; height: 34px; border-radius: 9px; background: var(--brand); display: grid; place-items: center; color: var(--gold); font-weight: 800; }
.public-nav .spacer { flex: 1; }

.hero {
  max-width: 1120px; margin: 0 auto; padding: 4rem 1.5rem 3rem;
  display: grid; grid-template-columns: 1.1fr .9fr; gap: 3rem; align-items: center;
}
.hero .eyebrow { display: inline-flex; align-items:center; gap:.4rem; color: var(--gold-600); font-weight: 700; font-size: .82rem; text-transform: uppercase; letter-spacing: .08em; background: var(--gold-50); border: 1px solid var(--gold-100); padding: .35rem .7rem; border-radius: 999px; }
.hero h1 { font-size: 3rem; margin: 1rem 0 1rem; letter-spacing: -.03em; }
.hero p.sub { font-size: 1.2rem; color: var(--text-muted); margin-bottom: 1.75rem; }
.hero .cta { display: flex; gap: .8rem; flex-wrap: wrap; }
.hero-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); padding: 1.25rem; transform: rotate(-1deg);
}
.hero-card .bar { height: 10px; border-radius: 999px; background: var(--brand-100); margin: .5rem 0; }
.hero-card .bar.short { width: 60%; } .hero-card .bar.mid { width: 80%; }

.section { max-width: 1120px; margin: 0 auto; padding: 2.5rem 1.5rem; }
.section h2 { font-size: 1.8rem; text-align: center; }
.section .section-sub { text-align: center; color: var(--text-muted); max-width: 640px; margin: 0 auto 2.5rem; }
.feature-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1.25rem; }
.feature { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; box-shadow: var(--shadow-sm); }
.feature .ico { width: 44px; height: 44px; border-radius: 11px; background: var(--brand-50); color: var(--brand-600); display: grid; place-items: center; margin-bottom: 1rem; }
.feature h3 { font-size: 1.1rem; }

.steps { counter-reset: step; display: grid; gap: 1rem; max-width: 760px; margin: 0 auto; }
.step { display: flex; gap: 1rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow-sm); }
.step .num { counter-increment: step; flex: 0 0 38px; width: 38px; height: 38px; border-radius: 999px; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 800; }
.step .num::before { content: counter(step); }

.cta-band { background: linear-gradient(135deg, var(--brand), var(--founders)); color: #fff; border-radius: var(--radius-lg); padding: 3rem 2rem; text-align: center; margin: 2.5rem auto; max-width: 1120px; border-top: 4px solid var(--gold); }
.cta-band h2 { color: #fff; }
.cta-band p { color: rgba(255,255,255,.9); max-width: 540px; margin: 0 auto 1.5rem; }
.cta-band .btn-secondary { background: var(--gold); border-color: var(--gold); color: var(--brand); font-weight: 700; }
.cta-band .btn-secondary:hover { background: var(--gold-600); border-color: var(--gold-600); color: #fff; }

.site-foot { border-top: 1px solid var(--border); margin-top: 2rem; }
.site-foot .inner { max-width: 1120px; margin: 0 auto; padding: 2rem 1.5rem; display: flex; flex-wrap: wrap; gap: 1rem; justify-content: space-between; color: var(--text-muted); font-size: .88rem; }

/* auth card */
.auth-wrap { min-height: calc(100vh - 70px); display: grid; place-items: center; padding: 2rem 1rem; }
.auth-card { width: 100%; max-width: 430px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: 2rem; }
.auth-card h1 { font-size: 1.5rem; text-align: center; }
.auth-card .sub { text-align: center; color: var(--text-muted); margin-bottom: 1.5rem; }

/* author header strip */
.author-strip { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.25rem; box-shadow: var(--shadow-sm); margin-bottom: 1.5rem; }
.author-strip .who { font-weight: 700; }
.author-strip .links { display: flex; gap: .8rem; flex-wrap: wrap; margin-left: auto; font-size: .9rem; }

/* UC Berkeley seal (shown only in the logged-in area) */
.topbar-seal { height: 34px; width: 34px; flex: 0 0 34px; }
.author-strip .author-photo { width: 76px; height: 76px; flex: 0 0 76px; border-radius: 50%;
  object-fit: cover; object-position: center 25%; border: 2px solid var(--gold); box-shadow: var(--shadow-sm); }
.author-strip .seal-lg { height: 76px; width: 76px; flex: 0 0 76px; margin-left: 1rem; }
@media (max-width: 560px) { .topbar-seal { display: none; } .author-strip .seal-lg { margin-left: 0; } }

/* utilities */
.stack > * + * { margin-top: 1rem; }
.flex { display: flex; gap: 1rem; }
.flex.between { justify-content: space-between; align-items: center; }
.flex.wrap { flex-wrap: wrap; }
.flex.center { align-items: center; }
.gap-sm { gap: .5rem; }
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; }
.mt-1 { margin-top: .5rem; } .mt-2 { margin-top: 1rem; } .mt-3 { margin-top: 1.5rem; }
.hidden { display: none !important; }

/* ---------- responsive --------------------------------------------------- */
@media (max-width: 1024px) {
  .hero { grid-template-columns: 1fr; padding-top: 2.5rem; }
  .hero-card { display: none; }
  .grid.cols-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 860px) {
  :root { --sidebar-w: 248px; }
  .sidebar { transform: translateX(-100%); transition: transform .25s ease; box-shadow: var(--shadow-lg); }
  body.nav-open .sidebar { transform: none; }
  .main { margin-left: 0; }
  .topbar .hamburger { display: inline-flex; }
  .nav-backdrop { display: none; position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 35; }
  body.nav-open .nav-backdrop { display: block; }
  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; }
  .content { padding: 1.1rem; }
}
@media (max-width: 560px) {
  h1 { font-size: 1.6rem; }
  .hero h1 { font-size: 2.2rem; }
  .author-strip .links { margin-left: 0; }
}

/* ===================================================================== */
/*  v2 polish: progress bars, alerts, premium landing                    */
/* ===================================================================== */
.progress { height: 12px; background: #e9edf3; box-shadow: inset 0 1px 2px rgba(15,23,42,.08); }
.progress-bar {
  background: linear-gradient(90deg, var(--brand), var(--gold), var(--brand));
  background-size: 200% 100%; animation: progFlow 2.2s linear infinite;
  transition: width .5s cubic-bezier(.4,0,.2,1); position: relative;
}
.progress-bar::after {
  content:""; position:absolute; inset:0; border-radius:999px;
  background-image: linear-gradient(45deg, rgba(255,255,255,.22) 25%, transparent 25%,
    transparent 50%, rgba(255,255,255,.22) 50%, rgba(255,255,255,.22) 75%, transparent 75%);
  background-size: .9rem .9rem; animation: progStripes 1s linear infinite;
}
@keyframes progFlow { to { background-position: 200% 0; } }
@keyframes progStripes { to { background-position: .9rem 0; } }

.alert { border-left-width: 4px; align-items: center; }
.alert.success { border-left-color: var(--green); }
.alert.error   { border-left-color: var(--red); }
.alert.info    { border-left-color: var(--blue); }
.alert.warning { border-left-color: var(--amber); }
.alert::before { font-weight: 800; font-size: 1rem; line-height: 1; flex: 0 0 auto; }
.alert.success::before { content: "✓"; color: var(--green); }
.alert.error::before   { content: "✕"; color: var(--red); }
.alert.info::before    { content: "ℹ"; color: var(--blue); }
.alert.warning::before { content: "⚠"; color: var(--amber); }

/* premium landing */
.gradient-text {
  background: linear-gradient(115deg, var(--brand) 0%, var(--founders) 55%, var(--gold-600) 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero-wrap { position: relative; overflow: hidden; }
.hero-wrap::before, .hero-wrap::after { content:""; position:absolute; z-index:0; pointer-events:none; border-radius:50%; filter: blur(8px); }
.hero-wrap::before { top:-26%; right:-8%; width:620px; height:620px; background: radial-gradient(circle, rgba(59,126,161,.20), transparent 62%); }
.hero-wrap::after  { bottom:-36%; left:-10%; width:520px; height:520px; background: radial-gradient(circle, rgba(253,181,21,.16), transparent 62%); }
.hero-wrap .hero { position: relative; z-index: 1; }

.mockup { background: var(--surface); border:1px solid var(--border); border-radius:16px; box-shadow: var(--shadow-lg); overflow:hidden; transform: rotate(-1deg); }
.mockup .bar-top { display:flex; gap:.4rem; align-items:center; padding:.7rem .9rem; border-bottom:1px solid var(--border); background:var(--surface-2); }
.mockup .bar-top i { width:11px; height:11px; border-radius:50%; background:#dfe4ee; display:inline-block; }
.mockup .bar-top span { margin-left:.6rem; font-size:.78rem; color:var(--text-faint); }
.mockup .body { padding:1.1rem; }

.stat-band { display:grid; grid-template-columns: repeat(auto-fit,minmax(150px,1fr)); gap:1rem; max-width:1000px; margin:2.5rem auto 0; padding:0 1.5rem; }
.stat { text-align:center; padding:1.1rem 1rem; background:var(--surface); border:1px solid var(--border); border-radius:var(--radius); box-shadow:var(--shadow-sm); }
.stat .n { font-size:1.7rem; font-weight:800; letter-spacing:-.02em; }
.stat .n.brand { color:var(--brand); } .stat .n.gold { color:var(--gold-600); }
.stat .l { color:var(--text-muted); font-size:.84rem; font-weight:500; margin-top:.15rem; }

.feature { transition: transform .15s ease, box-shadow .15s ease; }
.feature:hover { transform: translateY(-3px); box-shadow: var(--shadow); }

/* ===================================================================== */
/*  v3 polish — from the UI/logic audit                                   */
/* ===================================================================== */
:root { --text-muted: #52667a; --text-faint: #64748b; }  /* better WCAG contrast */

.paper { margin-bottom: 1rem; }
.paper > summary { padding: 1rem 1.1rem; }
.paper .rank { margin-right: .15rem; }
.paper .abstract { color: var(--text-muted); line-height: 1.6; }

.card-header { border-bottom: 2px solid var(--brand-100); }

.empty { border: 1px solid var(--border);
  background: linear-gradient(135deg, var(--brand-50), var(--gold-50)); }
.empty .ico { font-size: 2.6rem; }
.empty h3 { margin-top: .4rem; }

.progress { background: var(--brand-50); }

input:hover, select:hover, textarea:hover { border-color: var(--text-faint); }

@media (max-width: 860px) {
  .topbar { padding: 0 1rem; }
  #topicSwitchForm select { min-width: 120px; }
}
@media (max-width: 560px) {
  #topicSwitchForm select { min-width: auto; max-width: 120px; }
  .btn-row { flex-direction: column; align-items: stretch; }
  .btn-row > .btn { width: 100%; }
}
