/* Agent Arena — theme shared with the porting guide (internal/guide). Colours
   and type follow the AlisX/Google Sans palette: a light surface with a red
   brand accent, rather than the arena's original dark theme. */
:root {
    --bg: #eceff1;
    --surface: #ffffff;
    --surface-hover: #f1f3f4;
    --border: #dadce0;
    --border-soft: #e8eaed;
    --text: #202124;
    --text-body: #3c4043;
    --text-muted: #5f6368;
    /* Brand accent: buttons, active tabs, active section, progress bar. */
    --accent: #d93025;
    --accent-hover: #b3261e;
    --accent-bright: #ea4335;
    --accent-soft: #f6c8c4;
    /* Links stay blue so they read as links rather than as the brand accent. */
    --link: #1a73e8;
    --link-soft: #d2e3fc;
    --code-bg: #f8f9fa;
    --danger: #d93025;
    --success: #1e8e3e;
    --radius: 12px;

    --topbar-h: 56px;
    --sticky-offset: 80px;

    --sans: "Google Sans", Roboto, -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
    --mono: "Roboto Mono", ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
    --shadow: 0 1px 2px rgba(60, 64, 67, .1), 0 1px 3px 1px rgba(60, 64, 67, .08);
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    font-family: var(--sans);
    background: var(--bg);
    color: var(--text-body);
    line-height: 1.5;
}

/* ---------------------------------------------------------------- topbar --- */
/* Shared chrome between the arena (/) and the guide (/guide). */

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 0 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--border-soft);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: var(--text);
    font-size: 18px;
}

/* Sized off the topbar so the logo scales with it and never sets its height.
   The mark carries its own padding inside a square viewBox, so it is set a
   little taller than the wordmark and pulled tight against it. */
.brand-logo {
    height: calc(var(--topbar-h) - 16px);
    width: auto;
    display: block;
    margin-left: -6px;
}

.brand-mark { font-weight: 600; letter-spacing: -.2px; }
.brand-name { color: var(--text-muted); }

.topbar-nav {
    display: flex;
    gap: 4px;
    margin-left: auto;
}

.topbar-link {
    padding: 6px 14px;
    border-radius: 999px;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    transition: background .12s ease-out, color .12s ease-out;
}

.topbar-link:hover { background: var(--surface-hover); color: var(--text); }
.topbar-link.is-active { background: var(--accent-soft); color: var(--accent); }

.progress {
    position: absolute;
    inset: auto 0 -1px 0;
    height: 3px;
    background: transparent;
}

.progress-fill {
    height: 100%;
    width: 0;
    background: var(--accent);
    transition: width .15s ease-out;
}

.container {
    max-width: 1180px;
    margin: 0 auto;
    padding: 48px 24px;
}

.app-header {
    text-align: center;
    margin-bottom: 32px;
}

.app-header h1 {
    margin: 0;
    font-size: 2rem;
    font-weight: 400;
    letter-spacing: -0.02em;
}

.subtitle {
    margin: 8px 0 0;
    color: var(--text-muted);
}

.register-form {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
}

/* Base-URL field with a static agent-card suffix rendered inside the box. */
.url-field {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: stretch;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: border-color 0.15s;
}

.url-field:focus-within {
    border-color: var(--accent);
}

.register-form input {
    flex: 1;
    min-width: 0;
    padding: 12px 16px;
    font-size: 1rem;
    background: transparent;
    border: none;
    color: var(--text);
    outline: none;
}

.url-suffix {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    padding: 0 14px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.85rem;
    color: var(--text-muted);
    background: var(--surface-hover);
    border-left: 1px solid var(--border);
    white-space: nowrap;
    user-select: none;
}

/* Narrow screens: the suffix cannot share a line with the input. */
@media (max-width: 640px) {
    .url-suffix {
        display: none;
    }
}

button {
    padding: 12px 20px;
    font-size: 1rem;
    font-weight: 600;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.15s;
}

button:hover:not(:disabled) {
    background: var(--accent-hover);
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.status {
    margin-bottom: 24px;
    padding: 10px 16px;
    border-radius: var(--radius);
    font-size: 0.9rem;
}

.status.error {
    background: rgba(217, 48, 37, 0.12);
    color: var(--danger);
    border: 1px solid rgba(217, 48, 37, 0.3);
}

.status.success {
    background: rgba(30, 138, 62, 0.12);
    color: var(--success);
    border: 1px solid rgba(30, 138, 62, 0.3);
}

button.secondary {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
}

button.secondary:hover:not(:disabled) {
    background: var(--surface-hover);
    color: var(--text);
}

.candidate {
    background: var(--surface);
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 8px;
}

.candidate-head {
    display: flex;
    align-items: center;
    gap: 12px;
}

.candidate-head h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 400;
    word-break: break-word;
}

