/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    /* Palette: warm naturals */
    --ink: #1b1b1e;
    --ink-soft: #44444a;
    --ink-muted: #8a8a8f;
    --paper: #f6f5f1;
    --paper-warm: #edece8;
    --paper-card: #ffffff;
    --teal: #2a9d8f;
    --teal-dim: rgba(42,157,143,0.12);
    --coral: #e76f51;
    --coral-dim: rgba(231,111,81,0.10);
    --amber: #e9c46a;
    --amber-dim: rgba(233,196,106,0.15);
    --night: #111116;
    --night-soft: rgba(255,255,255,0.08);
    --night-text: rgba(255,255,255,0.88);
    --night-muted: rgba(255,255,255,0.35);
    --radius: 14px;
}

body {
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--paper);
    color: var(--ink);
    line-height: 1.55;
    min-height: 100dvh;
    -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ═══════════════════════════════════
   LANDING & ADMIN (container pages)
   ═══════════════════════════════════ */
.container {
    max-width: 440px;
    margin: 0 auto;
    padding: 80px 20px 40px;
}

.container h1 {
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    margin-bottom: 4px;
}

.subtitle, .topic { color: var(--ink-muted); margin-bottom: 24px; }
.meta { font-size: 0.82rem; color: var(--ink-muted); }
.meta a { color: var(--teal); text-decoration: none; }

.form-card {
    background: var(--paper-card);
    padding: 28px;
    border-radius: var(--radius);
    box-shadow: 0 1px 2px rgba(0,0,0,0.04), 0 6px 20px rgba(0,0,0,0.03);
}

label {
    display: block; font-weight: 600; font-size: 0.72rem;
    text-transform: uppercase; letter-spacing: 0.08em;
    color: var(--ink-muted); margin: 16px 0 6px;
}

input[type="text"], input[type="password"], textarea {
    width: 100%; padding: 13px 14px;
    border: 1.5px solid var(--paper-warm); border-radius: 10px;
    font-size: 1rem; font-family: inherit; background: var(--paper);
    color: var(--ink); transition: border-color 0.2s, box-shadow 0.2s;
}
input:focus, textarea:focus {
    outline: none; border-color: var(--teal);
    box-shadow: 0 0 0 3px var(--teal-dim);
}
textarea { resize: vertical; }

/* Shared buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 10px 20px; border: 1.5px solid var(--paper-warm); border-radius: 10px;
    font-size: 0.92rem; font-family: inherit; cursor: pointer;
    background: var(--paper-card); color: var(--ink); transition: all 0.15s;
}
.btn:hover { background: var(--paper); }
.btn-lg { padding: 15px; font-size: 1rem; width: 100%; margin-top: 20px; font-weight: 600; border-radius: 12px; }
.btn-primary { background: var(--teal); color: #fff; border-color: var(--teal); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-danger { background: var(--coral); color: #fff; border-color: var(--coral); }
.btn-danger:hover { filter: brightness(1.08); }
.btn-sm { padding: 5px 12px; font-size: 0.8rem; border-radius: 8px; }
.error-text { color: var(--coral); margin-top: 8px; font-size: 0.88rem; }

/* ═══════════════════════════════════
   TABLE PAGE – fullscreen
   ═══════════════════════════════════ */
.page-table { background: var(--night); height: 100dvh; overflow: hidden; }

/* ── Tabs ── */
.tabs {
    display: flex; height: 46px;
    background: rgba(255,255,255,0.04);
    position: sticky; top: 0; z-index: 50;
}

.tab {
    flex: 1; display: flex; align-items: center; justify-content: center;
    background: none; border: none;
    font-size: 0.82rem; font-family: inherit; font-weight: 500;
    letter-spacing: 0.04em; text-transform: uppercase;
    color: var(--night-muted); cursor: pointer; transition: color 0.2s;
    position: relative;
}

.tab.active { color: var(--night-text); }

