/* Skod: mobile-first styles. Light by default, dark via prefers-color-scheme. */
:root {
    --bg: #f4f3ef;
    --surface: #ffffff;
    --surface-2: #ecebe5;
    --text: #1d2422;
    --muted: #66706c;
    --line: #e1dfd7;
    --accent: #1d5c57;
    --accent-text: #ffffff;
    --accent-soft: #dcebe8;
    --ok: #237a4b;
    --ok-soft: #dff2e6;
    --warn: #9a6500;
    --warn-soft: #fbefd5;
    --danger: #b3261e;
    --danger-soft: #fbe4e2;
    --star: #d39b00;
    --radius: 14px;
    --tabbar-h: 58px;
    --safe-b: env(safe-area-inset-bottom, 0px);
    --safe-t: env(safe-area-inset-top, 0px);
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #111615;
        --surface: #1a201f;
        --surface-2: #232b29;
        --text: #e9eeec;
        --muted: #98a39f;
        --line: #2c3533;
        --accent: #5fb3a9;
        --accent-text: #0d1715;
        --accent-soft: #1f3532;
        --ok: #6fcf97;
        --ok-soft: #1c3326;
        --warn: #f0b74a;
        --warn-soft: #3a2f17;
        --danger: #ff8a80;
        --danger-soft: #3d1f1d;
        --star: #f4c430;
        color-scheme: dark;
    }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

a { color: var(--accent); }
h1 { font-size: 1.5rem; margin: 0 0 .5rem; }
h2 { font-size: 1rem; margin: 0 0 .5rem; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
[hidden] { display: none !important; }

/* ------------------------------------------------------------ chrome */

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: calc(var(--safe-t) + .6rem) 1rem .6rem;
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: saturate(1.4) blur(12px);
    -webkit-backdrop-filter: saturate(1.4) blur(12px);
    border-bottom: 1px solid var(--line);
}

.brand {
    font-weight: 800;
    letter-spacing: -.02em;
    text-decoration: none;
    color: var(--accent);
    font-size: 1.15rem;
}

.topbar-title { font-weight: 600; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.content {
    max-width: 680px;
    margin: 0 auto;
    padding: .75rem 1rem calc(var(--tabbar-h) + var(--safe-b) + 1.5rem);
}

.tabbar {
    position: fixed;
    inset: auto 0 0 0;
    z-index: 10;
    display: flex;
    justify-content: space-around;
    height: calc(var(--tabbar-h) + var(--safe-b));
    padding-bottom: var(--safe-b);
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: saturate(1.4) blur(12px);
    -webkit-backdrop-filter: saturate(1.4) blur(12px);
    border-top: 1px solid var(--line);
}

.tabbar a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    color: var(--muted);
    text-decoration: none;
    font-size: .7rem;
    font-weight: 600;
}

.tabbar svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabbar a.active { color: var(--accent); }

/* Request indicator: the spinner in the top bar shows while any htmx request runs. */
.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid var(--line);
    border-top-color: var(--accent);
    border-radius: 50%;
    opacity: 0;
    transition: opacity .15s;
}
body.busy .spinner { opacity: 1; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
    position: fixed;
    left: 50%;
    bottom: calc(var(--tabbar-h) + var(--safe-b) + 12px);
    transform: translateX(-50%);
    z-index: 20;
    max-width: calc(100% - 2rem);
    padding: .6rem 1rem;
    border-radius: 999px;
    background: var(--text);
    color: var(--bg);
    font-size: .9rem;
    box-shadow: 0 6px 20px rgb(0 0 0 / .2);
}

/* ------------------------------------------------------------ day strip & filters */

.days {
    display: flex;
    gap: .4rem;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    margin: 0 -1rem;
    padding: .25rem 1rem .5rem;
    scrollbar-width: none;
}
.days::-webkit-scrollbar { display: none; }

.day {
    flex: 0 0 auto;
    scroll-snap-align: start;
    width: 3.4rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: .4rem 0 .3rem;
    border-radius: 12px;
    background: var(--surface);
    border: 1px solid var(--line);
    color: var(--text);
    text-decoration: none;
}
.day .wd { font-size: .7rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.day .dn { font-size: 1.15rem; font-weight: 700; }
.day .dot { width: 5px; height: 5px; border-radius: 50%; margin-top: 2px; background: transparent; }
.day .dot.on { background: var(--accent); }
.day.weekend .wd { color: var(--accent); }
.day.selected { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.day.selected .wd { color: inherit; opacity: .85; }
.day.selected .dot.on { background: var(--accent-text); }

.filters { display: flex; flex-direction: column; gap: .5rem; margin: .25rem 0 .75rem; }

input[type=search], input[type=email], input[type=password], input[type=text] {
    width: 100%;
    font: inherit;
    font-size: 16px; /* prevents iOS zoom on focus */
    padding: .65rem .85rem;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--text);
}
input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.chips { display: flex; gap: .4rem; flex-wrap: wrap; }
.chip {
    padding: .35rem .8rem;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--text);
    font-size: .85rem;
    font-weight: 600;
    text-decoration: none;
}
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

