/* =========================================================================
   SOMA CEA — Project Document Register
   Design concept: a drawing register (sidebar) next to a plotted sheet
   (viewer), framed with print registration marks and a real title block —
   the same conventions used on the BOQs/drawings this tool displays.
   ========================================================================= */

:root, :root[data-theme="dark"] {
    color-scheme: dark;

    --ink:        #0a0a0a;
    --ink-2:      #0f1210;
    --panel:      rgba(20, 20, 20, 0.78);
    --panel-2:    rgba(255, 255, 255, 0.03);
    --line:       rgba(212, 175, 55, 0.20);
    --line-soft:  rgba(255, 255, 255, 0.08);

    --gold:       #d4af37;
    --gold-light: #f3d572;
    --steel:      #6f8fa8;   /* blueprint-adjacent secondary accent */

    --text:       #f0f0f0;
    --text-dim:   #a9a9a9;
    --text-faint: #6f6f6f;

    /* Chrome surfaces (header, mobile nav, footer) — kept separate from
       --ink so they can shift independently of the page background per
       theme, without hardcoding rgba(0,0,0,..) all over the file. */
    --surface-header: rgba(10, 10, 10, 0.92);
    --surface-nav:     rgba(8, 8, 8, 0.98);
    --surface-footer:  #030303;
    --surface-glow-1: rgba(212, 175, 55, 0.07);
    --surface-glow-2: rgba(111, 143, 168, 0.06);

    --danger:  #e08585;
    --success: #9fe0af;

    --font-body: 'Inter', 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'SFMono-Regular', Consolas, monospace;

    --radius-lg: 24px;
    --radius-md: 14px;
    --ease: cubic-bezier(.22,1,.36,1);
}

/* Day view — the same drawing-register concept lit like a plotted sheet
   under studio light instead of a lightbox at night. The PDF/photo/video
   viewer canvas intentionally stays dark in both themes, the same way a
   photo editor's canvas stays dark regardless of UI theme — it's the
   content that needs to read cleanly there, not the surrounding chrome. */
:root[data-theme="light"] {
    color-scheme: light;

    --ink:        #f3f1ea;
    --ink-2:      #ffffff;
    --panel:      rgba(255, 255, 255, 0.82);
    --panel-2:    rgba(10, 10, 10, 0.035);
    --line:       rgba(160, 118, 20, 0.28);
    --line-soft:  rgba(10, 10, 10, 0.09);

    --gold:       #a8791f;
    --gold-light: #8a6116;
    --steel:      #386178;

    --text:       #1a1712;
    --text-dim:   #5c574c;
    --text-faint: #8c8676;

    --surface-header: rgba(255, 255, 255, 0.88);
    --surface-nav:     rgba(255, 255, 255, 0.97);
    --surface-footer:  #ece8dd;
    --surface-glow-1: rgba(168, 121, 31, 0.10);
    --surface-glow-2: rgba(56, 97, 120, 0.07);

    --danger:  #b3413f;
    --success: #2f7a44;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: var(--font-body);
    background:
        radial-gradient(680px 420px at 12% -10%, var(--surface-glow-1), transparent 60%),
        radial-gradient(600px 500px at 100% 10%, var(--surface-glow-2), transparent 55%),
        var(--ink);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    transition: background-color .3s var(--ease), color .3s var(--ease);
}

a { color: inherit; }

/* ===== Header ===== */
.header {
    position: sticky;
    top: 0;
    width: 100%;
    height: 85px;
    background: var(--surface-header);
    backdrop-filter: blur(16px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 0 50px;
    z-index: 1000;
    border-bottom: 1px solid var(--line);
    transition: background-color .3s var(--ease), border-color .3s var(--ease);
}
.logo {
    font-size: 24px;
    font-weight: 800;
    letter-spacing: 2px;
    color: var(--gold);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 12px;
}
.logo-sub { color: var(--text-dim); font-weight: 600; }
.logo-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--gold);
    position: relative;
    flex-shrink: 0;
}
.logo-icon::after {
    content: "";
    position: absolute;
    inset: 0;
    border: 2px solid var(--gold);
    border-radius: 9px;
    transform: translate(4px, -4px);
}
.nav-links { display: flex; gap: 36px; }
.nav-links a {
    color: var(--text-dim);
    text-decoration: none;
    font-weight: 600;
    font-size: 13px;
    letter-spacing: 1.4px;
    position: relative;
    transition: color .25s var(--ease);
}
.nav-links a:hover, .nav-links a.active { color: var(--gold); }
.nav-links a::after {
    content: '';
    position: absolute;
    bottom: -8px; left: 0;
    width: 0; height: 2px;
    background: var(--gold);
    transition: width .25s var(--ease);
}
.nav-links a:hover::after, .nav-links a.active::after { width: 100%; }

