/* Logic2030 — Styles */

/* ── Fonts ─────────────────────────────────────────────────────────── */

@font-face {
    font-family: 'Source Sans Pro';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('/static/fonts/source-sans-pro-regular.woff2') format('woff2');
}

@font-face {
    font-family: 'Source Sans Pro';
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url('/static/fonts/source-sans-pro-600.woff2') format('woff2');
}

@font-face {
    font-family: 'Source Sans Pro';
    font-style: italic;
    font-weight: 400;
    font-display: swap;
    src: url('/static/fonts/source-sans-pro-italic.woff2') format('woff2');
}

/* ── Variables ─────────────────────────────────────────────────────── */

:root {
    --bg: #ffffff;
    --surface: #f5f5f5;
    --surface2: #ebebeb;
    --accent: #e94560;
    --accent-dim: rgba(233, 69, 96, 0.10);
    --text: #000000;
    --text-dim: #555555;
    --success: #2e7d32;
    --error: #c62828;
    --strict-border: #e65100;
    --border-color: #cccccc;
    --font-body: 'Century Schoolbook', Georgia, 'Times New Roman', serif;
    --font-deriv: 'Source Sans Pro', 'Segoe UI', system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

.hidden { display: none !important; }

/* ── Accent helper ─────────────────────────────────────────────────── */

.accent { color: var(--accent); }

/* ── Header ────────────────────────────────────────────────────────── */

header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.7rem 2rem;
    background: var(--surface);
    border-bottom: 2px solid var(--accent);
}

.header-title { display: flex; align-items: baseline; gap: 0.7rem; }

header h1 {
    font-family: var(--font-body);
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.header-sub {
    font-size: 0.8rem;
    color: var(--text-dim);
    font-weight: 400;
}

header nav {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

header nav a {
    color: var(--accent);
    text-decoration: none;
    font-size: 0.85rem;
}
header nav a:hover { text-decoration: underline; }

/* ── Base form controls ────────────────────────────────────────────── */

select, input, button {
    font-family: var(--font-deriv);
    font-size: 0.9rem;
    padding: 0.4rem 0.7rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: #fff;
    color: var(--text);
    outline: none;
    transition: border-color 0.15s;
}

select:focus, input:focus { border-color: var(--accent); }

button {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    cursor: pointer;
    font-weight: 600;
    transition: opacity 0.12s;
}
button:hover { opacity: 0.88; }
button:active { opacity: 0.75; }

.btn-secondary {
    background: transparent;
    border-color: var(--border-color);
    color: var(--text-dim);
}
.btn-secondary:hover { border-color: var(--text-dim); color: var(--text); opacity: 1; }

/* ── Main layout (single column) ───────────────────────────────────── */

main {
    max-width: 880px;
    margin: 0 auto;
    padding: 1rem 2rem 2rem;
}

/* ── Symbol toolbar ────────────────────────────────────────────────── */

#symbol-toolbar {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.6rem 0.8rem;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

#symbol-toolbar-deriv {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.6rem 0.8rem;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    margin-top: 0.3rem;
    margin-bottom: 0.8rem;
    flex-wrap: wrap;
}

.toolbar-label {
    font-family: var(--font-deriv);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-dim);
    margin-right: 0.2rem;
    font-weight: 600;
}

.toolbar-sep {
    width: 1px;
    height: 1.6rem;
    background: var(--border-color);
    margin: 0 0.3rem;
}

.sym-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.3rem 0.55rem;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    font-weight: 400;
    color: var(--text);
    transition: background 0.12s, border-color 0.12s;
    position: relative;
}

.sym-btn:hover {
    background: var(--accent-dim);
    border-color: var(--accent);
    opacity: 1;
}

.sym-btn .sym {
    font-family: var(--font-deriv);
    font-size: 1.05rem;
    line-height: 1;
}