/* ------------------------------------------------------------ rows */

.rows { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .5rem; }

.row {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: .7rem .8rem;
}
.row.is-mine { border-color: var(--accent); box-shadow: inset 4px 0 0 var(--accent); }
.row.is-started, .row.is-cancelled { opacity: .6; }
.row.is-duplicate { border-color: var(--warn); }

.row-main { display: flex; align-items: center; gap: .75rem; }

.time {
    flex: 0 0 3.4rem;
    display: flex;
    flex-direction: column;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    font-size: 1.05rem;
}
.time small, .time .small { font-weight: 500; color: var(--muted); font-size: .72rem; }

.info { flex: 1; min-width: 0; }
.name { font-weight: 600; overflow-wrap: anywhere; }
.star { color: var(--star); margin-right: .2rem; }
.sub { color: var(--muted); font-size: .85rem; display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }

.side { display: flex; flex-direction: column; align-items: flex-end; gap: .35rem; flex: 0 0 auto; }

.cap { font-size: .8rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.cap-ok { color: var(--ok); }
.cap-low { color: var(--warn); }
.cap-full { color: var(--danger); }

.badge, .tag {
    display: inline-block;
    padding: .2rem .55rem;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 700;
    text-decoration: none;
}
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-wait { background: var(--warn-soft); color: var(--warn); }
.badge-off { background: var(--surface-2); color: var(--muted); }
.tag-warn { background: var(--warn-soft); color: var(--warn); padding: .05rem .45rem; }

.confirm { margin-top: .6rem; padding-top: .6rem; border-top: 1px dashed var(--line); }
.confirm p { margin: 0 0 .5rem; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; }

.warn { color: var(--warn); font-weight: 600; font-size: .9rem; }

.msg { margin: .6rem 0 0; padding: .55rem .75rem; border-radius: 10px; font-size: .9rem; }
.msg-ok { background: var(--ok-soft); color: var(--ok); }
.msg-error { background: var(--danger-soft); color: var(--danger); }
.msg-warn { background: var(--warn-soft); color: var(--warn); margin-bottom: .75rem; }
.msg-info { background: var(--accent-soft); color: var(--accent); }
.content > .msg { margin-top: 0; margin-bottom: .75rem; }

.empty { text-align: center; padding: 2.5rem 1rem; color: var(--muted); }
.hidden-note { text-align: center; color: var(--muted); font-size: .85rem; margin-top: 1rem; }

/* ------------------------------------------------------------ buttons */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    min-height: 40px;
    padding: .5rem 1rem;
    border-radius: 999px;
    border: 1px solid transparent;
    font: inherit;
    font-weight: 700;
    font-size: .92rem;
    text-decoration: none;
    cursor: pointer;
    touch-action: manipulation;
}
.btn-sm { min-height: 32px; padding: .3rem .85rem; font-size: .82rem; }
.btn-block { width: 100%; }
.btn-primary { background: var(--accent); color: var(--accent-text); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn:disabled { opacity: .6; cursor: default; }
.btn:active:not(:disabled) { transform: scale(.97); }

.when-busy { display: none; }
.htmx-request .when-busy, .htmx-request.when-busy { display: inline; }
.htmx-request .when-idle { display: none; }

/* ------------------------------------------------------------ bookings */

.segmented {
    display: flex;
    background: var(--surface-2);
    border-radius: 12px;
    padding: 3px;
    margin-bottom: .75rem;
}
.segmented a {
    flex: 1;
    text-align: center;
    padding: .45rem;
    border-radius: 9px;
    color: var(--muted);
    font-weight: 600;
    text-decoration: none;
}
.segmented a.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgb(0 0 0 / .1); }

/* ------------------------------------------------------------ settings */

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: .9rem;
    margin-bottom: .75rem;
}
.card p { margin: 0 0 .6rem; }

.favs { display: flex; flex-wrap: wrap; gap: .4rem; }
.fav {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .35rem .7rem;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: .85rem;
    cursor: pointer;
}
.fav.on { border-color: var(--star); background: color-mix(in srgb, var(--star) 14%, var(--surface)); }
.fav-star { color: var(--star); }
.fav-count { color: var(--muted); font-size: .72rem; }

.row-form { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: .6rem; }

.switch {
    position: relative;
    flex: 0 0 auto;
    width: 48px;
    height: 28px;
    border-radius: 999px;
    border: 0;
    background: var(--line);
    cursor: pointer;
}
.switch .knob {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgb(0 0 0 / .3);
    transition: left .15s;
}
.switch.on { background: var(--accent); }
.switch.on .knob { left: 23px; }

/* ------------------------------------------------------------ login */

.login { max-width: 420px; margin: 1.5rem auto 0; }
.stack { display: flex; flex-direction: column; gap: .9rem; margin-top: 1rem; }
.stack label > span { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .3rem; }
.check { display: flex; gap: .6rem; align-items: flex-start; }
.check input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--accent); }
.check span { font-weight: 600; }
.check small { display: block; font-weight: 400; margin-top: .15rem; }
.fineprint { margin-top: 2rem; font-size: .78rem; color: var(--muted); text-align: center; }
