/* ═══════════════════════════════════════════
   HistoLabX — BerlinAnalytix Design System
   DAkkS-accredited Histopathology CRO
   ═══════════════════════════════════════════ */

/* Fonts self-hosted — see static/css/fonts.css (GDPR/Schrems II) */
@import url('/static/css/fonts.css');

:root {
    /* ── Brand palette (forest green + warm neutrals) ── */
    --brand: #1b6b4a;
    --brand-dark: #155a3d;
    --brand-light: #e8f5ee;
    --brand-mid: #a3d9b8;
    --brand-glow: rgba(27,107,74,0.10);

    /* ── Semantic colours ── */
    --danger: #c53030;
    --danger-bg: #fef0ed;
    --teal: #1b6b4a;
    --teal-bg: #e8f5ee;
    --amber: #b7791f;
    --amber-bg: #fefcbf;
    --amber-fg: #744210;

    /* ── Surfaces ── */
    --bg: #f5f5f0;
    --bg2: #eeeee8;
    --surface: #ffffff;
    --warm: #fafaf6;
    --border: #e5e5e0;
    --border2: #d0d0ca;
    --nav-bg: #0d1a12;
    --footer-bg: #0f1a2e;

    /* ── Text hierarchy ── */
    --text: #1a1a2e;
    --text2: #4a4a5a;
    --text3: #7a7a8a;
    --text4: #a0a0aa;

    /* ── Radii ── */
    --radius: 10px;
    --radius-sm: 6px;
    --radius-lg: 12px;

    /* ── Shadows (subtle, institutional) ── */
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.04);
    --shadow-md: 0 2px 8px rgba(0,0,0,0.06);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.10);

    /* ── Typography ── */
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-display: 'Source Serif 4', 'Georgia', serif;
    --mono: 'JetBrains Mono', 'Consolas', monospace;
    --transition: 0.15s ease;

    /* ═══════════════════════════════════════════════════════════════
       Phase 4.2 v2 token additions — viewer rework foundation
       (DESIGN_PROMPT §10, landed 2026-05-04). Additive layer; no
       existing tokens renamed.
       ═══════════════════════════════════════════════════════════════ */

    /* ── Accessibility floor — non-negotiable ── */
    --focus-ring: 0 0 0 2px var(--brand);
    --focus-ring-offset: 2px;

    /* ── Specimen-stain palette (promoted from inline templates/base.html
          :15-22 to :root). Currently scoped to the navbar's style block;
          promoting makes them available to viewer chrome (Mode tabs,
          status pills, the on-brand viewer's accent strokes). The
          existing inline definitions in base.html stay (harmless
          shadowing of identical values). ── */
    --specimen-black: #1a1420;
    --specimen-deep:  #2a2038;
    --stain-purple:   #6b5a8e;
    --stain-lavender: #9b8bb8;
    --stain-pink:     #c94068;
    --stain-rose:     #d4758a;
    --stain-blue:     #7088a8;
    --stain-red:      #a83040;

    /* ── Tissue palette ── matches TISSUE_COLORS in
          static/js/dist/viewer-bundle.min.js so chrome (toolbar tissue
          buttons, sidebar tissue dots) renders with the same colors as
          canvas overlays. The JS map stays as-is per DESIGN §4
          (annotation rendering preserved); these CSS tokens read the
          same values for chrome consistency. ── */
    --tissue-bsm:        #00E5FF;  /* bone substitute — cyan */
    --tissue-newbone:    #39FF14;  /* new bone — neon green */
    --tissue-softtissue: #FFE600;  /* soft tissue — yellow */
    --tissue-deadspace:  #FF6D00;  /* dead space — orange */
    --tissue-artifact:   #FF0090;  /* artifact — hot pink */

    /* ── Grade palette (semantic ISO 10993-6 0–4 gradient) ── */
    --grade-0: #6b7a7c;  /* none — neutral cool */
    --grade-1: #5a8aa8;  /* slight — cool blue */
    --grade-2: #c4a050;  /* mild — gold */
    --grade-3: #c97840;  /* moderate — amber */
    --grade-4: #c54040;  /* severe — destructive red */

    /* ── GLP block (institutional, NOT warning-coded) ── */
    --glp-bg:     rgba(107,90,142,0.08);
    --glp-border: rgba(107,90,142,0.20);
    --glp-fg:     #4f4170;

    /* ── Cormorant Garamond binding (REQUIRED for the slide-title
          component in the new study header strip per DESIGN §1B).
          Cormorant is already loaded by static/css/fonts.css; this
          gives it a token name. Outfit also loads in fonts.css but
          remains intentionally unbound — Wave 2 will either bind it
          to a navbar/login token per the README's five-typeface
          system, or unload to reduce orphan-loaded weight. ── */
    --font-display-serif: 'Cormorant Garamond', 'Source Serif 4', Georgia, serif;
}

