/* Quill — design tokens and layout. No framework. */

:root {
    --bg: #f4f1ea;
    --surface: #fffdf8;
    --ink: #1e1c19;
    --muted: #6d675d;
    --line: #e1dcd1;
    --accent: #2f5d4e;
    --accent-ink: #f7f5ef;
    --accent-soft: #e6ece6;
    --danger: #9b3030;
    --ok: #3f7d5a;
    --star: #c49a2a;
    --sidebar-bg: #1b1d1c;
    --sidebar-ink: #ebe7df;
    --sidebar-muted: #9a958b;
    --sidebar-line: #2b2e2c;
    --sidebar-active: #2f5d4e;
    --radius: 8px;
    --sidebar-width: 15rem;
    --serif: ui-serif, "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #141413;
        --surface: #1c1b19;
        --ink: #e9e5dc;
        --muted: #9c968a;
        --line: #2d2b27;
        --accent: #8fbda8;
        --accent-ink: #0f1a15;
        --accent-soft: #22312a;
        --danger: #e08a84;
        --ok: #7cc39a;
        --star: #d6ad3d;
        --sidebar-bg: #0f100f;
        --sidebar-line: #232523;
        --sidebar-active: #2f5d4e;
    }
}

* { box-sizing: border-box; }

html { color-scheme: light dark; }

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    color: var(--ink);
    font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: .15em; }

h1 { margin: 0 0 .5rem; font: 400 1.75rem/1.25 var(--serif); letter-spacing: -0.005em; }
h2 { margin: 0 0 .5rem; font: 400 1.2rem/1.3 var(--serif); }
h3 { margin: 1.25rem 0 .4rem; font-size: .8125rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
p  { margin: 0 0 1rem; }
p:last-child { margin-bottom: 0; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.wrap { word-break: break-all; }
.nowrap { white-space: nowrap; }

code, pre {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: .875em;
}
code {
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: .1em .4em;
}
pre {
    margin: 0;
    padding: .75rem .9rem;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 6px;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-word;
}
pre code { border: 0; padding: 0; background: none; }

/* ---------- Shell: sidebar + content ---------- */

.shell {
    flex: 1;
    width: 100%;
    max-width: 40rem;
    margin: 0 auto;
    padding: 2.5rem 1.25rem;
}
.shell.wide { max-width: 56rem; }
.shell > .card + .card { margin-top: 1.25rem; }

.footer {
    padding: 1.25rem;
    text-align: center;
    color: var(--muted);
    font-size: .8125rem;
}
.footer a { color: inherit; }

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    background: var(--sidebar-bg);
    color: var(--sidebar-ink);
    border-right: 1px solid var(--sidebar-line);
    overflow-y: auto;
}
body.with-sidebar .shell,
body.with-sidebar .footer { margin-left: var(--sidebar-width); }
body.with-sidebar .shell { max-width: calc(40rem + var(--sidebar-width)); padding-left: 2.5rem; padding-right: 2.5rem; }
body.with-sidebar .shell.wide { max-width: calc(60rem + var(--sidebar-width)); }

.sidebar-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.1rem 1.1rem .9rem;
}
.brand {
    display: inline-flex;
    align-items: center;
    gap: .6rem;
    color: inherit;
    text-decoration: none;
    font: 400 1.3rem/1 var(--serif);
}
.brand img { display: block; }

.sidenav { display: flex; flex-direction: column; padding: .25rem .6rem; }
.sidenav a {
    display: block;
    padding: .5rem .6rem;
    margin: .1rem 0;
    border-radius: 7px;
    color: var(--sidebar-ink);
    text-decoration: none;
    font-size: .9375rem;
}
.sidenav a:hover { background: var(--sidebar-line); }
.sidenav a[aria-current="page"] { background: var(--sidebar-active); color: #f7f5ef; font-weight: 600; }
.sidenav-bottom { margin-top: auto; padding-top: .75rem; border-top: 1px solid var(--sidebar-line); }

.account {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .9rem 1.1rem 1.1rem;
    font-size: .8125rem;
    color: var(--sidebar-muted);
}
.account .me { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--sidebar-ink); }
.account .avatar { border-radius: 50%; object-fit: cover; }
.account button.link { color: var(--sidebar-muted); }

