@import url('https://fonts.googleapis.com/css2?family=Syne:wght=700;800&family=JetBrains+Mono:wght=400;500&family=Inter:wght=400;500&display=swap');

:root {
    --bg: #0C0C0C;
    --surface: #131313;
    --surface2: #181818;
    --border: #242424;
    --border2: #2E2E2E;
    --amber: #F0A500;
    --amber-soft: rgba(240,165,0,0.1);
    --amber-dim: #7A5400;
    --teal: #00BFA5;
    --teal-soft: rgba(0,191,165,0.1);
    --danger: #E05252;
    --danger-soft: rgba(224,82,82,0.1);
    --text: #E4E4DC;
    --text-muted: #4A4A45;
    --text-mid: #888880;
    --sidebar-w: 240px;
}

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

body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Inter', sans-serif;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ── LAYOUT ── */
.page-wrap {
    display: flex;
    min-height: 100vh;
}

/* ── SIDEBAR ── */
.sidebar {
    width: var(--sidebar-w);
    min-height: 100vh;
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 36px 24px;
    display: flex;
    flex-direction: column;
    gap: 36px;
    position: fixed;
    top: 0; left: 0;
    overflow-y: auto;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand-mark {
    width: 32px; height: 32px;
    background: var(--amber);
    color: #0C0C0C;
    font-family: 'Syne', sans-serif;
    font-weight: 800;
    font-size: 12px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 4px;
    letter-spacing: 0.05em;
}

.brand-name {
    font-family: 'Syne', sans-serif;
    font-weight: 700;
    font-size: 1rem;
    color: var(--text);
    letter-spacing: -0.02em;
}

.sidebar-tagline p {
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.6;
    border-left: 2px solid var(--border2);
    padding-left: 12px;
}

.sidebar-tips {
    display: flex;
    flex-direction: column;
    gap: 16px;
    flex: 1;
}

.tip {
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.tip-icon {
    color: var(--amber);
    font-size: 8px;
    margin-top: 4px;
    flex-shrink: 0;
}

.tip p {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.7rem;
    color: var(--text-muted);
    line-height: 1.6;
}

.tip kbd, kbd {
    background: var(--surface2);
    border: 1px solid var(--border2);
    border-radius: 2px;
    padding: 1px 4px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.65rem;
    color: var(--text-mid);
}

.sidebar-footer {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.65rem;
    color: var(--text-muted);
    letter-spacing: 0.05em;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

/* ── MAIN COLUMN ── */
.main-col {
    margin-left: var(--sidebar-w);
    flex: 1;
    padding: 56px 48px;
    max-width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.main-col > * {
    width: 100%;
    max-width: 680px;
}

/* ── PANEL ── */
.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
    animation: fadeUp 0.4s ease both;
}

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(14px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ── SETUP PANEL ── */
.panel-header {
    padding: 36px 36px 0;
    margin-bottom: 28px;
}

.eyebrow {
    font-family: 'JetBrains Mono', monospace;
    font-size: 9px;
    color: var(--amber);
    letter-spacing: 0.25em;
    text-transform: uppercase;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.eyebrow::before {
    content: '';
    width: 20px; height: 1px;
    background: var(--amber);
    display: inline-block;
}

.panel-header h1 {
    font-family: 'Syne', sans-serif;
    font-size: clamp(1.9rem, 3.5vw, 2.6rem);
    font-weight: 800;
    line-height: 1.1;
    letter-spacing: -0.04em;
    color: var(--text);
    margin-bottom: 10px;
}

.panel-header h1 em {
    font-style: normal;
    color: var(--amber);
}

.panel-sub {
    font-size: 0.82rem;
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
    line-height: 1.6;
}

.panel-notice {
    font-size: 0.78rem;
    color: #c8860a;
    background: rgba(240, 165, 0, 0.08);
    border: 1px solid rgba(240, 165, 0, 0.25);
    border-radius: 6px;
    padding: 6px 10px;
    margin-top: 10px;
    font-family: 'JetBrains Mono', monospace;
}

.form-body {
    padding: 0 36px 36px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

label {
    font-family: 'JetBrains Mono', monospace;
    font-size: 9px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.2em;
}

textarea {
    width: 100%;
    height: 130px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text);
    padding: 14px 16px;
    font-size: 0.875rem;
    font-family: 'Inter', sans-serif;
    resize: none;
    line-height: 1.65;
    transition: border-color 0.2s, box-shadow 0.2s;
}

textarea:focus {
    outline: none;
    border-color: var(--amber-dim);
    box-shadow: 0 0 0 3px var(--amber-soft);
}

textarea::placeholder { color: var(--text-muted); }

.form-row {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.field-sm { flex: 0 0 120px; margin-bottom: 0; }

select {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text);
    padding: 11px 12px;
    font-size: 0.82rem;
    font-family: 'JetBrains Mono', monospace;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%234A4A45' d='M5 6L0 0h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    transition: border-color 0.2s;
}

select:focus { outline: none; border-color: var(--amber-dim); }

/* ── BUTTONS ── */
.btn {
    padding: 11px 20px;
    border-radius: 4px;
    border: 1px solid transparent;
    font-size: 0.8rem;
    font-weight: 500;
    font-family: 'JetBrains Mono', monospace;
    cursor: pointer;
    transition: all 0.15s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    letter-spacing: 0.03em;
    white-space: nowrap;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
    background: var(--amber);
    color: #0C0C0C;
    border-color: var(--amber);
    flex: 1;
    font-weight: 700;
}
.btn-primary:hover { background: #FFB733; border-color: #FFB733; }

.btn-got-it {
    background: var(--teal-soft);
    color: var(--teal);
    border-color: rgba(0,191,165,0.25);
    flex: 1;
    font-size: 0.85rem;
    padding: 14px;
}
.btn-got-it:hover { background: rgba(0,191,165,0.18); border-color: var(--teal); }

.btn-review {
    background: var(--danger-soft);
    color: var(--danger);
    border-color: rgba(224,82,82,0.25);
    flex: 1;
    font-size: 0.85rem;
    padding: 14px;
}
.btn-review:hover { background: rgba(224,82,82,0.18); border-color: var(--danger); }

.btn-outline {
    background: transparent;
    color: var(--text-mid);
    border-color: var(--border2);
    flex: 1;
}
.btn-outline:hover { color: var(--text); border-color: var(--text-muted); }

/* ── LOADING ── */
.loading-panel {
    padding: 72px 36px;
    text-align: center;
    border-style: dashed;
}

.loader-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.loader-ring {
    width: 48px; height: 48px;
}

.loader-ring svg { animation: spin 1.4s linear infinite; }

.loader-arc { animation: arcPulse 1.4s ease-in-out infinite; }

@keyframes spin { to { transform: rotate(360deg); } }

@keyframes arcPulse {
    0%, 100% { stroke-dasharray: 20 106; }
    50% { stroke-dasharray: 60 66; }
}

.loader-text {
    font-family: 'Syne', sans-serif;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.02em;
}

.blink { color: var(--amber); animation: blink 1s step-end infinite; }
@keyframes blink { 50% { opacity: 0; } }

.loader-sub {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.72rem;
    color: var(--text-muted);
    letter-spacing: 0.05em;
}

/* ── DECK HEADER ── */
.deck-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 20px;
}

.deck-counter {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.72rem;
    color: var(--text-muted);
    white-space: nowrap;
    flex-shrink: 0;
}

.progress-track {
    flex: 1;
    height: 2px;
    background: var(--border);
    border-radius: 1px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--amber);
    width: 0%;
    transition: width 0.45s cubic-bezier(0.4,0,0.2,1);
}

.score-badge {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.7rem;
    color: var(--teal);
    background: var(--teal-soft);
    border: 1px solid rgba(0,191,165,0.2);
    padding: 3px 10px;
    border-radius: 2px;
    white-space: nowrap;
    flex-shrink: 0;
    transition: all 0.25s;
}

.score-badge.bump {
    transform: scale(1.08);
    background: rgba(0,191,165,0.2);
}

/* ── FLASHCARD ── */
.flashcard {
    width: 100%;
    height: 300px;
    perspective: 1400px;
    cursor: pointer;
    margin-bottom: 14px;
    border-radius: 6px;
}

.flashcard:focus { outline: 2px solid var(--amber-dim); outline-offset: 3px; }

.card-inner {
    width: 100%; height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.5s cubic-bezier(0.4,0,0.2,1);
}

.flashcard.flipped .card-inner { transform: rotateY(180deg); }

.card-face {
    position: absolute;
    inset: 0;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    border-radius: 6px;
    padding: 32px 28px;
    display: flex;
    flex-direction: column;
    justify-content: stretch;             /* Forces the children elements to span the card height */
    overflow-y: auto;                    /* Allows smooth scrolling if text runs super long */
    border: 1px solid var(--border);
    -webkit-overflow-scrolling: touch;
}

/* BULLETPROOF MOBILE TOGGLE: Forces opposite side text layers to completely turn off rendering when flipped */
.flashcard.flipped .card-front {
    visibility: hidden;
    pointer-events: none;
}
.flashcard:not(.flipped) .card-back {
    visibility: hidden;
    pointer-events: none;
}

.card-front {
    background: var(--surface);
    transition: border-color 0.2s;
}

.card-front:hover { border-color: var(--border2); }

.card-back {
    background: var(--surface2);
    border-color: var(--amber-dim);
    transform: rotateY(180deg);
}

.card-eyebrow {
    font-family: 'JetBrains Mono', monospace;
    font-size: 8px;
    letter-spacing: 0.25em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-eyebrow::after {
    content: '';
    flex: 1; height: 1px;
    background: var(--border);
}

.card-eyebrow-answer { color: var(--amber-dim); }
.card-eyebrow-answer::after { background: var(--amber-dim); opacity: 0.3; }

.card-text {
    font-family: 'Syne', sans-serif;
    font-size: clamp(1.05rem, 2.2vw, 1.35rem);
    font-weight: 700;
    line-height: 1.45;
    color: var(--text);
    position: relative;
    z-index: 1;
    
    /* FIX: Force the text wrapper to fill the exact length of the card frame */
    flex-grow: 1;
    display: flex;
    align-items: center;                 /* Centers the text vertically inside that full height */
}

.card-text-answer {
    font-family: 'Inter', sans-serif;
    font-weight: 400;
    font-size: clamp(0.9rem, 1.8vw, 1.05rem);
    line-height: 1.7;
    letter-spacing: 0;
    
    /* FIX: Appends the same full-frame growth strategy to your answers */
    flex-grow: 1;
    display: flex;
    align-items: center;
}

.card-text-answer {
    font-family: 'Inter', sans-serif;
    font-weight: 400;
    font-size: clamp(0.9rem, 1.8vw, 1.05rem);
    line-height: 1.7;
    letter-spacing: 0;
}

.card-ghost {
    position: absolute;
    bottom: -20px; right: 12px;
    font-family: 'Syne', sans-serif;
    font-size: 8rem;
    font-weight: 800;
    color: rgba(255,255,255,0.025);
    line-height: 1;
    pointer-events: none;
    user-select: none;
}

.card-ghost-back { color: rgba(240,165,0,0.05); }

.flip-cue {
    position: absolute;
    bottom: 16px; right: 18px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 8px;
    color: var(--text-muted);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    transition: color 0.2s;
}

.card-front:hover .flip-cue { color: var(--text-mid); }
.flip-cue-back { color: var(--amber-dim); }

/* ── CARD ACTIONS ── */
.card-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
}

/* ── KEYBOARD ROW ── */
.kbd-row {
    display: flex;
    gap: 18px;
    justify-content: center;
    margin-top: 4px;
}

.kbd-row span {
    font-family: 'JetBrains Mono', monospace;
    font-size: 9px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 5px;
}

/* ── RESULTS ── */
.results-panel {
    padding: 52px 40px;
    text-align: center;
}

.results-eyebrow {
    font-family: 'JetBrains Mono', monospace;
    font-size: 9px;
    color: var(--amber);
    letter-spacing: 0.25em;
    text-transform: uppercase;
    margin-bottom: 24px;
}

.results-score-wrap {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 4px;
    margin-bottom: 6px;
}

.results-score {
    font-family: 'Syne', sans-serif;
    font-size: 5.5rem;
    font-weight: 800;
    color: var(--amber);
    line-height: 1;
    letter-spacing: -0.06em;
    animation: popIn 0.5s cubic-bezier(0.34,1.56,0.64,1) both;
}

.results-denom {
    font-family: 'Syne', sans-serif;
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: -0.03em;
}

@keyframes popIn {
    from { transform: scale(0.6); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.results-caption {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.7rem;
    color: var(--text-muted);
    letter-spacing: 0.15em;
    text-transform: uppercase;
    margin-bottom: 28px;
}

.results-bar-track {
    width: 100%;
    height: 3px;
    background: var(--border);
    border-radius: 2px;
    margin-bottom: 24px;
    overflow: hidden;
}

.results-bar-fill {
    height: 100%;
    background: var(--amber);
    border-radius: 2px;
    width: 0%;
    transition: width 1s ease 0.3s;
}

.results-msg {
    font-size: 0.875rem;
    color: var(--text-mid);
    line-height: 1.65;
    max-width: 320px;
    margin: 0 auto 32px;
}

.results-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

/* ── TOAST ── */
.toast {
    position: fixed;
    bottom: 24px; left: 50%;
    transform: translateX(-50%) translateY(60px);
    background: var(--surface2);
    border: 1px solid var(--border2);
    color: var(--text-mid);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.72rem;
    padding: 10px 18px;
    border-radius: 4px;
    letter-spacing: 0.05em;
    transition: transform 0.3s ease;
    z-index: 200;
    white-space: nowrap;
    pointer-events: none;
}

.toast.show { transform: translateX(-50%) translateY(0); }

/* ── CONFETTI ── */
#confetti-canvas {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 999;
}

/* ── HIDDEN ── */
.hidden { display: none !important; }

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
    .sidebar { display: none; }
    .main-col { margin-left: 0; padding: 32px 20px; justify-content: flex-start; padding-top: 48px; }
    
    /* Set this to whatever standard mobile height you prefer (e.g., 320px or 360px) */
    .flashcard { 
        height: 340px; 
    }
    
    .results-score { font-size: 4rem; }
}

/* ── UPLOAD ZONE ── */
.upload-zone {
    border: 1px dashed var(--border2);
    border-radius: 4px;
    background: var(--bg);
    transition: all 0.2s;
    cursor: pointer;
    margin-bottom: 4px;
}

.upload-zone:hover, .upload-zone.dragover {
    border-color: var(--amber-dim);
    background: var(--amber-soft);
}

.upload-zone.has-file {
    border-color: var(--teal);
    background: var(--teal-soft);
}

.upload-inner {
    padding: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
}

.upload-zone.has-file .upload-inner { color: var(--teal); }

.divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 12px 0;
}

.divider::before, .divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

.divider span {
    font-family: 'JetBrains Mono', monospace;
    font-size: 9px;
    color: var(--text-muted);
    letter-spacing: 0.15em;
    text-transform: uppercase;
}