:root {
    --paper: #f3eee3;
    --paper-2: #fffbf4;
    --ink: #1b1712;
    --ink-soft: #5c564c;
    --line: #d9d0c0;
    --teal: #0f6b56;
    --teal-2: #148067;
    --amber: #e09a12;
    --amber-ink: #6a4700;
    --blue: #215ea8;
    --blue-soft: #d7e6f8;
    --gray: #8d877c;
    --rose: #b44538;
    --rose-soft: #f6d9d4;
    --wall: #4a4742;
    --shadow: 0 18px 40px rgba(40, 28, 8, 0.08);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
}

body {
    background:
        radial-gradient(1200px 500px at 10% -10%, #efe4c8 0%, transparent 55%),
        var(--paper);
    color: var(--ink);
    font-family: Outfit, "Segoe UI", sans-serif;
    font-size: 16px;
    line-height: 1.45;
}

a {
    color: var(--teal);
}

.page {
    max-width: 1120px;
    margin: 0 auto;
    padding: 24px 18px 64px;
}

.crumb ol {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 0;
    list-style: none;
    margin: 0 0 18px;
    padding: 0;
    font-family: "IBM Plex Mono", ui-monospace, monospace;
    font-size: 12px;
}

.crumb li {
    display: inline-flex;
    align-items: center;
}

.crumb li:not(:last-child)::after {
    content: "/";
    margin: 0 8px;
    color: var(--gray);
}

.crumb a {
    text-decoration: none;
}

.crumb [aria-current="page"] {
    color: var(--ink-soft);
}

.eyebrow {
    margin: 0 0 8px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    font-size: 11px;
    font-weight: 560;
    color: var(--teal);
}

h1,
h2,
h3 {
    font-family: Fraunces, Georgia, serif;
    font-optical-sizing: auto;
    margin: 0;
}

h1 {
    font-size: clamp(28px, 4vw, 40px);
    font-weight: 620;
    letter-spacing: -0.03em;
    line-height: 1.1;
    max-width: 18ch;
}

h3 {
    font-size: 15px;
    font-weight: 620;
    margin: 0 0 6px;
}

.lede {
    max-width: 62ch;
    color: var(--ink-soft);
    margin: 10px 0 0;
}

.read {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin: 18px 0 8px;
}

.read div {
    padding: 10px 12px;
    background: var(--paper-2);
    border: 1px solid var(--line);
}

.read b {
    display: block;
    font-family: "IBM Plex Mono", ui-monospace, monospace;
    font-size: 12px;
    color: var(--teal);
    margin-bottom: 2px;
}

.read span {
    color: var(--ink-soft);
    font-size: 14px;
}

.words {
    margin: 0 0 16px;
    padding: 14px 16px 12px;
    background: var(--paper-2);
    border: 1px solid var(--line);
}

.words h2 {
    font-size: 22px;
    margin: 0 0 8px;
}

.words p {
    margin: 0 0 8px;
    color: var(--ink-soft);
}

.words dl {
    display: grid;
    grid-template-columns: 4.5rem 1fr;
    gap: 8px 12px;
    margin: 10px 0 0;
}

.words dt {
    font-family: "IBM Plex Mono", ui-monospace, monospace;
    font-size: 18px;
    color: var(--teal);
}

.words dd {
    margin: 0;
    color: var(--ink-soft);
}

.words.algos dl {
    grid-template-columns: 7.2rem 1fr;
}

.words.algos dt {
    font-size: 13px;
    padding-top: 2px;
}

.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 18px 0 14px;
}

.tabs button {
    appearance: none;
    border: 1px solid var(--line);
    background: var(--paper-2);
    color: var(--ink-soft);
    font: 560 13px Outfit, sans-serif;
    padding: 8px 12px;
    border-radius: 999px;
    cursor: pointer;
}

.tabs button:hover {
    border-color: #b9ae9a;
    color: var(--ink);
}

.tabs button[aria-selected="true"] {
    background: var(--ink);
    border-color: var(--ink);
    color: #f7f1e6;
}

.stage {
    display: grid;
    grid-template-columns: minmax(280px, 420px) 1fr;
    gap: 18px;
    align-items: start;
}

.board,
.panel {
    background: var(--paper-2);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
}

.board {
    padding: 14px;
}

.board-head {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: flex-start;
    margin-bottom: 10px;
}

.board-head h2 {
    font-size: 22px;
    font-weight: 620;
}

.formula {
    margin: 4px 0 0;
    font-family: "IBM Plex Mono", ui-monospace, monospace;
    font-size: 13px;
    color: var(--teal);
}

.status {
    flex: none;
    font-size: 12px;
    font-weight: 560;
    padding: 5px 10px;
    border-radius: 999px;
    background: #efe6d4;
    color: var(--ink-soft);
}

.status.is-run {
    background: #f8e4b0;
    color: var(--amber-ink);
}

.status.is-ok {
    background: #d7efe6;
    color: var(--teal);
}

.status.is-stuck {
    background: var(--rose-soft);
    color: var(--rose);
}

.maze {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 3px;
    padding: 8px;
    background: #e8dfcc;
    border-radius: 10px;
}

.cell {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    background: #f4edda;
    color: #6d665b;
    position: relative;
}

.cell .id {
    font-family: "IBM Plex Mono", ui-monospace, monospace;
    font-size: 12px;
    font-weight: 500;
    line-height: 1;
}

