/* The app's look: colour tokens (light, and dark when the device prefers it), then the shared pieces.
   Use the tokens, not fixed colours, so both themes work. */

:root {
    --bg: #f6f6f4;
    --surface: #ffffff;
    --surface-2: #f0f0ec;
    --border: #deded8;
    --text: #1d1d1b;
    --muted: #6b6b66;
    --accent: #2457d6;
    --accent-text: #ffffff;
    --accent-soft: #e6edfc;
    --ok-text: #1f7a3d;
    --ok-soft: #e4f4e9;
    --warn-text: #8a5a00;
    --warn-soft: #fbf0d9;
    --error-text: #b3261e;
    --error-soft: #fbe5e3;
    --radius: 10px;
    --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #141416;
        --surface: #1d1d20;
        --surface-2: #26262a;
        --border: #34343a;
        --text: #ececef;
        --muted: #9a9aa3;
        --accent: #7aa2ff;
        --accent-text: #0d1430;
        --accent-soft: #1f2a48;
        --ok-text: #7fd69b;
        --ok-soft: #1a3324;
        --warn-text: #f0c46a;
        --warn-soft: #3a2f16;
        --error-text: #ff8a80;
        --error-soft: #3d1d1b;
    }
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 16px/1.5 var(--font);
}

a { color: var(--accent); }
code, pre { font-family: var(--mono); font-size: 0.9em; }
h1 { font-size: 1.5rem; margin: 0 0 0.75rem; }
h2 { font-size: 1.15rem; margin: 1.25rem 0 0.5rem; }
.card > h2:first-child { margin-top: 0; }
.muted { color: var(--muted); }
.ok-text { color: var(--ok-text); }
.error-text { color: var(--error-text); }

/* Header */
.top {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    padding: 0.75rem 1rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; color: var(--text); text-decoration: none; }
.nav { display: flex; gap: 0.25rem; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.nav a { white-space: nowrap; }
.nav a {
    padding: 0.35rem 0.7rem;
    border-radius: 6px;
    color: var(--muted);
    text-decoration: none;
}
.nav a.active, .nav a:hover { background: var(--surface-2); color: var(--text); }
.badge {
    display: inline-block;
    min-width: 1.3em;
    padding: 0 0.35em;
    margin-left: 0.25em;
    border-radius: 999px;
    background: var(--accent);
    color: var(--accent-text);
    font-size: 0.75rem;
    text-align: center;
}
.logout { display: flex; align-items: center; gap: 0.5rem; margin: 0; }
.who { color: var(--muted); font-size: 0.9rem; }

/* Page */
.page { max-width: 960px; margin: 0 auto; padding: 1rem; }
.narrow { max-width: 480px; margin: 0 auto; padding: 2rem 1rem; }
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1rem;
}
.tabs { display: flex; gap: 0.25rem; margin-bottom: 1rem; border-bottom: 1px solid var(--border); }
.tabs a {
    padding: 0.5rem 0.9rem;
    color: var(--muted);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}
.tabs a.active { color: var(--text); border-bottom-color: var(--accent); }

/* Messages */
.notice {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin: 0 0 1rem;
    background: var(--accent-soft);
    white-space: pre-line;
}
.notice.ok { background: var(--ok-soft); color: var(--ok-text); }
.notice.warn { background: var(--warn-soft); color: var(--warn-text); }
.notice.error { background: var(--error-soft); color: var(--error-text); }
.notice-card.warn { border-color: var(--warn-text); }
.notice-card.error { border-color: var(--error-text); }
.output {
    white-space: pre-wrap;
    word-break: break-word;
    background: var(--surface-2);
    color: var(--text);
    padding: 0.6rem;
    border-radius: 6px;
    margin: 0.5rem 0 0;
    max-height: 16rem;
    overflow: auto;
}