.sym-btn kbd {
    font-family: var(--font-deriv);
    font-size: 0.6rem;
    color: var(--text-dim);
    background: var(--surface2);
    padding: 0.1rem 0.25rem;
    border-radius: 2px;
    line-height: 1;
    border: none;
}

.sym-btn.sym-paren {
    font-family: var(--font-deriv);
    font-size: 1rem;
    padding: 0.3rem 0.6rem;
}

/* ── Motivation blurb ─────────────────────────────────────────────── */

.motivation-blurb {
    font-style: italic;
    color: var(--text-dim);
    padding: 0.6rem 0.8rem;
    background: var(--accent-dim);
    border-left: 3px solid var(--accent);
    border-radius: 0 4px 4px 0;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

/* ── Problem header (preset problem display) ──────────────────────── */

.problem-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    margin-bottom: 1rem;
}

.problem-header-formulas {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.25rem 0.8rem;
    align-items: baseline;
}

.problem-header-label {
    font-size: 0.8rem;
    color: var(--text-dim);
    text-align: right;
    font-weight: 500;
}

.problem-header-value {
    font-family: var(--font-deriv);
    font-size: 1.05rem;
    font-weight: 600;
}

.problem-header-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

/* ── Setup section ─────────────────────────────────────────────────── */

#setup {
    margin-bottom: 1rem;
}

.setup-grid {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.45rem 0.8rem;
    align-items: center;
    margin-bottom: 0.6rem;
}

.setup-grid label {
    font-size: 0.85rem;
    color: var(--text-dim);
    text-align: right;
    font-weight: 500;
}

.setup-grid input {
    font-family: var(--font-deriv);
    width: 100%;
}

.setup-actions {
    display: flex;
    gap: 0.5rem;
}

#global-message {
    margin-top: 0.5rem;
    font-size: 0.9rem;
    min-height: 1.4em;
}

.msg-valid { color: var(--success); }
.msg-invalid { color: var(--error); }

/* ── Derivation area ───────────────────────────────────────────────── */

#derivation-area {
    margin-top: 0.5rem;
}

#lines-container {
    font-family: var(--font-deriv);
    font-size: 0.95rem;
    background: var(--surface);
    border-radius: 6px;
    padding: 0.8rem 0.6rem;
    min-height: 160px;
    margin-bottom: 0.8rem;
    border: 1px solid var(--border-color);
}

/* Individual derivation line */
.deriv-line {
    display: grid;
    grid-template-columns: 36px 1fr 150px 28px;
    align-items: center;
    padding: 0.25rem 0.4rem;
    border-radius: 3px;
    gap: 0.5rem;
}

.deriv-line:hover {
    background: rgba(0, 0, 0, 0.035);
}

.line-num {
    color: var(--text-dim);
    text-align: right;
    font-size: 0.82rem;
    user-select: none;
}

.line-formula {
    padding-left: 0;
}

.line-just {
    color: var(--text-dim);
    font-size: 0.82rem;
    text-align: right;
}

.line-status {
    text-align: center;
    font-size: 1rem;
}

/* Show lines */
.line-show .line-formula {
    color: var(--accent);
    font-weight: 600;
}

.line-show .line-formula::before {
    content: "SHOW  ";
    font-size: 0.7rem;
    letter-spacing: 0.06em;
    vertical-align: 1px;
}

/* Completed show line */
.line-show-complete .line-formula {
    color: var(--success);
}

.line-show-complete .line-formula::before {
    content: "\2713  SHOW  ";
}

/* Boxed-off lines (completed subderivation) */
.line-boxed {
    opacity: 0.5;
}

/* Assumption lines */
.line-assumption .line-formula {
    font-style: italic;
}

/* Depth indentation */
.depth-1 .line-formula { padding-left: 1.5rem; }
.depth-2 .line-formula { padding-left: 3rem; }
.depth-3 .line-formula { padding-left: 4.5rem; }
.depth-4 .line-formula { padding-left: 6rem; }

