/* PsychBay — clean light design system (devbay family, violet accent) */
:root {
    --bg: #f8fafc;
    --bg-soft: #f1f5f9;
    --text: #0f172a;
    --text-dim: #64748b;
    --text-faint: #94a3b8;
    --card: #ffffff;
    --card-strong: #f8fafc;
    --border: #e2e8f0;
    --border-strong: #cbd5e1;
    --accent-1: #7c3aed;
    --accent-2: #6d28d9;
    --accent-3: #a78bfa;
    --accent-soft: rgba(124, 58, 237, 0.08);
    --good: #059669;
    --good-soft: rgba(5, 150, 105, 0.1);
    --warn: #d97706;
    --warn-soft: rgba(217, 119, 6, 0.12);
    --bad: #dc2626;
    --bad-soft: rgba(220, 38, 38, 0.1);
    --radius: 0.625rem;
    --shadow: 0 1px 2px 0 rgba(15, 23, 42, 0.04);
    --shadow-hover: 0 4px 12px 0 rgba(15, 23, 42, 0.08);
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC",
            "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

[data-theme="dark"] {
    --bg: #0f172a;
    --bg-soft: #1e293b;
    --text: #f1f5f9;
    --text-dim: #94a3b8;
    --text-faint: #64748b;
    --card: #1e293b;
    --card-strong: #0f172a;
    --border: #334155;
    --border-strong: #475569;
    --accent-1: #a78bfa;
    --accent-2: #c4b5fd;
    --accent-3: #8b5cf6;
    --accent-soft: rgba(167, 139, 250, 0.14);
    --good: #34d399;
    --good-soft: rgba(52, 211, 153, 0.14);
    --warn: #fbbf24;
    --warn-soft: rgba(251, 191, 36, 0.14);
    --bad: #f87171;
    --bad-soft: rgba(248, 113, 113, 0.14);
    --shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-hover: 0 4px 12px 0 rgba(0, 0, 0, 0.4);
}

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

html { scroll-behavior: smooth; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
    transition: background 0.3s ease, color 0.3s ease;
}

.container { width: min(1100px, 92vw); margin: 0 auto; }

/* ---------- header ---------- */
.site-header {
    position: sticky; top: 0; z-index: 50;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}
.nav { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); }
.brand-logo { display: flex; }
.brand-name { font-size: 1.25rem; font-weight: 800; letter-spacing: -0.02em; }
.brand-accent { color: var(--accent-1); }
.nav-right { display: flex; align-items: center; gap: 10px; }
.icon-btn {
    display: flex; align-items: center; justify-content: center;
    width: 38px; height: 38px; border-radius: 0.5rem;
    background: var(--card); border: 1px solid var(--border);
    color: var(--text-dim); cursor: pointer; transition: all 0.15s ease;
    font-family: inherit;
}
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); background: var(--card-strong); }
.icon-moon { display: none; }
[data-theme="light"] .icon-sun { display: none; }
[data-theme="light"] .icon-moon { display: block; }

.lang-select {
    appearance: none; -webkit-appearance: none;
    background: var(--card); border: 1px solid var(--border);
    border-radius: 0.5rem; color: var(--text-dim);
    font-family: inherit; font-size: 0.8rem; font-weight: 600;
    padding: 8px 28px 8px 12px; cursor: pointer; transition: all 0.15s ease;
    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 d='M1 1l4 4 4-4' stroke='%2394a3b8' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 10px center;
}
.lang-select:hover { color: var(--text); border-color: var(--border-strong); }

/* ---------- hero ---------- */
.hero { text-align: center; padding: 64px 0 40px; }
.hero-title {
    font-size: clamp(2.2rem, 5.5vw, 3.4rem);
    font-weight: 900; letter-spacing: -0.03em; line-height: 1.15;
}
.grad-text { color: var(--accent-1); }
.hero-sub { max-width: 680px; margin: 18px auto 0; color: var(--text-dim); font-size: 1.05rem; }