/* ═══════════════════════════════════════════════════════════════
   Phase 4.2 v2 — accessibility floor + annotation glow
   (DESIGN §10). Live in the global stylesheet so every component
   inherits without per-component opt-in.
   ═══════════════════════════════════════════════════════════════ */

/* Focus-visible ring — accessibility non-negotiable. */
button:focus-visible,
a:focus-visible,
[tabindex]:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
    border-radius: var(--radius-sm);  /* match component radius for crispness */
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    height: 100%;
    -webkit-font-smoothing: antialiased;
    font-size: 13px;
    line-height: 1.6;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text4); }

/* ═══════════════════
   TOOLBAR
   ═══════════════════ */
.toolbar {
    background: url('/static/histology_banner.png') center/cover no-repeat;
    border-bottom: none;
    height: 52px;
    display: flex;
    align-items: center;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 100;
}
.toolbar-brand-bar {
    height: 2px;
    background: var(--brand);
    position: sticky;
    top: 52px;
    z-index: 100;
}
.toolbar-logo {
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 800;
    color: #000000;
    text-decoration: none;
    letter-spacing: -0.3px;
    text-shadow: 0 1px 3px rgba(255,255,255,0.5);
}
.toolbar-logo span { color: #1b6b4a; text-shadow: 0 1px 3px rgba(255,255,255,0.5); }
.toolbar-sep {
    width: 1px;
    height: 20px;
    background: rgba(255,255,255,0.15);
    margin: 0 14px;
}
.toolbar-nav { display: flex; gap: 2px; }
.toolbar-btn {
    padding: 5px 12px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 700;
    color: rgba(0,0,0,0.7);
    text-decoration: none;
    border: none;
    background: none;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
    font-family: var(--font);
    text-shadow: 0 1px 2px rgba(255,255,255,0.4);
}
.toolbar-btn:hover { background: rgba(255,255,255,0.3); color: #000000; }
.toolbar-btn.active { background: rgba(255,255,255,0.4); color: #1b6b4a; font-weight: 800; }
/* Bug 5 / Finding 8-D: When .toolbar-btn sits inside the dark global nav
   (via {% block toolbar_extra %}), its default dark-on-light styling
   rendered as faded/low-contrast text on the dark navbar — users
   reported it overlapping/bleeding into the Upload Slide item. Override
   for the dark-nav context: light text, subtle hover. */
.histolab-nav .toolbar-btn {
    color: rgba(245, 240, 234, 0.85);
    text-shadow: none;
    padding: 7px 14px;
    font-weight: 600;
}
.histolab-nav .toolbar-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}
.histolab-nav .toolbar-sep {
    margin: 0 10px;
    width: 1px;
    height: 20px;
    background: rgba(255, 255, 255, 0.15);
}
.toolbar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 10px;
}
.role-badge {
    font-size: 9px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-family: var(--font);
}
.role-admin { background: rgba(197,48,48,0.2); color: #991b1b; }
.role-evaluator { background: rgba(27,107,74,0.2); color: #155a3d; }
.role-analyst { background: rgba(0,0,0,0.1); color: rgba(0,0,0,0.7); }
.role-educator { background: rgba(27,107,74,0.2); color: #155a3d; }
.role-student { background: rgba(0,0,0,0.1); color: rgba(0,0,0,0.7); }

/* GLP-Certified Evaluator indicator (precheck Issue 3 / PR 4.6).
   Inline pill rendered by the glp_indicator macro in _macros.html
   wherever a certified evaluator's name appears. Visual mirrors
   .role-badge so it sits naturally beside role tags. The amber/gold
   tone marks it out from the green/red role pills without overpowering
   them. */
.glp-cert-badge {
    display: inline-block;
    margin-left: 4px;
    padding: 1px 6px;
    border-radius: 4px;
    background: rgba(212,135,42,0.15);
    color: #8a5a16;
    font-size: 10px;
    font-weight: 600;
    line-height: 1.4;
    vertical-align: middle;
    cursor: help;
    /* The star glyph leans baseline-up in most fonts; nudge it down
       so the pill looks vertically centred against neighbouring text. */
}
/* Profile-page variant — larger, with explanatory text. Used by
   glp_sticker macro on profile.html. */
.glp-cert-sticker {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: 6px;
    background: rgba(212,135,42,0.1);
    border: 1px solid rgba(212,135,42,0.35);
    color: #8a5a16;
    font-size: 13px;
    font-weight: 600;
    margin: 4px 0 12px;
}
.glp-cert-sticker-icon {
    font-size: 16px;
    color: #b88030;
}
.glp-cert-sticker-text {
    letter-spacing: 0.02em;
}
.toolbar-user-name {
    font-size: 12px;
    font-weight: 500;
    color: rgba(255,255,255,0.85);
}
.toolbar-logout {
    font-size: 12px;
    color: rgba(255,255,255,0.5);
    text-decoration: none;
    padding: 5px 8px;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}
.toolbar-logout:hover { background: rgba(255,255,255,0.08); color: rgba(255,255,255,0.9); }

/* ═══════════════════
   LOGIN
   ═══════════════════ */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    padding: 24px;
}
.login-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 380px;
    overflow: hidden;
    border: 1px solid var(--border);
}
.login-brand-bar {
    height: 3px;
    background: var(--brand);
}
.login-body { padding: 36px 32px 32px; }
.login-title {
    font-family: var(--font-display);
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 2px;
    letter-spacing: -0.3px;
    color: var(--text);
}
.login-subtitle {
    font-size: 12px;
    color: var(--text3);
    margin-bottom: 28px;
}
.form-label {
    display: block;
    font-size: 11px;
    font-weight: 500;
    color: var(--text2);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}
.form-input {
    width: 100%;
    padding: 8px 10px;
    font-size: 12px;
    font-family: var(--font);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    outline: none;
    transition: border-color var(--transition);
    background: var(--surface);
    color: var(--text);
}
.form-input:focus {
    border-color: var(--brand);
}
.form-group { margin-bottom: 16px; }
.modal-body .form-group { margin-bottom: 12px; }
.btn-primary {
    width: 100%;
    padding: 10px;
    font-size: 12px;
    font-weight: 600;
    font-family: var(--font);
    background: var(--brand);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
}
.btn-primary:hover { background: var(--brand-dark); }
.login-hint {
    text-align: center;
    margin-top: 16px;
    font-size: 12px;
    color: var(--text4);
}
.login-hint code {
    font-family: var(--mono);
    background: var(--bg);
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 11px;
}
.flash-error {
    background: var(--danger-bg);
    color: var(--danger);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 500;
    margin-bottom: 14px;
    border-left: 3px solid var(--danger);
}

/* ═══════════════════
   DASHBOARD
   ═══════════════════ */
.page-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px 36px;
}
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 28px;
}
.page-title {
    font-family: var(--font-display);
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.3px;
    color: var(--text);
    line-height: 1.2;
}
.page-subtitle {
    font-size: 13px;
    color: var(--text3);
    margin-top: 2px;
}
.btn {
    padding: 8px 20px;
    font-size: 12px;
    font-weight: 600;
    font-family: var(--font);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
}
.btn-brand { background: var(--brand); color: white; }
.btn-brand:hover { background: var(--brand-dark); }
.btn-outline {
    background: var(--surface);
    color: var(--text2);
    border: 1.5px solid var(--border);
}
.btn-outline:hover { border-color: var(--brand); color: var(--brand); }
.btn-danger { background: var(--danger-bg); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: white; }
.btn-sm { padding: 6px 12px; font-size: 11px; }
.btn-xs { padding: 3px 8px; font-size: 10px; }