.candidate .desc {
    margin: 10px 0 0;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.candidate .host {
    display: block;
    margin-top: 10px;
    color: var(--accent);
    font-size: 0.8rem;
    text-decoration: none;
    word-break: break-all;
}

.candidate .host:hover {
    text-decoration: underline;
}

.candidate-actions {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}

/* --- Quest run --------------------------------------------------------- */

.quest {
    background: var(--surface);
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    padding: 24px;
}

.quest-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.quest-eyebrow {
    display: block;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-muted);
}

.quest-title h3 {
    margin: 4px 0 0;
    font-size: 1.3rem;
    font-weight: 400;
    letter-spacing: -0.02em;
    word-break: break-word;
}

.quest-score {
    display: flex;
    align-items: baseline;
    gap: 6px;
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
}

.quest-score-value {
    display: inline-block;
    font-size: 2.2rem;
    font-weight: 700;
    line-height: 1;
    color: var(--success);
    transition: transform 0.2s ease;
}

.quest-score-value.bump {
    transform: scale(1.18);
}

.quest-score-max {
    font-size: 1rem;
    color: var(--text-muted);
}

.quest-track {
    height: 4px;
    margin-top: 20px;
    background: var(--bg);
    border-radius: 999px;
    overflow: hidden;
}

.quest-track-fill {
    width: 0;
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--success));
    border-radius: 999px;
    transition: width 0.5s ease;
}

.quest-intro {
    min-height: 1.4em;
    margin: 20px 0 0;
    color: var(--text-muted);
    font-size: 0.95rem;
    font-style: italic;
}

.quest-log {
    list-style: none;
    margin: 4px 0 0;
    padding: 0;
}

.quest-stage {
    position: relative;
    padding: 20px 0 20px 44px;
}

/* The rail threading the challenges together into one journey. */
.quest-stage::before {
    content: "";
    position: absolute;
    top: 20px;
    bottom: -20px;
    left: 13px;
    width: 2px;
    background: var(--border);
}

.quest-stage:last-child::before {
    display: none;
}

.stage-marker {
    position: absolute;
    top: 16px;
    left: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-muted);
    background: var(--bg);
    border: 2px solid var(--border);
    border-radius: 999px;
    font-variant-numeric: tabular-nums;
}

.quest-stage.pending .stage-marker {
    color: var(--accent);
    border-color: var(--accent);
    animation: pulse 1.6s ease-in-out infinite;
}

.quest-stage.passed .stage-marker {
    color: #fff;
    background: var(--success);
    border-color: var(--success);
}

.quest-stage.failed .stage-marker {
    color: var(--danger);
    border-color: rgba(217, 48, 37, 0.5);
}

.quest-stage.pending .stage-body {
    opacity: 1;
}

.stage-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
}

.stage-name {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 400;
    letter-spacing: -0.01em;
    word-break: break-word;
}

.stage-points {
    flex-shrink: 0;
    padding: 2px 10px;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 999px;
    font-variant-numeric: tabular-nums;
}

/* The story beat for this challenge, typed out as the agent attempts it. */
.stage-story {
    min-height: 1.5em;
    margin: 10px 0 0;
    color: var(--text);
    font-size: 0.95rem;
    line-height: 1.6;
}

.stage-story.typing::after {
    content: "▌";
    margin-left: 1px;
    color: var(--accent);
    animation: blink 1s step-end infinite;
}