/* ── Command bar ──────────────────────────────────────────────────── */

#command-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.6rem;
    background: var(--surface);
    border-radius: 6px;
    margin-bottom: 0.5rem;
    border: 1px solid var(--border-color);
}

#command-input {
    flex: 1;
    font-family: var(--font-deriv);
    font-size: 0.95rem;
    padding: 0.45rem 0.7rem;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text);
}

#command-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-dim);
}

#command-input::placeholder {
    color: #999;
    font-size: 0.85rem;
}

.btn-undo {
    padding: 0.35rem 0.6rem;
    font-size: 0.8rem;
    flex-shrink: 0;
}

.command-hint {
    font-family: var(--font-deriv);
    font-size: 0.78rem;
    color: var(--text-dim);
    white-space: nowrap;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.command-hint.hint-error {
    color: var(--error);
}

.command-hint.hint-ok {
    color: var(--success);
}

/* ── Line controls (input row) ─────────────────────────────────────── */

#line-controls {
    display: flex;
    gap: 0.4rem;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 0.6rem;
}

#formula-input {
    flex: 1;
    min-width: 180px;
    font-family: var(--font-deriv);
}

.short-input {
    width: 90px;
    font-family: var(--font-deriv);
}

/* ── Rule reference list ──────────────────────────────────────────── */

#rule-panel {
    background: var(--surface);
    border-radius: 6px;
    margin-bottom: 0.8rem;
    border: 1px solid var(--border-color);
    overflow: hidden;
}

#rule-panel-header {
    padding: 0.45rem 0.7rem;
    border-bottom: 1px solid var(--border-color);
}

#rule-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
}

.rule-row {
    display: grid;
    grid-template-columns: 56px 1fr 72px;
    align-items: center;
    padding: 0.3rem 0.7rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    cursor: pointer;
    transition: background 0.1s;
}

.rule-row:hover {
    background: var(--accent-dim);
}

.rule-row.rule-active {
    background: var(--accent-dim);
}

.rule-row.rule-disabled {
    opacity: 0.4;
    text-decoration: line-through;
    cursor: default;
    pointer-events: none;
}

.rule-name {
    font-family: var(--font-deriv);
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text);
}

.rule-desc {
    font-size: 0.75rem;
    color: var(--text-dim);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rule-shortcut {
    font-family: var(--font-deriv);
    font-size: 0.72rem;
    color: var(--accent);
    text-align: right;
}

.rule-sep {
    grid-column: 1 / -1;
    padding: 0.25rem 0.7rem 0.15rem;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--strict-border);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

@media (max-width: 640px) {
    #rule-list { grid-template-columns: 1fr; }
}

/* ── Validation bar (above lines) ─────────────────────────────────── */

#validation-bar {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 0.6rem;
}

.btn-next-problem {
    background: transparent;
    border: 1px solid var(--success);
    color: var(--success);
    font-weight: 600;
}
.btn-next-problem:hover:not(:disabled) {
    background: var(--success);
    color: #fff;
    opacity: 1;
}
.btn-next-problem:disabled {
    opacity: 0.35;
    cursor: default;
}
.btn-next-problem.glow {
    animation: glow-pulse 1.5s ease-in-out 3;
}

@keyframes glow-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(46, 125, 50, 0); }
    50% { box-shadow: 0 0 8px 3px rgba(46, 125, 50, 0.45); }
}

/* ── Derivation footer ─────────────────────────────────────────────── */

.derivation-footer {
    display: flex;
    gap: 0.5rem;
}

#btn-validate-all {
    background: transparent;
    border: 1px solid var(--success);
    color: var(--success);
    font-weight: 600;
}
#btn-validate-all:hover {
    background: var(--success);
    color: #fff;
    opacity: 1;
}

.btn-quit {
    background: transparent;
    border: 1px solid var(--error);
    color: var(--error);
    font-weight: 600;
    margin-left: auto;
}
.btn-quit:hover {
    background: var(--error);
    color: #fff;
    opacity: 1;
}