/* ===== Day / Night toggle ===== */
.theme-toggle {
    position: relative;
    display: inline-flex;
    align-items: center;
    width: 54px;
    height: 28px;
    padding: 0;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--panel-2);
    cursor: pointer;
    flex-shrink: 0;
    transition: background-color .25s var(--ease), border-color .25s var(--ease);
}
.theme-toggle-track {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 7px;
    font-size: 11px;
    color: var(--text-faint);
    pointer-events: none;
}
.theme-toggle-thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--gold);
    color: var(--ink);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    line-height: 1;
    transform: translateX(0);
    transition: transform .28s var(--ease), background-color .28s var(--ease);
    box-shadow: 0 1px 4px rgba(0,0,0,0.35);
}
[data-theme="light"] .theme-toggle-thumb {
    transform: translateX(26px);
    background: var(--steel);
    color: #fff;
}
.theme-toggle:focus-visible { outline: 2px solid var(--gold-light); outline-offset: 2px; }
.theme-toggle:hover { border-color: var(--gold); }

.nav-toggle {
    display: none;
    width: 40px; height: 40px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: transparent;
    color: var(--gold);
    font-size: 18px;
    cursor: pointer;
    flex-shrink: 0;
}

.mobile-nav {
    display: none;
    flex-direction: column;
    position: sticky;
    top: 85px;
    background: var(--surface-nav);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--line);
    max-height: 0;
    overflow: hidden;
    transition: max-height .3s var(--ease);
    z-index: 999;
}
.mobile-nav.open { max-height: 320px; }
.mobile-nav a {
    padding: 16px 24px;
    border-bottom: 1px solid var(--line-soft);
    color: var(--text-dim);
    text-decoration: none;
    font-weight: 600;
    font-size: 13px;
    letter-spacing: 1.4px;
}
.mobile-nav a.active, .mobile-nav a:hover { color: var(--gold); }

/* Mobile-only trigger for the document register drawer */
.register-trigger {
    display: none;
    align-items: center;
    gap: 10px;
    width: 100%;
    margin-bottom: 20px;
    padding: 14px 18px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 12px;
    letter-spacing: 1px;
    cursor: pointer;
}
.register-trigger-count {
    margin-left: auto;
    color: var(--ink);
    background: var(--gold);
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 9px;
}

.scrim {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 998;
}
.scrim[hidden] { display: none; }

/* ===== Page title ===== */
.container { max-width: 1400px; margin: 0 auto; padding: 48px 40px 80px; }

.page-title { margin-bottom: 34px; max-width: 640px; }
.eyebrow {
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 3px;
    color: var(--gold);
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
}
.eyebrow::before { content: ''; width: 24px; height: 1px; background: var(--gold); }
.page-title h1 {
    font-size: clamp(28px, 3.4vw, 40px);
    font-weight: 800;
    letter-spacing: .5px;
    margin-bottom: 12px;
}
.page-sub { color: var(--text-dim); font-size: 1rem; max-width: 46ch; }

/* ===== Layout ===== */
.doc-viewer-wrapper {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 24px;
    align-items: start;
}

/* ===== Register (sidebar) ===== */
.doc-list {
    background: var(--panel);
    backdrop-filter: blur(6px);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    overflow: hidden;
    position: sticky;
    top: 105px;
}
.doc-list-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px;
    border-bottom: 1px solid var(--line-soft);
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--text-dim);
}
.doc-count { color: var(--gold); }

.doc-search-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 18px;
    border-bottom: 1px solid var(--line-soft);
}
.doc-search-icon { font-size: 12px; opacity: .6; flex-shrink: 0; }
.doc-search {
    flex: 1;
    min-width: 0;
    font-family: var(--font-body);
    font-size: 13px;
    padding: 8px 12px;
    border-radius: 999px;
    border: 1px solid var(--line-soft);
    background: rgba(255,255,255,0.03);
    color: var(--text);
}
.doc-search::placeholder { color: var(--text-faint); }
.doc-search:focus-visible { outline: 2px solid var(--gold-light); outline-offset: 1px; }
/* Remove the native WebKit "clear" and search-decoration icon so it
   doesn't clash with our own magnifier icon on the left. */