.slide-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}
.slide-card {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    color: inherit;
    display: block;
}
.slide-card:hover {
    border-color: var(--brand);
    box-shadow: var(--shadow-md);
}
.slide-thumb {
    width: 100%;
    height: 170px;
    object-fit: cover;
    background: var(--bg2);
    display: block;
}
.slide-thumb-placeholder {
    width: 100%;
    height: 170px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg2);
    color: var(--text4);
    font-size: 13px;
}
.slide-info { padding: 12px 14px; }
.slide-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.slide-meta {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
}
.slide-meta-pill {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
    background: var(--brand-light);
    color: var(--brand);
}

/* ═══════════════════
   SECTION TITLES
   ═══════════════════ */
.section-title {
    font-family: var(--font);
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--brand);
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.section-title::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}
.detail-section-title {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--brand);
    margin-bottom: 8px;
}

/* ═══════════════════
   FOLDERS / CARDS
   ═══════════════════ */
.folder-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
    margin-bottom: 28px;
}
.folder-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    text-decoration: none;
    color: inherit;
    position: relative;
    transition: all var(--transition);
}
.folder-card:hover {
    border-color: var(--brand);
    box-shadow: var(--shadow-md);
}
.folder-icon {
    font-size: 22px;
    flex-shrink: 0;
    line-height: 1;
}
.folder-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    line-height: 1.3;
}
.folder-desc { font-size: 11px; color: var(--text3); margin-top: 2px; }
.folder-count { font-size: 11px; color: var(--text3); }