/* ── Help page ─────────────────────────────────────────────────────── */

.help-main {
    display: block;
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem;
}

.help-main section {
    margin-bottom: 2rem;
}

.help-main h2 {
    color: var(--accent);
    margin-bottom: 0.8rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.3rem;
}

.ref-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.ref-table th, .ref-table td {
    padding: 0.5rem 0.8rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.ref-table th {
    background: var(--surface2);
    color: var(--accent);
    font-weight: 600;
}

.ref-table code {
    background: var(--surface2);
    padding: 0.15rem 0.4rem;
    border-radius: 3px;
    font-family: var(--font-deriv);
}

.help-main ul {
    padding-left: 1.5rem;
}

.help-main li {
    margin-bottom: 0.4rem;
}

.help-main p {
    margin-bottom: 0.5rem;
    line-height: 1.5;
}

/* ── Homepage ──────────────────────────────────────────────────────── */

.home-main {
    max-width: 760px;
    margin: 0 auto;
    padding: 2.5rem 2rem 3rem;
    background: #FAFAF8;
}

/* Hero section */
.home-hero {
    text-align: center;
    margin-bottom: 2.5rem;
}

.home-hero h2 {
    font-family: var(--font-body);
    font-size: 2.2rem;
    line-height: 1.2;
    margin-bottom: 0.7rem;
}

.home-hero-sub {
    font-size: 1.1rem;
    color: var(--text-dim);
    line-height: 1.6;
    margin-bottom: 1.4rem;
    max-width: 540px;
    margin-left: auto;
    margin-right: auto;
}

.home-cta {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 0.8rem;
    flex-wrap: wrap;
}

.home-btn {
    display: inline-block;
    padding: 0.65rem 1.5rem;
    border-radius: 4px;
    font-size: 0.95rem;
    font-weight: 600;
    text-decoration: none;
    transition: opacity 0.15s;
    font-family: var(--font-deriv);
}
.home-btn:hover { opacity: 0.85; }

.home-btn-primary {
    background: var(--accent);
    color: #fff;
    border: 2px solid var(--accent);
}

.home-btn-secondary {
    background: transparent;
    color: var(--accent);
    border: 2px solid var(--accent);
}

.home-tertiary {
    font-size: 0.88rem;
    margin-bottom: 0.5rem;
}
.home-tertiary a {
    color: var(--text-dim);
    text-decoration: none;
}
.home-tertiary a:hover {
    color: var(--accent);
}

.home-kbd-hint {
    font-family: var(--font-deriv);
    font-size: 0.78rem;
    color: var(--text-dim);
}
.home-kbd-hint kbd {
    display: inline-block;
    padding: 0.1rem 0.4rem;
    background: var(--surface2);
    border: 1px solid var(--border-color);
    border-radius: 3px;
    font-family: var(--font-deriv);
    font-size: 0.75rem;
    font-weight: 600;
}

/* Visual demo section */
.home-demo {
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.home-demo h3 {
    color: var(--accent);
    font-size: 1.1rem;
    margin-bottom: 0.2rem;
}

.home-demo-subtitle {
    font-family: var(--font-deriv);
    font-size: 0.95rem;
    color: var(--text-dim);
    margin-bottom: 1rem;
}

.demo-derivation {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.demo-group {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 1rem;
    align-items: center;
}

.demo-lines {
    display: flex;
    flex-direction: column;
}

.demo-line {
    display: grid;
    grid-template-columns: 36px 1fr 120px 28px;
    align-items: center;
    padding: 0.25rem 0.4rem;
    gap: 0.5rem;
    font-family: var(--font-deriv);
    font-size: 0.95rem;
}

.demo-num {
    color: var(--text-dim);
    text-align: right;
    font-size: 0.82rem;
}

.demo-formula {
    padding-left: 0;
}

.demo-just {
    color: var(--text-dim);
    font-size: 0.82rem;
    text-align: right;
}

.demo-status {
    text-align: center;
    font-size: 1rem;
}

.demo-ok {
    color: var(--success);
}

.demo-show-complete .demo-formula {
    color: var(--success);
    font-weight: 600;
}

.demo-boxed {
    opacity: 0.5;
}

.demo-indent .demo-formula {
    padding-left: 1.5rem;
}

.demo-assumption {
    font-style: italic;
}

.demo-annotation {
    font-family: var(--font-deriv);
    font-size: 0.78rem;
    color: var(--text-dim);
    white-space: nowrap;
}

.demo-ann-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.2em;
    height: 1.2em;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    margin-right: 0.3rem;
    vertical-align: middle;
}

.demo-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 0.8rem;
}

.demo-note {
    font-size: 0.85rem;
    color: var(--text-dim);
}

.btn-replay {
    font-size: 0.78rem;
    padding: 0.3rem 0.7rem;
}

/* Proof line animation */
@keyframes line-appear {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes check-appear {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.demo-derivation.animate .proof-line {
    opacity: 0;
    animation: line-appear 0.6s ease forwards;
}

/* Stagger each proof-line element — there are ~10 total (lines + annotations) */
.demo-derivation.animate .demo-group:nth-child(1) .proof-line:nth-child(1) { animation-delay: 0.0s; }
.demo-derivation.animate .demo-group:nth-child(1) .proof-line:nth-child(2) { animation-delay: 0.6s; }
.demo-derivation.animate .demo-group:nth-child(1) .demo-annotation.proof-line { animation-delay: 1.0s; }
.demo-derivation.animate .demo-group:nth-child(2) .proof-line:nth-child(1) { animation-delay: 1.6s; }
.demo-derivation.animate .demo-group:nth-child(2) .demo-annotation.proof-line { animation-delay: 2.1s; }
.demo-derivation.animate .demo-group:nth-child(3) .proof-line:nth-child(1) { animation-delay: 2.7s; }
.demo-derivation.animate .demo-group:nth-child(3) .demo-annotation.proof-line { animation-delay: 3.2s; }
.demo-derivation.animate .demo-group:nth-child(4) .proof-line:nth-child(1) { animation-delay: 3.8s; }
.demo-derivation.animate .demo-group:nth-child(4) .proof-line:nth-child(2) { animation-delay: 4.4s; }
.demo-derivation.animate .demo-group:nth-child(4) .demo-annotation.proof-line { animation-delay: 4.9s; }

.demo-derivation.animate .demo-status {
    opacity: 0;
    animation: check-appear 0.3s ease forwards;
}

.demo-derivation.animate .demo-group:nth-child(1) .proof-line:nth-child(1) .demo-status { animation-delay: 0.4s; }
.demo-derivation.animate .demo-group:nth-child(1) .proof-line:nth-child(2) .demo-status { animation-delay: 1.0s; }
.demo-derivation.animate .demo-group:nth-child(2) .proof-line:nth-child(1) .demo-status { animation-delay: 2.1s; }
.demo-derivation.animate .demo-group:nth-child(3) .proof-line:nth-child(1) .demo-status { animation-delay: 3.2s; }
.demo-derivation.animate .demo-group:nth-child(4) .proof-line:nth-child(1) .demo-status { animation-delay: 4.2s; }
.demo-derivation.animate .demo-group:nth-child(4) .proof-line:nth-child(2) .demo-status { animation-delay: 4.8s; }

@media (prefers-reduced-motion: reduce) {
    .demo-derivation.animate .proof-line,
    .demo-derivation.animate .demo-status {
        animation: none;
        opacity: 1;
        transform: none;
    }
}

/* Value propositions — 3-column grid */
.home-value-props {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2rem;
    margin-bottom: 2.5rem;
}

.value-prop {
    text-align: center;
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.value-prop.visible {
    opacity: 1;
    transform: translateY(0);
}

.value-prop h4 {
    font-size: 0.95rem;
    margin-bottom: 0.7rem;
}

.value-prop-visual {
    display: flex;
    justify-content: center;
}

/* Mini proof line visual */
.mini-proof-line {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.35rem 0.8rem;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-family: var(--font-deriv);
    font-size: 0.88rem;
}

.mini-formula { font-weight: 600; }
.mini-just { color: var(--text-dim); font-size: 0.78rem; }
.mini-check { color: var(--success); }

/* Chapter progression dots */
.chapter-dots {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.25rem 1rem;
    text-align: left;
}

.chapter-dot {
    font-size: 0.8rem;
    color: var(--accent);
    white-space: nowrap;
}

/* Mini command bar */
.mini-command-bar {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.8rem;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-family: var(--font-deriv);
    font-size: 0.88rem;
}

.mini-prompt { color: var(--text-dim); }
.mini-input { font-weight: 600; }

/* Sample problems section */
.home-sample-problems {
    margin-bottom: 2rem;
}

.home-sample-problems h3 {
    color: var(--accent);
    font-size: 1.1rem;
    margin-bottom: 1rem;
}

.sample-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.8rem;
    margin-bottom: 1rem;
}

.sample-card {
    display: block;
    padding: 0.8rem 1rem;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    text-decoration: none;
    color: var(--text);
    transition: border-color 0.15s, box-shadow 0.15s, opacity 0.5s ease, transform 0.5s ease;
    opacity: 0;
    transform: translateY(12px);
}
.sample-card.visible {
    opacity: 1;
    transform: translateY(0);
}
.sample-card:hover {
    border-color: var(--accent);
    box-shadow: 0 1px 4px rgba(233, 69, 96, 0.12);
}

.sample-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.3rem;
}

.sample-chapter {
    font-family: var(--font-deriv);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--accent);
    background: var(--accent-dim);
    padding: 0.15rem 0.4rem;
    border-radius: 3px;
}

.sample-card-title {
    font-weight: 600;
    font-size: 0.92rem;
    margin-bottom: 0.25rem;
}

.sample-card-formula {
    font-family: var(--font-deriv);
    font-size: 0.85rem;
    color: var(--text-dim);
}

/* Difficulty dots (shared with problems page) */
.problem-diff {
    display: inline-flex;
    gap: 3px;
    align-items: center;
}

.diff-dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    border: 1.5px solid var(--text-dim);
    background: transparent;
}

