* { box-sizing: border-box; }

:root {
    color-scheme: dark;
    --bg: #0f1115;
    --surface: #1a1d23;
    --surface-2: #232831;
    --border: #2d333d;
    --text: #e6e8eb;
    --text-muted: #9aa0a8;
    --text-dim: #6b7280;
    --primary: #6aa9e9;
    --primary-hover: #8bbef0;
    --pass: #34d399;
    --pass-bg: #11271f;
    --fail: #f87171;
    --fail-bg: #2a1417;
    --warn: #fbbf24;
    --warn-bg: #2a1f08;
    --highlight-bg: #3a2f08;
    --highlight-border: #fbbf24;
    --highlight-text: #fde68a;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    max-width: 920px;
    margin: 0 auto;
    padding: 1rem 1.25rem 4rem;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
}

a { color: var(--primary); }
a:hover { color: var(--primary-hover); }

header {
    border-bottom: 1px solid var(--border);
    margin-bottom: 1.5rem;
}
header a {
    color: inherit;
    text-decoration: none;
}
header h1 { margin: 0.5rem 0; font-size: 1.4rem; }

h2 { margin-top: 0; }
.meta { color: var(--text-muted); font-size: 0.9rem; }

section { margin: 1.5rem 0; }

.task, .scenario {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 0.9rem 1rem;
    border-radius: 4px;
}

.info-stream { list-style: none; padding-left: 0; margin: 0; }
.info-stream li {
    padding: 0.5rem 0.7rem;
    margin: 0.3rem 0;
    color: var(--text-dim);
    background: transparent;
    border-left: 3px solid transparent;
    border-radius: 0 3px 3px 0;
    transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}
.info-stream li.latest {
    color: var(--highlight-text);
    background: var(--highlight-bg);
    border-left-color: var(--highlight-border);
    font-weight: 500;
}

.sheet {
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    margin-bottom: 1rem;
    background: var(--surface);
}
.scenario-list { list-style: none; padding-left: 0; }
.scenario-list li { padding: 0.5rem 0; border-top: 1px solid var(--border); }
.scenario-list li:first-child { border-top: 0; }
.scenario-list .preview { margin: 0.25rem 0 0; color: var(--text-muted); font-size: 0.9rem; }

.phase {
    border: 1px solid var(--border);
    background: var(--surface);
    padding: 1rem 1.25rem;
    border-radius: 4px;
    margin-top: 1.25rem;
}

.shuffled-steps { list-style: none; padding-left: 0; margin: 0; }
.shuffled-steps li {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
}
.shuffled-steps li:last-child { border-bottom: 0; }
.order-input {
    width: 4rem;
    padding: 0.3rem 0.4rem;
    font-size: 1rem;
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 3px;
}

.position-list { list-style: none; padding-left: 0; margin: 0; counter-reset: pos; }
.position-list li {
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--border);
}
.position-list li:last-child { border-bottom: 0; }
.position-list label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}
.position-label {
    min-width: 4.5rem;
    font-weight: 600;
    color: var(--primary);
}
.position-select {
    flex: 1;
    min-width: 12rem;
    padding: 0.4rem 0.5rem;
    font-size: 1rem;
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 4px;
}

.pick-outcome {
    padding: 0.6rem 0.9rem;
    margin: 0 0 1rem;
    border-radius: 4px;
    font-weight: 500;
    border-left: 4px solid var(--border);
    background: var(--surface-2);
}
.pick-outcome.correct {
    background: var(--pass-bg);
    border-left-color: var(--pass);
    color: var(--pass);
}
.pick-outcome.incorrect {
    background: var(--fail-bg);
    border-left-color: var(--fail);
    color: var(--fail);
}

.step-questions {
    margin: 1rem 0;
    padding: 0.75rem 1rem;
    background: var(--surface-2);
    border-left: 3px solid var(--primary);
    border-radius: 0 4px 4px 0;
}
.step-questions h4 { margin: 0 0 0.5rem; }
.critical { color: var(--fail); font-weight: normal; font-size: 0.85em; }

.question { margin: 0.85rem 0; }
.question .prompt { font-weight: 600; margin-bottom: 0.4rem; }
.option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.2rem 0;
    cursor: pointer;
}
.fill-input {
    width: 100%;
    max-width: 24rem;
    padding: 0.4rem 0.5rem;
    font-size: 1rem;
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 4px;
}
.fill-input:focus, .position-select:focus, .order-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(106, 169, 233, 0.25);
}

.submit {
    margin-top: 1.25rem;
    padding: 0.7rem 1.6rem;
    font-size: 1rem;
    background: var(--primary);
    color: #0f1115;
    border: 0;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
}
.submit:hover { background: var(--primary-hover); }
.submit.secondary {
    margin-left: 0.6rem;
    background: transparent;
    color: var(--primary);
    border: 1px solid var(--primary);
}
.submit.secondary:hover { background: rgba(106, 169, 233, 0.1); }