/* Forms */
.form { display: flex; flex-direction: column; gap: 0.4rem; }
.form h2 { margin-top: 1rem; }
label { font-weight: 600; font-size: 0.95rem; margin-top: 0.4rem; }
label.check { font-weight: 400; display: flex; gap: 0.5rem; align-items: flex-start; }
input, select, button { font: inherit; }
input:not([type="checkbox"]), select {
    width: 100%;
    padding: 0.55rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
}
input:focus, select:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
input[aria-invalid="true"] { border-color: var(--error-text); }
.field-error { color: var(--error-text); margin: 0; font-size: 0.9rem; }
.hint { color: var(--muted); margin: 0; font-size: 0.9rem; }
button {
    padding: 0.55rem 1rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
    cursor: pointer;
}
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); margin-top: 0.75rem; }
button.danger { background: var(--error-text); color: var(--surface); border-color: var(--error-text); margin-top: 0.75rem; }
button.secondary { background: var(--surface-2); }
button:disabled { opacity: 0.6; cursor: progress; }
.form button { align-self: flex-start; }
.link-button { background: none; border: none; color: var(--accent); padding: 0; }
form.inline { display: inline; margin-left: 0.5rem; }

/* Lists and tables */
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 0.4rem 1rem; margin: 0 0 1rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.changes { padding-left: 1.25rem; }
.changes li { margin-bottom: 0.75rem; }
.changes li > span { display: block; font-size: 0.85rem; }
.changes p { margin: 0.25rem 0 0; color: var(--muted); }
.plain-list { list-style: none; padding: 0; margin: 0; }
.plain-list li { padding: 0.35rem 0; border-bottom: 1px solid var(--border); }
.plain-list li:last-child { border-bottom: none; }
.table { width: 100%; border-collapse: collapse; margin-top: 0.75rem; }
.table th, .table td { text-align: left; padding: 0.5rem; border-bottom: 1px solid var(--border); }
.table th { color: var(--muted); font-weight: 600; font-size: 0.9rem; }

/* Update now's steps */
.steps { padding-left: 1.25rem; margin: 0.75rem 0 0; }
.steps li { color: var(--muted); }
.steps li[data-state="running"] { color: var(--text); font-weight: 600; }
.steps li[data-state="running"]::after { content: " …"; }
.steps li[data-state="done"] { color: var(--ok-text); }
.steps li[data-state="done"]::after { content: " ✓"; }
.steps li[data-state="failed"] { color: var(--error-text); }
.steps li[data-state="failed"]::after { content: " ✗"; }
.result:empty { display: none; }

@media (max-width: 560px) {
    .facts { grid-template-columns: 1fr; }
    .facts dt { margin-top: 0.5rem; }
    .table { font-size: 0.9rem; }
    .who { display: none; }
    /* Phones: the links get their own row under the name, and scroll sideways inside it if they don't fit */
    .top { flex-wrap: wrap; row-gap: 0.4rem; }
    .brand { flex: 1; }
    .nav { order: 3; flex-basis: 100%; }
}

/* Pull requests (Updates page) */
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
.card-head h2 { margin: 0; }
.pull { border: 1px solid var(--border); border-radius: 8px; margin: 0.5rem 0; background: var(--surface-2); }
.pull > summary { cursor: pointer; padding: 0.6rem 0.8rem; list-style: none; display: flex; flex-wrap: wrap; gap: 0.25rem 0.75rem; }
.pull > summary::-webkit-details-marker { display: none; }
.pull-title { font-weight: 600; flex: 1 1 16rem; }
.pull-meta { flex-basis: 100%; font-size: 0.85rem; }
.pull-tags { display: flex; gap: 0.35rem; flex-wrap: wrap; }
.tag { font-size: 0.75rem; padding: 0.1rem 0.5rem; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); }
.tag.checks-passed { color: var(--ok-text); background: var(--ok-soft); border-color: transparent; }
.tag.checks-failed { color: var(--error-text); background: var(--error-soft); border-color: transparent; }
.tag.checks-running { color: var(--warn-text); background: var(--warn-soft); border-color: transparent; }
.pull-body { padding: 0 0.8rem 0.8rem; }
.pull-text { margin: 0.25rem 0 0.5rem; color: var(--muted); white-space: normal; overflow-wrap: anywhere; }
.pull-checks, .pull-files { padding-left: 1.1rem; margin: 0.4rem 0; font-size: 0.9rem; }
.pull-files code { overflow-wrap: anywhere; }
.pull-checks .checks-passed { color: var(--ok-text); }
.pull-checks .checks-failed { color: var(--error-text); }
.pull-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.75rem; margin-top: 0.5rem; }
.pull-actions p { flex-basis: 100%; margin: 0; }
.pull-actions button.primary { margin-top: 0; }
.merge-password { margin-top: 0.75rem; max-width: 24rem; }
.token { margin-top: 1rem; }
.token summary { cursor: pointer; }
.row { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; }