.diff-dot.filled {
    background: var(--text-dim);
}

.problem-badge {
    font-family: var(--font-deriv);
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-dim);
    background: var(--surface2);
    padding: 0.1rem 0.35rem;
    border-radius: 3px;
}

/* "See all" link */
.home-see-all {
    text-align: center;
    font-size: 0.9rem;
}
.home-see-all a {
    color: var(--text-dim);
    text-decoration: none;
}
.home-see-all a:hover {
    color: var(--accent);
}

/* ── Bios section (homepage) ──────────────────────────────────────── */

.home-bios {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.bio-card {
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
}

.bio-photo {
    width: 140px;
    height: auto;
    border-radius: 4px;
    flex-shrink: 0;
    filter: grayscale(100%);
}

.bio-text h4 {
    font-size: 1rem;
    margin-bottom: 0.4rem;
}

.bio-dates {
    font-weight: 400;
    color: var(--text-dim);
    font-size: 0.88rem;
}

.bio-text p {
    font-size: 0.88rem;
    line-height: 1.65;
    color: var(--text-dim);
    text-align: justify;
    hyphens: auto;
}

@media (max-width: 640px) {
    .bio-card {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
    .bio-photo { width: 120px; }
    .bio-text p { text-align: left; }
}

/* ── Problems page ─────────────────────────────────────────────────── */

.problems-main {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem;
}

.problems-chapter {
    margin-bottom: 2rem;
}

.problems-chapter h2 {
    color: var(--text);
    margin-bottom: 0.8rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.3rem;
}

.problems-chapter h2 .chapter-num {
    color: var(--accent);
    font-size: 0.85em;
    margin-right: 0.3rem;
}

.no-problems {
    color: var(--text-dim);
    font-style: italic;
    font-size: 0.9rem;
}

.problem-card {
    display: block;
    padding: 0.8rem 1rem;
    margin-bottom: 0.5rem;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    text-decoration: none;
    color: var(--text);
    transition: border-color 0.15s, box-shadow 0.15s;
}
.problem-card:hover {
    border-color: var(--accent);
    box-shadow: 0 1px 4px rgba(233, 69, 96, 0.12);
}

.problem-card-header {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.3rem;
}

.problem-card-title {
    flex: 1;
    font-weight: 600;
    font-size: 0.95rem;
}

.problem-motivation {
    font-size: 0.82rem;
    color: var(--text-dim);
    font-style: italic;
    line-height: 1.4;
}

.problem-restrictions {
    font-size: 0.75rem;
    color: var(--strict-border);
    margin-top: 0.3rem;
    font-weight: 500;
}

/* ── Problem Bank ─────────────────────────────────────────────────── */

.problem-bank {
    margin-top: 1.2rem;
}

.problem-bank h3 {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--strict-border);
    margin-bottom: 0.5rem;
    padding-bottom: 0.25rem;
    border-bottom: 1px dashed var(--strict-border);
}

.bank-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.4rem;
}