/* ═══════════════════
   EMPTY STATES
   ═══════════════════ */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text3);
}
.empty-state h3 {
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 600;
    color: var(--text2);
    margin-bottom: 6px;
}
.empty-state p { font-size: 12px; line-height: 1.6; }

/* ═══════════════════
   VIEWER PAGE
   ═══════════════════ */
.viewer-page {
    display: flex;
    /* 54px top nav from base.html. The Mode tabs row (.viewer-study-header)
       used to also reserve ~50px here, but Phase 4.2 follow-up
       (2026-05-05) floated those pills over the canvas via position:fixed
       — so we no longer subtract their height and the canvas reclaims
       that vertical space. */
    height: calc(100vh - 54px);
    background: var(--bg2);
}
.viewer-container, .viewer-main {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: var(--bg2);
}
.sidebar {
    /* Phase 4.2 Task 4.E (DESIGN §7 + §8 DD#1): morphometry sidebar
       widened from 320 → 360 to match the on-brand screenshot's right
       rail. Score-viewer's `.sv-sidebar` stays at 340px until Wave 2
       chrome unification — see VIEWER_REWORK_DESIGN_PROMPT §8 DD#1
       footnote + the score_viewer divergence note in
       templates/partials/viewer_toolbar.html. */
    width: 360px;
    min-width: 360px;
    background: var(--surface);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}
.sidebar-header {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
}
.sidebar-title {
    font-family: var(--font-display);
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.3;
}
.sidebar-subtitle { font-size: 11px; color: var(--text3); margin-top: 2px; }

/* Viewer toolbar icons */
.viewer-toolbar {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 6px 10px;
    display: flex;
    gap: 4px;
    box-shadow: var(--shadow-md);
    z-index: 10;
}
.viewer-tool-btn {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    border: none;
    background: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text3);
    transition: all var(--transition);
    font-size: 14px;
}
.viewer-tool-btn:hover { background: var(--bg); color: var(--text); }
.viewer-tool-btn.active { background: var(--brand-light); color: var(--brand); }

/* ─────────────────────────────────────────────────────────────────
   Phase 4.2 Task 4.B/4.C — tissue pre-selector (named buttons)
   Lives next to .viewer-toolbar / .viewer-tool-btn so the toolbar's
   visual contract is one place. Moved out of viewer.html's inline
   <style> block in Task 4.C per James's CSS-location correction.
   ───────────────────────────────────────────────────────────────── */
.tissue-pre-btn {
    height: 22px;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    background: transparent;
    padding: 0 6px 0 4px;
    gap: 5px;
    font-size: 10px;
    font-weight: 700;
    color: rgba(255,255,255,0.75);
    letter-spacing: 0.02em;
    text-transform: uppercase;
}
.tissue-pre-btn .tissue-swatch {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    opacity: 0.55;
    flex-shrink: 0;
}
.tissue-pre-btn .tissue-name { white-space: nowrap; }
.tissue-pre-btn:hover {
    background: rgba(255,255,255,0.06);
    color: #fff;
}
.tissue-pre-btn:hover .tissue-swatch { opacity: 0.8; }
.tissue-pre-btn.active {
    background: rgba(255,255,255,0.10);
    color: #fff;
    outline: 1px solid rgba(255,255,255,0.45);
    outline-offset: 0;
}
.tissue-pre-btn.active .tissue-swatch { opacity: 1; }