.stage-req {
    margin: 10px 0 0;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.stage-req-label {
    display: block;
    margin-bottom: 2px;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.stage-verdict {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 14px;
    padding: 10px 14px;
    font-size: 0.9rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: calc(var(--radius) - 4px);
}

.quest-stage.passed .stage-verdict {
    border-color: rgba(30, 138, 62, 0.35);
    background: rgba(30, 138, 62, 0.08);
}

.quest-stage.failed .stage-verdict {
    border-color: rgba(217, 48, 37, 0.3);
    background: rgba(217, 48, 37, 0.06);
}

.verdict-mark {
    font-weight: 700;
}

.quest-stage.passed .verdict-mark {
    color: var(--success);
}

.quest-stage.failed .verdict-mark {
    color: var(--danger);
}

.verdict-text {
    color: var(--text-muted);
}

.quest-stage.passed .verdict-text {
    color: var(--text);
}

.verdict-time {
    margin-left: auto;
    font-size: 0.8rem;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.verdict-score {
    font-weight: 600;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.quest-stage.passed .verdict-score {
    color: var(--success);
}

.stage-error {
    margin: 8px 0 0;
    font-size: 0.8rem;
    color: var(--danger);
    word-break: break-word;
}

.spinner {
    width: 14px;
    height: 14px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 999px;
    animation: spin 0.8s linear infinite;
}

.quest-outcome {
    margin-top: 24px;
    padding: 20px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-align: center;
    animation: rise 0.4s ease;
}

.quest-outcome.good {
    border-color: rgba(30, 138, 62, 0.4);
}

.quest-outcome.poor {
    border-color: rgba(217, 48, 37, 0.3);
}

.outcome-eyebrow {
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-muted);
}

.quest-outcome h4 {
    margin: 6px 0 0;
    font-size: 1.4rem;
    font-weight: 400;
    letter-spacing: -0.02em;
}

.quest-outcome.good h4 {
    color: var(--success);
}

.quest-outcome.poor h4 {
    color: var(--danger);
}

.quest-outcome p {
    margin: 8px 0 0;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.quest-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 24px;
}

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

@keyframes blink {
    50% { opacity: 0; }
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(217, 48, 37, 0.35); }
    50% { box-shadow: 0 0 0 6px rgba(217, 48, 37, 0); }
}

@keyframes rise {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    .spinner,
    .stage-story.typing::after,
    .quest-stage.pending .stage-marker,
    .quest-outcome {
        animation: none;
    }

    .challenges-track {
        scroll-behavior: auto;
    }
}

.challenges-section {
    margin-top: 40px;
}

.section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
}

.section-head h2 {
    margin: 0;
    font-size: 1.4rem;
    font-weight: 400;
    letter-spacing: -0.02em;
}

.challenges-total {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--accent);
    font-variant-numeric: tabular-nums;
}

.challenges-carousel {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 16px;
}

.challenges-track {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    padding: 4px 2px 8px;
    flex: 1;
}

.challenges-track::-webkit-scrollbar {
    display: none;
}

.carousel-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 36px;
    width: 36px;
    height: 36px;
    padding: 0;
    margin: 0;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-size: 1.3rem;
    line-height: 1;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.carousel-nav:hover:not(:disabled) {
    background: var(--surface-hover);
    border-color: var(--accent);
}

.carousel-nav:disabled {
    opacity: 0.35;
    cursor: default;
}

.challenges-dots {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 12px;
}

.challenges-dots:empty {
    display: none;
}

.challenge-dot {
    width: 8px;
    height: 8px;
    padding: 0;
    border-radius: 999px;
    border: none;
    background: var(--border);
    cursor: pointer;
    transition: background 0.15s, transform 0.15s;
}

.challenge-dot:hover {
    background: var(--text-muted);
}

.challenge-dot.active {
    background: var(--accent);
    transform: scale(1.2);
}

.challenge-card {
    flex: 0 0 clamp(240px, 80vw, 320px);
    scroll-snap-align: start;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    transition: background 0.15s, border-color 0.15s;
}

.challenge-card:hover {
    background: var(--surface-hover);
    border-color: var(--accent);
}

.challenge-stage {
    display: block;
    margin-bottom: 8px;
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-muted);
}

.challenge-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
}

.challenge-head h3 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 400;
    word-break: break-word;
}

.challenge-points {
    flex-shrink: 0;
    padding: 2px 10px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent);
    background: rgba(217, 48, 37, 0.12);
    border: 1px solid rgba(217, 48, 37, 0.3);
    border-radius: 999px;
    font-variant-numeric: tabular-nums;
}