.tab.active::after {
    content: ""; position: absolute;
    inset: 8px auto 8px auto; left: 50%; transform: translateX(-50%);
    width: calc(100% - 24px); height: calc(100% - 16px);
    background: rgba(255,255,255,0.08);
    border-radius: 8px;
    z-index: -1;
}

.tab-content { display: none; }
.tab-content.active { display: flex; flex-direction: column; }

/* ═══════════════════════════════════
   RECORDING SCREEN
   ═══════════════════════════════════ */
#tab-record {
    height: calc(100dvh - 46px);
    overflow: hidden;
    background: var(--night);
    color: #fff;
    position: relative;
}

.waveform {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    display: block;
    z-index: 0;
}

.rec-screen {
    position: relative; z-index: 1;
    flex: 1; display: flex; flex-direction: column;
    justify-content: space-between;
    padding: 16px 0 36px;
    max-width: 560px; width: 100%; margin: 0 auto;
}

.rec-top {
    display: flex; justify-content: space-between; align-items: center;
    padding: 0 24px;
    color: var(--night-muted); font-size: 0.82rem; font-weight: 500;
    letter-spacing: 0.02em;
}

.rec-center {
    display: flex; flex-direction: column; align-items: center;
    justify-content: center; flex: 1;
}

.timer {
    font-size: 4.5rem; font-weight: 200;
    font-variant-numeric: tabular-nums;
    letter-spacing: 3px;
    color: var(--night-text);
    line-height: 1;
}

.rec-bottom {
    display: flex; flex-direction: column; align-items: center;
    gap: 14px; min-height: 130px; padding: 0 24px;
}

.controls { display: flex; flex-direction: column; align-items: center; gap: 14px; width: 100%; }

/* Record button */
.rec-btn {
    width: 84px; height: 84px; border-radius: 50%;
    border: 3px solid rgba(255,255,255,0.2);
    background: transparent;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: all 0.2s; position: relative;
}
.rec-btn:hover { border-color: rgba(255,255,255,0.35); }
.rec-btn:active { transform: scale(0.94); }

.rec-btn-inner {
    display: block; width: 56px; height: 56px;
    background: var(--coral); border-radius: 50%;
    transition: all 0.25s cubic-bezier(0.4,0,0.2,1);
}
.rec-btn-inner.is-stop { width: 28px; height: 28px; border-radius: 6px; }

.rec-btn.recording { animation: pulse-ring 2s ease-out infinite; }
@keyframes pulse-ring {
    0% { box-shadow: 0 0 0 0 rgba(231,111,81,0.45); }
    70% { box-shadow: 0 0 0 22px rgba(231,111,81,0); }
    100% { box-shadow: 0 0 0 0 rgba(231,111,81,0); }
}

.rec-actions { display: flex; align-items: center; justify-content: center; gap: 28px; }

.ctrl-btn {
    width: 50px; height: 50px; border-radius: 50%; border: none;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: all 0.15s;
}
.ctrl-btn svg { width: 20px; height: 20px; }
.ctrl-placeholder { visibility: hidden; }
.ctrl-pause { background: rgba(255,255,255,0.1); color: #fff; }
.ctrl-pause:hover { background: rgba(255,255,255,0.18); }
.ctrl-resume { background: var(--teal-dim); color: var(--teal); }
.ctrl-resume:hover { background: rgba(42,157,143,0.25); }

.send-btn {
    width: 68px; height: 68px; border-radius: 50%; border: none;
    cursor: pointer; background: var(--teal); color: #fff;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s;
    box-shadow: 0 4px 18px rgba(42,157,143,0.35);
}
.send-btn svg { width: 26px; height: 26px; }
.send-btn:hover { transform: scale(1.06); box-shadow: 0 6px 26px rgba(42,157,143,0.45); }
.send-btn:active { transform: scale(0.95); }

.upload-pulse {
    width: 60px; height: 60px; border-radius: 50%;
    background: var(--teal-dim);
    animation: breathe 1.6s ease-in-out infinite;
}
@keyframes breathe {
    0%, 100% { transform: scale(1); opacity: 0.4; }
    50% { transform: scale(1.3); opacity: 1; }
}

.rec-hint {
    font-size: 0.8rem; color: var(--night-muted);
    text-align: center; font-weight: 400;
}
.rec-hint.rec-live { color: var(--coral); font-weight: 500; animation: blink 2s infinite; }
.rec-hint.rec-success { color: var(--teal); }
@keyframes blink { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }

/* ═══════════════════════════════════
   RESULTS SCREEN (presentation)
   ═══════════════════════════════════ */
#tab-results {
    background: var(--paper);
    color: var(--ink);
    height: calc(100dvh - 46px);
    overflow-y: auto;
    scroll-snap-type: y mandatory;
}

