:root {
    --paper: #f3eee4;
    --paper-2: #e8e0d2;
    --card: #fbf8f1;
    --ink: #171614;
    --ink-soft: #3d3933;
    --muted: #746c62;
    --line: #d9d0c2;
    --accent: #9a3f1b;
    --ok: #355a43;
    --tap: 48px;
    --display: "Fraunces", "Iowan Old Style", Georgia, serif;
    --sans: "Inter", system-ui, sans-serif;
    --mono: "IBM Plex Mono", ui-monospace, monospace;
    --shadow: 0 1px 0 rgba(23, 22, 20, 0.06);
    --max: 1080px;
    --radius: 10px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
html { background: var(--paper); }
body {
    font-family: var(--sans);
    color: var(--ink);
    background: var(--paper);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
img, video { max-width: 100%; display: block; }
a { color: inherit; }

#app { min-height: 100dvh; display: flex; flex-direction: column; }

.shell { min-height: 100dvh; display: flex; flex-direction: column; }
.shell-body {
    flex: 1;
    width: min(var(--max), calc(100% - 2.5rem));
    margin: 0 auto;
    padding: 2rem 0 5.5rem;
}
@media (min-width: 900px) {
    .shell-body { padding-bottom: 3rem; }
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    background: rgba(243, 238, 228, 0.92);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--line);
}
.topbar-inner {
    width: min(var(--max), calc(100% - 2.5rem));
    margin: 0 auto;
    min-height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}
.brand {
    display: flex;
    flex-direction: column;
    text-decoration: none;
    min-height: var(--tap);
    justify-content: center;
}
.brand-kicker {
    font-family: var(--mono);
    font-size: 0.68rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--muted);
}
.brand-name {
    font-family: var(--display);
    font-size: 1.05rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}
.nav {
    display: flex;
    gap: 0.25rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}
.nav a, .nav button.linkish {
    min-height: var(--tap);
    display: inline-flex;
    align-items: center;
    padding: 0 0.85rem;
    text-decoration: none;
    color: var(--muted);
    background: none;
    border: 0;
    border-radius: 999px;
}
.nav a.is-active, .nav a:focus-visible, .nav button.linkish:focus-visible {
    color: var(--ink);
    background: var(--paper-2);
}

.kicker {
    font-family: var(--mono);
    font-size: 0.72rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--muted);
    margin: 0 0 0.75rem;
}
h1, h2, .display {
    font-family: var(--display);
    font-weight: 500;
    letter-spacing: -0.02em;
    line-height: 1.12;
    margin: 0 0 0.75rem;
}
h1, .display { font-size: clamp(2.1rem, 5vw, 3.6rem); }
h2 { font-size: clamp(1.6rem, 3vw, 2.2rem); }
.lede {
    font-size: 1.15rem;
    color: var(--ink-soft);
    max-width: 36rem;
    margin: 0 0 2rem;
}
p { margin: 0 0 1rem; }
.muted { color: var(--muted); }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: var(--tap);
    padding: 0.85rem 1.4rem;
    border-radius: 999px;
    border: 1px solid transparent;
    text-decoration: none;
    font-weight: 600;
    letter-spacing: 0.02em;
    background: var(--ink);
    color: var(--card);
}
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.btn[disabled] { opacity: 0.45; pointer-events: none; }
.btn-ghost {
    background: transparent;
    color: var(--ink);
    border-color: var(--line);
}
.btn-row { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 1.5rem; }

.field { display: flex; flex-direction: column; gap: 0.45rem; margin: 1.25rem 0; }
.field label { font-weight: 500; }
.field input, .field textarea, .field select {
    min-height: var(--tap);
    padding: 0.8rem 1rem;
    border: 1px solid var(--line);
    background: var(--card);
    border-radius: 8px;
}
.field textarea { min-height: 8rem; resize: vertical; }
.field input:focus, .field textarea:focus, .field select:focus {
    outline: 2px solid var(--ink);
    outline-offset: 1px;
}
.code-input {
    font-family: var(--mono);
    letter-spacing: 0.28em;
    text-transform: uppercase;
    font-size: 1.35rem;
    text-align: center;
}

.center-page {
    min-height: 100dvh;
    display: grid;
    place-items: center;
    padding: 2rem 1.25rem 3rem;
}
.center-card { width: min(36rem, 100%); }
.steps-3 {
    display: grid;
    gap: 1rem;
    margin: 2rem 0;
}
@media (min-width: 720px) {
    .steps-3 { grid-template-columns: repeat(3, 1fr); }
}
.step-card, .card, .explore-card, .project-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.step-card, .card { padding: 1.25rem 1.3rem; }
.continue-card {
    padding: 1.5rem 1.6rem;
    margin-bottom: 2.5rem;
    background: var(--ink);
    color: var(--card);
    border-radius: var(--radius);
}
.continue-card .kicker, .continue-card .lede { color: rgba(251, 248, 241, 0.72); }
.continue-card .btn { background: var(--card); color: var(--ink); }

.explore-list { display: grid; gap: 0.75rem; }
.explore-card {
    display: grid;
    grid-template-columns: 4.2rem 1fr auto;
    gap: 1rem;
    align-items: center;
    padding: 1rem 1.1rem;
    text-decoration: none;
    min-height: 5.25rem;
    width: 100%;
    text-align: left;
}
.explore-num {
    font-family: var(--mono);
    font-size: 0.85rem;
    letter-spacing: 0.12em;
    color: var(--muted);
}
.explore-card h3 {
    font-family: var(--display);
    font-size: 1.35rem;
    margin: 0 0 0.15rem;
}
.explore-card p { margin: 0; color: var(--muted); font-size: 0.95rem; }
.status {
    font-family: var(--mono);
    font-size: 0.68rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--muted);
    white-space: nowrap;
}
.status-in_progress { color: var(--accent); }
.status-explored { color: var(--ok); }
.status-project_added { color: var(--ink); font-weight: 500; }