.challenge-desc {
    margin: 12px 0 0;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.challenge-req {
    margin: 12px 0 0;
    font-size: 0.85rem;
    color: var(--text);
}

.challenge-req-label {
    display: block;
    margin-bottom: 2px;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.empty-state {
    text-align: center;
    color: var(--text-muted);
    margin-top: 40px;
}

.leaderboard-section {
    margin-top: 0;
}

.leaderboard-section h2 {
    margin: 0;
    font-size: 1.4rem;
    font-weight: 400;
    letter-spacing: -0.02em;
}

.section-note {
    margin: 4px 0 16px;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.leaderboard {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.leaderboard th,
.leaderboard td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.leaderboard thead th {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    font-weight: 600;
}

.leaderboard tbody tr:last-child td {
    border-bottom: none;
}

.leaderboard tbody tr:hover {
    background: var(--surface-hover);
}

.leaderboard .rank-col {
    width: 48px;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.leaderboard .num-col {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.leaderboard .score {
    color: var(--accent);
    font-weight: 600;
}

.leaderboard tbody tr:nth-child(1) .rank-col,
.leaderboard tbody tr:nth-child(2) .rank-col,
.leaderboard tbody tr:nth-child(3) .rank-col {
    color: var(--success);
    font-weight: 700;
}

/* ============================================================= /guide === */
/* The porting guide (internal/guide): a single markdown-driven page with a
   sticky section rail. Ported from the standalone codelab app. */

.shell {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 244px;
    gap: 28px;
    align-items: start;
    max-width: 1360px;
    margin: 0 auto;
    padding: 28px 28px 96px;
}

.paper {
    background: var(--surface);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 48px clamp(24px, 5vw, 64px) 96px;
    min-width: 0;
}

.lab-title {
    margin: 0 0 32px;
    color: var(--text);
    font-size: clamp(32px, 4vw, 46px);
    font-weight: 400;
    line-height: 1.15;
    letter-spacing: -.5px;
}

/* ---------------------------------------------------------- about this guide --- */

.about {
    border: 1px solid var(--border);
    border-left: 5px solid var(--accent-bright);
    border-radius: 8px;
    padding: 22px 28px;
    margin-bottom: 8px;
}

.about-label {
    margin: 0 0 14px;
    color: var(--text-muted);
    font-size: 12px;
    letter-spacing: .9px;
    text-transform: uppercase;
}

.about-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 0;
    margin: 0;
    padding: 0;
    list-style: none;
    font-size: 15px;
    color: var(--text-body);
}

.about-meta li {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 22px;
}

.about-meta li:first-child { padding-left: 0; }
.about-meta li + li { border-left: 1px solid var(--border); }

.icon {
    width: 20px;
    height: 20px;
    flex: none;
    fill: var(--text-muted);
}

/* --------------------------------------------------------------- sections --- */

.lab-section {
    scroll-margin-top: var(--sticky-offset);
    padding-top: 24px;
}

.section-title {
    margin: 32px 0 4px;
    color: var(--text);
    font-size: clamp(26px, 2.6vw, 32px);
    font-weight: 400;
    line-height: 1.25;
    letter-spacing: -.3px;
}

/* --------------------------------------------------- markdown typography --- */

.md > :first-child { margin-top: 20px; }
.md > :last-child { margin-bottom: 0; }

.md h2, .md h3, .md h4, .md h5, .md h6 {
    color: var(--text);
    font-weight: 400;
    line-height: 1.3;
    scroll-margin-top: var(--sticky-offset);
}

.md h2 { margin: 40px 0 12px; font-size: 26px; }
.md h3 { margin: 32px 0 10px; font-size: 22px; }
.md h4 { margin: 28px 0 8px; font-size: 18px; font-weight: 500; }
.md h5, .md h6 { margin: 24px 0 8px; font-size: 16px; font-weight: 500; }

.md p { margin: 0 0 16px; }

.md a {
    color: var(--link);
    text-decoration: none;
}

.md a:hover { text-decoration: underline; }

.md ul, .md ol {
    margin: 0 0 16px;
    padding-left: 26px;
}

.md li { margin: 6px 0; }
.md li > ul, .md li > ol { margin: 6px 0; }

.md li.task-item { list-style: none; margin-left: -22px; }
.md li.task-item input { margin-right: 8px; }

.md img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
}

.md hr {
    height: 1px;
    border: 0;
    background: var(--border-soft);
    margin: 32px 0;
}

.md strong { font-weight: 500; color: var(--text); }

/* code */

.md code {
    font-family: var(--mono);
    font-size: .9em;
    background: #f1f3f4;
    color: #37474f;
    padding: 2px 6px;
    border-radius: 4px;
}

.md pre {
    position: relative;
    background: var(--code-bg);
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    margin: 0 0 20px;
    padding: 16px 20px;
    overflow-x: auto;
    line-height: 1.6;
}

.md pre code {
    background: none;
    padding: 0;
    color: #202124;
    font-size: 14px;
    white-space: pre-wrap;
    word-break: break-word;
}

/* Syntax highlighting for fenced ```go / ```bash blocks (see internal/guide/markdown/highlight.go) */
.md pre code .tok-kw { color: #a626a4; }
.md pre code .tok-type { color: #0184bc; }
.md pre code .tok-str { color: #50a14f; }
.md pre code .tok-com { color: #9aa0a6; font-style: italic; }
.md pre code .tok-num { color: #986801; }
.md pre code .tok-const { color: #b76b01; }
.md pre code .tok-fn { color: #4078f2; }
.md pre code .tok-var { color: #986801; }

.md pre[data-lang]::before {
    content: attr(data-lang);
    position: absolute;
    top: 0;
    right: 12px;
    color: var(--text-muted);
    font-family: var(--sans);
    font-size: 11px;
    letter-spacing: .6px;
    text-transform: uppercase;
}

.copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--surface);
    color: var(--text-muted);
    font: inherit;
    font-size: 12px;
    cursor: pointer;
    opacity: 0;
    transition: opacity .12s ease-out;
}

.md pre:hover .copy-btn,
.copy-btn:focus-visible { opacity: 1; }
.copy-btn:hover { color: var(--accent); border-color: var(--accent-soft); }

/* tables */

.table-wrap {
    overflow-x: auto;
    margin: 0 0 20px;
}

.md table {
    border-collapse: collapse;
    width: 100%;
    font-size: 15px;
}

.md th, .md td {
    border: 1px solid var(--border);
    padding: 10px 14px;
    text-align: left;
    vertical-align: top;
}

.md th {
    background: var(--code-bg);
    color: var(--text);
    font-weight: 500;
}

/* quotes and callouts */

.md blockquote {
    margin: 0 0 20px;
    padding: 16px 20px;
    border-left: 4px solid var(--border);
    border-radius: 0 8px 8px 0;
    background: var(--code-bg);
}

.md blockquote > :last-child { margin-bottom: 0; }

.md .callout-title {
    margin: 0 0 8px;
    font-weight: 500;
    font-size: 14px;
    letter-spacing: .3px;
    text-transform: uppercase;
}

.md .callout-note      { background: #e8f0fe; border-color: var(--link); }
.md .callout-tip       { background: #e6f4ea; border-color: #1e8e3e; }
.md .callout-important { background: #f3e8fd; border-color: #8430ce; }
.md .callout-warning   { background: #fef7e0; border-color: #f9ab00; }
.md .callout-caution   { background: #fce8e6; border-color: #d93025; }

.md .callout-note .callout-title      { color: #1967d2; }
.md .callout-tip .callout-title       { color: #188038; }
.md .callout-important .callout-title { color: #7627bb; }
.md .callout-warning .callout-title   { color: #b06000; }
.md .callout-caution .callout-title   { color: #c5221f; }

/* ------------------------------------------------------------------- rail --- */

.rail {
    position: sticky;
    top: var(--sticky-offset);
    max-height: calc(100vh - var(--sticky-offset) - 24px);
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
}

.rail-list {
    margin: 0;
    padding: 0 2px 8px;
    list-style: none;
}

.rail-item {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
    padding: 12px 14px;
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
    color: var(--text-body);
    font-size: 14px;
    line-height: 1.35;
    text-decoration: none;
    transition: background .12s ease-out, color .12s ease-out;
}

.rail-item:hover { background: #f8f9fa; }

.rail-num {
    display: grid;
    place-items: center;
    flex: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--border);
    color: var(--surface);
    font-size: 13px;
    font-weight: 500;
}

.rail-item.is-done .rail-num { background: #9aa0a6; }

.rail-item.is-active {
    color: var(--accent);
    font-weight: 500;
    box-shadow: 0 0 0 1px var(--accent-soft), 0 1px 3px rgba(217, 48, 37, .25);
}

.rail-item.is-active .rail-num { background: var(--accent); }

/* ------------------------------------------------------------- responsive --- */

@media (max-width: 1024px) {
    .shell {
        grid-template-columns: minmax(0, 1fr);
        padding: 0 0 64px;
        gap: 0;
    }

    .paper {
        border-radius: 0;
        order: 2;
        padding-top: 32px;
    }

    .rail {
        order: 1;
        position: sticky;
        top: var(--topbar-h);
        z-index: 9;
        max-height: none;
        overflow: visible;
        background: var(--bg);
        padding: 10px 16px;
        border-bottom: 1px solid var(--border);
    }

    .rail-list {
        display: flex;
        gap: 8px;
        overflow-x: auto;
        padding-bottom: 4px;
        scrollbar-width: none;
    }

    .rail-list::-webkit-scrollbar { display: none; }

    .rail-item {
        margin-bottom: 0;
        white-space: nowrap;
    }

    .rail-item .rail-label {
        max-width: 26ch;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

@media print {
    .topbar, .rail, .copy-btn { display: none; }
    .shell { display: block; padding: 0; }
    .paper { box-shadow: none; padding: 0; }
}
