:root {
    color-scheme: light;
    --ink: #223d37;
    --muted: #4e625a;
    --paper: #f8f6ef;
    --accent: #9b512f;
    --line: #d4d9cc;
    font-family: system-ui, sans-serif;
    color: var(--ink);
    background: var(--paper);
    font-size: 18px;
    line-height: 1.65;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; }
main { flex: 1; }
a { color: inherit; text-underline-offset: 0.2em; }
a:hover { color: var(--accent); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; }
.skip-link { position: absolute; top: -5rem; left: 1rem; background: white; padding: 0.6rem; z-index: 2; }
.skip-link:focus { top: 1rem; }
.site-header, main, .site-footer { width: 100%; margin: 0; padding: 0 2rem; }
.site-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding-top: 1.4rem; padding-bottom: 1.4rem; }
.site-header-main { display: flex; align-items: center; flex-wrap: wrap; gap: 1rem; min-width: 0; }
.site-header:has(#railway-toolbar), .editor-page {
    grid-template-columns: minmax(0, 4fr) minmax(14rem, 1fr);
    gap: 2rem;
}
.site-header:has(#railway-toolbar) { display: grid; }
.site-header:has(#railway-toolbar) > nav {
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 0.75rem;
    min-width: 0;
    padding-left: 1.5rem;
    border-left: 1px solid var(--line);
}
#railway-toolbar { flex: 1; min-width: 0; }
#railway-toolbar .revision-tools { justify-content: flex-end; }
@media (max-width: 900px) {
    .site-header:has(#railway-toolbar) { grid-template-columns: minmax(0, 1fr); gap: 0.75rem; }
    .site-header:has(#railway-toolbar) > nav { padding-left: 0; border-left: 0; }
}
.brand { display: flex; align-items: center; gap: 0.6rem; font-size: 1.5rem; font-weight: 750; text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 2.1rem; height: 2.1rem; background: var(--ink); color: white; border-radius: 0.35rem; font-family: Georgia, serif; }
nav { display: flex; align-items: center; gap: 1.5rem; }
nav a { font-weight: 600; text-decoration: none; }
.button { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: 0.45rem 1.1rem; font-size: 0.9rem; border: 1px solid var(--ink); border-radius: 0.35rem; background: var(--ink); color: white; font: inherit; font-weight: 650; text-decoration: none; cursor: pointer; }
.button:hover { background: #365b50; color: white; }
.button-small { min-height: 30px; padding: 0.2rem 0.8rem; font-size: 0.8rem; font-weight: 600; }
.button-secondary { background: transparent; color: var(--ink); }
.hero { display: grid; grid-template-columns: 1.2fr 1fr; gap: 3rem; align-items: center; padding: 4rem 0 3rem; }
.eyebrow { font-size: 0.7rem; font-weight: 750; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
h1, h2, h3 { line-height: 1.2; }
h1 { margin: 1rem 0; font: 3.1rem/1.1 Georgia, serif; letter-spacing: -0.04em; }
h1 em { color: var(--accent); font-style: normal; }
h2 { font: 1.8rem/1.25 Georgia, serif; }
h3 { font-size: 1.15rem; }
.lead { font-size: 1.15rem; }
.hero-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 1.1rem; margin: 1.8rem 0 1rem; }
.text-link { font-size: 0.85rem; }
.availability { font-size: 0.8rem; color: var(--muted); max-width: 28rem; }
.railway-card { padding: 2rem; background: #e8ecdf; border: 1px solid var(--line); border-radius: 0.7rem; }
.line-diagram { display: flex; position: relative; justify-content: space-between; margin: 3rem 0; }
.line-diagram::before { content: ""; position: absolute; top: 0.6rem; left: 1rem; right: 1rem; height: 4px; background: var(--ink); }
.line-diagram > div { display: flex; position: relative; flex-direction: column; align-items: center; gap: 0.25rem; }
.station-dot { width: 1.4rem; height: 1.4rem; border: 4px solid var(--ink); border-radius: 50%; background: var(--paper); margin-bottom: 0.6rem; }
.line-diagram small { font-size: 0.6rem; }
blockquote { margin: 0; font: 1.8rem/1.35 Georgia, serif; }
.railway-card > p:last-child { color: var(--muted); font-size: 0.85rem; }
.principles { border-top: 1px solid var(--line); padding: 2rem 0; }
.feature-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2rem; }
.feature-number { color: var(--accent); font-size: 0.75rem; font-weight: 700; }
.feature-grid p { color: var(--muted); font-size: 0.9rem; }
.invitation { display: flex; gap: 2rem; justify-content: space-between; align-items: center; border-top: 1px solid var(--line); padding: 2rem 0 3rem; }
.invitation p { margin: 0.4rem 0; font-size: 0.9rem; }
.site-footer { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1rem; border-top: 1px solid var(--line); padding-top: 1.5rem; padding-bottom: 1.5rem; font-size: 0.7rem; color: var(--muted); }
.form-card { max-width: 580px; margin: 3rem auto 4rem; padding: 2rem; background: white; border: 1px solid var(--line); border-radius: 0.7rem; }
.form-card h1 { font-size: 2.2rem; overflow-wrap: anywhere; }
form { display: flex; flex-direction: column; }
label { margin: 1rem 0 0.3rem; font-weight: 600; }
input:not([type="hidden"]) { width: 100%; min-height: 48px; padding: 0.6rem; border: 1px solid #7b8c82; border-radius: 0.25rem; font: inherit; }
form .button { margin-top: 1.5rem; }
.field-hint, .form-footer { font-size: 0.8rem; color: var(--muted); }
.field-hint { margin: 0.4rem 0 0; }
.form-error { background: #fcf0e9; border-left: 4px solid #a53620; padding: 0.8rem 1rem; color: #7a271c; }
.form-error ul { margin-bottom: 0; }
.notice { border-left: 4px solid var(--ink); padding: 0.2rem 1rem; background: var(--paper); }
@media (max-width: 800px) {
    .hero { grid-template-columns: 1fr; padding-top: 2rem; gap: 2rem; }
    h1 { font-size: 2.7rem; }
    .feature-grid { grid-template-columns: 1fr; gap: 1rem; }
    .invitation { align-items: flex-start; flex-direction: column; gap: 1rem; }
}
@media (max-width: 480px) {
    .site-header, main, .site-footer { padding-left: 1rem; padding-right: 1rem; }
    nav { gap: 0.75rem; font-size: 0.8rem; }
    .brand { font-size: 1.2rem; }
    .brand-mark { display: none; }
    .form-card, .railway-card { padding: 1.25rem; }
    h1 { font-size: 2.3rem; }
}

.runs-console { max-width: 1100px; margin: 2rem auto 4rem; padding: 0 1rem; }
.run-list { padding-left: 1.2rem; }
.run-create { max-width: 580px; margin-top: 2rem; }
.run-create fieldset { margin: 1rem 0; }
.run-create fieldset label { display: block; }
.run-posts { width: 100%; border-collapse: collapse; margin-top: 1rem; }
.run-posts th, .run-posts td { text-align: left; padding: 0.4rem 0.6rem; border-bottom: 1px solid var(--line); }
.invite-code { font-family: monospace; letter-spacing: 0.08em; }
.link-button { background: none; border: 0; padding: 0 0.4rem; color: inherit; text-decoration: underline; cursor: pointer; font: inherit; }
.run-page { border-collapse: collapse; margin: 1.5rem 0; background: white; }
.run-page caption { text-align: left; font-weight: 650; padding-bottom: 0.3rem; }
.run-page td { border: 1px solid var(--line); min-width: 3.2rem; height: 1.6rem; padding: 0 0.25rem; font-size: 0.85rem; }
.run-page tr.struck td { text-decoration: line-through; background: #f3f3f3; }

.run-chat {
    max-width: 40rem;
    margin-top: 1.5rem;
}

.run-chat .chat-log {
    max-height: 14rem;
    margin: 0 0 0.5rem;
    padding: 0.4rem 0.6rem;
    overflow-y: auto;
    list-style: none;
    border: 1px solid #999;
}

.run-chat .chat-form {
    display: flex;
    gap: 0.4rem;
}

.run-chat .chat-form input {
    flex: 1;
}

.account-link { font-weight: 650; }
.logout-form { display: inline; margin: 0; }
.landing { display: grid; grid-template-columns: repeat(auto-fit, minmax(22rem, 1fr)); gap: 3rem; padding: 3rem 0; }
.landing-intro p, .landing-features ul { max-width: 40rem; }
.landing h1 { font-size: 3rem; margin-top: 0; }
.capabilities { padding-left: 1.2rem; }
.capabilities li { margin-bottom: 0.6rem; }
.dashboard { display: grid; grid-template-columns: repeat(auto-fit, minmax(26rem, 1fr)); gap: 3rem; padding: 2rem 0 3rem; align-items: start; }
.dashboard-column h2 { margin-top: 0; padding-bottom: 0.4rem; border-bottom: 2px solid var(--ink); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: 1.6rem; }
.panel-head h3 { margin: 0; }
.item-list { list-style: none; margin: 0.6rem 0 0; padding: 0; }
.item-list li { display: flex; align-items: center; gap: 1rem; padding: 0.55rem 0; border-bottom: 1px solid var(--line); }
.item-name { flex: 1; font-weight: 600; overflow-wrap: anywhere; }
.item-meta { color: var(--muted); font-size: 0.8rem; }
.state { font-size: 0.8rem; font-weight: 700; }
.state-running { color: #1d6b3a; }
.state-paused { color: var(--accent); }
.empty { color: var(--muted); font-size: 0.9rem; margin: 0.6rem 0 0; }
.ended { margin-top: 1.6rem; }
.ended summary { cursor: pointer; font-weight: 650; }
dialog { border: 1px solid var(--line); border-radius: 0.7rem; padding: 1.5rem 2rem; min-width: 22rem; }
dialog::backdrop { background: rgba(34, 61, 55, 0.4); }
.dialog-actions { display: flex; gap: 0.8rem; }

.profile { padding: 2rem 0 3rem; }
.profile h1 { margin-top: 0; font-size: 2rem; }
.profile-details { display: grid; grid-template-columns: max-content 1fr; gap: 0.5rem 2rem; margin: 1.5rem 0; }
.profile-details dt { color: var(--muted); font-weight: 600; }
.profile-details dd { margin: 0; overflow-wrap: anywhere; }
.profile form { align-self: flex-start; }
.logout-form { display: flex; align-items: center; }
.logout-form .button { margin-top: 0; }
