:root {
    color-scheme: dark;
    --ink: #fff8ea;
    --muted: #c9c0ad;
    --subtle: #918978;
    --bg: #171512;
    --panel: rgba(35, 32, 27, 0.94);
    --panel-strong: rgba(48, 43, 35, 0.97);
    --line: rgba(255, 248, 234, 0.14);
    --line-strong: rgba(255, 248, 234, 0.24);
    --brass: #c69a4a;
    --teal: #2fbea7;
    --teal-dark: #1f6f61;
    --green: #7bbf6a;
    --garnet: #db4b54;
    --focus: 0 0 0 3px rgba(47, 190, 167, 0.32), 0 0 0 6px rgba(198, 154, 74, 0.18);
    --surface-shadow: 0 0 0 1px rgba(255, 248, 234, 0.09), 0 16px 46px rgba(0, 0, 0, 0.28);
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--bg); -webkit-font-smoothing: antialiased; }

body {
    min-height: 100vh;
    min-height: 100svh;
    margin: 0;
    color: var(--ink);
    font-family: "Aptos", "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    background:
        linear-gradient(145deg, rgba(23, 21, 18, 0.98), rgba(35, 31, 26, 0.98) 48%, rgba(17, 32, 29, 0.98)),
        repeating-linear-gradient(90deg, rgba(255, 248, 234, 0.035) 0 1px, transparent 1px 48px);
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(105deg, rgba(198, 154, 74, 0.08), transparent 34%, rgba(47, 190, 167, 0.08) 78%, transparent);
}

button, textarea, audio { font: inherit; }
a { color: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

.recordings-app {
    position: relative;
    width: min(100%, 1440px);
    min-height: 100vh;
    min-height: 100svh;
    margin: 0 auto;
    background: linear-gradient(180deg, rgba(42, 37, 30, 0.94), rgba(25, 23, 20, 0.98));
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    min-height: 86px;
    padding: max(16px, env(safe-area-inset-top)) clamp(18px, 4vw, 54px) 16px;
    border-bottom: 1px solid var(--line);
    background: rgba(21, 19, 16, 0.88);
}

.topbar::after {
    content: "";
    position: absolute;
    top: 84px;
    right: 0;
    left: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--brass), var(--teal), transparent);
    opacity: .72;
}

