/* Raumkalender – Gestaltung */

:root {
  color-scheme: light dark;
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --hover: #f6f7f9;
  --line: #e3e6eb;
  --line-soft: #eceef2;
  --line-strong: #cfd4dc;
  --text: #1b1e25;
  --muted: #667085;
  --faint: #a4abb8;
  --accent: #3b5bdb;
  --accent-ink: #ffffff;
  --accent-soft: #edf1ff;
  --ok: #0f7b56;
  --danger: #d0342c;
  --danger-soft: #fdecea;
  --warn: #a15c07;
  --warn-soft: #fff8e6;
  --warn-line: #f2d999;
  --now: #e03131;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-lg: 0 12px 40px rgba(16, 24, 40, .22);
  --hh: 52px;   /* Höhe einer Stunde im Zeitraster */
  --gut: 56px;  /* Breite der Uhrzeit-Spalte */
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.4;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #181b21;
    --surface-2: #22262e;
    --hover: #1e2229;
    --line: #2b303a;
    --line-soft: #232831;
    --line-strong: #3a414e;
    --text: #e9ebef;
    --muted: #9aa3b2;
    --faint: #5d6675;
    --accent: #7c93ff;
    --accent-ink: #0c1230;
    --accent-soft: #1f2748;
    --ok: #4cc79a;
    --danger: #ff7b72;
    --danger-soft: #3a1c1b;
    --warn: #f0b757;
    --warn-soft: #2e2613;
    --warn-line: #5a4a1e;
    --now: #ff6b6b;
    --shadow-sm: none;
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, .6);
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, h4, p { margin: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ic { flex: none; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.spacer { flex: 1; }

#app { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }

/* ---------- Bausteine ---------- */

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-sm); }

.btn {
  height: 40px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--text); font-weight: 500; font-size: 14px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  white-space: nowrap; text-decoration: none; transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger-ghost { border-color: transparent; background: none; color: var(--danger); padding: 0 10px; }
.btn.danger-ghost:hover { background: var(--danger-soft); }
.btn.block { width: 100%; }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: none; }
.btn.is-busy, .choice.is-busy { opacity: .6; cursor: progress; }

.iconbtn {
  width: 40px; height: 40px; border-radius: 50%; border: 0; background: none; color: var(--text);
  display: grid; place-items: center; flex: none;
}
.iconbtn:hover { background: var(--surface-2); }
.iconbtn.sm { width: 28px; height: 28px; }

.seg { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: none; padding: 6px 12px; border-radius: 8px; font-size: 14px; font-weight: 500; color: var(--muted); }
.seg button:hover { color: var(--text); }
.seg button.is-active { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, .12); }

.avatar {
  width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--c, var(--accent)); color: #fff;
  font-weight: 600; font-size: 13px; letter-spacing: .02em; display: grid; place-items: center; flex: none;
}
.avatar.sm { width: 32px; height: 32px; font-size: 12px; }

.badge {
  font-style: normal; font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 99px;
  background: var(--accent-soft); color: var(--accent); margin-left: 6px; vertical-align: 1px; white-space: nowrap;
}
.badge.off { background: var(--surface-2); color: var(--muted); }

.alert { padding: 10px 12px; border-radius: 10px; font-size: 14px; }
.alert.error { background: var(--danger-soft); color: var(--danger); }

/* ---------- Formulare ---------- */