/* Narrow screens: the sidebar becomes a top bar with a toggle. */
.menu-toggle { position: absolute; opacity: 0; width: 0; height: 0; }
.menu-button {
    display: none;
    align-items: center;
    gap: .5rem;
    cursor: pointer;
    font-size: .9375rem;
    color: var(--sidebar-ink);
}
.menu-button .bars,
.menu-button .bars::before,
.menu-button .bars::after {
    display: block;
    width: 18px;
    height: 2px;
    background: currentColor;
    border-radius: 1px;
    content: '';
    position: relative;
}
.menu-button .bars::before { position: absolute; top: -6px; }
.menu-button .bars::after { position: absolute; top: 6px; }

@media (max-width: 52rem) {
    .sidebar { position: static; width: auto; border-right: 0; border-bottom: 1px solid var(--sidebar-line); }
    body.with-sidebar .shell,
    body.with-sidebar .footer { margin-left: 0; }
    body.with-sidebar .shell { padding-left: 1.25rem; padding-right: 1.25rem; max-width: 40rem; }
    .menu-button { display: inline-flex; }
    .sidenav, .account { display: none; }
    .menu-toggle:checked ~ .sidebar .sidenav,
    .menu-toggle:checked ~ .sidebar .account { display: flex; }
    .sidenav-bottom { margin-top: 0; }
}

@media (max-width: 36rem) {
    .shell { padding: 1.25rem 1rem; }
    .card { padding: 1.25rem; }
}

/* ---------- Cards and text ---------- */

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1.75rem;
    box-shadow: 0 1px 2px rgba(20, 18, 14, .04), 0 8px 24px -16px rgba(20, 18, 14, .12);
}
.card h2:not(:first-child) { margin-top: 1.75rem; }
.card-header {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: .75rem 1rem;
}
.card-header h1, .card-header h2 { margin-bottom: 0; }

.hero { text-align: center; }
.hero h1 { font-size: 2.1rem; }
.hero-icon { margin-bottom: .25rem; }
.hero form { text-align: left; }

.facts {
    margin: 1.25rem 0;
    padding: 0;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: .4rem 1rem;
    align-items: baseline;
}
.facts dt { color: var(--muted); font-size: .875rem; }
.facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

.rows { margin: 1rem 0; padding: 0; list-style: none; display: grid; gap: .5rem; }
.rows > li {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
    align-items: center;
    justify-content: space-between;
    padding: .65rem .8rem;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 6px;
}
.rows-block > li { display: block; }
.rows-quiet > li { background: transparent; border-style: dashed; justify-content: flex-start; }

.tags { display: flex; flex-wrap: wrap; gap: .35rem; margin: .4rem 0; }
.tag {
    padding: .1rem .45rem;
    font-size: .75rem;
    color: var(--muted);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 999px;
}
.tag-warn { color: var(--danger); border-color: var(--danger); }

.divider { display: flex; align-items: center; gap: .75rem; margin: 1.5rem 0 1rem; color: var(--muted); font-size: .8125rem; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--line); }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.error-code { font-size: 2.5rem; margin-bottom: .25rem; }

/* ---------- Forms ---------- */

.stack { display: grid; gap: 1.1rem; margin-top: 1.5rem; }
.stack-tight { gap: .75rem; margin-top: 1rem; }
.field { display: grid; gap: .35rem; }
.field label, .field .label { font-size: .875rem; font-weight: 600; }
.field label .muted { font-weight: 400; }
.field input, .field textarea, .field select, .input {
    width: 100%;
    padding: .6rem .7rem;
    font: inherit;
    color: var(--ink);
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 6px;
}
.field textarea { resize: vertical; min-height: 4.5em; line-height: 1.5; }
.field input:focus-visible, .field textarea:focus-visible, .field select:focus-visible, .input:focus-visible,
.chips:focus-within {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
    border-color: var(--accent);
}
.field input[readonly] { color: var(--muted); }
.field-row { display: flex; flex-wrap: wrap; gap: .5rem; }
.field-row > * { flex: 1 1 8rem; }
.field-row > .narrow { flex: 0 1 7rem; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); }

.checks { margin: 0; padding: 0; list-style: none; display: grid; gap: .5rem; }
.checks > li { display: grid; gap: .2rem; }
.checks label { display: flex; align-items: baseline; gap: .5rem; font-weight: 400; }
.checks label > span { flex: 1; }
.checks input[type="checkbox"], .checks input[type="radio"] { width: auto; flex: none; margin: 0; padding: 0; }
.check-inline { display: inline-flex; align-items: center; gap: .5rem; font-size: .9375rem; }
.check-inline input { width: auto; margin: 0; }

.hint { margin: 0; font-size: .8125rem; color: var(--muted); }
.hint a { color: inherit; }