.brand { display: inline-flex; align-items: center; gap: 13px; min-width: 0; text-decoration: none; }
.brand-mark { position: relative; flex: 0 0 48px; width: 48px; height: 48px; border-radius: 16px; background: linear-gradient(145deg, #d7ae61, rgba(123,191,106,.74)); box-shadow: inset 0 1px rgba(255,255,255,.35), 0 10px 24px rgba(0,0,0,.28); }
.brand-mark::before, .brand-mark::after { content: ""; position: absolute; left: 50%; transform: translateX(-50%); border-radius: 99px; background: var(--bg); }
.brand-mark::before { top: 10px; width: 14px; height: 22px; box-shadow: inset 0 -3px rgba(255,248,234,.2); }
.brand-mark::after { bottom: 9px; width: 26px; height: 4px; }
.brand-copy { display: grid; gap: 2px; min-width: 0; }
.brand-copy strong { font-size: clamp(1.04rem, 2vw, 1.26rem); line-height: 1.1; }
.brand-copy span { color: var(--muted); font-size: .78rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }

.back-link, .primary-link, .secondary-link { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; border-radius: 12px; font-weight: 800; text-decoration: none; }
.back-link { padding: 0 15px 0 13px; color: var(--muted); box-shadow: 0 0 0 1px var(--line); transition: color 150ms, background 150ms, transform 150ms; }
.back-link svg { width: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.back-link:hover { color: var(--ink); background: rgba(255,248,234,.07); }

main { padding: clamp(26px, 5vw, 64px) clamp(16px, 4vw, 54px) 48px; }
.page-intro { display: flex; align-items: end; justify-content: space-between; gap: 34px; max-width: 1220px; margin: 0 auto 28px; }
.eyebrow { margin: 0 0 7px; color: var(--brass); font-size: .72rem; line-height: 1.2; font-weight: 850; letter-spacing: .1em; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
h1 { max-width: 780px; margin-bottom: 12px; font-size: clamp(2.25rem, 6vw, 4.8rem); line-height: .94; letter-spacing: -.045em; text-wrap: balance; }
.intro-copy { max-width: 720px; margin-bottom: 0; color: var(--muted); font-size: clamp(1rem, 1.7vw, 1.2rem); line-height: 1.55; }
.retention-note { display: flex; align-items: center; gap: 12px; flex: 0 0 min(100%, 310px); padding: 14px; border-radius: 16px; color: var(--muted); background: rgba(47,190,167,.08); box-shadow: 0 0 0 1px rgba(47,190,167,.2); font-size: .86rem; line-height: 1.35; }
.retention-note svg { flex: 0 0 30px; width: 30px; fill: none; stroke: var(--teal); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.retention-note span { display: grid; gap: 2px; }
.retention-note strong { color: var(--ink); }

.page-alert { max-width: 1220px; margin: 0 auto 18px; padding: 14px 16px; border-radius: 12px; color: #ffd9d9; background: rgba(182,64,74,.18); box-shadow: 0 0 0 1px rgba(219,75,84,.34); line-height: 1.45; }
.state-card { max-width: 680px; margin: 7vh auto; padding: clamp(30px, 7vw, 64px); border-radius: 24px; text-align: center; background: linear-gradient(180deg, rgba(255,248,234,.078), rgba(255,248,234,.028)), var(--panel); box-shadow: var(--surface-shadow); }
.state-card h2, .detail-placeholder h2 { margin-bottom: 10px; font-size: clamp(1.55rem, 4vw, 2.15rem); }
.state-card p:not(.eyebrow), .detail-placeholder p { max-width: 500px; margin-right: auto; margin-bottom: 24px; margin-left: auto; color: var(--muted); line-height: 1.55; }
.state-icon { display: inline-grid; width: 56px; height: 56px; margin-bottom: 18px; place-items: center; border-radius: 17px; color: var(--teal); background: rgba(47,190,167,.11); box-shadow: 0 0 0 1px rgba(47,190,167,.18); }
.state-icon svg { width: 28px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.state-icon-error { color: var(--garnet); background: rgba(219,75,84,.11); box-shadow: 0 0 0 1px rgba(219,75,84,.2); }
.primary-link, .secondary-link { padding: 0 18px; }
.primary-link { color: var(--bg); background: linear-gradient(180deg, #dfbd72, var(--brass)); }
.secondary-link { color: var(--ink); box-shadow: 0 0 0 1px var(--line-strong); }

.workspace { display: grid; grid-template-columns: minmax(300px, 380px) minmax(0, 1fr); gap: 18px; max-width: 1220px; margin: 0 auto; align-items: start; }
.library-panel, .review-panel { border-radius: 22px; background: linear-gradient(180deg, rgba(255,248,234,.072), rgba(255,248,234,.025)), var(--panel); box-shadow: var(--surface-shadow); }
.library-panel { position: sticky; top: 18px; overflow: hidden; }
.panel-heading, .review-heading, .section-heading { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.panel-heading { padding: 20px; border-bottom: 1px solid var(--line); }
.panel-heading h2, .review-heading h2, .section-heading h3 { margin: 0; }
.panel-heading h2 { font-size: 1.12rem; }
.count-badge { display: inline-grid; min-width: 34px; height: 34px; padding: 0 9px; place-items: center; border-radius: 99px; color: var(--ink); background: rgba(198,154,74,.14); box-shadow: 0 0 0 1px rgba(198,154,74,.22); font-size: .78rem; font-weight: 850; }
.recording-list { max-height: min(68vh, 760px); margin: 0; padding: 8px; overflow-y: auto; list-style: none; scrollbar-color: var(--line-strong) transparent; }
.library-more { padding: 12px; border-top: 1px solid var(--line); }
.library-more button { width: 100%; }
.recording-item { margin: 0; }
.recording-button { width: 100%; min-height: 98px; padding: 14px; border: 0; border-radius: 14px; color: var(--ink); text-align: left; background: transparent; cursor: pointer; transition: background 150ms, box-shadow 150ms, transform 150ms; }
.recording-button:hover { background: rgba(255,248,234,.06); }
.recording-button[aria-current="true"] { background: linear-gradient(135deg, rgba(47,190,167,.15), rgba(198,154,74,.08)); box-shadow: inset 0 0 0 1px rgba(47,190,167,.27); }
.recording-row, .recording-secondary { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.employee-name { min-width: 0; overflow: hidden; font-size: .98rem; font-weight: 820; text-overflow: ellipsis; white-space: nowrap; }
.recording-date { margin-top: 8px; color: var(--muted); font-size: .79rem; }
.recording-secondary { margin-top: 7px; color: var(--subtle); font-size: .73rem; font-variant-numeric: tabular-nums; }
.status-pill { display: inline-flex; align-items: center; flex: 0 0 auto; min-height: 25px; padding: 3px 8px; border-radius: 99px; color: #cffff5; background: rgba(47,190,167,.14); box-shadow: inset 0 0 0 1px rgba(47,190,167,.2); font-size: .66rem; font-weight: 850; letter-spacing: .04em; text-transform: uppercase; }
.status-pill.status-warning { color: #ffe7ad; background: rgba(216,166,64,.14); box-shadow: inset 0 0 0 1px rgba(216,166,64,.22); }
.status-pill.status-error { color: #ffd1d3; background: rgba(219,75,84,.14); box-shadow: inset 0 0 0 1px rgba(219,75,84,.24); }

.review-panel { min-height: 570px; padding: clamp(20px, 3vw, 34px); }
.detail-placeholder { display: grid; min-height: 500px; place-content: center; justify-items: center; text-align: center; }
.review-heading { align-items: flex-start; padding-bottom: 24px; border-bottom: 1px solid var(--line); }
.review-heading h2 { margin-bottom: 12px; font-size: clamp(1.65rem, 3vw, 2.45rem); line-height: 1.05; }
.detail-meta { display: flex; flex-wrap: wrap; gap: 7px 16px; color: var(--muted); font-size: .82rem; }
.detail-meta span { position: relative; }
.detail-meta span + span::before { content: ""; position: absolute; top: 50%; left: -9px; width: 3px; height: 3px; border-radius: 50%; background: var(--brass); }
.audio-card { margin-top: 22px; padding: 20px; border-radius: 18px; background: rgba(15,14,12,.52); box-shadow: 0 0 0 1px var(--line); }
.section-heading h3 { font-size: 1.12rem; }
.file-size { color: var(--subtle); font-size: .76rem; font-variant-numeric: tabular-nums; }
audio { width: 100%; height: 50px; margin-top: 16px; accent-color: var(--teal); }
.audio-loading { display: flex; align-items: center; gap: 10px; min-height: 50px; margin-top: 14px; color: var(--muted); font-size: .84rem; }
.inline-error { margin: 14px 0 6px; color: #ffd1d3; line-height: 1.45; }
.text-button { min-height: 44px; padding: 0; border: 0; color: var(--teal); background: transparent; font-weight: 800; cursor: pointer; }

.evaluation-form { margin-top: 28px; }
.evaluation-heading { align-items: flex-start; }
.draft-status { flex: 0 0 auto; padding: 5px 9px; border-radius: 99px; color: var(--muted); background: rgba(255,248,234,.06); font-size: .7rem; font-weight: 800; }
.draft-status.is-dirty { color: #ffe7ad; background: rgba(216,166,64,.12); }
.draft-status.is-saved { color: #cffff5; background: rgba(47,190,167,.12); }
.form-intro { margin: 9px 0 24px; color: var(--muted); font-size: .86rem; line-height: 1.5; }
.evaluation-form label { display: block; margin: 18px 0 8px; color: var(--ink); font-size: .84rem; font-weight: 820; }
.evaluation-form textarea { display: block; width: 100%; min-height: 108px; resize: vertical; padding: 13px 14px; border: 1px solid var(--line-strong); border-radius: 12px; outline: none; color: var(--ink); background: rgba(10,9,8,.58); line-height: 1.5; transition: border-color 150ms, box-shadow 150ms, background 150ms; }
.evaluation-form textarea::placeholder { color: #817a6b; }
.evaluation-form textarea:hover { border-color: rgba(255,248,234,.34); }
.evaluation-form textarea:focus-visible { border-color: var(--teal); box-shadow: var(--focus); background: rgba(10,9,8,.78); }
.form-actions, .dialog-actions { display: flex; align-items: center; gap: 12px; margin-top: 24px; }
.primary-button, .secondary-button, .danger-button { min-height: 46px; padding: 0 18px; border: 0; border-radius: 12px; font-weight: 850; cursor: pointer; transition: transform 150ms, background 150ms, opacity 150ms, box-shadow 150ms; }
.primary-button { color: var(--bg); background: linear-gradient(180deg, #75dccb, var(--teal)); box-shadow: 0 10px 24px rgba(47,190,167,.14); }
.secondary-button { color: var(--ink); background: rgba(255,248,234,.08); box-shadow: inset 0 0 0 1px var(--line); }
.danger-button { margin-left: auto; color: #ffd9da; background: rgba(182,64,74,.12); box-shadow: inset 0 0 0 1px rgba(219,75,84,.3); }
.primary-button:hover, .secondary-button:hover, .danger-button:hover { transform: translateY(-1px); }
button:disabled { cursor: wait; opacity: .56; transform: none !important; }

.loader { display: inline-block; width: 42px; height: 42px; margin-bottom: 20px; border: 3px solid rgba(255,248,234,.12); border-top-color: var(--teal); border-radius: 50%; animation: spin 800ms linear infinite; }
.loader-small { width: 20px; height: 20px; margin: 0; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }

dialog { width: min(calc(100% - 32px), 500px); padding: 0; border: 0; border-radius: 20px; color: var(--ink); background: var(--panel-strong); box-shadow: 0 0 0 1px var(--line-strong), 0 30px 90px rgba(0,0,0,.65); }
dialog::backdrop { background: rgba(5,4,3,.72); backdrop-filter: blur(4px); }
.dialog-card { padding: clamp(24px, 5vw, 34px); }
.dialog-icon { display: grid; width: 50px; height: 50px; margin-bottom: 20px; place-items: center; border-radius: 15px; color: var(--garnet); background: rgba(219,75,84,.12); box-shadow: inset 0 0 0 1px rgba(219,75,84,.22); }
.dialog-icon svg { width: 25px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.dialog-card h2 { margin-bottom: 10px; font-size: 1.65rem; }
.dialog-card p:not(.eyebrow) { margin-bottom: 0; color: var(--muted); line-height: 1.55; }
.dialog-actions { justify-content: flex-end; }
.dialog-actions .danger-button { margin-left: 0; }

footer { display: flex; justify-content: space-between; gap: 18px; padding: 20px clamp(18px, 4vw, 54px) max(22px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); color: var(--subtle); font-size: .76rem; }
footer a { color: var(--muted); }

:focus-visible { outline: none; box-shadow: var(--focus); }

@media (max-width: 840px) {
    .page-intro { align-items: stretch; flex-direction: column; }
    .retention-note { flex-basis: auto; }
    .workspace { grid-template-columns: 1fr; }
    .library-panel { position: static; }
    .recording-list { display: grid; grid-auto-columns: minmax(270px, 82vw); grid-auto-flow: column; gap: 4px; max-height: none; overflow-x: auto; overflow-y: hidden; scroll-snap-type: x proximity; }
    .recording-item { scroll-snap-align: start; }
    .library-more { display: flex; justify-content: flex-end; }
    .library-more button { width: auto; }
}

@media (max-width: 540px) {
    .topbar { min-height: 76px; padding-right: 14px; padding-left: 14px; }
    .topbar::after { top: 74px; }
    .brand-mark { flex-basis: 42px; width: 42px; height: 42px; border-radius: 14px; }
    .brand-mark::before { top: 8px; }
    .brand-mark::after { bottom: 7px; }
    .brand-copy span { display: none; }
    .back-link { width: 44px; padding: 0; font-size: 0; }
    .back-link svg { width: 21px; }
    main { padding: 30px 12px 36px; }
    h1 { font-size: clamp(2.1rem, 13vw, 3.3rem); }
    .page-intro { gap: 22px; }
    .library-panel, .review-panel { border-radius: 17px; }
    .library-more button { width: 100%; }
    .review-panel { min-height: 480px; padding: 18px 14px; }
    .review-heading { gap: 12px; }
    .review-heading .status-pill { margin-top: 2px; }
    .audio-card { padding: 16px 12px; }
    .evaluation-heading { display: block; }
    .draft-status { display: inline-block; margin-top: 10px; }
    .form-actions { align-items: stretch; flex-direction: column; }
    .form-actions button { width: 100%; }
    .danger-button { margin-left: 0; }
    .dialog-actions { flex-direction: column-reverse; }
    .dialog-actions button { width: 100%; }
    footer { align-items: flex-start; flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
