:root {
    --vb-bg: #f6f7f9;
    --vb-card: #ffffff;
    --vb-ink: #1a1d21;
    --vb-muted: #6b7280;
    --vb-line: #e4e7eb;
    --vb-accent: #2563eb;
    --vb-again: #dc2626;
    --vb-hard: #d97706;
    --vb-good: #16a34a;
    --vb-easy: #0891b2;
    --vb-new: #6366f1;
    --vb-learning: #d97706;
    --vb-known: #16a34a;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: system-ui, "Segoe UI", Arial, sans-serif;
    color: var(--vb-ink);
    background: var(--vb-bg);
}

#app { max-width: 60rem; margin: 0 auto; padding: 1.5rem 1rem 4rem; }

.vb-loading { text-align: center; color: var(--vb-muted); padding: 4rem 0; }

.vb-header { position: relative; }
.vb-header h1 { font-size: 1.5rem; margin: 0; }
.vb-subtitle { margin: 0.15rem 0 1rem; color: var(--vb-muted); font-size: 0.9rem; }
.vb-reset-btn {
    position: absolute; top: 0; right: 0;
    border: 1px solid var(--vb-line); background: var(--vb-card); color: var(--vb-muted);
    border-radius: 8px; padding: 0.3rem 0.7rem; font-size: 0.8rem; cursor: pointer;
}
.vb-reset-btn:hover { border-color: var(--vb-again); color: var(--vb-again); }

.vb-study-controls { display: flex; flex-wrap: wrap; gap: 1rem; margin-bottom: 1rem; }
.vb-control-row { display: flex; align-items: center; gap: 0.4rem; }
.vb-control-label { color: var(--vb-muted); font-size: 0.8rem; }

.vb-progress { max-width: 46rem; margin: 0 auto 0.75rem; }
.vb-progress-text { color: var(--vb-muted); font-size: 0.8rem; margin-bottom: 0.25rem; }
.vb-progress-track { height: 6px; background: var(--vb-line); border-radius: 999px; overflow: hidden; }
.vb-progress-fill { height: 100%; background: var(--vb-accent); border-radius: 999px; transition: width 0.2s ease; }

.vb-pager { display: flex; align-items: center; gap: 0.75rem; margin-top: 0.75rem; }
.vb-pager-info { color: var(--vb-muted); font-size: 0.85rem; }

.vb-stats { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-bottom: 1rem; }
.vb-tile {
    display: flex; flex-direction: column; align-items: center;
    background: var(--vb-card); border: 1px solid var(--vb-line); border-radius: 10px;
    padding: 0.5rem 1rem; min-width: 5.5rem;
}
.vb-tile-value { font-size: 1.35rem; font-weight: 700; }
.vb-tile-caption { font-size: 0.72rem; color: var(--vb-muted); text-transform: uppercase; letter-spacing: 0.03em; }

