:root {
  --bg: #f6f1ea; --card: #fffdf9; --ink: #2b211b; --ink2: #4a3d34; --muted: #8b7b6e;
  --line: #e8dfd3; --accent: #8a5a3b; --accent-ink: #fffdf9; --good: #3f6f4a; --warn: #a8661b; --bad: #a33a2b;
  --chip: #efe6da; --shadow: 0 1px 2px rgba(43,33,27,.05), 0 4px 14px rgba(43,33,27,.05);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1714; --card: #262019; --ink: #f1e9df; --ink2: #d8ccbf; --muted: #a39484;
    --line: #3a3129; --accent: #d39a6e; --accent-ink: #1c1714; --good: #8cc29a; --warn: #e0a95c; --bad: #e88a7b;
    --chip: #332a22; --shadow: none;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
a { color: var(--accent); }
main { max-width: 640px; margin: 0 auto; padding: 8px 16px 48px; }
h1, h2, h3, .brand { font-family: Fraunces, Georgia, serif; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 1.75rem; line-height: 1.15; margin: .2em 0 .4em; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; margin: 0; }
.section { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-family: inherit; font-weight: 600; margin: 28px 0 10px; }
.count { background: var(--accent); color: var(--accent-ink); border-radius: 999px; padding: 0 8px; margin-left: 4px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }
code { background: var(--chip); padding: 1px 5px; border-radius: 4px; font-size: .9em; }

.top { display: flex; justify-content: space-between; align-items: center; max-width: 640px; margin: 0 auto; padding: 14px 16px; padding-top: max(14px, env(safe-area-inset-top)); }
.brand { text-decoration: none; color: var(--ink); font-size: 1.25rem; }
.brand span { color: var(--accent); }
.top nav { display: flex; gap: 14px; align-items: center; font-size: .95rem; }
.top nav a { text-decoration: none; }
footer { text-align: center; padding: 24px; font-size: .8rem; }
footer a { color: var(--muted); text-decoration: none; }

.hero p { margin: 0 0 8px; }
.card { display: block; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 18px; margin: 0 0 12px; box-shadow: var(--shadow); }
.card.slim { padding: 12px 14px; }
.card.dim, .dim { opacity: .6; }
.card.empty { text-align: center; color: var(--muted); }
.row-link { text-decoration: none; color: inherit; }
.opening { position: relative; text-decoration: none; color: inherit; padding-right: 96px; transition: transform .08s ease, border-color .15s; }
.opening:active { transform: scale(.99); }
.opening:hover { border-color: var(--accent); }
.opening .kind, .kind { font-size: .78rem; text-transform: uppercase; letter-spacing: .07em; color: var(--accent); font-weight: 600; }
.opening .time { font-size: 1.15rem; font-weight: 600; margin: 2px 0; }
.opening .cta { position: absolute; right: 16px; top: 50%; transform: translateY(-50%); font-weight: 600; color: var(--accent); }
.opening.session { border-left: 4px solid var(--accent); }
.opening.free { border-left: 4px solid var(--good); }
.opening.free .kind { color: var(--good); }
.time.big { font-size: 1.3rem; font-weight: 600; margin: 0 0 12px; }
.map { width: 100%; height: auto; border-radius: 10px; border: 1px solid var(--line); display: block; margin: 10px 0 12px; aspect-ratio: 600 / 280; object-fit: cover; background: var(--chip); }
.note { font-style: italic; color: var(--ink2); margin: 10px 0; }

.flash { background: var(--chip); border-radius: 10px; padding: 10px 14px; margin: 8px 0 14px; }
.flash.err { background: color-mix(in srgb, var(--bad) 15%, var(--card)); color: var(--bad); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 18px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; }
.btn.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }
.btn.tiny { min-height: 30px; padding: 0 10px; font-size: .8rem; font-weight: 500; }
.btn.google { width: 100%; margin-top: 8px; }
.btnrow { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
button.link { background: none; border: 0; color: var(--accent); font: inherit; padding: 0; cursor: pointer; }
form.inline { display: inline; margin: 0; }

.stack { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: .9rem; font-weight: 500; }
input, select, textarea { font: inherit; font-size: 16px; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%; min-height: 44px; }
textarea { resize: vertical; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 10px; }
@media (max-width: 380px) { .grid3 { grid-template-columns: 1fr 1fr; } .grid3 label:first-child { grid-column: 1 / -1; } }
fieldset { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
legend { font-size: .9rem; font-weight: 500; margin-bottom: 6px; }
.choice { flex-direction: row; align-items: flex-start; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; font-weight: 400; cursor: pointer; }
.choice:has(input:checked) { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 7%, var(--card)); }
.choice input { width: auto; min-height: 0; margin-top: 4px; accent-color: var(--accent); }
.results { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.results button { width: 100%; text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font: inherit; color: var(--ink); cursor: pointer; }
.searchrow { display: flex; gap: 8px; }
.searchrow input { flex: 1; }

.pill { display: inline-block; font-size: .72rem; padding: 1px 8px; border-radius: 999px; background: var(--chip); color: var(--ink2); font-weight: 600; vertical-align: middle; text-transform: lowercase; }
.pill.confirmed { background: color-mix(in srgb, var(--good) 18%, var(--card)); color: var(--good); }
.pill.requested { background: color-mix(in srgb, var(--warn) 18%, var(--card)); color: var(--warn); }
.pill.declined, .pill.cancelled { background: color-mix(in srgb, var(--bad) 14%, var(--card)); color: var(--bad); }

/* admin */
.status div + div { margin-top: 6px; }
.switches { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 0 0 8px; }
.switch button { width: 100%; display: flex; align-items: center; gap: 12px; text-align: left; padding: 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font: inherit; cursor: pointer; }
.switch .sw { flex: none; width: 42px; height: 26px; border-radius: 999px; background: var(--line); position: relative; transition: background .15s; }
.switch .sw::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: left .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch.on .sw { background: var(--good); }
.switch.on .sw::after { left: 19px; }
.week { margin-bottom: 18px; }
.weekhead, .dayhead { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.weekhead { padding: 8px 0; border-bottom: 2px solid var(--ink); margin-bottom: 4px; }
.dayrow { padding: 10px 0; border-bottom: 1px solid var(--line); }
.ovs { display: flex; gap: 6px; }
.ovsel { width: auto; min-height: 32px; padding: 4px 8px; font-size: .78rem; border-radius: 999px; background: var(--chip); border-color: transparent; }
.ovsel.on { color: var(--good); }
.ovsel.off { color: var(--muted); }
.ovsel.set { border-color: currentColor; font-weight: 600; }
.op { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: .88rem; padding: 6px 0 0; color: inherit; text-decoration: none; }
.op.off > span:not(.tag) { text-decoration: line-through; color: var(--muted); }
.op .state { color: var(--muted); margin-left: auto; font-size: .8rem; }
.tag { font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; padding: 1px 6px; border-radius: 4px; background: var(--chip); color: var(--ink2); font-weight: 700; }
.op.free .tag { color: var(--good); }
.op.session .tag { color: var(--accent); }
.tag.requested { color: var(--warn); }
.tag.confirmed { color: var(--good); }
details.card summary { cursor: pointer; font-weight: 600; }
.weekdays { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { flex-direction: row; }
.chip input { position: absolute; opacity: 0; width: 0; height: 0; }
.chip span { display: inline-block; padding: 8px 12px; border-radius: 999px; border: 1px solid var(--line); cursor: pointer; font-weight: 600; font-size: .85rem; }
.chip input:checked + span { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chip input:focus-visible + span { outline: 2px solid var(--accent); }

/* guest preview banner */
.preview { background: var(--ink); color: var(--bg); border-radius: 10px; padding: 8px 14px; margin: 4px 0 14px; font-size: .88rem; }
.preview a { color: var(--bg); font-weight: 600; }

/* week view */
main.wide, .top.wide { max-width: 1100px; }
.adminbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.links { margin-top: 18px; }
.pending { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; }
.pending .card { margin: 0; }
.wk-head { display: flex; align-items: center; gap: 6px; margin: 18px 0 8px; }
.wk-title { flex: 1; text-align: center; font-family: Fraunces, Georgia, serif; font-weight: 650; font-size: 1.2rem; }
.btn.on { background: var(--ink); color: var(--bg); }
.presets { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 8px; scrollbar-width: none; }
.preset { flex: none; border-radius: 999px; padding: 7px 12px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font: inherit; font-size: .82rem; font-weight: 600; cursor: pointer; }
.preset.free { box-shadow: inset 4px 0 0 var(--good); }
.preset.session { box-shadow: inset 4px 0 0 var(--accent); }
.preset.armed { background: var(--ink); color: var(--bg); }
.preset.add { border-style: dashed; color: var(--muted); }
.armbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; background: var(--chip); border-radius: 10px; padding: 8px 12px; font-size: .88rem; margin-bottom: 8px; }
.inlinecheck { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; }
.inlinecheck input { width: auto; min-height: 0; accent-color: var(--accent); }

.grid { display: grid; grid-template-columns: 40px repeat(var(--cols), minmax(0, 1fr)); user-select: none; -webkit-user-select: none; touch-action: pan-y; border-bottom: 1px solid var(--line); }
.corner, .dh { position: sticky; top: 0; z-index: 6; background: var(--bg); border-bottom: 1px solid var(--line); }
.dh { text-align: center; font-size: .78rem; font-weight: 700; padding: 6px 0; }
.dh.today { color: var(--accent); }
.dh.past { color: var(--muted); font-weight: 500; }
.dh.nopub::after { content: " ·"; color: var(--muted); }
.gutter { position: relative; height: calc(var(--hours) * 48px); }
.gutter span { position: absolute; right: 6px; transform: translateY(-50%); font-size: .66rem; color: var(--muted); }
.gutter span:first-child { transform: none; }
.col { position: relative; height: calc(var(--hours) * 48px); border-left: 1px solid var(--line);
  background-image: linear-gradient(to bottom, var(--line) 1px, transparent 1px), linear-gradient(to bottom, color-mix(in srgb, var(--line) 45%, transparent) 1px, transparent 1px);
  background-size: 100% 48px, 100% 24px; cursor: crosshair; }
.col.past { background-color: color-mix(in srgb, var(--ink) 5%, transparent); cursor: default; }
.col.armed { cursor: copy; background-color: color-mix(in srgb, var(--accent) 6%, transparent); }
.col.armed:hover { background-color: color-mix(in srgb, var(--accent) 14%, transparent); }
.ev { position: absolute; left: 2px; right: 2px; z-index: 1; overflow: hidden; border-radius: 6px; padding: 2px 4px; font-size: .62rem; line-height: 1.2; color: var(--muted);
  background: repeating-linear-gradient(135deg, var(--chip) 0 5px, color-mix(in srgb, var(--chip) 40%, transparent) 5px 10px); border: 1px solid var(--line); pointer-events: none; }
.blk { position: absolute; left: 3px; right: 3px; z-index: 2; overflow: hidden; border-radius: 8px; padding: 3px 5px; font-size: .7rem; line-height: 1.25; cursor: grab; }
.blk b { display: block; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.blk span, .blk em { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.blk em { font-style: normal; font-weight: 700; text-transform: uppercase; font-size: .58rem; letter-spacing: .04em; opacity: .8; }
.blk.free { background: color-mix(in srgb, var(--good) 20%, var(--card)); border: 1px solid var(--good); }
.blk.session { background: color-mix(in srgb, var(--accent) 26%, var(--card)); border: 1px solid var(--accent); }
.blk.skipped, .blk.paused { background: transparent; border-style: dashed; opacity: .55; }
.blk.skipped b, .blk.skipped span { text-decoration: line-through; }
.blk.conflict { box-shadow: inset 0 0 0 2px var(--bad); }
.blk.ro { cursor: pointer; border-style: dotted; }
.blk.dragging { opacity: .3; }
.blk .rs { position: absolute; left: 0; right: 0; bottom: 0; height: 9px; cursor: ns-resize; }
.blk .rs::after { content: ""; position: absolute; left: 50%; bottom: 3px; width: 18px; height: 2px; margin-left: -9px; border-radius: 2px; background: currentColor; opacity: .35; }
.bkg { position: absolute; left: 38%; right: 3px; z-index: 3; overflow: hidden; border-radius: 7px; padding: 2px 5px; font-size: .66rem; font-weight: 700; white-space: nowrap; text-overflow: ellipsis;
  background: var(--ink); color: var(--bg); cursor: pointer; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.bkg.requested { background: var(--warn); color: #fff; animation: pulse 1.8s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--warn) 30%, transparent); } }
.ghost { position: absolute; left: 3px; right: 3px; z-index: 5; pointer-events: none; border: 2px dashed var(--accent); border-radius: 8px; padding: 2px 5px; font-size: .7rem; font-weight: 700;
  background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); }
.legend { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; font-size: .74rem; color: var(--muted); margin-top: 10px; }
.lg { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: -6px; vertical-align: -2px; }
.lg.free { background: color-mix(in srgb, var(--good) 30%, var(--card)); border: 1px solid var(--good); }
.lg.session { background: color-mix(in srgb, var(--accent) 35%, var(--card)); border: 1px solid var(--accent); }
.lg.ev { background: var(--chip); border: 1px solid var(--line); }
.lg.bkg { background: var(--ink); }
.lg.req { background: var(--warn); }
@media (max-width: 520px) {
  .grid { grid-template-columns: 30px repeat(var(--cols), minmax(0, 1fr)); }
  .gutter span { font-size: .58rem; right: 3px; }
  .blk { padding: 2px 3px; font-size: .62rem; }
  .blk .rs { display: none; }
}

dialog.sheet { border: 0; padding: 0; width: 100%; max-width: 520px; margin: auto auto 0; border-radius: 18px 18px 0 0; background: var(--card); color: var(--ink); max-height: 92vh; }
@media (min-width: 700px) { dialog.sheet { margin: auto; border-radius: 18px; } }
dialog.sheet::backdrop { background: rgba(20, 14, 10, .4); }
.sheet-form { display: flex; flex-direction: column; gap: 12px; padding: 18px 18px max(18px, env(safe-area-inset-bottom)); }
.sheet-form h3 { font-size: 1.15rem; }
.sheet-form p { margin: 0; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.seg label { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; cursor: pointer; gap: 2px; }
.seg label small { color: var(--muted); font-weight: 400; font-size: .76rem; }
.seg label:has(input:checked) { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 9%, var(--card)); }
.seg input { position: absolute; opacity: 0; width: 0; height: 0; }
.pill.booked { background: var(--ink); color: var(--bg); }
.pill.conflict { color: var(--bad); }
.toast { position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 100; max-width: calc(100% - 32px);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-size: .88rem; box-shadow: 0 4px 16px rgba(0,0,0,.2); }
.toast.err { background: var(--bad); color: #fff; border-radius: 12px; }

.envbar { position: fixed; top: 0; left: 50%; transform: translateX(-50%); z-index: 50; background: var(--warn); color: #fff; font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; padding: 1px 10px; border-radius: 0 0 6px 6px; }