/* ─────────────────────────────────────────────────────────────────
   Phase 4.2 Task 4.B — Mode tabs in study-header strip
   (DESIGN §1B + §8 DD#3). Two-pill row at the top of the viewport;
   active pill is filled with --brand, inactive pill is outlined.
   Inactive tab is an htmx anchor (hx-get against the new
   /api/slides/<id>/sidebar?mode=<other> endpoint, falling back to
   href full-page navigation when JS is disabled).
   ───────────────────────────────────────────────────────────────── */
.viewer-study-header {
    /* Phase 4.2 follow-up (2026-05-05): float Mode tabs over the canvas
       instead of taking a full strip of vertical space below the navbar.
       Reclaims ~50px of canvas height; the .viewer-mode-tabs cluster
       inside this wrapper keeps its own white-bg pill styling so it
       reads as a self-contained floating control over the slide image.
       Anchored top-left of viewport via position:fixed; navbar is 54px
       tall, plus 8px breathing room above the cluster. */
    position: fixed;
    top: 62px;
    left: 16px;
    z-index: 30;
    background: transparent;
    border: none;
    padding: 0;
    display: flex;
    align-items: center;
    gap: 18px;
}
.viewer-mode-tabs {
    display: flex;
    align-items: center;
    gap: 4px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 100px;
    padding: 3px;
}
.viewer-mode-tab {
    padding: 4px 14px;
    font-size: 11px;
    font-weight: 700;
    color: var(--text2);
    text-decoration: none;
    border-radius: 100px;
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    white-space: nowrap;
    user-select: none;
}
.viewer-mode-tab:not(.active):hover {
    background: var(--surface);
    color: var(--text);
}
.viewer-mode-tab.active {
    background: var(--brand);
    color: #fff;
    cursor: default;
}

/* Nudge OSD navigator (minimap) down so it doesn't overlap the
   floating Mode tabs pill cluster (Phase 4.2 follow-up 2026-05-05).
   The pill cluster floats at viewport top:62 / left:16, ~40px tall;
   without these overrides the OSD-default top:0 / left:0 anchor puts
   the navigator directly behind the pill.
   Different offsets per viewer:
     * .viewer-page (morphometry) — only the pill above; navigator
       sits at top:56 with ~6px gap below the pill.
     * .sv-page (scoring) — ISO 10993-6 SCORING badge sits between
       the pill and the navigator (badge at top:54, ~26px tall),
       so the navigator is pushed further down to top:92. */
.viewer-page .navigator {
    top: 56px !important;
    left: 16px !important;
}
.sv-page .navigator {
    top: 92px !important;
    left: 12px !important;
}

/* ─────────────────────────────────────────────────────────────────
   Phase 4.2 Task 4.E — desktop-only viewer + small-screen banner
   (DESIGN §7). Phase 4.2 ships desktop ≥1280px only; tablet drawer
   (1024–1279px) and phone bottom-sheet (<768px) are Wave 2 / Tier
   1.7. The layout stays functional below 1024px (existing
   .sidebar 900px / 640px overrides shrink it gracefully) but a
   quiet "Best viewed on desktop" banner appears in the study-header
   strip via the media query below. The banner markup is rendered
   server-side (always in DOM) and CSS-gated to <1024px — no JS
   breakpoint detection per the prompt's "Out of Phase 4.2 scope".
   ───────────────────────────────────────────────────────────────── */
.viewer-small-screen-banner {
    display: none;
    align-items: center;
    gap: 6px;
    margin-left: auto;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text2);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    letter-spacing: 0.02em;
    white-space: nowrap;
}
.viewer-small-screen-banner::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--amber);
    flex-shrink: 0;
}
@media (max-width: 1023.98px) {
    .viewer-small-screen-banner { display: inline-flex; }
}