/* Make tabs adapt to results light bg when active */
#tab-results.active ~ .tabs,
body:has(#tab-results.active) .tabs {
    background: rgba(0,0,0,0.03);
}
body:has(#tab-results.active) .tab { color: var(--ink-muted); }
body:has(#tab-results.active) .tab.active { color: var(--ink); }
body:has(#tab-results.active) .tab.active::after { background: rgba(0,0,0,0.06); }
body:has(#tab-results.active) { background: var(--paper); }

/* Slide = one session = viewport */
.slide {
    min-height: calc(100dvh - 46px);
    display: flex; flex-direction: column;
    padding: 0;
    scroll-snap-align: start;
    border-bottom: 1px solid var(--paper-warm);
}
.slide:last-child { border-bottom: none; }

.slide-empty {
    display: flex; align-items: center; justify-content: center;
}

.slide-error { border-left: 4px solid var(--coral); }

.slide-bar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 20px 32px 0;
    flex-shrink: 0;
}

.slide-num {
    font-size: 0.72rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.1em;
    color: var(--ink-muted);
}
.slide-time {
    font-size: 0.72rem; font-weight: 500;
    color: var(--ink-muted); font-variant-numeric: tabular-nums;
}

.pill {
    font-size: 0.68rem; font-weight: 600; padding: 3px 10px;
    border-radius: 20px; text-transform: uppercase; letter-spacing: 0.06em;
}
.pill-proc { background: var(--amber-dim); color: #a67c00; animation: blink 2s infinite; }
.pill-err { background: var(--coral-dim); color: var(--coral); }

.retry-btn {
    padding: 10px 28px; border-radius: 10px; border: 1.5px solid var(--paper-warm);
    background: var(--paper-card); font-family: inherit; font-size: 0.88rem;
    cursor: pointer; transition: all 0.15s; color: var(--ink);
}
.retry-btn:hover { background: var(--paper-warm); }

.slide-body {
    flex: 1; display: flex;
    padding: 24px 32px 32px;
    gap: 40px;
    overflow: hidden;
}

.slide-body--center {
    align-items: center; justify-content: center;
}

/* Two columns */
.col {
    flex: 1; overflow-y: auto;
    min-height: 0;
    padding-right: 12px;
}

/* Scrollbar styling for columns */
.col::-webkit-scrollbar { width: 4px; }
.col::-webkit-scrollbar-track { background: transparent; }
.col::-webkit-scrollbar-thumb { background: var(--paper-warm); border-radius: 4px; }

.col-label {
    font-size: 0.65rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.12em;
    color: var(--teal); margin-bottom: 24px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--teal-dim);
}

.col-empty { color: var(--ink-muted); font-size: 0.9rem; }

/* Topics: clean typography, no boxes */
.topic-item { margin-bottom: 32px; }

.topic-item h2 {
    font-size: 1.35rem; font-weight: 700;
    letter-spacing: -0.02em; color: var(--ink);
    margin-bottom: 8px; line-height: 1.3;
}

.topic-item p {
    font-size: 1rem; color: var(--ink-soft);
    line-height: 1.65;
}

/* Quotes: decorative */
.quote-fig {
    position: relative;
    padding: 20px 0 20px 0;
    margin-bottom: 28px;
}
.quote-fig:not(:last-child) {
    border-bottom: 1px solid var(--paper-warm);
    padding-bottom: 28px;
}

.quote-fig blockquote {
    font-size: 1.2rem;
    font-style: italic;
    line-height: 1.6;
    color: var(--ink);
    font-family: Georgia, "Times New Roman", "Noto Serif", serif;
    position: relative;
    padding-left: 28px;
}

.quote-fig blockquote::before {
    content: "\201E";
    position: absolute; left: 0; top: -6px;
    font-size: 3rem; line-height: 1;
    font-family: Georgia, serif;
    color: var(--coral);
    opacity: 0.35;
}

.quote-fig figcaption {
    margin-top: 10px; padding-left: 28px;
    font-size: 0.82rem; font-weight: 600;
    color: var(--teal); font-style: normal;
    font-family: inherit;
}

.empty-state {
    color: var(--ink-muted); font-size: 1.05rem;
    text-align: center;
}

/* Loader dots */
.loader-dots { display: flex; gap: 8px; }
.loader-dots span {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--ink-muted); opacity: 0.3;
    animation: dot-bounce 1.4s infinite ease-in-out both;
}
.loader-dots span:nth-child(1) { animation-delay: -0.32s; }
.loader-dots span:nth-child(2) { animation-delay: -0.16s; }
@keyframes dot-bounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.3; }
    40% { transform: scale(1); opacity: 1; }
}