.bank-card {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.8rem;
    background: var(--bg);
    border: 1px solid var(--border-color);
    border-left: 3px solid var(--strict-border);
    border-radius: 4px;
    text-decoration: none;
    color: var(--text);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.bank-card:hover {
    border-color: var(--accent);
    border-left-color: var(--accent);
    box-shadow: 0 1px 4px rgba(233, 69, 96, 0.12);
}

.bank-title {
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

/* ── Theorem Bank ─────────────────────────────────────────────────── */

.theorem-bank {
    margin-top: 1.2rem;
}

.theorem-bank h3 {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-dim);
    margin-bottom: 0.5rem;
    padding-bottom: 0.25rem;
    border-bottom: 1px dashed var(--border-color);
}

.theorem-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.4rem;
}

.theorem-card {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.8rem;
    background: var(--bg);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    text-decoration: none;
    color: var(--text);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.theorem-card:hover {
    border-color: var(--accent);
    box-shadow: 0 1px 4px rgba(233, 69, 96, 0.12);
}

.theorem-title {
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.theorem-formula {
    flex: 1;
    font-family: var(--font-deriv);
    font-size: 0.85rem;
    color: var(--text-dim);
    text-align: right;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

@media (max-width: 640px) {
    .theorem-grid, .bank-grid { grid-template-columns: 1fr; }
}

/* ── Responsive ────────────────────────────────────────────────────── */

@media (max-width: 768px) {
    .home-value-props { grid-template-columns: 1fr; gap: 1.5rem; }
}

@media (max-width: 640px) {
    header { flex-direction: column; gap: 0.5rem; padding: 0.7rem 1rem; }
    .header-title { justify-content: center; }
    main { padding: 0.8rem 1rem 2rem; }
    .setup-grid { grid-template-columns: 1fr; }
    .setup-grid label { text-align: left; }
    #symbol-toolbar { justify-content: center; }
    #symbol-toolbar-deriv { justify-content: center; }
    .home-main { padding: 1.5rem 1rem 2rem; }
    .home-hero h2 { font-size: 1.5rem; }
    .demo-group { grid-template-columns: 1fr; }
    .demo-annotation { white-space: normal; padding-left: 0.4rem; margin-bottom: 0.5rem; }
    .sample-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
    .value-prop, .sample-card {
        opacity: 1;
        transform: none;
        transition: none;
    }
}

/* ── Tutorial Panel ───────────────────────────────────────────────── */

.tutorial-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 340px;
    height: 100vh;
    background: var(--bg);
    border-left: 2px solid var(--accent);
    box-shadow: -2px 0 12px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    font-family: var(--font-deriv);
    overflow-y: auto;
    transition: transform 0.25s ease;
}

.tutorial-panel.hidden {
    display: none !important;
}

body.tutorial-active main {
    margin-right: 340px;
    max-width: none;
    padding-right: 2rem;
}

.tutorial-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.8rem 1rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--surface);
}