/* Annotation cards in sidebar */
.anno-card {
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background var(--transition);
    font-size: 12px;
}
.anno-card:hover { background: rgba(27,107,74,0.03); }
.anno-card.selected { background: var(--brand-light); border-left: 3px solid var(--brand); }

/* ─────────────────────────────────────────────────────────────────
   Phase 4.2 Task 4.0/4.G — annotation glow (live-vs-inert visual
   differentiator for the annotation-as-anchor pattern foundation).
   Annotations carrying attached learning material get a neon glow;
   inert annotations stay matte. Sharp inner ring + softer outer
   halo for a "neon" feel without overwhelming the slide.
   The full Wave 2 click-to-open-pdf trigger is deferred; Phase 4.2
   ships only the visual differentiator + the token plumbing.
   Task 4.G cleanup: relocated from §10 token block to live next to
   .anno-card (its structural neighbour), and refactored to derive
   the colour from --stain-pink via color-mix() so a future palette
   rebrand flows through automatically. Hard-coded rgba triplets
   removed.
   ───────────────────────────────────────────────────────────────── */
.annotation-live {
    box-shadow:
        0 0 0 1.5px color-mix(in srgb, var(--stain-pink) 95%, transparent),
        0 0 18px color-mix(in srgb, var(--stain-pink) 55%, transparent);
    transition: box-shadow var(--transition);
}
.annotation-live:hover {
    box-shadow:
        0 0 0 2px var(--stain-pink),
        0 0 24px color-mix(in srgb, var(--stain-pink) 75%, transparent);
}
.anno-category-badge {
    display: inline-block;
    font-size: 9px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
    background: var(--brand-light);
    color: var(--brand);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.anno-expert-star { color: var(--amber); }

/* Filter pills */
.filter-pill {
    font-size: 11px;
    font-weight: 500;
    padding: 4px 12px;
    border-radius: 100px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text2);
    cursor: pointer;
    transition: all var(--transition);
    font-family: var(--font);
}
.filter-pill:hover { border-color: var(--brand); color: var(--brand); }
.filter-pill.active {
    background: var(--brand);
    border-color: var(--brand);
    color: white;
}

/* Morphometry summary */
.summ-total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 3px 0;
}
.tissue-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
    vertical-align: middle;
}

/* Measurement list */
.meas-row {
    padding: 6px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 11px;
    cursor: pointer;
    transition: background var(--transition);
    display: flex;
    align-items: center;
    gap: 8px;
}
.meas-row:hover { background: rgba(27,107,74,0.03); }
.meas-row.selected { background: var(--brand-light); }

/* Detail panel */
.detail-panel { padding: 16px; }
.detail-back {
    font-size: 11px;
    color: var(--brand);
    cursor: pointer;
    background: none;
    border: none;
    font-family: var(--font);
    font-weight: 500;
    margin-bottom: 12px;
    display: block;
}
.detail-back:hover { text-decoration: underline; }
.detail-header { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.detail-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.detail-title { font-size: 15px; font-weight: 600; color: var(--text); }
.detail-description { font-size: 12px; color: var(--text2); line-height: 1.6; margin-top: 6px; }
.detail-divider { height: 1px; background: var(--border); margin: 14px 0; }

/* Material cards */
.material-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 6px;
    text-decoration: none;
    color: inherit;
    transition: border-color var(--transition);
}
.material-card:hover { border-color: var(--brand); }
.material-icon { font-size: 18px; flex-shrink: 0; }
.material-title { font-size: 12px; font-weight: 500; color: var(--text); }
.material-type { font-size: 10px; color: var(--text4); }

/* Scale bar — physical-distance indicator overlaid on the OSD canvas.
   The HTML structure (see templates/viewer.html line ~333) is:
     <div class="scale-bar-container">
       <div class="scale-bar-line">         (width set inline by JS)
       <div class="scale-bar-label">100 µm  (text set inline by JS)
   updateScaleBar() in static/js/viewer-base.js toggles .hidden when
   the slide has no MPP (microns_per_pixel == 0).

   Positioned bottom-left above the centered .viewer-toolbar (bottom:16px,
   ~40px tall): bottom:70px clears the toolbar with a small gap. Original
   bottom-right placement (2026-05-04) overlapped the toolbar's right
   edge when the tissue palette was wide enough to reach across. */