details.advanced summary { cursor: pointer; font-size: .875rem; color: var(--muted); }
details.advanced[open] summary { margin-bottom: .6rem; }

.button {
    display: inline-block;
    padding: .65rem 1.1rem;
    font: inherit;
    font-weight: 600;
    color: var(--accent-ink);
    background: var(--accent);
    border: 1px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    text-decoration: none;
    line-height: 1.3;
}
.button:hover { filter: brightness(.94); }
.button:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.button:disabled { opacity: .55; cursor: default; filter: none; }
.button-quiet { color: var(--ink); background: transparent; border-color: var(--line); }
.button-small { padding: .3rem .6rem; font-size: .8125rem; }
.button-danger { background: var(--danger); color: #fff; }
.button-danger:hover { filter: brightness(1.05); }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; margin-top: 1.5rem; }
.actions .spacer { flex: 1; }
button.link {
    padding: 0;
    font: inherit;
    color: var(--accent);
    background: none;
    border: 0;
    cursor: pointer;
    text-decoration: underline;
}
form.inline { display: inline; }

.inline-form { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1rem; }
.inline-form select, .inline-form input { flex: 1 1 14rem; padding: .5rem; font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; }

/* Toggle buttons: syndication targets, channels, quick picks. */
.toggle-buttons { display: flex; flex-wrap: wrap; gap: .4rem; }
.toggle-buttons button, .toggle {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .4rem .7rem;
    font: inherit;
    font-size: .875rem;
    color: var(--ink);
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 999px;
    cursor: pointer;
}
.toggle-buttons button img { width: 16px; height: 16px; border-radius: 3px; }
.toggle-buttons button[aria-pressed="true"], .toggle[aria-pressed="true"] {
    color: var(--accent-ink);
    background: var(--accent);
    border-color: var(--accent);
}

/* Tag chips input */
.chips {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
    padding: .35rem .45rem;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 6px;
    cursor: text;
}
.chips .chip {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .15rem .3rem .15rem .55rem;
    font-size: .875rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 999px;
}
.chips .chip button { padding: 0 .25rem; font: inherit; line-height: 1; color: var(--muted); background: none; border: 0; cursor: pointer; }
.chips input { flex: 1 1 6rem; width: auto; min-width: 6rem; padding: .25rem .3rem; font: inherit; color: var(--ink); background: none; border: 0; outline: none; }
/* The box carries the focus ring; the inner input must not add its own. */
.chips input:focus-visible { outline: none; border: 0; box-shadow: none; }

/* ---------- Messages ---------- */

.alert {
    margin: 1.25rem 0 0;
    padding: .8rem 1rem;
    border: 1px solid var(--danger);
    border-left-width: 3px;
    border-radius: 0 var(--radius) var(--radius) 0;
    color: var(--danger);
    font-size: .9375rem;
}
.notice {
    margin: 1.25rem 0 0;
    padding: .8rem 1rem;
    border: 1px solid var(--line);
    border-left: 3px solid var(--accent);
    border-radius: 0 var(--radius) var(--radius) 0;
    background: var(--bg);
    font-size: .9375rem;
}
.notice-ok { border-left-color: var(--ok); }
.alert:first-child, .notice:first-child { margin-top: 0; }

/* Raw Micropub request/response, for troubleshooting */
.response-panel { margin-top: 1.25rem; }
.response-panel summary { cursor: pointer; font-size: .875rem; color: var(--muted); }
.response-panel pre { margin-top: .5rem; max-height: 24rem; overflow: auto; font-size: .8125rem; }
.status-ok { color: var(--ok); }
.status-bad { color: var(--danger); }

/* ---------- Photos, maps, previews ---------- */

.photo-grid { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .5rem; }
.photo-grid .photo {
    position: relative;
    width: 7.5rem;
    height: 7.5rem;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid var(--line);
    background: var(--bg);
    cursor: pointer;
}
.photo-grid .photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-grid .photo.uploading { opacity: .6; }
.photo-grid .photo .badge {
    position: absolute;
    left: .35rem;
    bottom: .35rem;
    padding: .05rem .4rem;
    font-size: .7rem;
    color: #fff;
    background: rgba(0,0,0,.6);
    border-radius: 999px;
}
.photo-grid .add {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 7.5rem;
    height: 7.5rem;
    border: 1px dashed var(--line);
    border-radius: 6px;
    color: var(--muted);
    background: none;
    cursor: pointer;
    font: inherit;
}

.map-preview { margin-top: .5rem; }
.map-preview img { display: block; width: 100%; height: auto; border-radius: 6px; border: 1px solid var(--line); }

