:root {
    --bg: #1a1707; --bg2: #26200a; --card: rgba(255,255,255,.06); --line: rgba(255,255,255,.17);
    --ink: #fefce8; --muted: #d9cf9a; --accent: #facc15; --accent-ink: #2b2100; --field: rgba(255,255,255,.08); --bad: #fda4af; --ok: #4ade80; --off: rgba(255,255,255,.07);
    color-scheme: dark;
}
@media (prefers-color-scheme: light) {
    :root { --bg: #fffbea; --bg2: #fdf3c4; --card: #fff; --line: #ecdca0; --ink: #2b2100; --muted: #6b5a1c;
            --accent: #a16207; --accent-ink: #fff; --field: #fffbea; --bad: #be123c; --ok: #15803d; --off: #f3ecd0; color-scheme: light; }
}
:root[data-theme="light"] { --bg: #fffbea; --bg2: #fdf3c4; --card: #fff; --line: #ecdca0; --ink: #2b2100; --muted: #6b5a1c;
            --accent: #a16207; --accent-ink: #fff; --field: #fffbea; --bad: #be123c; --ok: #15803d; --off: #f3ecd0; color-scheme: light; }
* { box-sizing: border-box; }
html { background: var(--bg2); }
body { margin: 0; min-height: 100vh; padding: clamp(1rem,4vw,2.5rem) 1rem 4rem; display: flex; justify-content: center;
       font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink);
       background: linear-gradient(180deg, var(--bg), var(--bg2)) fixed; touch-action: manipulation; }
.app { width: min(600px, 100%); }
header { text-align: center; margin-bottom: 1.1rem; }
h1 { margin: 0; font-size: 1.9rem; letter-spacing: -.02em; }
.sub { margin: .3rem 0 0; color: var(--muted); font-size: 1rem; font-weight: 400; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 1.1rem; margin-bottom: .9rem; }
label { display: block; margin: .9rem 0 .35rem; font-size: .9rem; font-weight: 600; color: var(--muted); }
.pair > div > label, .card > .pair:first-child label { margin-top: 0; }
input, select { width: 100%; min-height: 48px; padding: .6rem .8rem; font: inherit; font-size: 1.05rem; color: var(--ink); background: var(--field); border: 1px solid var(--line); border-radius: 12px; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.pair > div, .person .city, .person .own > * { min-width: 0; }
input, select { min-width: 0; max-width: 100%; }
input[type="date"] { display: block; -webkit-appearance: none; appearance: none; text-align: left; }
@media (max-width: 440px) { .pair { grid-template-columns: 1fr; } .person .own { grid-template-columns: 1fr; } }
input:focus-visible, button:focus-visible, select:focus-visible, summary:focus-visible, a:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.link { margin: .5rem 0 0; padding: .4rem 0; min-height: 36px; border: 0; background: none; color: var(--accent); font: inherit; font-size: .95rem; font-weight: 600; cursor: pointer; }
.hint { margin: 0 0 .5rem; color: var(--muted); font-size: .85rem; }
.error { margin: .6rem 0 0; color: var(--bad); font-weight: 600; }
.people { list-style: none; margin: 0; padding: 0; display: grid; gap: .8rem; }
.person { display: grid; grid-template-columns: 1fr auto; gap: .4rem; align-items: start; padding: .7rem; border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 14px; background: rgba(127,127,127,.08); }
.person .city { display: grid; gap: .25rem; }
.person .meta { font-size: .85rem; color: var(--muted); min-height: 1.2em; padding-left: .2rem; }
.person .meta.bad { color: var(--bad); font-weight: 600; }
.person .meta button { border: 0; background: none; color: var(--accent); font: inherit; font-size: .85rem; font-weight: 600; cursor: pointer; padding: 0 0 0 .5rem; }
.person .own { display: grid; grid-template-columns: 1fr 1fr; gap: .4rem; }
.person .own-note { grid-column: 1 / -1; font-size: .85rem; color: var(--muted); min-height: 0; }
.person .own-note:empty { display: none; }
.person .hours { min-height: 44px; font-size: .95rem; }
.person .own select { min-height: 40px; font-size: .95rem; }
.person .x { width: 48px; min-height: 48px; border-radius: 12px; border: 1px solid var(--line); background: transparent; color: var(--muted); font-size: 1.3rem; cursor: pointer; }
.big-label { color: var(--muted); font-size: .9rem; font-weight: 600; }
.big { font-size: clamp(1.6rem, 7.5vw, 2.1rem); font-weight: 800; letter-spacing: -.02em; color: var(--accent); line-height: 1.2; margin: .15rem 0 .5rem; }
.big.warn { color: var(--bad); }
.lead { margin: 0 0 .8rem; font-size: 1.02rem; }
.table { list-style: none; margin: 0; padding: 0; display: grid; gap: .35rem; }
.table li { display: grid; grid-template-columns: 1fr auto; gap: 0 .7rem; padding: .55rem .75rem; background: var(--field); border-radius: 10px; border-left: 4px solid var(--ok); font-size: .98rem; }
.table li.out { border-left-color: var(--bad); }
.table li b { font-variant-numeric: tabular-nums; text-align: right; }
.table li small { grid-column: 1 / -1; color: var(--muted); }
.table li.out small { color: var(--bad); font-weight: 600; }
.note { margin: .7rem 0 0; color: var(--bad); font-weight: 600; font-size: .93rem; }
h3 { margin: 1.2rem 0 .4rem; font-size: 1rem; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chips button { min-height: 40px; padding: .3rem .8rem; border-radius: 99px; border: 1px solid var(--line); background: var(--field); color: var(--ink); font: inherit; font-size: .92rem; font-variant-numeric: tabular-nums; cursor: pointer; }
.chips button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 700; }
.strips { display: grid; gap: .5rem; }
.strip-name { font-size: .82rem; color: var(--muted); margin-bottom: 2px; }
.strip { display: grid; grid-template-columns: repeat(48, 1fr); gap: 1px; height: 18px; }
.strip i { background: var(--off); border-radius: 1px; }
.strip i.on { background: var(--ok); opacity: .55; }
.strip i.pick { opacity: 1; outline: 2px solid var(--accent); outline-offset: 0; z-index: 1; }
.strip i.pick:not(.on) { background: var(--bad); opacity: 1; }
.axis { display: flex; justify-content: space-between; font-size: .75rem; color: var(--muted); }
.actions { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: .5rem; margin: 1.2rem 0 .2rem; }
.primary, .second { display: flex; align-items: center; justify-content: center; text-align: center; min-height: 48px; padding: .3rem; border-radius: 12px; font: inherit; font-weight: 700; font-size: .95rem; cursor: pointer; text-decoration: none; }
.primary { background: var(--accent); color: var(--accent-ink); border: 0; }
.second { background: var(--field); color: var(--ink); border: 1px solid var(--line); }
.row-tools { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.ghost { min-height: 44px; border-radius: 12px; border: 1px dashed var(--line); background: transparent; color: var(--ink); font: inherit; cursor: pointer; }
.msg { min-height: 1.4em; margin: .5rem 0 0; text-align: center; color: var(--muted); font-size: .9rem; }
.msg button { margin-left: .5rem; padding: .2rem .7rem; border-radius: 8px; border: 1px solid var(--line); background: var(--field); color: var(--ink); font: inherit; cursor: pointer; }
.faq h2 { font-size: 1.1rem; margin: 1.5rem 0 .5rem; }
details { border-top: 1px solid var(--line); padding: .6rem 0; }
summary { cursor: pointer; font-weight: 600; min-height: 32px; }
details p { margin: .4rem 0 0; color: var(--muted); }
footer { text-align: center; margin-top: 1.5rem; font-size: .9rem; } footer a { color: var(--muted); }
[hidden] { display: none !important; }
@media (max-width: 380px) { .actions { grid-template-columns: 1fr; } }

/* back to the list of all apps */
.back { display: inline-flex; align-items: center; gap: .4rem; min-height: 44px; margin: 0 0 .5rem; padding: 0 1rem 0 .8rem; border: 1px solid var(--line, rgba(127,127,127,.4)); border-radius: 999px; color: var(--muted, var(--mut, inherit)); font-size: .92rem; font-weight: 600; text-decoration: none; background: transparent; }
.back:hover { color: var(--ink, inherit); border-color: currentColor; }
.back:focus-visible { outline: 3px solid var(--accent, var(--acc, #fff)); outline-offset: 2px; }
@media print { .back { display: none; } }

/* light / dark switch (theme.js sets data-theme); without it the device setting decides */
:root[data-theme="dark"] {
    --bg: #1a1707; --bg2: #26200a; --card: rgba(255,255,255,.06); --line: rgba(255,255,255,.17);
    --ink: #fefce8; --muted: #d9cf9a; --accent: #facc15; --accent-ink: #2b2100; --field: rgba(255,255,255,.08); --bad: #fda4af; --ok: #4ade80; --off: rgba(255,255,255,.07);
    color-scheme: dark;
}

/* laptops and desktops: two columns instead of one phone-sized column */
@media (min-width: 900px) {
    .app { width: min(1160px, 100%); display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); column-gap: 1.5rem; align-items: start; }
    .app > * { grid-column: 1 / -1; }
    .app > .card:not(.result):not(#result), .app > .app-in { grid-column: 1; }
    .app > .result, .app > #result { grid-column: 2; margin-top: 0; }
    .app > .card { margin-bottom: .9rem; }
    .app > .faq, .app > footer { width: min(760px, 100%); justify-self: center; }
    header h1 { font-size: 2.3rem; }
    .tabs { max-width: 560px; justify-self: center; width: 100%; }
    /* before there is a result, keep the lone form card centered and phone-sized */
    .app:has(> #result[hidden]) > .card { grid-column: 1 / -1; width: min(560px, 100%); justify-self: center; }
    .app > .row-tools { grid-column: 1 / -1; display: flex; gap: .6rem; justify-content: center; }
    .app > .row-tools .ghost { width: auto; padding: 0 1.2rem; }
}