/* ═══════════════════════════════════
   ADMIN
   ═══════════════════════════════════ */
.page-admin { background: var(--paper); }
.page-admin .container { max-width: 720px; }

.admin-toolbar {
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: 10px;
    margin-bottom: 16px; padding: 12px 16px;
    background: var(--paper-card); border-radius: var(--radius);
    border: 1px solid var(--paper-warm);
    box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}

.select-all-label {
    display: flex; align-items: center; gap: 8px;
    font-size: 0.85rem; font-weight: 500; color: var(--ink-soft);
    cursor: pointer; text-transform: none; letter-spacing: 0;
    margin: 0;
}
.select-all-label input { width: 16px; height: 16px; accent-color: var(--teal); cursor: pointer; }

.toolbar-actions { display: flex; gap: 6px; }

.admin-table-card {
    background: var(--paper-card); border: 1px solid var(--paper-warm);
    border-radius: var(--radius); margin-bottom: 20px; overflow: hidden;
    box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}
.admin-table-header {
    display: flex; justify-content: space-between; align-items: flex-start;
    padding: 16px 20px; border-bottom: 1px solid var(--paper-warm);
    gap: 12px;
}
.admin-table-header h3 { font-size: 1.05rem; font-weight: 700; }
.admin-table-header .topic { margin-bottom: 4px; font-size: 0.88rem; }
.admin-table-header .meta { font-size: 0.82rem; }
.admin-table-header .meta a { margin-right: 4px; }

.admin-sessions { padding: 6px 20px; }

.admin-session {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px 0; border-bottom: 1px solid var(--paper); gap: 8px;
    font-size: 0.88rem;
}
.admin-session:last-child { border-bottom: none; }