.form { display: grid; gap: 14px; }
.form > .seg { justify-self: start; }
.field { display: grid; gap: 6px; min-width: 0; }
.field > span { font-size: 13px; font-weight: 500; color: var(--muted); }
input, select, textarea {
  width: 100%; min-width: 0; height: 44px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 10px;
  background: var(--surface); font-size: 16px; /* 16px verhindert das Hineinzoomen am iPhone */
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
input[type="checkbox"] { width: 20px; height: 20px; padding: 0; flex: none; accent-color: var(--accent); margin: 1px 0 0; }
input[type="date"], input[type="time"] { -webkit-appearance: none; appearance: none; text-align: left; }
input::-webkit-date-and-time-value { text-align: left; }
textarea.code { height: auto; padding: 10px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.inline { display: flex; align-items: center; gap: 8px; }
.inline > span { white-space: nowrap; font-size: 14px; }
.num { width: 76px; flex: none; }
.copyrow { display: flex; gap: 8px; }
.btnrow { display: flex; gap: 8px; flex-wrap: wrap; }
.checkrow { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; }
.linkbtn { border: 0; background: none; padding: 0; color: var(--accent); text-decoration: underline; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: -4px; }
.chip { height: 32px; padding: 0 12px; border-radius: 99px; border: 1px solid var(--line-strong); background: var(--surface); font-size: 13px; }
.chip:hover { background: var(--hover); }
.chip.is-on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }

.subbox { background: var(--surface-2); border-radius: 12px; padding: 12px; display: grid; gap: 10px; }
.wdpick { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.wdpick button { height: 38px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--surface); font-size: 13px; font-weight: 500; padding: 0; }
.wdpick button.is-on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

.rule-summary { display: flex; gap: 8px; align-items: center; font-size: 14px; font-weight: 500; color: var(--accent); }
.check { min-height: 22px; }
.check-line { display: flex; gap: 8px; align-items: center; font-size: 14px; font-weight: 500; }
.check-line.good { color: var(--ok); }
.check-line.bad { color: var(--danger); }
.check-box { background: var(--warn-soft); border: 1px solid var(--warn-line); border-radius: 12px; padding: 12px; font-size: 14px; }
.check-box strong { display: flex; gap: 8px; align-items: center; color: var(--warn); }
.check-box ul { margin: 8px 0 0; padding-left: 26px; }
.check-box p { margin-top: 8px; }

/* Abrechnung */
.btn.is-off { opacity: .45; pointer-events: none; }
.monthpick { display: grid; gap: 12px; }
.monthpick-nav { display: flex; align-items: center; gap: 4px; background: var(--surface-2); border-radius: 12px; padding: 4px; }
.monthpick-nav strong { flex: 1; text-align: center; font-size: 16px; }
.monthpick .chips { margin-top: 0; }
.report-preview { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; display: grid; gap: 10px; min-height: 96px; transition: opacity .12s; }
.report-preview.is-loading { opacity: .5; }
.report-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.rtable { width: 100%; border-collapse: collapse; font-size: 14px; }
.rtable th { text-align: left; font-size: 11.5px; font-weight: 500; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 4px 0 6px; border-bottom: 1px solid var(--line); }
.rtable td { padding: 7px 0; border-bottom: 1px solid var(--line-soft); }
.rtable .num { text-align: right; font-variant-numeric: tabular-nums; width: 84px; }
.rtable .dot { display: inline-block; width: 9px; height: 9px; border-radius: 3px; background: var(--c); margin-right: 8px; }
.rtable tfoot td { font-weight: 650; border-bottom: 0; border-top: 1.5px solid var(--text); padding-top: 8px; }

.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatches button { width: 32px; height: 32px; border-radius: 50%; border: 0; background: var(--c); color: #fff; display: grid; place-items: center; padding: 0; }
.swatches button.is-on { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--c); }

/* ---------- Anmeldung & Einrichtung ---------- */

.auth-page { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; overflow: auto; flex: 1; }
.auth-card { width: min(400px, 100%); padding: 28px; display: grid; gap: 14px; }
.auth-card h1 { font-size: 22px; letter-spacing: -.01em; }
.auth-card h2 { font-size: 14px; margin: 10px 0 -4px; }
.auth-logo { border-radius: 12px; }

.boot { margin: auto; width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Kopfzeile ---------- */

.topbar {
  display: flex; align-items: center; gap: 12px; height: 60px; padding: 0 16px; flex: none;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand img { border-radius: 8px; flex: none; }
.brand-name { font-weight: 650; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }
.navgrp { display: flex; align-items: center; gap: 2px; min-width: 0; flex: 1; margin-left: 8px; }
.today-btn { margin-right: 6px; }
.range { font-size: 18px; font-weight: 600; letter-spacing: -.01em; margin-left: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.range-sub { margin-left: 8px; font-size: 12px; font-weight: 600; color: var(--muted); background: var(--surface-2); padding: 2px 8px; border-radius: 99px; vertical-align: 2px; }

.menu {
  position: fixed; top: 56px; right: 12px; z-index: 60; min-width: 250px; padding: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg);
}
.menu-head { display: grid; padding: 8px 10px 10px; }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px; border: 0; background: none; border-radius: 8px; text-align: left; font-size: 14px; }
.menu-item:hover { background: var(--surface-2); }
.menu-item .ic { color: var(--muted); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }

/* ---------- Layout ---------- */

.layout { flex: 1; min-height: 0; display: flex; }
.main { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; padding: 16px; }
.sidebar { display: none; }
.tabbar, .fab { display: none; }

@media (min-width: 1080px) {
  .sidebar { display: flex; flex-direction: column; gap: 14px; width: 280px; flex: none; padding: 16px 0 16px 16px; overflow-y: auto; }
}

.status { display: flex; gap: 12px; align-items: center; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.status i { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.status.free i { background: var(--ok); box-shadow: 0 0 0 4px color-mix(in srgb, var(--ok) 18%, transparent); }
.status.busy i { background: var(--danger); box-shadow: 0 0 0 4px color-mix(in srgb, var(--danger) 18%, transparent); }
.status strong { display: block; font-size: 14px; }
.status span { font-size: 13px; color: var(--muted); }

.mini { padding: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.mini-head { display: flex; align-items: center; gap: 2px; margin-bottom: 6px; }
.mini-head strong { flex: 1; font-size: 14px; padding-left: 6px; }
.mini-grid { display: grid; grid-template-columns: repeat(7, 1fr); row-gap: 2px; }
.mini-wd { text-align: center; font-size: 11px; color: var(--muted); padding: 4px 0; }
.mini-day { position: relative; aspect-ratio: 1; border: 0; background: none; border-radius: 50%; font-size: 12.5px; padding: 0; }
.mini-day:hover { background: var(--surface-2); }
.mini-day.is-out { color: var(--faint); }
.mini-day.is-range { background: var(--accent-soft); border-radius: 0; }
.mini-day.is-sel { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.mini-day.is-today { background: var(--accent); color: var(--accent-ink); font-weight: 600; border-radius: 50%; }
.mini-day i { position: absolute; left: 50%; bottom: 3px; width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: currentColor; opacity: .45; }

.people { padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.people h4 { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 6px; }
.person { display: flex; align-items: center; gap: 9px; padding: 4px 0; font-size: 14px; }
.person i { width: 10px; height: 10px; border-radius: 3px; background: var(--c); flex: none; }

/* ---------- Woche & Tag (Zeitraster) ---------- */

.tg { flex: 1; min-height: 0; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.tg-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.tg-head {
  position: sticky; top: 0; z-index: 5; display: grid; grid-template-columns: var(--gut) repeat(7, minmax(0, 1fr));
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.tg-single .tg-head { grid-template-columns: repeat(7, minmax(0, 1fr)); }
.tg-hd { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 8px 0 4px; border: 0; background: none; }
.tg-hd-wd { font-size: 11.5px; font-weight: 500; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.tg-hd-num { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; font-size: 17px; font-weight: 500; }
.tg-hd:hover .tg-hd-num { background: var(--surface-2); }
.tg-hd.is-selected .tg-hd-num { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.tg-hd.is-today .tg-hd-wd { color: var(--accent); }
.tg-hd.is-today .tg-hd-num { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.tg-single .tg-hd.is-today:not(.is-selected) .tg-hd-num { background: none; color: var(--accent); box-shadow: inset 0 0 0 1.5px var(--accent); }
.tg-hd-dot { width: 5px; height: 5px; border-radius: 50%; visibility: hidden; }
.tg-single .tg-hd-dot.has { visibility: visible; background: var(--faint); }

.tg-body { display: grid; grid-template-columns: var(--gut) repeat(var(--cols), minmax(0, 1fr)); height: calc(var(--hh) * 24); }
.tg-gutter { position: relative; }
.tg-hour { position: absolute; right: 8px; transform: translateY(-50%); font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.tg-col {
  position: relative; border-left: 1px solid var(--line); cursor: cell; touch-action: pan-y;
  background-image: linear-gradient(to bottom, var(--line-soft) 1px, transparent 1px);
  background-size: 100% var(--hh);
}
.tg-col.is-today { background-color: color-mix(in srgb, var(--accent) 5%, transparent); }

.ev {
  position: absolute; left: 2px; right: 5px; z-index: 1; min-height: 16px; overflow: hidden;
  display: flex; flex-direction: column; text-align: left; padding: 3px 7px; border: 0;
  border-left: 3px solid var(--c); border-radius: 6px; font-size: 12px; line-height: 1.3;
  background: color-mix(in srgb, var(--c) 15%, var(--surface)); color: var(--text);
  box-shadow: 0 0 0 1px var(--surface);
}
.ev:hover { background: color-mix(in srgb, var(--c) 24%, var(--surface)); }
.ev.is-mine { background: color-mix(in srgb, var(--c) 24%, var(--surface)); }
.ev.is-mine:hover { background: color-mix(in srgb, var(--c) 32%, var(--surface)); }
.ev-name { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; color: color-mix(in srgb, var(--c) 62%, var(--text)); flex: none; }
.ev-name .ic { margin-left: 4px; vertical-align: -1px; opacity: .8; }
.ev-time { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; font-variant-numeric: tabular-nums; flex: none; }
.ev-title { color: var(--muted); overflow: hidden; }
.ev-sm .ev-title, .ev-xs .ev-title { display: none; }
.ev-xs { flex-direction: row; align-items: center; gap: 6px; padding-top: 0; padding-bottom: 0; font-size: 11px; }
.ev-xs .ev-name { flex: 0 1 auto; }
.tg-single .ev { font-size: 13px; padding: 4px 10px; }

.ev-ghost {
  position: absolute; left: 2px; right: 5px; z-index: 2; pointer-events: none; padding: 3px 7px; border-radius: 6px;
  font-size: 12px; font-weight: 600; color: var(--accent); font-variant-numeric: tabular-nums;
  background: color-mix(in srgb, var(--accent) 16%, var(--surface)); border: 1.5px dashed var(--accent);
}
.now-line { position: absolute; left: 0; right: 0; height: 2px; margin-top: -1px; z-index: 3; background: var(--now); pointer-events: none; }
.now-line::before { content: ""; position: absolute; left: -5px; top: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--now); }

/* ---------- Monat ---------- */

.mv {
  flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr));
  grid-template-rows: auto repeat(var(--rows), minmax(0, 1fr));
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px; overflow: hidden;
}
.mv-wd { padding: 9px 0 7px; text-align: center; font-size: 11.5px; font-weight: 500; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.mv-cell { min-height: 0; overflow: hidden; display: flex; flex-direction: column; gap: 2px; padding: 4px 4px 2px; border-top: 1px solid var(--line); border-left: 1px solid var(--line); cursor: pointer; }
.mv-cell:nth-child(7n + 1) { border-left: 0; }
.mv-cell:hover { background: var(--hover); }
.mv-num { width: 26px; height: 26px; flex: none; align-self: flex-start; display: grid; place-items: center; border: 0; background: none; border-radius: 50%; font-size: 13px; font-weight: 500; padding: 0; }
.mv-num:hover { background: var(--surface-2); }
.mv-cell.is-out .mv-num { color: var(--faint); }
.mv-cell.is-out .mv-ev { opacity: .55; }
.mv-cell.is-today .mv-num { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.mv-evs { display: flex; flex-direction: column; gap: 2px; min-height: 0; }
.mv-ev {
  flex: none; height: 20px; display: flex; align-items: center; gap: 5px; padding: 0 6px; overflow: hidden; white-space: nowrap;
  border: 0; border-radius: 5px; font-size: 12px; text-align: left;
  background: color-mix(in srgb, var(--c) 15%, var(--surface)); color: var(--text);
}
.mv-ev:hover { background: color-mix(in srgb, var(--c) 26%, var(--surface)); }
.mv-ev-t { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; flex: none; }
.mv-ev-n { font-weight: 600; overflow: hidden; text-overflow: ellipsis; color: color-mix(in srgb, var(--c) 62%, var(--text)); }
.mv-more { flex: none; height: 20px; padding: 0 6px; border: 0; background: none; text-align: left; font-size: 11.5px; font-weight: 500; color: var(--muted); border-radius: 5px; }
.mv-more:hover { background: var(--surface-2); color: var(--text); }
.mv-dots { display: none; }

/* ---------- Liste ---------- */

.lv { flex: 1; min-height: 0; overflow-y: auto; margin: -16px; }
.lv-inner { max-width: 720px; margin: 0 auto; padding: 16px; display: flex; flex-direction: column; gap: 18px; }
.lv-filter { align-self: flex-start; }
.lv-date { font-size: 13px; font-weight: 500; color: var(--muted); margin: 0 0 6px 4px; }
.lv-date b { color: var(--accent); font-weight: 650; }
.lv-rows { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.lv-row { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 58px; padding: 9px 14px; border: 0; border-top: 1px solid var(--line-soft); background: none; text-align: left; }
.lv-row:first-child { border-top: 0; }
.lv-row:hover { background: var(--hover); }
.lv-time { display: flex; flex-direction: column; width: 44px; flex: none; font-size: 13px; font-variant-numeric: tabular-nums; }
.lv-time span { color: var(--muted); }
.lv-bar { width: 4px; align-self: stretch; border-radius: 2px; background: var(--c); flex: none; }
.lv-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.lv-name { font-weight: 600; }
.lv-sub { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lv-rep { color: var(--muted); display: grid; }
.lv-more { margin-top: -4px; }
.empty { display: grid; gap: 12px; justify-items: center; text-align: center; padding: 56px 16px; color: var(--muted); }

/* ---------- Dialoge ---------- */

dialog.dlg {
  border: 0; padding: 0; border-radius: 18px; background: var(--surface); color: var(--text);
  width: min(500px, calc(100vw - 32px)); max-height: min(88vh, 800px); max-height: min(88dvh, 800px);
  box-shadow: var(--shadow-lg); overflow: hidden;
}
dialog.dlg.dlg-sm { width: min(420px, calc(100vw - 32px)); }
dialog.dlg[open] { display: flex; flex-direction: column; animation: pop .16s ease-out; }
dialog.dlg::backdrop { background: rgba(12, 16, 24, .5); }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
@keyframes sheet { from { transform: translateY(40%); opacity: 0; } }
.dlg-head { display: flex; align-items: center; padding: 14px 12px 4px 20px; flex: none; }
.dlg-title { flex: 1; font-size: 18px; letter-spacing: -.01em; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dlg-body { flex: 1; min-height: 0; overflow-y: auto; padding: 10px 20px 20px; }
.dlg-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 12px 20px; border-top: 1px solid var(--line); flex: none; }

.detail { display: grid; gap: 12px; }
.detail-who { display: flex; align-items: center; gap: 12px; padding-bottom: 4px; }
.detail-who > i { width: 6px; align-self: stretch; min-height: 36px; border-radius: 3px; background: var(--c); flex: none; }
.detail-who strong { font-size: 19px; letter-spacing: -.01em; }
.detail-who div span { display: block; color: var(--muted); }
.detail-row { display: flex; align-items: center; gap: 10px; }
.detail-row .ic { color: var(--muted); }
.confirm-q { font-weight: 600; }

.choices { display: grid; gap: 8px; }
.choice { display: grid; gap: 2px; text-align: left; padding: 12px 14px; border: 1px solid var(--line-strong); border-radius: 12px; background: var(--surface); }
.choice:hover { border-color: var(--accent); background: var(--accent-soft); }

.userlist { display: grid; }
.userrow { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 4px; border: 0; border-bottom: 1px solid var(--line-soft); background: none; text-align: left; }
.userrow:last-child { border-bottom: 0; }
.userrow:hover { background: var(--hover); }
.userrow-main { flex: 1; min-width: 0; display: grid; }
.userrow .ic { color: var(--faint); }

.toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: max-content; max-width: calc(100vw - 32px); }
.toast { display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-radius: 12px; font-size: 14px; font-weight: 500; background: #1d222c; color: #fff; box-shadow: var(--shadow-lg); animation: pop .18s ease-out; transition: opacity .25s; }
.toast.error { background: #b3261e; }
.toast.out { opacity: 0; }

/* ---------- Tablet ---------- */

@media (max-width: 1000px) {
  .brand-name { display: none; }
  .navgrp { margin-left: 0; }
}
@media (max-width: 820px) {
  .range-sub { display: none; }
  .range { font-size: 16px; }
  .seg.views button { padding: 6px 9px; }
  .book-btn { width: 40px; padding: 0; }
  .book-btn span { display: none; }
}

/* ---------- Handy ---------- */

@media (max-width: 640px) {
  :root { --hh: 48px; --gut: 42px; }

  .topbar {
    display: grid; height: auto; padding: 8px 8px 4px 12px; gap: 2px 6px;
    grid-template-columns: auto 1fr auto auto;
    grid-template-areas: "brand brand today avatar" "prev range range next";
    padding-top: calc(8px + env(safe-area-inset-top));
  }
  .brand { grid-area: brand; }
  .brand-name { display: block; max-width: none; }
  .navgrp { display: contents; }
  .today-btn { grid-area: today; height: 34px; margin: 0; }
  .avatar { grid-area: avatar; justify-self: end; margin-right: 4px; }
  .nav-prev { grid-area: prev; }
  .nav-next { grid-area: next; justify-self: end; }
  .range { grid-area: range; text-align: center; margin: 0; align-self: center; font-size: 16px; }
  .range-sub { display: inline; }
  .seg.views, .book-btn { display: none; }
  .menu { top: calc(52px + env(safe-area-inset-top)); right: 8px; }

  .main { padding: 0; }
  .tg, .mv { border: 0; border-radius: 0; }
  .lv { margin: 0; }
  .lv-inner { padding: 12px 12px 96px; }

  .tabbar {
    display: grid; grid-template-columns: repeat(4, 1fr); flex: none;
    background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
  }
  .tabbar button { display: flex; flex-direction: column; align-items: center; gap: 2px; height: 56px; justify-content: center; border: 0; background: none; color: var(--muted); font-size: 11px; font-weight: 500; }
  .tabbar button.is-active { color: var(--accent); }
  .fab {
    display: grid; place-items: center; position: fixed; right: 16px; bottom: calc(72px + env(safe-area-inset-bottom)); z-index: 20;
    width: 56px; height: 56px; border-radius: 18px; border: 0; background: var(--accent); color: var(--accent-ink);
    box-shadow: 0 6px 20px color-mix(in srgb, var(--accent) 45%, transparent), 0 2px 6px rgba(0, 0, 0, .2);
  }
  .fab:active { transform: scale(.96); }

  .tg-hd { padding-top: 6px; }
  .tg-hd-num { width: 32px; height: 32px; font-size: 16px; }
  .tg:not(.tg-single) .ev { left: 1px; right: 2px; padding: 2px 3px; border-left-width: 2px; font-size: 10.5px; border-radius: 4px; }
  .tg:not(.tg-single) .ev-time, .tg:not(.tg-single) .ev-title, .tg:not(.tg-single) .ev-name .ic { display: none; }
  .tg:not(.tg-single) .ev-name { white-space: normal; line-height: 1.2; }
  .tg:not(.tg-single) .ev-name .w { display: block; overflow: hidden; text-overflow: ellipsis; }
  .tg-hour { right: 5px; font-size: 10px; }

  .mv-cell { align-items: center; padding: 6px 0 2px; }
  .mv-num { align-self: center; width: 30px; height: 30px; font-size: 14px; }
  .mv-evs { display: none; }
  .mv-dots { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 3px; padding: 0 4px; }
  .mv-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--c); }
  .mv-dots b { font-size: 10px; line-height: 6px; color: var(--muted); }

  dialog.dlg, dialog.dlg.dlg-sm {
    width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: 20px 20px 0 0;
    max-height: 92vh; max-height: 92dvh;
  }
  dialog.dlg[open] { animation: sheet .2s ease-out; }
  .dlg-foot { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
  .toasts { bottom: calc(84px + env(safe-area-inset-bottom)); }
  .auth-card { padding: 22px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