.tutorial-title {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--accent);
}

.tutorial-close {
    background: transparent;
    border: none;
    font-size: 1.3rem;
    color: var(--text-dim);
    cursor: pointer;
    padding: 0.2rem 0.4rem;
    line-height: 1;
    border-radius: 3px;
}
.tutorial-close:hover {
    background: var(--accent-dim);
    color: var(--accent);
    opacity: 1;
}

.tutorial-progress {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 1rem;
}

.tutorial-progress-bar {
    flex: 1;
    height: 6px;
    background: var(--surface2);
    border-radius: 3px;
    overflow: hidden;
}

.tutorial-progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 3px;
    transition: width 0.3s ease;
}

.tutorial-progress-text {
    font-size: 0.72rem;
    color: var(--text-dim);
    white-space: nowrap;
}

.tutorial-content {
    flex: 1;
    padding: 1rem;
    font-size: 0.88rem;
    line-height: 1.55;
    color: var(--text);
}

.tutorial-content strong {
    color: var(--accent);
}

.tutorial-content code {
    background: var(--surface2);
    padding: 0.15rem 0.4rem;
    border-radius: 3px;
    font-family: var(--font-deriv);
    font-size: 0.85em;
    font-weight: 600;
}

.tutorial-hint-box {
    margin: 0 1rem 0.8rem;
    padding: 0.6rem 0.8rem;
    background: var(--surface);
    border: 1px solid var(--accent);
    border-radius: 6px;
    text-align: center;
}