.context {
    display: flex;
    gap: .75rem;
    margin-top: .6rem;
    padding: .75rem .9rem;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 6px;
    font-size: .9375rem;
}
.context img.author { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; flex: none; }
.context .body { min-width: 0; }
.context .name { font-weight: 600; }
.context .text { color: var(--muted); display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.context img.post-photo { max-width: 100%; max-height: 12rem; border-radius: 4px; margin-top: .4rem; }

.counter { font-size: .8125rem; color: var(--muted); text-align: right; }
.counter .over { color: var(--danger); font-weight: 600; }
.counter .warn { color: var(--star); }

.spinner {
    display: inline-block;
    width: 1em;
    height: 1em;
    border: 2px solid var(--line);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .8s linear infinite;
    vertical-align: -0.15em;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Dialogs */
dialog {
    width: min(32rem, calc(100vw - 2rem));
    padding: 1.5rem;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
dialog::backdrop { background: rgba(0,0,0,.4); }
dialog h2 { margin-top: 0; }

/* Autocomplete dropdown */
.autocomplete { position: relative; }
.autocomplete .suggestions {
    position: absolute;
    z-index: 10;
    left: 0; right: 0;
    margin: .2rem 0 0;
    padding: .25rem;
    list-style: none;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 6px;
    box-shadow: 0 8px 24px rgba(0,0,0,.12);
}
.autocomplete .suggestions li { padding: .45rem .6rem; border-radius: 4px; cursor: pointer; font-size: .9375rem; }
.autocomplete .suggestions li[aria-selected="true"], .autocomplete .suggestions li:hover { background: var(--accent-soft); }
.autocomplete .suggestions .secondary { display: block; font-size: .8125rem; color: var(--muted); }

/* Quick-pick buttons (food) */
.quick-buttons { display: grid; gap: .4rem; grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr)); }
.quick-buttons button {
    padding: .6rem .8rem;
    font: inherit;
    text-align: left;
    color: var(--ink);
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 6px;
    cursor: pointer;
}
.quick-buttons button:hover { border-color: var(--accent); }
.quick-buttons button .sub { display: block; font-size: .75rem; color: var(--muted); }

/* Star rating */
.stars { display: inline-flex; gap: .15rem; }
.stars button {
    width: 2rem; height: 2rem;
    padding: 0;
    font-size: 1.6rem;
    line-height: 1;
    color: var(--line);
    background: none;
    border: 0;
    cursor: pointer;
}
.stars button.on, .stars button.hover { color: var(--star); }
.stars-caption { font-size: .875rem; color: var(--muted); min-height: 1.3em; }

/* Itinerary legs */
.legs { display: grid; gap: 1rem; }
.leg { padding: 1rem; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; display: grid; gap: .6rem; position: relative; }
.leg .remove { position: absolute; top: .35rem; right: .6rem; font-size: 1.25rem; line-height: 1; color: var(--muted); text-decoration: none; }
.leg .remove:hover { color: var(--danger); }

/* Table */
table.list { width: 100%; border-collapse: collapse; font-size: .9375rem; }
table.list th, table.list td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
table.list th { font-size: .8125rem; color: var(--muted); font-weight: 600; }
.table-wrap { overflow-x: auto; }

.pager { display: flex; justify-content: space-between; align-items: center; margin-top: 1rem; font-size: .9375rem; }

[hidden] { display: none !important; }

/* Article editor */
.toolbar { display: inline-flex; flex-wrap: wrap; gap: .25rem; }
.toolbar .button-small { padding: .2rem .5rem; }
#article-form textarea { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9375rem; min-height: 18rem; }
.preview { padding: .75rem 1rem; min-height: 18rem; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; }
.preview img { max-width: 100%; }
.preview pre { white-space: pre; }

/* Legs: labels wrap their inputs */
.leg .field > label { display: grid; gap: .3rem; font-size: .8125rem; font-weight: 600; }
.leg .field > label input, .leg .field > label select { width: 100%; padding: .5rem .6rem; font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; }

/* Food */
.food-section + .food-section { margin-top: 1.25rem; }
.food-section h2 { margin-bottom: .5rem; }
.custom-row { margin-top: .5rem; }
.custom-row .narrow { flex: 0 0 auto; }
img.thumb { max-height: 4rem; border-radius: 4px; margin-top: .25rem; }

.docs-nav { margin-bottom: 1rem; color: var(--muted); }
.docs-nav a[aria-current="page"] { font-weight: 600; }