/* ---------- tool grid (home) ---------- */
.tool-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px; padding: 24px 0 40px;
}
.section-label { margin-top: 8px; font-size: 0.8rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-faint); }
.section-label-2 { margin-top: 26px; }
.tool-card {
    display: flex; flex-direction: column; gap: 6px;
    background: var(--card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 22px 20px;
    text-decoration: none; color: var(--text);
    box-shadow: var(--shadow);
    transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}
.tool-card:hover { border-color: var(--accent-3); box-shadow: var(--shadow-hover); transform: translateY(-2px); }
.tool-card svg { color: var(--accent-1); }
.tool-card h3 { font-size: 1.05rem; font-weight: 700; }
.tool-card p { font-size: 0.9rem; color: var(--text-dim); }

/* ---------- tool page ---------- */
.tool-page { padding: 40px 0 48px; }
.tool-head { margin-bottom: 28px; }
.back-link {
    display: inline-flex; align-items: center; gap: 6px;
    color: var(--text-dim); text-decoration: none;
    font-size: 0.9rem; font-weight: 600; margin-bottom: 14px;
}
.back-link:hover { color: var(--accent-1); }
.tool-head h1 { font-size: clamp(1.6rem, 3.5vw, 2.2rem); font-weight: 800; letter-spacing: -0.02em; }
.tool-head p { color: var(--text-dim); margin-top: 4px; }

.tool-layout {
    display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
    gap: 24px; align-items: start;
}
@media (max-width: 860px) {
    .tool-layout { grid-template-columns: 1fr; }
}

.panel {
    background: var(--card); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 24px;
}
.panel h2 { font-size: 0.85rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-faint); margin-bottom: 18px; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 0.88rem; font-weight: 600; color: var(--text-dim); margin-bottom: 5px; }
.field .hint { font-size: 0.78rem; color: var(--text-faint); font-weight: 400; margin-left: 4px; }
.input {
    width: 100%; padding: 10px 12px;
    background: var(--card-strong); border: 1px solid var(--border);
    border-radius: 0.5rem; color: var(--text);
    font-family: inherit; font-size: 0.95rem;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.input:focus { outline: none; border-color: var(--accent-1); box-shadow: 0 0 0 3px var(--accent-soft); }
.input[type="number"] { font-variant-numeric: tabular-nums; }

.input-wrap { position: relative; }
.input-wrap .suffix {
    position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
    font-size: 0.82rem; font-weight: 600; color: var(--text-faint);
    pointer-events: none;
}
.input-wrap .input { padding-right: 44px; }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
@media (max-width: 560px) {
    .field-row-3 { grid-template-columns: 1fr 1fr; }
}

.select {
    width: 100%; padding: 10px 12px;
    appearance: none; -webkit-appearance: none;
    background: var(--card-strong); border: 1px solid var(--border);
    border-radius: 0.5rem; color: var(--text);
    font-family: inherit; font-size: 0.95rem; cursor: pointer;
    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 d='M1 1l4 4 4-4' stroke='%2394a3b8' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 12px center;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.select:focus { outline: none; border-color: var(--accent-1); box-shadow: 0 0 0 3px var(--accent-soft); }
.select.small { width: auto; min-width: 130px; padding: 8px 30px 8px 10px; font-size: 0.85rem; }

.checkbox-field { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; cursor: pointer; }
.checkbox-field input { width: 18px; height: 18px; accent-color: var(--accent-1); cursor: pointer; flex-shrink: 0; }
.checkbox-field span { font-size: 0.9rem; font-weight: 600; color: var(--text-dim); }

.unit-group {
    display: inline-flex; background: var(--card-strong);
    border: 1px solid var(--border); border-radius: 0.5rem; padding: 3px;
}
.unit-btn {
    border: none; background: transparent; color: var(--text-dim);
    font-family: inherit; font-size: 0.8rem; font-weight: 700;
    padding: 5px 12px; border-radius: 0.4rem; cursor: pointer; transition: all 0.15s ease;
}
.unit-btn.active { background: var(--accent-1); color: #fff; }

textarea.input {
    width: 100%; padding: 10px 12px; resize: vertical; min-height: 84px;
    background: var(--card-strong); border: 1px solid var(--border);
    border-radius: 0.5rem; color: var(--text);
    font-family: var(--mono); font-size: 0.85rem; line-height: 1.6;
}
textarea.input:focus { outline: none; border-color: var(--accent-1); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ---------- results ---------- */
.result-panel { position: sticky; top: 84px; }
@media (max-width: 860px) {
    .result-panel { position: static; }
}
.result-hero {
    text-align: center; padding: 12px 0 18px;
    border-bottom: 1px solid var(--border); margin-bottom: 16px;
}
.result-hero .big {
    font-size: clamp(1.9rem, 4.5vw, 2.6rem);
    font-weight: 900; letter-spacing: -0.03em; line-height: 1.1;
    color: var(--accent-1); font-variant-numeric: tabular-nums;
}
.result-hero .big .unit { font-size: 0.55em; color: var(--text-dim); font-weight: 700; }
.result-hero .big-label { color: var(--text-dim); font-size: 0.95rem; margin-top: 4px; }
.result-rows { display: flex; flex-direction: column; gap: 10px; }
.result-row {
    display: flex; justify-content: space-between; align-items: baseline;
    gap: 12px; padding: 10px 14px; background: var(--card-strong);
    border: 1px solid var(--border); border-radius: 0.5rem;
    font-size: 0.92rem;
}
.result-row .k { color: var(--text-dim); }
.result-row .v { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.result-row.total { background: var(--accent-soft); border-color: var(--accent-3); }
.result-row.total .k { color: var(--text); }
.result-row.total .v { color: var(--accent-2); font-size: 1.05rem; }
.result-actions { display: flex; gap: 10px; margin-top: 18px; }
.btn {
    flex: 1; padding: 10px 16px;
    background: var(--accent-1); color: #fff;
    border: none; border-radius: 0.5rem;
    font-family: inherit; font-size: 0.92rem; font-weight: 700;
    cursor: pointer; transition: background 0.15s ease, transform 0.1s ease;
}
.btn:hover { background: var(--accent-2); }
.btn:active { transform: scale(0.98); }
.btn-ghost {
    flex: 1; padding: 10px 16px;
    background: var(--card); color: var(--text-dim);
    border: 1px solid var(--border); border-radius: 0.5rem;
    font-family: inherit; font-size: 0.92rem; font-weight: 600;
    cursor: pointer; transition: all 0.15s ease;
}
.btn-ghost:hover { color: var(--text); border-color: var(--border-strong); background: var(--card-strong); }
.btn-ghost.full { width: 100%; flex: none; }

/* verdict chips & notes */
.verdict { margin-top: 14px; }
.verdict-badge {
    display: inline-block; padding: 6px 12px; border-radius: 0.5rem;
    font-size: 0.9rem; font-weight: 700;
}
.verdict-badge.ok { background: var(--good-soft); color: var(--good); }
.verdict-badge.mid { background: var(--warn-soft); color: var(--warn); }
.verdict-badge.low { background: var(--bad-soft); color: var(--bad); }
.note-list { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.note {
    font-size: 0.82rem; color: var(--text-dim);
    background: var(--card-strong); border: 1px dashed var(--border-strong);
    border-radius: 0.5rem; padding: 9px 12px;
}
.note b { color: var(--text); }

.disclaimer {
    margin-top: 20px; padding: 12px 14px;
    font-size: 0.82rem; color: var(--text-faint);
    background: var(--card-strong); border: 1px dashed var(--border-strong);
    border-radius: 0.5rem;
}

/* ---------- reference table ---------- */
.table-scroll { overflow-x: auto; }
.ref-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.ref-table th {
    text-align: left; font-size: 0.75rem; text-transform: uppercase;
    letter-spacing: 0.06em; color: var(--text-faint);
    padding: 8px 12px; border-bottom: 1px solid var(--border-strong);
    white-space: nowrap;
}
.ref-table td { padding: 8px 12px; border-bottom: 1px solid var(--border); font-variant-numeric: tabular-nums; }
.ref-table tr:last-child td { border-bottom: none; }
.ref-table td.name { font-weight: 600; }
.ref-table .sub { color: var(--text-faint); font-size: 0.78rem; }
.ref-table.compact th, .ref-table.compact td { padding: 5px 8px; font-size: 0.84rem; }

/* ---------- lab demo stage ---------- */
.stage {
    min-height: 300px; display: flex; align-items: center; justify-content: center;
    flex-direction: column; gap: 10px;
    background: var(--card-strong); border: 1px dashed var(--border-strong);
    border-radius: 0.75rem; padding: 24px; text-align: center;
    cursor: pointer; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent;
    transition: background 0.15s ease, border-color 0.15s ease;
    position: relative; overflow: hidden;
}
.stage.no-click { cursor: default; }
.stage.waiting { background: var(--bad-soft); border: 1px solid var(--bad); cursor: default; }
.stage.go { background: var(--good-soft); border: 1px solid var(--good); }
.stage-title { font-size: clamp(1.3rem, 4vw, 1.8rem); font-weight: 800; letter-spacing: -0.02em; }
.stage-sub { font-size: 0.9rem; color: var(--text-dim); max-width: 380px; }
.stage-big { font-size: clamp(2.6rem, 9vw, 4.2rem); font-weight: 900; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; color: var(--accent-1); }
.stage-btn {
    padding: 12px 34px; background: var(--accent-1); color: #fff;
    border: none; border-radius: 0.5rem; font-family: inherit;
    font-size: 1rem; font-weight: 700; cursor: pointer;
    transition: background 0.15s ease, transform 0.1s ease;
    pointer-events: auto;
}
.stage-btn:hover { background: var(--accent-2); }
.stage-btn:active { transform: scale(0.98); }
.stage-btn.ghost { background: var(--card); color: var(--text-dim); border: 1px solid var(--border); }
.stage-btn.ghost:hover { color: var(--text); border-color: var(--border-strong); background: var(--card-strong); }
.stage-feedback { font-size: 1.1rem; font-weight: 800; }
.stage-feedback.good { color: var(--good); }
.stage-feedback.bad { color: var(--bad); }

/* choice reaction-time halves */
.choice-halves { position: absolute; inset: 0; display: grid; grid-template-columns: 1fr 1fr; }
.choice-half { display: flex; align-items: center; justify-content: center; }
.choice-half:first-child { border-right: 1px dashed var(--border-strong); }
.target-dot { width: 90px; height: 90px; border-radius: 50%; background: var(--accent-1); }

/* stroop */
.stroop-word { font-size: clamp(2.8rem, 10vw, 4.5rem); font-weight: 900; letter-spacing: -0.02em; line-height: 1.1; }
.ans-btns { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 16px; }
@media (max-width: 560px) { .ans-btns { grid-template-columns: 1fr 1fr; } }
.ans-btn {
    padding: 13px 8px; font-size: 0.95rem; font-weight: 700;
    background: var(--card-strong); border: 1px solid var(--border);
    border-radius: 0.5rem; cursor: pointer; color: var(--text);
    font-family: inherit; transition: all 0.12s ease;
}
.ans-btn:hover { border-color: var(--accent-1); }
.ans-btn.right { background: var(--good-soft); border-color: var(--good); color: var(--good); }
.ans-btn.wrong { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }

/* digit span */
.digit-display {
    font-size: clamp(3.6rem, 14vw, 6rem); font-weight: 900;
    font-variant-numeric: tabular-nums; font-family: var(--mono); line-height: 1;
}
.recall-input { max-width: 300px; margin: 0 auto; }

/* word recall */
.word-flash { font-size: clamp(1.9rem, 6.5vw, 3rem); font-weight: 800; letter-spacing: -0.02em; }

/* bar chart */
.bars { display: flex; align-items: stretch; gap: 5px; height: 160px; padding: 4px 2px 0; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; }
.bar-value { font-size: 0.66rem; color: var(--text-dim); font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar-track { flex: 1; width: 100%; display: flex; align-items: flex-end; }
.bar-fill { width: 100%; background: var(--accent-1); border-radius: 3px 3px 0 0; min-height: 3px; }
.bar-fill.dim { background: var(--accent-3); opacity: 0.55; }
.bar-fill.ok { background: var(--good); }
.bar-fill.mid { background: var(--warn); }
.bar-fill.low { background: var(--bad); }
.bar-label { font-size: 0.68rem; color: var(--text-faint); white-space: nowrap; }

/* scatter plot */
.scatter-wrap { border: 1px solid var(--border); border-radius: 0.6rem; background: var(--card-strong); padding: 8px; }
.scatter-wrap svg { width: 100%; height: auto; display: block; }

/* progress chip */
.progress-chip {
    display: inline-block; font-size: 0.78rem; font-weight: 700;
    color: var(--text-dim); background: var(--card-strong);
    border: 1px solid var(--border); border-radius: 999px;
    padding: 3px 12px; margin-bottom: 12px;
}

/* ---------- small helpers ---------- */
.mono { font-family: var(--mono); }
.muted { color: var(--text-dim); }
.tiny { font-size: 0.78rem; color: var(--text-faint); }
.mt { margin-top: 14px; }
.mb0 { margin-bottom: 0; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 560px) { .row2 { grid-template-columns: 1fr; } }
.btn-row { display: flex; gap: 10px; margin-top: 6px; }
.btn-row .btn, .btn-row .btn-ghost { flex: 1; }

/* ---------- footer ---------- */
.site-footer { border-top: 1px solid var(--border); padding: 32px 0 40px; margin-top: 24px; }
.footer-inner { display: flex; flex-direction: column; gap: 8px; align-items: center; text-align: center; }
.footer-tag { color: var(--text-dim); font-size: 0.9rem; }
.footer-meta { color: var(--text-faint); font-size: 0.8rem; }