.doc-search::-webkit-search-decoration,
.doc-search::-webkit-search-cancel-button { -webkit-appearance: none; }

.upload-row {
    padding: 16px 18px;
    border-bottom: 1px solid var(--line-soft);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    transition: background .18s var(--ease), box-shadow .18s var(--ease);
}
.upload-row.drag-over {
    background: rgba(212, 175, 55, 0.06);
    box-shadow: inset 0 0 0 2px var(--gold);
}
.upload-group { display: flex; flex-direction: column; gap: 8px; }
.upload-group-label {
    font-family: var(--font-mono);
    font-size: 9.5px;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--text-faint);
}
.upload-drop-hint {
    text-align: center;
    font-size: 10.5px;
    letter-spacing: .5px;
    color: var(--text-faint);
}

/* Daily / Weekly / Monthly segmented control — replaces what used to be
   three separate full-width buttons, one per report cadence. */
.doc-type-toggle {
    display: flex;
    gap: 4px;
    padding: 3px;
    background: var(--panel-2);
    border: 1px solid var(--line-soft);
    border-radius: 999px;
}
.doc-type-toggle-btn {
    flex: 1;
    padding: 7px 8px;
    border: none;
    border-radius: 999px;
    background: transparent;
    color: var(--text-faint);
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .5px;
    text-transform: uppercase;
    cursor: pointer;
    transition: background .16s var(--ease), color .16s var(--ease);
}
.doc-type-toggle-btn:hover { color: var(--text-dim); }
.doc-type-toggle-btn.active {
    background: var(--gold);
    color: #1a1400;
}

.upload-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 10px 14px;
    background: rgba(212, 175, 55, 0.08);
    border: 1px dashed var(--line);
    border-radius: 10px;
    color: var(--gold-light);
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    cursor: pointer;
    transition: background .2s var(--ease), border-color .2s var(--ease);
}
.upload-btn:hover { background: rgba(212, 175, 55, 0.16); border-color: var(--gold); }
.upload-btn i { font-style: normal; font-size: 13px; }

/* Video + Photo share one compact row instead of two stacked full-width
   buttons — they're picked far less often than a document upload, so they
   don't need the same visual weight. */
.upload-btn-pair { display: flex; gap: 8px; }
.upload-btn-compact { width: auto; flex: 1; padding: 9px 10px; font-size: 10px; }

.upload-btn-video {
    background: rgba(111, 143, 168, 0.10);
    color: #cfe0ec;
    border-color: rgba(111, 143, 168, 0.4);
}
.upload-btn-video:hover { background: rgba(111, 143, 168, 0.18); border-color: var(--steel); }

.upload-btn-photo {
    background: rgba(212, 175, 55, 0.06);
    color: var(--gold-light);
    border-color: rgba(212, 175, 55, 0.35);
}
.upload-btn-photo:hover { background: rgba(212, 175, 55, 0.14); border-color: var(--gold); }

.upload-progress {
    height: 4px;
    border-radius: 4px;
    background: rgba(255,255,255,0.08);
    overflow: hidden;
}
.upload-progress[hidden] { display: none; }
.upload-progress-bar {
    height: 100%;
    width: 0%;
    background: var(--steel);
    transition: width .15s linear;
}

.upload-hint {
    font-size: 11px;
    color: var(--text-faint);
    text-align: center;
}
.upload-hint-error { color: var(--danger); }
.upload-group-media .upload-hint { margin-top: -2px; }

.doc-list-items { display: flex; flex-direction: column; max-height: 62vh; overflow-y: auto; }

.doc-item {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 12px;
    width: 100%;
    text-align: left;
    background: transparent;
    border: none;
    border-left: 2px solid transparent;
    border-bottom: 1px solid var(--line-soft);
    padding: 14px 18px;
    cursor: pointer;
    color: var(--text-dim);
    transition: background .2s var(--ease), border-color .2s var(--ease), color .2s var(--ease);
}
.doc-item:last-child { border-bottom: none; }
.doc-item:hover { background: var(--panel-2); color: var(--text); }
.doc-item.active {
    background: rgba(212,175,55,0.08);
    border-left-color: var(--gold);
    color: var(--text);
}
.doc-item-code {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--gold);
    letter-spacing: .5px;
}
.doc-item.active .doc-item-code { color: var(--gold-light); }
.doc-item-title { font-size: 14px; font-weight: 600; line-height: 1.35; }
.doc-item-type {
    font-family: var(--font-mono);
    font-size: 9px;
    letter-spacing: 1px;
    color: var(--text-faint);
    border: 1px solid var(--line-soft);
    border-radius: 4px;
    padding: 3px 6px;
}
.doc-item.active .doc-item-type { color: var(--steel); border-color: rgba(111,143,168,0.35); }