.session-left { display: flex; align-items: center; gap: 10px; }
.session-left input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--teal); cursor: pointer; }
.session-info { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.session-dur { color: var(--ink-muted); font-size: 0.78rem; font-variant-numeric: tabular-nums; }

.admin-actions { display: flex; gap: 5px; flex-wrap: wrap; }

.badge {
    display: inline-block; font-size: 0.66rem; font-weight: 600;
    padding: 2px 8px; border-radius: 12px;
}
.badge.processing { background: var(--amber-dim); color: #a67c00; }
.badge.done { background: rgba(42,157,143,0.1); color: #1a7a6f; }
.badge.error { background: var(--coral-dim); color: var(--coral); }

.empty-msg { color: var(--ink-muted); text-align: center; padding: 20px; font-size: 0.9rem; }

/* Modal (shared) */
.modal {
    position: fixed; inset: 0; background: rgba(0,0,0,0.35);
    display: flex; align-items: center; justify-content: center;
    padding: 16px; z-index: 100; backdrop-filter: blur(6px);
}
.modal.hidden { display: none; }
.modal-body {
    background: var(--paper-card); border-radius: 18px; padding: 28px;
    width: 100%; max-width: 540px; max-height: 85vh; overflow-y: auto;
    box-shadow: 0 16px 48px rgba(0,0,0,0.12);
}
.modal-lg { max-width: 680px; }
.modal-top {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 16px;
}
.modal-top h3 { font-size: 1.1rem; font-weight: 700; }
.modal-close {
    background: none; border: none; font-size: 1.5rem; cursor: pointer;
    color: var(--ink-muted); line-height: 1; padding: 4px 8px; border-radius: 8px;
    transition: background 0.15s;
}
.modal-close:hover { background: var(--paper); }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }

/* Preview modal content */
.prev-section {
    font-size: 0.68rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.1em; color: var(--teal);
    margin: 20px 0 12px; padding-bottom: 8px;
    border-bottom: 2px solid var(--teal-dim);
}
.prev-section:first-child { margin-top: 0; }

.prev-topic { margin-bottom: 16px; }
.prev-topic h4 { font-size: 1rem; font-weight: 700; margin-bottom: 4px; }
.prev-topic p { font-size: 0.9rem; color: var(--ink-soft); line-height: 1.6; }

.prev-quote {
    padding: 12px 0 12px 24px; margin-bottom: 12px;
    position: relative;
}
.prev-quote::before {
    content: "\201E"; position: absolute; left: 0; top: 4px;
    font-size: 2rem; line-height: 1; font-family: Georgia, serif;
    color: var(--coral); opacity: 0.3;
}
.prev-quote blockquote {
    font-size: 0.95rem; font-style: italic; line-height: 1.6;
    font-family: Georgia, serif; color: var(--ink); margin: 0;
}
.prev-quote figcaption {
    margin-top: 6px; font-size: 0.8rem; font-weight: 600;
    color: var(--teal); font-style: normal;
}

/* ═══════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════ */

/* Mobile: no snap, natural scroll, stacked columns */
@media (max-width: 767px) {
    #tab-results {
        height: auto;
        min-height: calc(100dvh - 46px);
        scroll-snap-type: none;
    }
    .slide { min-height: auto; scroll-snap-align: none; }
    .slide-body {
        flex-direction: column;
        gap: 32px;
        padding: 20px 20px 40px;
        overflow: visible;
    }
    .col { overflow-y: visible; padding-right: 0; }
    .slide-bar { padding: 16px 20px 0; }
    .topic-item h2 { font-size: 1.15rem; }
    .quote-fig blockquote { font-size: 1.05rem; }

    /* Admin mobile */
    .admin-toolbar { flex-direction: column; align-items: stretch; }
    .toolbar-actions { justify-content: flex-end; }
    .admin-session { flex-direction: column; align-items: flex-start; }
    .admin-actions { width: 100%; }
}

@media (min-width: 768px) {
    .timer { font-size: 6rem; }
    .slide-body { padding: 28px 48px 40px; gap: 56px; }
    .topic-item h2 { font-size: 1.5rem; }
    .quote-fig blockquote { font-size: 1.3rem; }
}

@media (min-width: 1200px) {
    .timer { font-size: 7rem; }
    .slide-body { padding: 32px 64px 48px; gap: 72px; }
    .topic-item h2 { font-size: 1.65rem; }
    .quote-fig blockquote { font-size: 1.4rem; }
    .quote-fig blockquote::before { font-size: 4rem; }
}
