:root {
    --paper: #f4efe8;
    --panel: #fffcf8;
    --ink: #17211c;
    --muted: #66706a;
    --line: #e4dcd1;
    --accent: #0e6b5c;
    --accent-deep: #0b3d36;
    --aside: #12241f;
    --gold: #c4a574;
    --accent-ink: #f4fffc;
    --warn: #9a3412;
    --danger: #8d2e2e;
    --ok: #1f6b45;
    --shadow: 0 18px 50px rgba(23, 33, 28, 0.07);
    --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
    --sans: "Segoe UI", "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    color: var(--ink);
    font-family: var(--sans);
    background: var(--paper);
}

a { color: var(--accent); }

button, input, select { font: inherit; color: inherit; }

.app {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
    min-height: 100vh;
}

.rail {
    position: sticky;
    top: 0;
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 18px 12px 14px;
    background: #fffcf8;
    color: var(--ink);
    border-right: 1px solid var(--line);
}

.brand {
    display: flex;
    gap: 10px;
    align-items: center;
    color: var(--ink);
    text-decoration: none;
    font-family: var(--serif);
    font-size: 1.35rem;
    letter-spacing: -0.03em;
    padding: 0 8px;
}

.brand img { width: 28px; height: 28px; }

.rail nav { display: grid; gap: 4px; flex: 1; min-height: 0; overflow: auto; }
.nav-label { margin: 14px 10px 2px; font-size: 0.68rem; letter-spacing: 0.12em; text-transform: uppercase; color: #8b938e; }

.rail nav a, .ghost {
    border: 0;
    background: transparent;
    text-decoration: none;
    color: #31403b;
    padding: 8px 10px;
    border-radius: 10px;
    cursor: pointer;
    text-align: left;
}

.rail nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.94rem;
}
.rail nav a svg {
    width: 18px;
    height: 18px;
    flex: none;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.rail nav a.active, .rail nav a:hover { color: var(--accent-deep); background: #e7f3ef; }
.rail nav a.active { font-weight: 650; }

.rail-foot { margin-top: auto; display: grid; gap: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
.who { margin: 0; color: var(--ink); font-size: 0.92rem; display: flex; align-items: center; gap: 8px; }
.avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: var(--accent);
    color: var(--accent-ink);
    font-size: 0.82rem;
    font-weight: 650;
}
.rail .ghost { color: var(--ink); border: 1px solid var(--line); border-radius: 999px; background: #fff; }

.workspace { padding: 22px 28px 64px; width: min(1120px, 100%); }

.panel {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: none;
    padding: 20px;
}

.panel + .panel, .stack > * + * { margin-top: 16px; }

h1, h2 { font-family: var(--sans); font-weight: 650; letter-spacing: -0.03em; }
h1 { margin: 0 0 8px; font-size: 1.55rem; }
h2 { margin: 0 0 12px; font-size: 1.12rem; }
.lede { color: var(--muted); margin: 0 0 18px; max-width: 68ch; }
.kicker { margin: 0 0 6px; color: var(--accent); letter-spacing: 0.14em; text-transform: uppercase; font-size: 0.72rem; }

.subnav { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; }
.subnav a {
    text-decoration: none;
    color: var(--muted);
    border: 1px solid var(--line);
    background: var(--panel);
    border-radius: 999px;
    padding: 8px 12px;
}
.subnav a.active { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }

.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; }
.grow { flex: 1 1 180px; }

label { display: grid; gap: 6px; font-size: 0.92rem; }
label.check { display: flex; align-items: center; gap: 8px; padding-bottom: 2px; }
input[type="checkbox"] { width: 18px; height: 18px; padding: 0; }
label span, .field-name { color: var(--muted); }

input, select {
    width: 100%;
    border: 1px solid var(--line);
    background: #fffdf9;
    border-radius: 12px;
    padding: 11px 12px;
}

input:focus, select:focus, button:focus-visible, a:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.btn, button.primary {
    border: 0;
    border-radius: 999px;
    padding: 11px 16px;
    background: var(--accent);
    color: var(--accent-ink);
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
}

.btn.secondary, button.secondary, .btn.danger, button.danger {
    border-radius: 999px;
    padding: 11px 16px;
    cursor: pointer;
}

.btn.secondary, button.secondary {
    background: transparent;
    color: var(--ink);
    border: 1px solid var(--line);
}

.btn.danger, button.danger { background: var(--danger); color: #fff; border: 0; }

.flash {
    border-radius: 14px;
    padding: 12px 14px;
    margin-bottom: 16px;
    background: #fff7e8;
    border: 1px solid #efd7a4;
}
.flash.ok { background: #e8f6ee; border-color: #b7e0c6; color: var(--ok); }
.flash.error { background: #fdecec; border-color: #f0c2c2; color: var(--danger); }

.crumbs { display: flex; flex-wrap: wrap; gap: 6px; color: var(--muted); margin-bottom: 14px; }
.crumbs a { text-decoration: none; }

.meter { height: 8px; background: #efe4d4; border-radius: 99px; overflow: hidden; margin-bottom: 16px; }
.meter span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent-deep), var(--accent)); }

.files { width: 100%; border-collapse: collapse; }
.files th { text-align: left; font-size: 0.78rem; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.files th, .files td { padding: 12px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.files tr:last-child td { border-bottom: 0; }
.files tbody tr:hover td { background: #f4faf8; }
.name { font-weight: 600; text-decoration: none; color: inherit; display: inline-flex; align-items: center; gap: 8px; }
.kind-dir::before, .kind-file::before {
    content: "";
    width: 22px;
    height: 18px;
    border-radius: 4px 4px 3px 3px;
    background: #d7eee8;
    box-shadow: inset 0 6px 0 #0e6b5c;
    flex: none;
}
.kind-file::before {
    height: 22px;
    border-radius: 3px;
    background: #fff;
    box-shadow: inset 0 0 0 1.5px #0e6b5c;
}

.actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.actions form { display: flex; gap: 6px; align-items: center; }
.actions input { width: 140px; padding: 8px; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.card { padding: 16px; border-radius: 18px; background: #f3f7f5; border: 1px solid #dce8e4; }
.card strong { display: block; font-family: var(--sans); font-size: 1.35rem; font-weight: 650; }
.plan strong { font-size: 1.25rem; line-height: 1.25; margin-bottom: 8px; }
.card span { color: var(--muted); }

.auth {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 32px 16px;
    background:
        radial-gradient(700px 320px at 100% 0%, rgba(14, 107, 92, 0.12), transparent 60%),
        var(--paper);
}
.auth .panel { width: min(520px, 100%); }
.mark { font-family: var(--serif); font-size: 2rem; margin: 0 0 4px; }

.stage {
    min-height: 100vh;
    background: var(--aside);
}
.stage-grid {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(280px, 0.9fr) minmax(320px, 1.1fr);
    align-items: start;
}
.stage-aside {
    position: sticky;
    top: 0;
    height: 100vh;
    color: #f3f7f4;
    padding: 56px 48px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    background:
        radial-gradient(420px 240px at 10% 12%, rgba(196, 165, 116, 0.22), transparent 70%),
        linear-gradient(160deg, #18332c, var(--aside) 55%);
}
.stage-aside .word {
    font-family: var(--serif);
    font-size: clamp(3rem, 6vw, 4.6rem);
    margin: 0 0 12px;
    letter-spacing: -0.04em;
}
.stage-aside p { max-width: 28ch; color: rgba(243, 247, 244, 0.78); font-size: 1.05rem; line-height: 1.5; }
.stage-aside .rule { width: 48px; height: 2px; background: var(--gold); margin: 0 0 18px; }
.stage-main {
    background: var(--paper);
    display: grid;
    align-content: center;
    min-height: 100vh;
    padding: 48px 8vw;
}
.stage-main h1 { font-size: 2.2rem; }
.stage-main.install { align-content: start; overflow: auto; }
.link-quiet { color: var(--muted); }
.setup-checks { list-style: none; margin: 0 0 22px; padding: 0; display: grid; gap: 6px; }
.setup-checks li {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    padding: 8px 12px;
    border-radius: 12px;
    background: #f6f1ea;
}
.setup-checks li.bad { background: #fde8e4; }
.pill-ok, .pill-bad { font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; white-space: nowrap; }
.pill-ok { color: var(--ok); }
.pill-bad { color: var(--danger); white-space: normal; text-align: right; }

table.plain { width: 100%; border-collapse: collapse; }
table.plain th, table.plain td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
pre.log {
    white-space: pre-wrap;
    background: #17211c;
    color: #f6f1e8;
    border-radius: 16px;
    padding: 16px;
    overflow: auto;
    max-height: 360px;
}

.empty { color: var(--muted); padding: 18px 0; }
.drop { border: 1.5px dashed #c9b8a2; border-radius: 18px; padding: 16px; background: rgba(255, 255, 255, 0.45); }
.drop form + form { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.drop.hot { border-color: var(--accent); background: rgba(14, 107, 92, 0.08); }
code { font-family: Consolas, "Courier New", monospace; font-size: 0.92em; }

textarea {
    width: 100%;
    border: 1px solid var(--line);
    background: #fffdf9;
    border-radius: 12px;
    padding: 11px 12px;
    font: inherit;
    resize: vertical;
}

.plain-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.plain-list li { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.plain-list .is-done span { text-decoration: line-through; color: var(--muted); }
.more { margin-left: auto; }
.more summary { cursor: pointer; color: var(--accent); }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.photo { display: grid; gap: 6px; text-decoration: none; color: inherit; }
.photo img { width: 100%; height: 140px; object-fit: cover; border-radius: 14px; background: #efe8de; }
.photo span { font-size: 0.88rem; }
.hint { color: var(--muted); font-size: 0.88rem; }
.board { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.column { background: #f6f1ea; border-radius: 18px; padding: 14px; }
.column h2 { font-size: 1.15rem; }
.column .card { margin-top: 10px; background: #fffdf9; }
.column .card strong { font-size: 1.15rem; }
.column form.stack { margin-top: 12px; }
.people { display: flex; flex-wrap: wrap; gap: 8px; }
.people a { text-decoration: none; color: var(--ink); background: #fffdf9; border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; }
.people a.active { background: var(--accent); color: #f3f7f4; border-color: var(--accent); }
.letter { padding: 10px 0; border-bottom: 1px solid var(--line); }
.letter p { margin: 6px 0 0; }
.thread p { margin: 0 0 10px; }

@media (max-width: 860px) {
    .app { grid-template-columns: 1fr; }
    .rail {
        position: sticky;
        top: 0;
        z-index: 4;
        height: auto;
        width: 100%;
        overflow: hidden;
        gap: 10px;
        padding: 12px;
    }
    .nav-label { display: none; }
    .rail nav {
        display: flex;
        flex-direction: row;
        flex-wrap: nowrap;
        overflow-x: auto;
        gap: 6px;
        width: 100%;
        min-width: 0;
        min-height: 0;
    }
    .rail nav a { white-space: nowrap; padding: 8px 10px; }
    .rail-foot { margin-top: 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
    .row { flex-direction: column; align-items: stretch; }
    .row button, .row .btn { justify-content: center; }
    .workspace { padding: 22px 16px 56px; }
    .stage-grid { grid-template-columns: 1fr; }
    .stage-aside { position: static; height: auto; min-height: 220px; padding: 32px 24px; justify-content: flex-end; }
    .stage-main { padding: 28px 20px 48px; }
    .actions { justify-content: flex-start; }
    h1 { font-size: 2rem; }
    .files .hide-sm { display: none; }
}

.home { background: var(--paper); }
.home-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 28px;
}
.home-hero {
    margin: 0 28px;
    padding: 56px 48px 48px;
    border-radius: 28px;
    color: #f3f7f4;
    background:
        radial-gradient(420px 240px at 12% 0%, rgba(196, 165, 116, 0.28), transparent 70%),
        linear-gradient(155deg, #18332c, var(--aside) 58%);
}
.home-hero .rule { width: 48px; height: 2px; background: var(--gold); margin: 0 0 18px; }
.home-hero .kicker { color: #d7c4a4; }
.home-hero h1 {
    font-family: var(--serif);
    font-weight: 500;
    font-size: clamp(2.6rem, 6vw, 4.4rem);
    letter-spacing: -0.045em;
    line-height: 0.98;
    max-width: 12ch;
    margin: 0 0 16px;
}
.home-hero .lede { color: rgba(243, 247, 244, 0.78); font-size: 1.08rem; max-width: 42ch; }
.home-hero .btn { background: #f4efe8; color: var(--aside); }
.home-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    padding: 16px 28px 8px;
    max-width: 980px;
}
.home-grid article {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 18px 18px 16px;
}
.home-grid h2 { margin: 0 0 6px; }
.home-grid p { margin: 0; color: var(--muted); }
.home-foot { padding: 8px 28px 40px; color: var(--muted); }

@media (max-width: 720px) {
    .home-bar, .home-foot { padding-left: 16px; padding-right: 16px; }
    .home-hero { margin: 0 16px; padding: 36px 22px 28px; border-radius: 22px; }
    .home-grid { grid-template-columns: 1fr; padding: 14px 16px 8px; }
}