/* ===== View tabs (List / Gallery) ===== */
.doc-view-tabs {
    display: flex;
    gap: 6px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--line-soft);
}
.doc-view-tab {
    flex: 1;
    font-family: var(--font-mono);
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-faint);
    cursor: pointer;
    transition: background .18s var(--ease), color .18s var(--ease), border-color .18s var(--ease);
}
.doc-view-tab:hover { color: var(--text-dim); }
.doc-view-tab.active {
    background: rgba(212, 175, 55, 0.10);
    border-color: var(--line);
    color: var(--gold-light);
}

/* ===== Type filter chips (List view only) ===== */
.doc-type-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--line-soft);
}
.doc-type-filters[hidden] { display: none; }
.doc-type-chip {
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    padding: 5px 11px;
    border-radius: 999px;
    border: 1px solid var(--line-soft);
    background: transparent;
    color: var(--text-faint);
    cursor: pointer;
    transition: background .18s var(--ease), color .18s var(--ease), border-color .18s var(--ease);
}
.doc-type-chip:hover { color: var(--text-dim); border-color: var(--line); }
.doc-type-chip.active {
    background: var(--gold);
    color: #1a1400;
    border-color: var(--gold);
}
.doc-list-empty {
    padding: 24px 16px;
    text-align: center;
    color: var(--text-faint);
    font-size: 12.5px;
}

/* ===== Gallery view (approved photos + videos) ===== */
/* Explicit [hidden] override: .doc-list-items sets display:flex, and an
   author-stylesheet rule always wins over the UA's [hidden]{display:none}
   at equal specificity — without this, toggling the hidden attribute alone
   would leave List rows visible underneath the Gallery grid. */
.doc-list-items[hidden] { display: none; }

.gallery-view { padding: 14px; max-height: 62vh; overflow-y: auto; }
.gallery-view[hidden] { display: none; }

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}
.gallery-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
    background: transparent;
    border: none;
    padding: 0;
    text-align: left;
    cursor: pointer;
    border-radius: 10px;
}
.gallery-item:focus-visible { outline: 2px solid var(--gold-light); outline-offset: 2px; }

.gallery-thumb {
    position: relative;
    aspect-ratio: 1 / 1;
    border-radius: 10px;
    overflow: hidden;
    background: #050505;
    border: 1px solid var(--line-soft);
    transition: border-color .18s var(--ease), box-shadow .18s var(--ease);
}
.gallery-item:hover .gallery-thumb { border-color: var(--line); }
.gallery-item.active .gallery-thumb { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold); }

.gallery-thumb img, .gallery-thumb video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    pointer-events: none;
}

.gallery-play-badge {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    color: #fff;
    background: rgba(0,0,0,0.28);
    pointer-events: none;
}
.gallery-kind-pill {
    position: absolute;
    top: 6px;
    right: 6px;
    font-family: var(--font-mono);
    font-size: 8px;
    letter-spacing: .5px;
    padding: 2px 6px;
    border-radius: 999px;
    background: rgba(0,0,0,0.55);
    color: var(--gold-light);
    pointer-events: none;
}
.gallery-kind-video { color: #cfe0ec; }

.gallery-item-title {
    font-size: 12px;
    font-weight: 600;
    line-height: 1.3;
    padding: 0 2px;
    color: var(--text-dim);
    transition: color .18s var(--ease);
}
.gallery-item:hover .gallery-item-title,
.gallery-item.active .gallery-item-title { color: var(--text); }

.gallery-empty { color: var(--text-faint); font-size: 12px; padding: 10px 4px; }

@media (max-width: 640px) {
    .gallery-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ===== Viewer panel ===== */
.viewer-panel { min-width: 0; }

.viewer-frame {
    position: relative;
    background: var(--ink-2);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 22px;
}

/* Print registration marks — a nod to plotted-sheet corner ticks */
.reg-mark { position: absolute; width: 18px; height: 18px; pointer-events: none; }
.reg-mark::before, .reg-mark::after { content: ''; position: absolute; background: var(--gold); opacity: .55; }
.reg-mark::before { width: 100%; height: 1px; top: 50%; }
.reg-mark::after  { width: 1px; height: 100%; left: 50%; }
.reg-tl { top: 10px; left: 10px; }
.reg-tr { top: 10px; right: 10px; }
.reg-bl { bottom: 10px; left: 10px; }
.reg-br { bottom: 10px; right: 10px; }

.viewer {
    position: relative;
    height: 64vh;
    min-height: 420px;
    background: #050505;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--line-soft);
}
iframe { width: 100%; height: 100%; border: none; position: relative; z-index: 1; }
#videoViewer {
    width: 100%;
    height: 100%;
    display: block;
    background: #000;
    position: relative;
    z-index: 1;
}
#videoViewer[hidden] { display: none; }
#imageViewer {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
    background: #000;
    position: relative;
    z-index: 1;
}
#imageViewer[hidden] { display: none; }