.scale-bar-container {
    position: absolute;
    bottom: 70px;
    left: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    z-index: 15;
    pointer-events: none;
}
.scale-bar-line {
    height: 3px;
    background: rgba(0,0,0,0.78);
    border: 1px solid rgba(255,255,255,0.55);
    border-radius: 1px;
    /* width is set inline by updateScaleBar() */
}
.scale-bar-label {
    font-size: 11px;
    font-weight: 600;
    font-family: var(--font);
    color: #fff;
    background: rgba(0,0,0,0.5);
    padding: 2px 8px;
    border-radius: 100px;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

/* Mode banners */
.mode-banner {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    padding: 6px 16px;
    border-radius: 100px;
    font-size: 11px;
    font-weight: 600;
    font-family: var(--font);
    z-index: 15;
    white-space: nowrap;
    box-shadow: var(--shadow-md);
    background: var(--surface);
    color: var(--text2);
    border: 1px solid var(--border);
}
.mode-banner.pin-banner { background: var(--danger-bg); color: var(--danger); border-color: var(--danger); }
.mode-banner.measure-banner { background: #fef3cd; color: #856404; border-color: #b7791f; }

/* Edit fields */
.edit-field { margin-bottom: 12px; }
.edit-field label {
    display: block;
    font-size: 11px;
    font-weight: 500;
    color: var(--text3);
    margin-bottom: 4px;
}
.edit-field input, .edit-field textarea, .edit-field select {
    width: 100%;
    padding: 8px 10px;
    font-size: 12px;
    font-family: var(--font);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    outline: none;
    transition: border-color var(--transition);
    background: var(--surface);
    color: var(--text);
}
.edit-field input:focus, .edit-field textarea:focus, .edit-field select:focus {
    border-color: var(--brand);
}
.edit-field textarea { resize: vertical; min-height: 60px; }

/* Color picker */
.color-picker { display: flex; gap: 6px; flex-wrap: wrap; }
.color-swatch {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all var(--transition);
}
.color-swatch:hover { transform: scale(1.1); }
.color-swatch.active { border-color: var(--text); box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--text); }

/* ═══════════════════
   USERS PAGE
   ═══════════════════ */
.users-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
}
.users-table th {
    text-align: left;
    padding: 10px 16px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text3);
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}
.users-table td {
    padding: 10px 16px;
    font-size: 13px;
    border-bottom: 1px solid var(--border);
}
.users-table tr:last-child td { border-bottom: none; }
.users-table tr:hover td { background: rgba(27,107,74,0.03); }
.user-form-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
}
.user-form-row {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-wrap: wrap;
}
.user-form-row .form-group { margin-bottom: 0; flex: 1; min-width: 140px; }

/* ═══════════════════
   QUIZ
   ═══════════════════ */
.quiz-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 14px;
}
.quiz-question {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 14px;
    line-height: 1.4;
}
.quiz-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 6px;
    cursor: pointer;
    transition: all var(--transition);
    font-size: 13px;
}
.quiz-option:hover { border-color: var(--brand); background: var(--brand-light); }
.quiz-option.selected { border-color: var(--brand); background: var(--brand-light); }
.quiz-option.correct { border-color: var(--brand); background: var(--brand-light); }
.quiz-option.incorrect { border-color: var(--danger); background: var(--danger-bg); }
.quiz-option-marker {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 1.5px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    flex-shrink: 0;
}
.quiz-explanation {
    margin-top: 10px;
    padding: 10px;
    background: var(--brand-light);
    border-radius: var(--radius-sm);
    font-size: 12px;
    color: var(--brand);
    line-height: 1.5;
}

/* ═══════════════════
   COLOR ADJUST PANEL
   ═══════════════════ */
.color-panel {
    position: absolute;
    top: 12px;
    right: 12px;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 16px;
    width: 260px;
    z-index: 20;
    border: 1px solid var(--border);
}
.color-panel-title {
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 14px;
}
.slider-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}
.slider-label {
    font-size: 11px;
    color: var(--text3);
    width: 65px;
    flex-shrink: 0;
}
.slider-input {
    flex: 1;
    -webkit-appearance: none;
    height: 3px;
    border-radius: 2px;
    background: var(--bg2);
    outline: none;
}
.slider-input::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--brand);
    cursor: pointer;
}
.slider-value {
    font-size: 11px;
    font-family: var(--mono);
    color: var(--text3);
    width: 28px;
    text-align: right;
}