.results-table { width: 100%; border-collapse: collapse; background: var(--surface); }
.results-table th, .results-table td {
    padding: 0.5rem 0.6rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}
tr.correct { background: var(--pass-bg); }
tr.incorrect, tr.wrong { background: var(--fail-bg); }
tr.misplaced { background: var(--warn-bg); }

.result {
    padding: 0.75rem 1rem;
    margin-bottom: 0.6rem;
    border-left: 4px solid var(--border);
    background: var(--surface);
    border-radius: 0 4px 4px 0;
}
.result p { margin: 0.25rem 0; }
.result .step { font-size: 0.85rem; color: var(--text-muted); }
.result .prompt { font-weight: 600; }
.result.correct { border-color: var(--pass); background: var(--pass-bg); }
.result.partial { border-color: var(--warn); background: var(--warn-bg); }
.result.incorrect { border-color: var(--fail); background: var(--fail-bg); }

.feedback {
    margin-top: 0.6rem;
    padding: 0.5rem 0.75rem;
    border-radius: 0 4px 4px 0;
    border-left: 3px solid var(--border);
    background: var(--surface-2);
}
.feedback.correct { border-left-color: var(--pass); background: var(--pass-bg); }
.feedback.partial { border-left-color: var(--warn); background: var(--warn-bg); }
.feedback.incorrect { border-left-color: var(--fail); background: var(--fail-bg); }
.feedback p { margin: 0.2rem 0; }
.feedback .feedback-status { font-size: 0.95rem; }
.feedback.correct .feedback-status { color: var(--pass); }
.feedback.partial .feedback-status { color: var(--warn); }
.feedback.incorrect .feedback-status { color: var(--fail); }

.score-summary {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 1rem 1.25rem;
    border-radius: 4px;
}
.score-summary p { margin: 0.25rem 0; }
.score-summary .total { font-weight: bold; font-size: 1.1rem; margin-top: 0.5rem; }
.score-summary.pass { background: var(--pass-bg); border-color: var(--pass); }
.score-summary.fail { background: var(--fail-bg); border-color: var(--fail); }

.actions { margin-top: 1.5rem; }
.actions a { color: var(--primary); }

.sheet-actions { margin: 0.5rem 0 0.75rem; }
.sheet-actions a { font-weight: 500; }

.select-error {
    margin: 0 0 0.75rem;
    padding: 0.5rem 0.75rem;
    border-left: 3px solid var(--fail);
    background: var(--fail-bg);
    color: var(--fail);
    border-radius: 0 4px 4px 0;
}

.step-pool { list-style: none; padding-left: 0; margin: 0 0 1rem; }
.step-pool li {
    padding: 0.6rem 0.75rem;
    border-top: 1px solid var(--border);
    border-left: 3px solid transparent;
    cursor: pointer;
    user-select: none;
    transition: background 0.1s ease, color 0.1s ease, border-left-color 0.1s ease;
}
.step-pool li:first-child { border-top: 0; }
.step-pool li:hover { background: var(--surface-2); }
.step-pool li.selected {
    background: var(--pass-bg);
    border-left-color: var(--pass);
    color: var(--pass);
}
.step-pool li.selected:hover { background: var(--pass-bg); }

.ordering-list {
    list-style: none;
    padding-left: 0;
    margin: 0 0 1rem;
}
.ordering-list li {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 0.6rem;
    margin: 0.3rem 0;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 4px;
    transition: opacity 0.1s ease, box-shadow 0.1s ease;
}
.ordering-list li.dragging { opacity: 0.4; }
.ordering-list li.drop-above { box-shadow: 0 -2px 0 0 var(--primary) inset, 0 -2px 0 0 var(--primary); border-top-color: var(--primary); }
.ordering-list li.drop-below { box-shadow: 0 2px 0 0 var(--primary); border-bottom-color: var(--primary); }

.drag-handle {
    color: var(--text-muted);
    cursor: grab;
    font-size: 1.1rem;
    user-select: none;
    padding: 0 0.25rem;
}
.drag-handle:active { cursor: grabbing; }
@media (hover: none) {
    .drag-handle { display: none; }
    .ordering-list li { padding: 0.7rem 0.6rem; }
}

.ordering-desc { flex: 1; }

.order-arrows { display: flex; gap: 0.25rem; flex-shrink: 0; }
.order-arrow {
    background: transparent;
    color: var(--primary);
    border: 1px solid var(--border);
    border-radius: 4px;
    width: 2.2rem;
    height: 2.2rem;
    font-size: 1.1rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.1s ease, border-color 0.1s ease;
}
.order-arrow:hover:not(:disabled) {
    background: var(--surface);
    border-color: var(--primary);
}
.order-arrow:disabled {
    opacity: 0.3;
    cursor: default;
}