.tutorial-hint-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-dim);
    margin-bottom: 0.3rem;
}

.tutorial-hint-box code {
    font-family: var(--font-deriv);
    font-size: 1rem;
    font-weight: 700;
    color: var(--accent);
    background: none;
}

.tutorial-wrong-hint {
    margin: 0 1rem 0.5rem;
    padding: 0.45rem 0.7rem;
    background: #fff3e0;
    border: 1px solid #e65100;
    border-radius: 4px;
    font-size: 0.8rem;
    color: #e65100;
}

.tutorial-wrong-hint code {
    font-family: var(--font-deriv);
    font-weight: 700;
    background: none;
    padding: 0;
}

.tutorial-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 1rem;
    border-top: 1px solid var(--border-color);
    background: var(--surface);
}

.tutorial-nav-btn {
    padding: 0.35rem 0.8rem;
    font-size: 0.82rem;
}

.tutorial-step-counter {
    font-size: 0.75rem;
    color: var(--text-dim);
}

/* Tutorial highlighting */
.tutorial-highlight {
    outline: 2px solid var(--accent) !important;
    outline-offset: 2px;
    animation: tutorial-pulse 1.5s ease-in-out infinite;
    position: relative;
    z-index: 10;
}

@keyframes tutorial-pulse {
    0%, 100% { outline-color: var(--accent); }
    50% { outline-color: rgba(233, 69, 96, 0.35); }
}

/* ── Tutorial Mobile ─────────────────────────────────────────────── */

@media (max-width: 768px) {
    .tutorial-panel {
        position: fixed;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        height: 40vh;
        border-left: none;
        border-top: 2px solid var(--accent);
        box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.08);
    }

    body.tutorial-active main {
        margin-right: 0;
        padding-bottom: 42vh;
    }
}

@media (prefers-reduced-motion: reduce) {
    .tutorial-highlight {
        animation: none;
    }
}