/* Buttons that are links, wide tables, settings */
a.button {
    display: inline-block;
    padding: 0.55rem 1rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
    text-decoration: none;
}
a.button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.card-head a.button { white-space: nowrap; }
.table-wrap { overflow-x: auto; }
tr.inactive td { opacity: 0.6; }
.sticky-save { position: sticky; bottom: 0; padding: 0.75rem 0; background: var(--bg); }
.sticky-save button.primary { margin-top: 0; }
.who { text-decoration: none; }

/* Two-step login */
.setup-steps { padding-left: 1.25rem; }
.setup-steps li { margin-bottom: 0.75rem; }
.qr { width: 200px; max-width: 100%; margin: 0.75rem 0; }
.qr svg { display: block; width: 100%; height: auto; border-radius: 6px; }
.secret { font-size: 1rem; letter-spacing: 0.05em; overflow-wrap: anywhere; }
.codes { display: grid; grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr)); gap: 0.5rem; list-style: none; padding: 0; }
.codes code { font-size: 1.05rem; }

/* Events */
.tabs.small { margin-top: 0.5rem; }
.event-list { list-style: none; padding: 0; margin: 0; }
.event-row {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    padding: 0.75rem 0.25rem;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    text-decoration: none;
}
.event-list li:last-child .event-row { border-bottom: none; }
.event-row:hover { background: var(--surface-2); }
.event-date {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    min-width: 3.2rem; padding: 0.3rem; border-radius: 8px; background: var(--accent-soft); line-height: 1.1;
}
.event-date .day { font-size: 1.3rem; font-weight: 700; }
.event-date .month { font-size: 0.8rem; color: var(--muted); }
.event-main { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.event-main strong { overflow-wrap: anywhere; }
.event-main .muted { font-size: 0.88rem; }
.tag.state-on_sale { color: var(--ok-text); background: var(--ok-soft); border-color: transparent; }
.tag.state-draft, .tag.state-not_yet { color: var(--warn-text); background: var(--warn-soft); border-color: transparent; }
.tag.state-closed, .tag.state-past, .tag.state-archived { color: var(--muted); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.two > div { display: flex; flex-direction: column; gap: 0.4rem; }
textarea {
    width: 100%; padding: 0.55rem 0.7rem; border: 1px solid var(--border); border-radius: 8px;
    background: var(--surface); color: var(--text); font: inherit; resize: vertical;
}
h3 { font-size: 1rem; margin: 1.25rem 0 0.25rem; }
.type-row { border: 1px solid var(--border); border-radius: 8px; padding: 0.75rem; margin: 0 0 0.75rem; background: var(--surface-2); }
.type-row.removed { opacity: 0.45; }
.type-grid { display: grid; grid-template-columns: 2fr 1fr 0.8fr 1fr; gap: 0.4rem 0.75rem; }
.type-grid > div { display: flex; flex-direction: column; gap: 0.3rem; min-width: 0; }
.type-grid label { margin-top: 0; font-size: 0.85rem; }
.type-description { grid-column: 1 / -1; }
.event-status .row form { margin: 0; }
.event-status .row button.primary { margin-top: 0; }
.danger-text { color: var(--error-text); }
@media (max-width: 640px) {
    .two { grid-template-columns: 1fr; }
    .type-grid { grid-template-columns: 1fr 1fr; }
    .type-name { grid-column: 1 / -1; }
}