.vb-tabs, .vb-levels { display: flex; gap: 0.4rem; margin-bottom: 0.75rem; flex-wrap: wrap; }
.vb-levels { margin-bottom: 1.25rem; }
.vb-nav-btn {
    border: 1px solid var(--vb-line); background: var(--vb-card); color: var(--vb-ink);
    border-radius: 999px; padding: 0.35rem 0.9rem; font-size: 0.85rem; cursor: pointer;
}
.vb-nav-btn:hover { border-color: var(--vb-accent); }
.vb-nav-btn.is-active { background: var(--vb-accent); color: #fff; border-color: var(--vb-accent); }

.vb-card {
    background: var(--vb-card); border: 1px solid var(--vb-line); border-radius: 14px;
    padding: 2.5rem 1.5rem; text-align: center; box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.vb-card-word { font-size: 2.4rem; font-weight: 700; }
.vb-card-english { font-size: 1.4rem; margin-top: 1rem; color: var(--vb-accent); }
.vb-card-example { margin-top: 1.25rem; font-size: 1.05rem; }
.vb-card-example-en { margin-top: 0.25rem; color: var(--vb-muted); font-style: italic; }

.vb-actions { display: flex; gap: 0.5rem; justify-content: center; margin-top: 1rem; }
.vb-grades { flex-wrap: wrap; }
.vb-btn {
    border: none; border-radius: 10px; padding: 0.65rem 1.4rem; font-size: 0.95rem;
    color: #fff; cursor: pointer; min-width: 6rem;
}
.vb-btn-reveal { background: var(--vb-accent); }
.vb-btn:hover { filter: brightness(1.07); }

.vb-card-prompt { margin-top: 1rem; color: var(--vb-muted); font-size: 0.95rem; }

.vb-options { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; margin-top: 1rem; }
@media (max-width: 32rem) { .vb-options { grid-template-columns: 1fr; } }
.vb-option {
    border: 1px solid var(--vb-line); background: var(--vb-card); color: var(--vb-ink);
    border-radius: 10px; padding: 0.85rem 1rem; font-size: 1.05rem; cursor: pointer;
    text-align: center;
}
.vb-option:hover:not(:disabled) { border-color: var(--vb-accent); background: #f0f5ff; }
.vb-option:disabled { cursor: default; }
.vb-option-correct { background: #e7f7ec; border-color: var(--vb-good); color: #14532d; font-weight: 600; }
.vb-option-wrong { background: #fdeaea; border-color: var(--vb-again); color: #7f1d1d; }
.vb-option-dim { opacity: 0.55; }

.vb-verdict { text-align: center; margin-top: 1rem; font-weight: 600; }
.vb-verdict-correct { color: var(--vb-good); }
.vb-verdict-wrong { color: var(--vb-again); }

.vb-example { text-align: center; margin-top: 0.75rem; }
.vb-example-id { font-size: 1.05rem; }
.vb-example-en { color: var(--vb-muted); font-style: italic; margin-top: 0.15rem; }

.vb-done { text-align: center; padding: 2.5rem 1rem; color: var(--vb-muted); }
.vb-done p { font-size: 1.15rem; }

.vb-filter-bar { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.75rem; }
.vb-filter {
    padding: 0.5rem 0.75rem; width: 20rem; max-width: 60vw; font-size: 1rem;
    border: 1px solid var(--vb-line); border-radius: 8px;
}
.vb-filter-count { color: var(--vb-muted); font-size: 0.85rem; }

.vb-table { border-collapse: collapse; width: 100%; font-size: 0.9rem; }
.vb-table th, .vb-table td { text-align: left; padding: 0.35rem 0.6rem; border-bottom: 1px solid var(--vb-line); vertical-align: top; }
.vb-table thead th { position: sticky; top: 0; background: var(--vb-bg); }
.vb-c-rank { text-align: right; color: var(--vb-muted); width: 3rem; }
.vb-c-word { font-weight: 600; white-space: nowrap; }
.vb-ex-id { display: block; }
.vb-ex-en { display: block; color: var(--vb-muted); font-style: italic; }

.vb-status {
    display: inline-block; padding: 0.05rem 0.5rem; border-radius: 999px;
    font-size: 0.72rem; color: #fff; text-transform: uppercase; letter-spacing: 0.03em;
}
.vb-status-new { background: var(--vb-new); }
.vb-status-learning { background: var(--vb-learning); }
.vb-status-known { background: var(--vb-known); }

/* ---- Phone layout (<= 40rem): every pixel goes to the card ---------------------------------
   One stats row, settings as single swipeable rows, 2x2 answers, a compact card - so the word,
   all four answers and the Next button fit the first screen (locked by e2e/mobile.spec.ts).
   The browse table becomes stacked rows: word | meaning | status, example underneath. */
@media (max-width: 40rem) {
    #app { padding: 0.5rem 0.6rem 1.5rem; }

    .vb-header h1 { font-size: 1.1rem; line-height: 1.6rem; }
    .vb-subtitle { display: none; }
    .vb-reset-btn { padding: 0.15rem 0.5rem; font-size: 0.72rem; }
    .vb-header { margin-bottom: 0.4rem; }

    .vb-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.3rem; margin-bottom: 0.5rem; }
    .vb-tile { min-width: 0; padding: 0.25rem 0.1rem; border-radius: 8px; }
    .vb-tile-value { font-size: 1rem; }
    .vb-tile-caption { font-size: 0.58rem; letter-spacing: 0; white-space: nowrap; }

    .vb-tabs, .vb-levels, .vb-control-row {
        flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
    }
    .vb-tabs::-webkit-scrollbar, .vb-levels::-webkit-scrollbar, .vb-control-row::-webkit-scrollbar { display: none; }
    .vb-tabs, .vb-levels { gap: 0.3rem; margin-bottom: 0.4rem; }
    .vb-study-controls { gap: 0.3rem 0.75rem; margin-bottom: 0.4rem; }
    .vb-control-label { font-size: 0.7rem; white-space: nowrap; }
    .vb-nav-btn { padding: 0.25rem 0.65rem; font-size: 0.78rem; white-space: nowrap; flex: 0 0 auto; }

    .vb-progress { margin-bottom: 0.4rem; }
    .vb-progress-text { font-size: 0.7rem; margin-bottom: 0.15rem; }

    .vb-card { padding: 1rem 0.75rem; border-radius: 12px; }
    .vb-card-word { font-size: 2rem; }
    .vb-card-prompt { margin-top: 0.4rem; font-size: 0.85rem; }
    .vb-options { grid-template-columns: 1fr 1fr; gap: 0.4rem; margin-top: 0.5rem; }
    .vb-option { padding: 0.7rem 0.4rem; font-size: 0.95rem; min-height: 3rem; }
    .vb-verdict { margin-top: 0.5rem; }
    .vb-example { margin-top: 0.4rem; }
    .vb-example-id { font-size: 0.95rem; }
    .vb-example-en { font-size: 0.85rem; }
    .vb-actions { margin-top: 0.5rem; }
    .vb-btn { width: 100%; padding: 0.75rem; }

    .vb-filter-bar { gap: 0.5rem; margin-bottom: 0.4rem; }
    .vb-filter { flex: 1 1 auto; width: auto; max-width: none; padding: 0.45rem 0.6rem; }
    .vb-filter-count { font-size: 0.72rem; white-space: nowrap; }

    .vb-table thead { display: none; }
    .vb-table, .vb-table tbody { display: block; }
    .vb-table tr {
        display: grid; grid-template-columns: auto 1fr auto; gap: 0.1rem 0.6rem; align-items: baseline;
        padding: 0.45rem 0.1rem; border-bottom: 1px solid var(--vb-line);
    }
    .vb-table td { padding: 0; border: none; }
    .vb-table .vb-c-rank { display: none; }
    .vb-table .vb-c-word { grid-column: 1; grid-row: 1; }
    .vb-table .vb-c-en { grid-column: 2; grid-row: 1; }
    .vb-table .vb-c-status { grid-column: 3; grid-row: 1; }
    .vb-table .vb-c-ex { grid-column: 1 / -1; grid-row: 2; font-size: 0.82rem; }
    .vb-pager { flex-wrap: wrap; }
}