/* ═══════════════════
   MODALS
   ═══════════════════ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s;
}
.modal-overlay.active { opacity: 1; visibility: visible; }
.modal {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 500px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(16px);
    transition: transform 0.2s;
}
.modal-overlay.active .modal { transform: translateY(0); }
.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.modal-title {
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 700;
}
.modal-body {
    padding: 16px 20px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}
.modal-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    flex-shrink: 0;
}
.modal-hint { font-size: 11px; color: var(--text4); margin-top: 4px; }

/* ═══════════════════
   UTILITIES
   ═══════════════════ */
.flex { display: flex; }
.flex-center { align-items: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.text-muted { color: var(--text3); }
.text-sm { font-size: 12px; }
.text-xs { font-size: 10px; }
.fw-600 { font-weight: 600; }
.hidden { display: none !important; }

/* ═══════════════════
   UPLOAD MODAL
   ═══════════════════ */
.upload-dropzone {
    border: 1.5px dashed var(--border);
    border-radius: var(--radius);
    padding: 24px;
    text-align: center;
    transition: all var(--transition);
    cursor: pointer;
}
.upload-dropzone.compact {
    padding: 10px;
    border-style: solid;
    border-color: var(--brand-mid);
    background: var(--brand-light);
}
.upload-dropzone:hover, .upload-dropzone.dragover {
    border-color: var(--brand);
    background: var(--brand-light);
}
.upload-dropzone-icon {
    font-size: 32px;
    margin-bottom: 6px;
}
.upload-dropzone-text {
    font-size: 12px;
    color: var(--text3);
}
.upload-progress {
    margin-top: 14px;
    height: 3px;
    background: var(--bg2);
    border-radius: 2px;
    overflow: hidden;
}
.upload-progress-bar {
    height: 100%;
    background: var(--brand);
    border-radius: 2px;
    transition: width 0.3s;
}

/* ── Submission status badges ── */
.sub-status {
    display: inline-block;
    font-size: 9px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.sub-status.sub-none { background: var(--bg); color: var(--text4); }
.sub-status.sub-draft { background: var(--brand-light); color: var(--brand); }
.sub-status.sub-submitted { background: var(--amber-bg); color: var(--amber-fg); }
.sub-status.sub-approved { background: var(--brand-light); color: var(--brand); }

/* Sprint 0.3.1c-CLAIM-VIZ V.2 (2026-05-06) — claim attribution badge.
   Inline indicator next to slide title in the project dashboard's
   work-slides folder. Renders for any slide with claimed_by populated;
   provides at-a-glance "who has what claimed" oversight for admin /
   evaluator walking the dashboard. Existing tokens only — no new
   tokens introduced. The lock icon is a 10×10 inline SVG
   (currentColor stroke), kept terse to fit alongside the question
   and returned-revision badges without breaking title density. */
.claim-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    margin-left: 6px;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 0.3px;
    background: var(--surface-2, var(--bg));
    color: var(--text2, var(--text4));
    border: 1px solid var(--border);
    vertical-align: middle;
    white-space: nowrap;
}
.claim-badge-icon { flex-shrink: 0; opacity: 0.65; }
.claim-badge-name { font-weight: 600; }

/* ── Card delete button ── */
.card-delete-btn {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: none;
    background: var(--bg);
    color: var(--text4);
    font-size: 10px;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}
.folder-card:hover .card-delete-btn { display: flex; }
.card-delete-btn:hover { background: var(--danger-bg); color: var(--danger); }

/* ═══════════════════
   RESPONSIVE
   ═══════════════════ */

/* AI loading bar animation */
@keyframes aiLoadBar {
    0% { transform: translateX(-100%); }
    50% { transform: translateX(200%); }
    100% { transform: translateX(-100%); }
}

@media (max-width: 900px) {
    .sidebar { width: 300px; min-width: 300px; }
    .slide-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
}
@media (max-width: 640px) {
    .viewer-page { flex-direction: column; }
    .sidebar { width: 100%; min-width: 100%; max-height: 40vh; }
    .page-container { padding: 16px; }
}
