:root {
    --paper: #faf8f3;
    --ink: #1b2330;
    --muted: #8a8275;
    --accent: #0f6e5c;
    --accent-soft: #e4f0ed;
    --line: #e4dfd3;
    --danger: #b4442e;
    --danger-soft: #f6e8e3;
    --panel-bg: #ffffff;
    --panel-alt: #f4f2ec;
    --shadow-sm: 0 1px 2px rgba(27, 35, 48, 0.05);
    --shadow-md: 0 4px 14px rgba(27, 35, 48, 0.07);
    --radius: 6px;
    --sp-1: 0.35rem;
    --sp-2: 0.6rem;
    --sp-3: 0.9rem;
    --sp-4: 1.3rem;
    --sp-5: 2rem;
    --ease: 150ms ease;
    /* ── v2 design tokens (journal vocabulary) ── */
    --accent-ink: #0a4f41;
    --highlight: #f3e9c6;
    --ink-soft: #3a4352;
    --font-serif: Georgia, "Iowan Old Style", "Times New Roman", serif;
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    --measure: 62ch;
    --page: 1180px;
    --rule-double: 3px double var(--ink);
    --label: 0.8rem;
    /* type scale: use these, never raw rem values, on new UI */
    --fs-xs: 0.78rem;  --fs-sm: 0.9rem;  --fs-base: 1rem;  --fs-md: 1.125rem;
    --fs-lg: 1.4rem;   --fs-xl: 1.9rem;  --fs-2xl: clamp(2rem, 3.4vw, 2.8rem);
    --fs-hero: clamp(2.6rem, 5vw, 4rem);
    --track-label: 0.16em;
    --radius-lg: 12px;
    --shadow-lg: 0 24px 48px -20px rgba(27, 35, 48, 0.3);
  }
  * { box-sizing: border-box; }
  body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--font-sans);
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
  }
  html { scroll-behavior: smooth; }
  ::selection { background: var(--highlight); color: var(--ink); }
  h1, h2, h3 {
    font-family: var(--font-serif);
    font-weight: 600;
    letter-spacing: -0.01em;
    margin: 0 0 0.4em;
  }
  .mono {
    font-family: var(--font-mono);
  }
  a { color: var(--accent); text-decoration: none; }
  a:hover { text-decoration: underline; }
  :focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
  }
  @media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
  }
  header.site {
    border-bottom: 1px solid var(--line);
    padding: 1.1rem 1.5rem;
    display: flex;
    align-items: baseline;
    justify-content: space-between;
  }
  header.site .brand {
    font-family: Georgia, serif;
    font-weight: 700;
    font-size: 1.15rem;
    letter-spacing: 0.01em;
  }
  header.site .brand .mark { color: var(--accent); }
  .mark { display: inline-flex; flex-shrink: 0; }
  .mark svg, .mark img { width: 1.2em; height: 1.2em; display: block; object-fit: contain; }
  header.site nav a { margin-left: 1.2rem; font-size: 0.92rem; color: var(--muted); transition: color var(--ease); }
  header.site nav a:hover { color: var(--ink); }
  main { max-width: 760px; margin: 0 auto; padding: 2.2rem 1.5rem 4rem; }
  .query-line {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    border: 1px solid var(--line);
    background: white;
    border-radius: var(--radius);
    padding: 0.55rem 0.8rem;
  }
  .query-line label {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.78rem;
    color: var(--muted);
    letter-spacing: 0.04em;
  }
  .query-line input[type=text] {
    flex: 1;
    border: none;
    outline: none;
    font-size: 1rem;
    font-family: inherit;
    background: transparent;
  }
  .query-line button {
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 4px;
    padding: 0.45rem 0.9rem;
    font-size: 0.88rem;
    cursor: pointer;
  }
  .query-line button:hover { opacity: 0.9; }
  .card {
    border-left: 3px solid var(--line);
    padding: 0.2rem 0 0.2rem 1rem;
    margin: 1.6rem 0;
    transition: border-color var(--ease);
  }
  .card:hover { border-left-color: var(--accent); }
  .card .id-tag {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.75rem;
    color: var(--muted);
  }
  .card h3 { font-size: 1.05rem; margin-top: 0.25rem; }
  .card .abstract { color: #44403a; font-size: 0.93rem; margin: 0.5rem 0; }
  .card .actions { margin-top: 0.5rem; }
  .card .actions button, .card .actions a.btn {
    font-size: 0.82rem;
    border: 1px solid var(--line);
    background: white;
    color: var(--ink);
    padding: 0.32rem 0.7rem;
    border-radius: 4px;
    cursor: pointer;
    margin-right: 0.5rem;
    display: inline-block;
    transition: border-color var(--ease), color var(--ease);
  }
  .card .actions button:hover, .card .actions a.btn:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
  .reason-box {
    background: var(--accent-soft);
    border-radius: var(--radius);
    padding: 0.8rem 1rem;
    margin-top: 0.6rem;
    font-size: 0.93rem;
  }
  .empty {
    color: var(--muted);
    font-size: 0.92rem;
    padding: 2rem 1.2rem;
    text-align: center;
    border: 1px dashed var(--line);
    border-radius: var(--radius);
  }
  ul.plain { list-style: none; padding: 0; margin: 0.6rem 0 0; }
  ul.plain li {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--line);
    font-size: 0.92rem;
    display: flex;
    justify-content: space-between;
  }
  pre {
    background: #1b2330;
    color: #e8e6df;
    padding: 1rem;
    border-radius: var(--radius);
    overflow-x: auto;
    font-size: 0.85rem;
    line-height: 1.5;
  }
  .field { margin: 0.9rem 0; }
  .field .k { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
  .section-label {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.78rem;
    color: var(--muted);
    letter-spacing: 0.05em;
    text-transform: uppercase;
    margin: 2rem 0 0.5rem;
  }

  /* ── Shared component system ────────────────────────────────────────
     One button vocabulary and one panel vocabulary, used everywhere
     instead of each page hand-rolling its own near-duplicate classes. */

  .btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4em;
    border-radius: 4px;
    font-family: inherit;
    font-size: 0.85rem;
    padding: 0.42rem 0.9rem;
    cursor: pointer;
    border: 1px solid transparent;
    transition: border-color var(--ease), color var(--ease), background var(--ease), opacity var(--ease);
  }
  .btn:disabled { opacity: 0.55; cursor: not-allowed; }
  .btn-sm { padding: 0.24rem 0.6rem; font-size: 0.76rem; }
  .btn-primary { background: var(--accent); color: white; }
  .btn-primary:hover:not(:disabled) { opacity: 0.9; }
  .btn-secondary { background: var(--panel-bg); border-color: var(--line); color: var(--ink); }
  .btn-secondary:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
  .btn-ghost { background: none; border-color: transparent; color: var(--muted); padding: 0.2rem 0.4rem; }
  .btn-ghost:hover:not(:disabled) { color: var(--ink); }
  .btn-danger-ghost { background: none; border-color: transparent; color: var(--danger); padding: 0.2rem 0.4rem; font-size: 0.85rem; }
  .btn-danger-ghost:hover:not(:disabled) { background: var(--danger-soft); border-radius: 4px; }
  .btn-danger { background: var(--panel-bg); border-color: #e0a89c; color: var(--danger); }
  .btn-danger:hover:not(:disabled) { background: var(--danger-soft); }

  .flex { display: flex; align-items: center; }

  .panel {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    margin-bottom: var(--sp-4);
    overflow: hidden;
    background: var(--panel-bg);
    box-shadow: var(--shadow-sm);
  }
  .panel-accent { border-color: var(--accent); }
  .panel-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: var(--sp-2) var(--sp-3);
    background: var(--accent-soft);
    cursor: pointer;
    user-select: none;
  }
  .panel-header.static { cursor: default; }
  .panel-header.neutral { background: var(--panel-alt); }
  .panel-header h3 { margin: 0; font-size: 0.9rem; color: var(--accent); }
  .panel-header.neutral h3 { color: var(--ink); }
  .panel-header .chevron { color: var(--muted); font-size: 0.8rem; transition: transform var(--ease); }
  .panel-body { padding: var(--sp-3); display: none; }
  .panel-body.open { display: block; }
  .panel-hint { font-size: 0.78rem; color: var(--muted); margin: 0 0 var(--sp-3); line-height: 1.5; }

  .list-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: var(--sp-1) 0;
    border-bottom: 1px solid var(--line);
    font-size: 0.78rem;
  }
  .list-row:last-child { border-bottom: none; }

  .empty-error { border-color: #e0a89c; color: var(--danger); background: var(--danger-soft); }
  .inline-form { display: inline; }
  .tag-pill {
    font-size: 0.72rem; background: var(--accent-soft); color: var(--accent);
    padding: 0.1rem 0.5rem; border-radius: 10px;
  }
  .result-row { display:flex; flex-direction:column; align-items:flex-start; gap:0.2rem; padding:0.7rem 0; }
  .result-row .result-title { font-size:0.95rem; font-weight:500; color:var(--ink); }
  .result-row .result-meta { display:flex; gap:0.6rem; align-items:center; flex-wrap:wrap; margin-top:0.1rem; }
  .result-row .result-meta .mono { font-size:0.75rem; color:var(--muted); }
  .ptldr { font-size: 0.72rem; color: var(--muted); line-height: 1.4; margin-top: 0.3rem; font-style: italic; }
  .upload-line { margin-top: var(--sp-2); display:flex; gap:0.6rem; align-items:center; flex-wrap:wrap; }
  .upload-line label { font-size:0.82rem; color:var(--muted); }
  .subtitle { color:var(--muted); margin-top:-0.3em; }

  .field-group { margin-bottom: var(--sp-3); }
  .field-group label { display:block; font-size:0.72rem; text-transform:uppercase;
                       letter-spacing:0.05em; color:var(--accent); font-weight:600; margin-bottom:0.25rem; }
  .field-group label .req { color:var(--danger); }
  .field-group label .opt { font-size:0.7rem; color:var(--muted); font-weight:400; text-transform:none; letter-spacing:0; }
  .field-group textarea, .field-group input[type=text],
  .field-group input[type=email], .field-group input[type=password] {
    width:100%; border:1px solid var(--line); border-radius:4px;
    padding:0.45rem 0.55rem; font-family:inherit; font-size:0.88rem;
    resize:vertical; box-sizing:border-box; background:white;
    transition:border-color var(--ease);
  }
  .field-group textarea:focus, .field-group input:focus { outline:none; border-color:var(--accent); }
  .field-group .hint { font-size:0.75rem; color:var(--muted); margin-top:0.25rem; }
  .auth-form { max-width:380px; }

  /* ── Auth pages (login / signup) ─────────────────────────────────────
     Centered card instead of a form floating on the bare page background.
     Uses layout/auth_base.html (a standalone page, not the app-shell in
     layout/base.html) — an anonymous visitor on their way to sign up has
     no use for the Library/Search/Projects/Proposals nav, and showing it
     here just because base.html handles current_user()=None gracefully
     doesn't mean it belongs; the landing page (main/landing.html) made the
     same call for the same reason. */
  body.auth-page { margin:0; background:var(--paper); }
  .auth-nav { padding:1.1rem 1.5rem; display:flex; align-items:center; justify-content:space-between; }
  .auth-brand {
    display:inline-flex; align-items:center; gap:0.5rem;
    font-family:Georgia, "Iowan Old Style", "Times New Roman", serif;
    font-weight:700; font-size:1.1rem; letter-spacing:0.02em;
    color:var(--ink) !important; text-decoration:none !important;
  }
  .auth-mark { width:20px; height:20px; color:var(--accent); display:inline-flex; }
  .auth-mark svg, .auth-mark img { width:100%; height:100%; object-fit: contain; }
  .auth-back { font-size:0.86rem; color:var(--muted) !important; text-decoration:none !important; }
  .auth-back:hover { color:var(--accent) !important; }

  .auth-wrap { display:flex; justify-content:center; padding-top:1.5rem; }
  .auth-card {
    width:100%; max-width:400px; background:var(--panel-bg);
    border:1px solid var(--line); border-radius:10px;
    padding:2rem 1.9rem 1.8rem; box-shadow:var(--shadow-md);
  }
  .auth-card h1 { font-size:1.4rem; margin-bottom:0.25rem; }
  .auth-card .subtitle { margin-top:0; margin-bottom:1.4rem; font-size:0.9rem; }
  .auth-card .auth-form { max-width:none; }
  .auth-card .btn-block { margin-top:0.2rem; }
  .auth-footer { text-align:center; margin-top:1.3rem; margin-bottom:0; }

  .google-btn {
    display:flex; align-items:center; justify-content:center; gap:0.6rem;
    width:100%; background:white; color:#3c4043; border:1px solid #dadce0;
    border-radius:6px; padding:0.55rem 0.9rem; font-family:inherit;
    font-size:0.88rem; font-weight:500; cursor:pointer; text-decoration:none;
    transition:box-shadow var(--ease), background var(--ease);
  }
  .google-btn:hover { background:#f8f8f8; box-shadow:0 1px 3px rgba(60,64,67,0.25); text-decoration:none; }
  .google-btn svg { flex-shrink:0; }

  .auth-divider { display:flex; align-items:center; gap:0.8rem; margin:1.2rem 0; color:var(--muted); font-size:0.76rem; text-transform:uppercase; letter-spacing:0.04em; }
  .auth-divider::before, .auth-divider::after { content:""; flex:1; height:1px; background:var(--line); }

  .oauth-disabled-note { font-size:0.74rem; color:var(--muted); text-align:center; margin:1rem 0 0; padding:0.6rem; background:var(--panel-alt); border-radius:6px; }

  /* ── Avatars ── */
  .avatar {
    display:inline-flex; align-items:center; justify-content:center;
    width:1.6rem; height:1.6rem; border-radius:50%; overflow:hidden;
    background:var(--accent); color:white; font-size:0.72rem; font-weight:700;
    vertical-align:middle; flex-shrink:0;
  }
  .avatar img { width:100%; height:100%; object-fit:cover; }
  .avatar-lg { width:3.4rem; height:3.4rem; font-size:1.35rem; }
  .nav-user { display:inline-flex; align-items:center; gap:0.4rem; }

  /* ── Dropzone file upload ─────────────────────────────────────────────
     Shared by every "upload a PDF" spot in the app (home page, project
     sidebar, methodology/results panels) so file inputs stop looking like
     bare unstyled browser widgets. Styled to read as a real call-to-action
     at rest — an accent-tinted fill and a filled icon badge — rather than
     needing a hover to look like anything other than a faint dashed box. */
  .dropzone {
    position:relative; display:flex; align-items:center; gap:0.7rem;
    border:1.5px dashed var(--accent); border-radius:var(--radius);
    background:var(--accent-soft); padding:0.75rem 0.9rem;
    cursor:pointer; transition:border-color var(--ease), background var(--ease), box-shadow var(--ease);
  }
  .dropzone:hover { border-style:solid; box-shadow:0 0 0 3px rgba(15,110,92,0.12); }
  .dropzone.dz-drag { border-style:solid; background:var(--accent); box-shadow:0 0 0 3px rgba(15,110,92,0.18); }
  .dropzone.dz-drag .dz-text, .dropzone.dz-drag .dz-text strong { color:white; }
  .dropzone.dz-drag .dz-icon { background:white; color:var(--accent); }
  .dropzone.has-file { border-style:solid; }
  .dropzone input[type=file] {
    position:absolute; width:1px; height:1px; padding:0; margin:-1px;
    overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0;
  }
  .dropzone .dz-icon {
    flex-shrink:0; width:2.2rem; height:2.2rem; border-radius:50%;
    background:var(--accent); border:none;
    display:flex; align-items:center; justify-content:center;
    font-size:1.05rem; color:white; transition:background var(--ease), color var(--ease);
  }
  .dropzone .dz-copy { min-width:0; flex:1; }
  .dropzone .dz-text { font-size:0.85rem; color:var(--ink); }
  .dropzone .dz-text strong { color:var(--accent); }
  .dropzone .dz-hint { font-size:0.72rem; color:var(--muted); margin-top:0.1rem; }
  .dropzone .dz-filename {
    font-size:0.76rem; color:var(--accent); margin-top:0.2rem;
    white-space:nowrap; overflow:hidden; text-overflow:ellipsis; font-weight:600;
  }
  .dropzone-sm { padding:0.6rem 0.75rem; gap:0.55rem; }
  .dropzone-sm .dz-icon { width:1.85rem; height:1.85rem; font-size:0.85rem; }
  .dropzone-sm .dz-text { font-size:0.8rem; }
  .dropzone-row { display:flex; gap:0.6rem; align-items:stretch; flex-wrap:wrap; }
  .dropzone-row .dropzone { flex:1; min-width:220px; }

  /* ── App shell — left sidebar nav ─────────────────────────────────────
     Replaces the old top header bar. Fixed-width icon+label rail, brand
     at top, nav items in the middle, account controls pinned to the
     bottom. Collapses to icon-only below a breakpoint rather than hiding
     entirely, since the nav should stay reachable on a tablet-width
     window without needing a hamburger/drawer. */
  .app-shell { display: flex; min-height: 100vh; }

  .sidebar {
    width: 224px; flex-shrink: 0;
    background: var(--panel-bg);
    border-right: 1px solid var(--line);
    display: flex; flex-direction: column;
    padding: var(--sp-4) 0;
    position: sticky; top: 0; height: 100vh;
    transition: width var(--ease);
  }
  .sidebar .brand {
    font-family: Georgia, serif; font-weight: 700; font-size: 1.1rem;
    letter-spacing: 0.01em; padding: 0 var(--sp-4) var(--sp-4);
    display: flex; align-items: center; gap: 0.4rem;
  }
  .sidebar .brand .mark { color: var(--accent); }
  .sidebar .brand .brand-text { flex: 1; }

  .sidebar-toggle {
    flex-shrink: 0; display: flex; align-items: center; justify-content: center;
    width: 26px; height: 26px; padding: 0; border: none; border-radius: 6px;
    background: transparent; color: var(--muted); cursor: pointer;
    transition: background var(--ease), color var(--ease);
  }
  .sidebar-toggle:hover { background: var(--panel-alt); color: var(--ink); }
  .sidebar-toggle svg { width: 16px; height: 16px; }

  .sidebar-nav { flex: 1; display: flex; flex-direction: column; gap: 0.1rem; padding: 0 var(--sp-2); }
  .sidebar-nav a {
    display: flex; align-items: center; gap: 0.7rem;
    padding: 0.55rem 0.7rem; border-radius: 6px;
    font-size: 0.88rem; color: var(--muted); text-decoration: none;
    transition: background var(--ease), color var(--ease);
  }
  .sidebar-nav a:hover { background: var(--panel-alt); color: var(--ink); text-decoration: none; }
  .sidebar-nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
  .sidebar-nav a svg { flex-shrink: 0; width: 18px; height: 18px; }
  .sidebar-nav .nav-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  .sidebar-account { padding: var(--sp-3) var(--sp-2) 0; border-top: 1px solid var(--line); margin-top: var(--sp-2); }
  .sidebar-account .account-row {
    display: flex; align-items: center; gap: 0.55rem;
    padding: 0.45rem 0.7rem; border-radius: 6px; text-decoration: none;
    color: var(--ink); transition: background var(--ease);
  }
  .sidebar-account .account-row:hover { background: var(--panel-alt); text-decoration: none; }
  .sidebar-account .account-name { font-size: 0.83rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .sidebar-account .account-email { font-size: 0.72rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .sidebar-account form { padding: 0.15rem 0.7rem 0; }
  .sidebar-account .btn-ghost { font-size: 0.8rem; padding: 0.3rem 0; }

  .sidebar-auth { padding: 0 var(--sp-2); display: flex; flex-direction: column; gap: 0.3rem; }
  .sidebar-auth a { padding: 0.5rem 0.7rem; }

  .app-main { flex: 1; min-width: 0; }
  .app-main > main { max-width: 760px; margin: 0 auto; padding: 2.2rem 1.5rem 4rem; }

  /* ── Page top bar — title + contextual actions ───────────────────────
     Optional per-page header (see layout/base.html's `top_bar` block):
     a title on the left, action buttons on the right. Pages that need a
     full-bleed layout (e.g. the project workspace) override `main`'s
     max-width/padding in their own page CSS and make this bar sticky. */
  .top-bar {
    display: flex; align-items: center; gap: var(--sp-3);
    padding-bottom: 0.9rem; margin-bottom: var(--sp-4);
    border-bottom: 1px solid var(--line);
  }
  .top-bar-title {
    flex: 1; min-width: 0; font-size: 1rem; font-weight: 600; color: var(--ink);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .top-bar-title .tb-muted { font-weight: 400; color: var(--muted); }
  .top-bar-actions { display: flex; gap: 0.5rem; flex-shrink: 0; align-items: center; }

  /* Collapse to icon-only rail on narrower windows rather than disappearing */
  @media (max-width: 880px) {
    .sidebar { width: 64px; }
    .sidebar .brand .brand-text,
    .sidebar-nav .nav-label,
    .sidebar-account .account-email,
    .sidebar-account .account-name { display: none; }
    .sidebar .brand { justify-content: center; padding: 0 0 var(--sp-4); }
    .sidebar-nav a { justify-content: center; padding: 0.65rem; }
    .sidebar-account .account-row { justify-content: center; }
    .sidebar-account form { display: flex; justify-content: center; padding: 0.15rem 0; }
  }
  @media (max-width: 600px) {
    .app-shell { flex-direction: column; }
    .sidebar {
      width: 100%; height: auto; position: static; flex-direction: row;
      align-items: center; padding: 0.6rem var(--sp-3); overflow-x: auto;
      border-right: none; border-bottom: 1px solid var(--line);
    }
    .sidebar .brand { padding: 0 var(--sp-3) 0 0; }
    .sidebar-nav { flex-direction: row; flex: 0; }
    .sidebar-account { border-top: none; border-left: 1px solid var(--line); margin-top: 0; margin-left: auto; padding: 0 0 0 var(--sp-2); display: flex; align-items: center; }
    .sidebar-account .account-row { padding: 0.3rem; }
    .sidebar-account form { padding: 0; }
  }

  /* ── Manual sidebar toggle ─────────────────────────────────────────────
     Independent of the responsive auto-collapse above: html.sidebar-collapsed
     is applied/removed by JS and persisted in localStorage. Scoped to widths
     above the mobile breakpoint so it never fights the row layout, which
     already has its own compact treatment. */
  @media (min-width: 601px) {
    html.sidebar-collapsed .sidebar { width: 64px; }
    html.sidebar-collapsed .sidebar .brand { justify-content: center; padding: 0 0 var(--sp-4); }
    html.sidebar-collapsed .sidebar .brand .brand-text { display: none; }
    html.sidebar-collapsed .sidebar-nav a { justify-content: center; padding: 0.65rem; }
    html.sidebar-collapsed .sidebar-nav .nav-label { display: none; }
    html.sidebar-collapsed .sidebar-account .account-row { justify-content: center; }
    html.sidebar-collapsed .sidebar-account .account-name,
    html.sidebar-collapsed .sidebar-account .account-email { display: none; }
    html.sidebar-collapsed .sidebar-account form { display: flex; justify-content: center; padding: 0.15rem 0; }
    html.sidebar-collapsed .sidebar-toggle svg { transform: rotate(180deg); }
  }

  /* ── Arkive Assistant bubble ────────────────────────────────────────── */
  .assistant-root { position: fixed; right: var(--sp-4); bottom: var(--sp-4); z-index: 50; }

  .assistant-toggle {
    width: 52px; height: 52px; border-radius: 50%; border: none;
    background: var(--accent); color: white; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    box-shadow: var(--shadow-md); transition: transform var(--ease), opacity var(--ease);
  }
  .assistant-toggle:hover { transform: scale(1.05); }
  .assistant-toggle svg { width: 24px; height: 24px; }
  .assistant-toggle .icon-close { display: none; }
  .assistant-toggle[aria-expanded="true"] .icon-chat { display: none; }
  .assistant-toggle[aria-expanded="true"] .icon-close { display: block; }

  .assistant-panel {
    position: absolute; right: 0; bottom: calc(52px + var(--sp-3));
    width: 340px; max-width: calc(100vw - 2 * var(--sp-4));
    height: 460px; max-height: calc(100vh - 140px);
    background: var(--panel-bg); border: 1px solid var(--line); border-radius: 12px;
    box-shadow: var(--shadow-md); display: flex; flex-direction: column; overflow: hidden;
  }
  /* The panel's own display:flex above is an author-stylesheet rule, which
     always beats the browser's built-in `[hidden] { display: none }` rule
     regardless of specificity — author styles win over user-agent styles by
     origin, not just selector weight. Without this override the panel would
     stay visible (and un-closeable) no matter what the `hidden` attribute
     says. A higher-specificity selector guarantees this wins instead. */
  .assistant-panel[hidden] { display: none; }
  .assistant-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: var(--sp-3) var(--sp-3); border-bottom: 1px solid var(--line);
    font-family: Georgia, serif; font-weight: 700; font-size: 0.95rem;
  }
  .assistant-messages {
    flex: 1; overflow-y: auto; padding: var(--sp-3);
    display: flex; flex-direction: column; gap: 0.6rem;
  }
  .assistant-msg {
    font-size: 0.85rem; line-height: 1.5; padding: 0.5rem 0.7rem;
    border-radius: 10px; max-width: 88%; white-space: pre-wrap;
  }
  .assistant-msg-bot { background: var(--panel-alt); color: var(--ink); align-self: flex-start; }
  .assistant-msg-user { background: var(--accent-soft); color: var(--ink); align-self: flex-end; }
  .assistant-msg-error { background: var(--danger-soft); color: var(--danger); align-self: flex-start; }
  .assistant-msg-pending { background: var(--panel-alt); color: var(--muted); align-self: flex-start; font-style: italic; }

  .assistant-form {
    display: flex; gap: 0.5rem; align-items: flex-end;
    padding: var(--sp-2) var(--sp-3); border-top: 1px solid var(--line);
  }
  .assistant-input {
    flex: 1; resize: none; max-height: 90px; font: inherit; font-size: 0.85rem;
    padding: 0.4rem 0.6rem; border: 1px solid var(--line); border-radius: 8px;
    color: var(--ink); background: var(--paper);
  }
  .assistant-input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

  @media (max-width: 600px) {
    .assistant-panel { width: calc(100vw - 2 * var(--sp-3)); right: calc(-1 * var(--sp-4) + var(--sp-3)); }
  }

  /* ── v2 shared utilities (use on every page) ── */
  .label { font-family: var(--font-mono); font-size: var(--label); letter-spacing: .14em;
           text-transform: uppercase; color: var(--accent); }
  .rule-double { border: 0; border-top: var(--rule-double); margin: var(--sp-4) 0; }
  .btn-lg { padding: .75rem 1.4rem; font-size: 1rem; border-radius: var(--radius); font-weight: 600; }
  .btn-primary:hover:not(:disabled) { background: var(--accent-ink); opacity: 1; }
  .btn-outline { background: transparent; border-color: var(--ink); color: var(--ink); }
  .btn-outline:hover:not(:disabled) { background: var(--ink); color: var(--paper); text-decoration: none; }

  /* ── Busy system (static/js/shared/busy.js) ── */
  .app-main { position: relative; }
  .busy-bar { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 1000; opacity: 0; pointer-events: none; overflow: hidden; transition: opacity .25s; }
  .busy-bar.on { opacity: 1; }
  .busy-bar::before { content: ""; position: absolute; inset: 0; width: 40%; background: linear-gradient(90deg, transparent, var(--accent), #2fa88c, transparent); animation: busy-slide 1.3s cubic-bezier(.5,0,.5,1) infinite; }
  @keyframes busy-slide { from { transform: translateX(-100%); } to { transform: translateX(260%); } }
  .busy-dock { position: fixed; left: 50%; bottom: 1.4rem; z-index: 1000; display: flex; align-items: center; gap: .8rem; max-width: min(92vw, 560px);
    padding: .65rem 1.2rem .65rem .85rem; border-radius: 99px; background: var(--ink); color: var(--paper); box-shadow: var(--shadow-lg);
    opacity: 0; transform: translate(-50%, 24px); pointer-events: none; transition: opacity .3s, transform .35s cubic-bezier(.2,.8,.2,1); }
  .busy-dock.on { opacity: 1; transform: translate(-50%, 0); }
  .busy-txt { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
  .busy-label { font-size: .88rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .busy-sub { font-size: .68rem; letter-spacing: .04em; color: rgba(250,248,243,.65); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .busy-orbit { position: relative; flex-shrink: 0; width: 22px; height: 22px; border-radius: 50%; border: 2px solid rgba(250,248,243,.22); border-top-color: #7fe0c8; animation: busy-spin .9s linear infinite; }
  .busy-orbit::after { content: ""; position: absolute; inset: 5px; border-radius: 50%; background: #7fe0c8; opacity: .85; animation: busy-pulse 1.4s ease-in-out infinite; }
  @keyframes busy-spin { to { transform: rotate(360deg); } }
  @keyframes busy-pulse { 50% { transform: scale(.4); opacity: .4; } }
  .busy-veil { position: absolute; inset: 0; z-index: 40; background: rgba(250,248,243,.78); backdrop-filter: blur(3px); opacity: 0; visibility: hidden; transition: opacity .25s, visibility .25s; cursor: progress; }
  .busy-veil.on { opacity: 1; visibility: visible; }
  .busy-card { position: sticky; top: 28vh; max-width: 420px; margin: 24vh auto 0; padding: 1.8rem 1.8rem 1.4rem; text-align: center; background: var(--panel-bg); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); }
  .busy-orbit-lg { width: 42px; height: 42px; margin: 0 auto 1rem; display: block; border-color: var(--accent-soft); border-top-color: var(--accent); }
  .busy-orbit-lg::after { inset: 11px; background: var(--accent); }
  .busy-card-title { font-size: var(--fs-lg); margin: 0 0 .4rem; }
  .busy-card-phase { font-size: var(--fs-sm); color: var(--ink-soft); margin: 0 0 .9rem; min-height: 1.4em; }
  .busy-steps { display: flex; justify-content: center; gap: .4rem; margin-bottom: .9rem; }
  .busy-steps:empty { display: none; }
  .busy-steps i { width: 26px; height: 4px; border-radius: 4px; background: var(--line); transition: background .4s; }
  .busy-steps i.done { background: var(--accent); } .busy-steps i.now { background: var(--accent); animation: busy-blink 1s ease-in-out infinite; }
  @keyframes busy-blink { 50% { opacity: .35; } }
  .busy-card-note { font-size: var(--fs-xs); color: var(--muted); margin: 0; }
  .ai-locked { opacity: .5; cursor: not-allowed !important; }
  .is-loading { pointer-events: none; opacity: .85; }
  .is-loading .arr { animation: busy-spin .8s linear infinite; }
  @media (prefers-reduced-motion: reduce) { .busy-bar::before { animation-duration: 3s; } .busy-orbit { animation-duration: 2.5s !important; } }

  /* ── Buttons v2 (site-wide; overrides the older .btn rules above) ── */
  .btn { display: inline-flex; align-items: center; justify-content: center; gap: .5rem; height: 38px; padding: 0 1.05rem; border-radius: var(--radius);
    font-family: inherit; font-size: var(--fs-sm); font-weight: 600; letter-spacing: .005em; line-height: 1; white-space: nowrap; text-decoration: none; cursor: pointer;
    border: 1px solid transparent; transition: background var(--ease), color var(--ease), border-color var(--ease), box-shadow var(--ease), transform var(--ease); }
  .btn svg { width: 15px; height: 15px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
  .btn-sm { height: 32px; padding: 0 .85rem; font-size: var(--fs-xs); border-radius: calc(var(--radius) - 1px); }
  .btn:focus-visible { outline: 0; box-shadow: 0 0 0 3px rgba(15,110,92,.28); }
  .btn:active:not(:disabled) { transform: translateY(0) !important; }
  .btn:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; }
  .btn-primary { background: var(--accent); color: #fff; box-shadow: 0 8px 14px -10px var(--accent); }
  .btn-primary:hover:not(:disabled) { background: var(--accent-ink); opacity: 1; transform: translateY(-1px); text-decoration: none; }
  .btn-secondary { background: var(--panel-bg); border-color: var(--line); color: var(--ink); box-shadow: var(--shadow-sm); }
  .btn-secondary:hover:not(:disabled) { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-ink); text-decoration: none; }
  .btn-ghost { background: transparent; border-color: transparent; color: var(--ink-soft); padding: 0 .75rem; box-shadow: none; }
  .btn-ghost:hover:not(:disabled) { background: var(--panel-alt); color: var(--ink); }
  .btn-danger { background: var(--panel-bg); border-color: #e0a89c; color: var(--danger); }
  .btn-danger:hover:not(:disabled) { background: var(--danger-soft); border-color: var(--danger); }
  .btn-danger-ghost { background: transparent; border-color: transparent; color: var(--muted); }
  .btn-danger-ghost:hover:not(:disabled) { background: var(--danger-soft); color: var(--danger); }
  .btn-icon { width: 32px; padding: 0; }
  .app-legal { display: flex; gap: var(--sp-4); justify-content: center; padding: var(--sp-4) 0 var(--sp-3); font-size: var(--fs-xs); }
  .app-legal a { color: var(--muted); }
  .app-legal a:hover { color: var(--accent); }

/* Shared "Back" pill (templates/layout/_back.html; behaviour in js/shared/base.js) */
.back-link { display: inline-flex; align-items: center; gap: .4rem; margin: 0 0 1.1rem -.2rem; padding: .35rem .9rem .35rem .65rem; border-radius: 99px; font-size: var(--fs-xs); font-weight: 600; color: var(--muted) !important; text-decoration: none !important; transition: background var(--ease), color var(--ease); }
.back-link:hover { background: var(--accent-soft); color: var(--accent-ink) !important; }
.back-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.back-link .arr { display: inline-block; transition: transform .25s; }
.back-link:hover .arr { transform: translateX(-4px); }
@media print { .back-link { display: none !important; } }