.cell .sc {
    font-family: "IBM Plex Mono", ui-monospace, monospace;
    font-size: 9px;
    margin-top: 2px;
    opacity: 0.85;
}

.cell.wall {
    background: var(--wall);
    color: #c9c3b6;
}

.cell.wall .sc {
    display: none;
}

.cell.start {
    background: var(--rose);
    color: #fff8f6;
}

.cell.goal {
    background: #2f7a3d;
    color: #f4fff6;
}

.cell.expanded {
    background: #e4ddd0;
    color: #6a645a;
}

.cell.frontier {
    background: var(--blue-soft);
    color: #16386a;
}

.cell.next {
    box-shadow: inset 0 0 0 2px var(--blue);
}

.cell.current {
    background: #f6d889;
    color: #5a3d00;
    box-shadow: inset 0 0 0 2px var(--amber);
}

.cell.path {
    background: #cdeadf;
    color: #0b4a3b;
}

.cell.path.current,
.cell.frontier.current {
    background: #f6d889;
    color: #5a3d00;
}

.cell.drop {
    background: var(--rose-soft);
    color: var(--rose);
}

.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 12px;
    list-style: none;
    margin: 10px 0 0;
    padding: 0;
    color: var(--ink-soft);
    font-size: 12.5px;
}

.legend i {
    display: inline-block;
    width: 10px;
    height: 10px;
    margin-right: 4px;
    border-radius: 3px;
    vertical-align: -1px;
    border: 1px solid rgba(0, 0, 0, 0.12);
}

.sw-cur { background: #f6d889; }
.sw-next { background: var(--blue-soft); box-shadow: inset 0 0 0 1px var(--blue); }
.sw-path { background: #cdeadf; }
.sw-exp { background: #e4ddd0; }
.sw-wall { background: var(--wall); }

.transport {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    margin-top: 12px;
}

.transport button {
    min-width: 44px;
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fffdf8;
    color: var(--ink);
    font: 560 14px Outfit, sans-serif;
    cursor: pointer;
}

.transport button.primary {
    background: var(--teal);
    border-color: var(--teal);
    color: #f4fff9;
}

.transport button:disabled {
    opacity: 0.4;
    cursor: default;
}

.transport .step-count {
    margin: 0;
    font-family: "IBM Plex Mono", ui-monospace, monospace;
    font-size: 12px;
    color: var(--gray);
}

.panel {
    padding: 16px 16px 14px;
}

.panel section + section {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
}

.rule,
.say,
.why {
    margin: 0;
    color: var(--ink-soft);
}

.say {
    color: var(--ink);
    font-size: 17px;
}

.why {
    margin-top: 8px;
}

.nums {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.nums span {
    font-family: "IBM Plex Mono", ui-monospace, monospace;
    font-size: 13px;
    padding: 4px 8px;
    background: #efe6d4;
    border-radius: 6px;
}

.queue {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.chip {
    min-width: 52px;
    padding: 6px 8px;
    border-radius: 8px;
    background: var(--blue-soft);
    color: #16386a;
    font-family: "IBM Plex Mono", ui-monospace, monospace;
    font-size: 12px;
}

.chip b {
    display: block;
    font-size: 15px;
}

.chip.is-next {
    outline: 2px solid var(--blue);
}

.chip.is-drop {
    background: var(--rose-soft);
    color: var(--rose);
}

.empty {
    color: var(--gray);
    font-size: 14px;
}

.pathline {
    font-family: "IBM Plex Mono", ui-monospace, monospace;
    font-size: 13px;
    color: var(--ink);
    margin: 0;
    overflow-wrap: anywhere;
}

.hint {
    margin: 0 0 6px;
    font-size: 12px;
    color: var(--gray);
}

.tree-box {
    margin: 28px 0 0;
    padding: 16px;
    background: var(--paper-2);
    border: 1px solid var(--line);
}

.tree-box h2 {
    font-size: 22px;
    margin: 0 0 8px;
}

.tree-box p {
    margin: 0 0 12px;
    color: var(--ink-soft);
}

.tree-scroll {
    overflow-x: auto;
    background: #faf6ee;
    border: 1px solid #eadfcb;
    border-radius: 10px;
}

#tree {
    display: block;
    min-width: 100%;
}

.t-edge {
    stroke: #cbbfa8;
    stroke-width: 1.6;
}

.t-edge.on {
    stroke: var(--teal);
    stroke-width: 2.4;
}

.t-node circle {
    fill: #fffdf8;
    stroke: #c9beab;
    stroke-width: 1.6;
}

.t-node text {
    font-family: "IBM Plex Mono", ui-monospace, monospace;
    font-size: 11px;
    text-anchor: middle;
    fill: var(--ink);
}

.t-node.start circle {
    fill: #f6d9d4;
    stroke: var(--rose);
}

.t-node.goal circle {
    fill: #d7efe6;
    stroke: #2f7a3d;
}

.t-node.path circle {
    fill: #cdeadf;
    stroke: var(--teal);
}

.t-node.current circle {
    fill: #f6d889;
    stroke: var(--amber);
    stroke-width: 2.2;
}

.t-node.drop circle {
    fill: var(--rose-soft);
    stroke: var(--rose);
}

.foot {
    margin: 28px 0 0;
    padding-top: 14px;
    border-top: 1px solid var(--line);
    color: var(--ink-soft);
    font-size: 14px;
}

@media (max-width: 820px) {
    .stage,
    .read {
        grid-template-columns: 1fr;
    }
}