.viewer-loading {
    position: absolute; inset: 0;
    display: none;
    align-items: center; justify-content: center;
    flex-direction: column; gap: 14px;
    background: #050505;
    color: var(--text-dim);
    font-family: var(--font-mono);
    font-size: 12px;
    letter-spacing: 1px;
    z-index: 2;
}
.viewer-loading.active { display: flex; }
.spinner {
    width: 26px; height: 26px;
    border-radius: 50%;
    border: 2px solid rgba(212,175,55,0.25);
    border-top-color: var(--gold);
    animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Title block — mirrors the info strip on a real drawing sheet */
.title-block {
    margin-top: 18px;
    display: flex;
    align-items: stretch;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--panel-2);
}
.tb-field {
    padding: 12px 18px;
    border-right: 1px solid var(--line-soft);
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}
.tb-doc { flex: 1; }
.tb-label {
    font-family: var(--font-mono);
    font-size: 9px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--text-faint);
}
.tb-value {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.tb-field:not(.tb-doc) .tb-value { font-family: var(--font-mono); color: var(--gold-light); }

.tb-actions { display: flex; margin-left: auto; }
.tb-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 20px;
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: .5px;
    text-decoration: none;
    color: var(--text-dim);
    border-left: 1px solid var(--line-soft);
    transition: background .2s var(--ease), color .2s var(--ease);
}
.tb-btn:hover { background: rgba(212,175,55,0.10); color: var(--gold-light); }
.tb-btn i { font-style: normal; font-size: 13px; }

/* ===== Footer ===== */
.footer {
    background: var(--surface-footer);
    padding: 40px 40px 20px;
    border-top: 1px solid var(--line);
    margin-top: 60px;
    text-align: center;
    transition: background-color .3s var(--ease);
}
.footer p { color: var(--text-dim); font-size: 0.9rem; }
.footer a { color: var(--gold); text-decoration: none; }
.footer a:hover { text-decoration: underline; }
.footer-admin { margin-top: 6px; }
.footer-admin a { color: var(--text-faint); font-size: 0.78rem; letter-spacing: 1px; }
.footer-admin a:hover { color: var(--gold); }

/* ===== Focus visibility (accessibility floor) ===== */
a:focus-visible, button:focus-visible {
    outline: 2px solid var(--gold-light);
    outline-offset: 2px;
}

/* ===== Reduced motion ===== */
@media (prefers-reduced-motion: reduce) {
    * { transition-duration: .001ms !important; animation-duration: .001ms !important; }
}

/* ===== Responsive ===== */
@media (max-width: 900px) {
    .nav-links { display: none; }
    .nav-toggle { display: flex; align-items: center; justify-content: center; }
    .mobile-nav { display: flex; }

    .doc-viewer-wrapper { grid-template-columns: 1fr; }

    .register-trigger { display: flex; }

    .doc-list {
        position: fixed;
        top: 85px; right: 0; bottom: 0;
        width: min(320px, 86vw);
        border-radius: 0;
        border-top: none; border-bottom: none; border-right: none;
        transform: translateX(100%);
        transition: transform .3s var(--ease);
        z-index: 999;
    }
    .doc-list.open { transform: translateX(0); }
    .doc-list-items { max-height: calc(100vh - 85px - 54px); }

    .title-block { flex-wrap: wrap; }
    .tb-field { flex: 1 1 45%; border-bottom: 1px solid var(--line-soft); }
    .tb-actions { flex: 1 1 100%; margin-left: 0; border-top: 1px solid var(--line-soft); }
    .tb-btn { flex: 1; justify-content: center; }
}

@media (max-width: 640px) {
    .header { padding: 0 20px; height: 70px; }
    .mobile-nav { top: 70px; }
    .doc-list { top: 70px; }
    .container { padding: 32px 20px 60px; }
    .viewer { height: 52vh; min-height: 320px; }
    .viewer-frame { padding: 14px; }
}