.thumb {
    width: 3.4rem;
    height: 3.4rem;
    object-fit: cover;
    border-radius: 6px;
    background: var(--paper-2);
}

.marks { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.mark {
    width: 3.2rem;
    height: 3.2rem;
    border: 1px solid var(--line);
    background: var(--card);
    border-radius: 8px;
    display: grid;
    place-items: center;
}
.mark.is-on { border-color: var(--ink); outline: 2px solid var(--ink); }
.mark span {
    display: block;
    width: 1.15rem;
    height: 1.15rem;
    background: var(--ink);
}
.mark-1 span { border-radius: 50%; }
.mark-2 span { width: 1.2rem; height: 0.55rem; }
.mark-3 span { clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.mark-4 span { width: 1.1rem; height: 1.1rem; }
.mark-5 span { border-radius: 2px 2px 12px 12px; height: 1.25rem; }
.mark-6 span { width: 0.5rem; height: 1.3rem; }

.rail {
    display: flex;
    gap: 0.35rem;
    overflow-x: auto;
    padding-bottom: 0.4rem;
    margin: 0 0 1.75rem;
    -webkit-overflow-scrolling: touch;
}
.rail a {
    flex: 0 0 auto;
    min-height: 2.6rem;
    padding: 0.5rem 0.85rem;
    border-radius: 999px;
    text-decoration: none;
    color: var(--muted);
    border: 1px solid transparent;
    font-size: 0.92rem;
}
.rail a.is-on { color: var(--ink); border-color: var(--ink); }
.rail a.is-done { color: var(--ok); }

.video-frame {
    background: #1b1916;
    color: #f3eee4;
    min-height: 240px;
    border-radius: var(--radius);
    display: grid;
    place-items: center;
    padding: 2rem;
    text-align: center;
    margin: 1.25rem 0 1.5rem;
}
.video-frame iframe {
    width: 100%;
    aspect-ratio: 16 / 9;
    min-height: 220px;
    height: auto;
    border: 0;
    border-radius: var(--radius);
}
.video-frame.is-media {
    background: #000;
    min-height: 0;
    padding: 0;
    display: block;
}
.prompt { font-size: 1.25rem; margin-bottom: 1rem; }
.choice {
    display: block;
    width: 100%;
    text-align: left;
    min-height: var(--tap);
    padding: 0.9rem 1rem;
    margin: 0 0 0.55rem;
    border: 1px solid var(--line);
    background: var(--card);
    border-radius: 8px;
}
.choice.is-on { border-color: var(--ink); background: #efe8db; }

.make-block { padding: 1.25rem 0; border-top: 1px solid var(--line); }
.make-block:first-child { border-top: 0; }
.list-plain { margin: 0 0 1rem; padding-left: 1.1rem; }
.list-plain li { margin: 0.25rem 0; }

.drop {
    border: 1px dashed var(--muted);
    background: var(--card);
    border-radius: var(--radius);
    min-height: 7rem;
    display: grid;
    place-items: center;
    padding: 1rem;
    text-align: center;
    cursor: pointer;
}
.media-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 0.75rem; margin: 1rem 0; }
.media-row img, .media-row video { width: 100%; height: 140px; object-fit: cover; border-radius: 6px; }

.portfolio-grid {
    display: grid;
    gap: 1rem;
}
@media (min-width: 720px) {
    .portfolio-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1024px) {
    .portfolio-grid { grid-template-columns: repeat(3, 1fr); }
}
.project-card { overflow: hidden; text-decoration: none; display: block; }
.project-card img { width: 100%; height: 200px; object-fit: cover; background: var(--paper-2); }
.project-card .body { padding: 1.1rem 1.15rem 1.3rem; }
.project-card h3 { font-family: var(--display); font-size: 1.4rem; margin: 0.2rem 0 0.4rem; }
.stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
    margin: 0 0 2rem;
}
.stat { padding: 1rem; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.stat b {
    display: block;
    font-family: var(--display);
    font-size: 1.8rem;
    font-weight: 500;
}

.error {
    color: var(--accent);
    margin: 0.75rem 0;
}
.notice {
    padding: 1rem 1.1rem;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
}

.bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    background: rgba(243, 238, 228, 0.96);
    border-top: 1px solid var(--line);
    padding: 0.2rem 0.4rem calc(0.2rem + env(safe-area-inset-bottom));
    z-index: 20;
}
.bottom-nav a {
    min-height: 3.4rem;
    display: grid;
    place-items: center;
    text-decoration: none;
    font-size: 0.82rem;
    color: var(--muted);
}
.bottom-nav a.is-active { color: var(--ink); font-weight: 600; }
@media (min-width: 900px) {
    .bottom-nav { display: none; }
}

.admin table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.admin th, .admin td { text-align: left; padding: 0.7rem 0.4rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.admin pre { white-space: pre-wrap; font-size: 0.8rem; background: var(--card); padding: 0.8rem; border-radius: 6px; }

.sample-project {
    display: grid;
    grid-template-columns: 96px 1fr;
    gap: 1rem;
    align-items: center;
    padding: 1rem;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    margin: 1.5rem 0;
}
.sample-swatch { height: 96px; background: #cfc4b0; border-radius: 6px; }

@media (min-width: 900px) {
    .split {
        display: grid;
        grid-template-columns: 1.1fr 0.9fr;
        gap: 2.5rem;
        align-items: start;
    }
}
