:root {
  --purple: #56176a;
  --purple-hover: #451254;
  --purple-deep: #3c0e4a;
  --purple-tint: #f3ecf7;
  --purple-line: #dccbe6;
  --ink: #211c26;
  --ink-2: #43394d;
  --muted: #6b6473;
  --subtle: #8c8593;
  --border: #ece8f0;
  --border-strong: #d8d1df;
  --canvas: #f4f2f6;
  --card: #ffffff;
  --row-alt: #fbfafc;
  --free-fg: #1f7a52;
  --free-bg: #e4f3ec;
  --taken-fg: #6e5e7a;
  --taken-bg: #f1edf5;
  --err-bg: #fbeaea;
  --err-fg: #a12b2b;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(33, 28, 38, 0.04), 0 2px 8px rgba(33, 28, 38, 0.04);
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
}

*,
*::before,
*::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--canvas); font-size: 15px; line-height: 1.5; }
.wrap { max-width: 880px; margin: 0 auto; padding: 0 16px; }
h1, h2 { margin: 0; line-height: 1.25; }
button { font: inherit; }

/* ── Header ─────────────────────────────────────────────────────────── */
.topbar { background: linear-gradient(180deg, var(--purple) 0%, var(--purple-deep) 100%); color: #fff; padding-top: env(safe-area-inset-top); }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 64px; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark { flex: 0 0 auto; width: 34px; height: 34px; border-radius: 8px; background: #fff; color: var(--purple); display: grid; place-items: center; font-weight: 700; font-size: 18px; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-title { font-weight: 600; font-size: 16px; white-space: nowrap; }
.brand-sub { font-size: 12px; opacity: 0.8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who { display: flex; align-items: center; gap: 12px; min-width: 0; }
.who-name { font-size: 14px; opacity: 0.9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.btn-signout { background: rgba(255, 255, 255, 0.12); color: #fff; border: 1px solid rgba(255, 255, 255, 0.3); border-radius: 6px; padding: 6px 12px; font-size: 13px; cursor: pointer; white-space: nowrap; }
.btn-signout:hover { background: rgba(255, 255, 255, 0.2); }

/* ── Blocks ─────────────────────────────────────────────────────────── */
.notice { margin: 20px 0 16px; padding: 16px 18px; background: var(--card); border: 1px solid var(--border); border-left: 4px solid var(--purple); border-radius: var(--radius); box-shadow: var(--shadow); }
.notice h1 { font-size: 18px; margin-bottom: 6px; }
.notice p { margin: 0; color: var(--ink-2); }

.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 16px; }
.placeholder { padding: 28px 16px; text-align: center; color: var(--muted); }
.signin { padding: 32px 20px; text-align: center; }
.signin h2 { font-size: 18px; margin-bottom: 6px; }
.signin p { margin: 0 0 20px; color: var(--muted); }

.label { display: block; font-size: 12px; font-weight: 600; letter-spacing: 0.4px; text-transform: uppercase; color: var(--subtle); margin-bottom: 4px; }
.me { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }
.me > div { padding: 14px 18px; }
.me-who { border-right: 1px solid var(--border); }
.me-name { font-size: 17px; font-weight: 600; }
.my-list { display: flex; flex-wrap: wrap; gap: 6px; }
.my-item { display: inline-flex; align-items: center; gap: 6px; background: var(--purple-tint); border: 1px solid var(--purple-line); color: var(--purple-deep); border-radius: 999px; padding: 3px 10px; font-size: 13px; font-weight: 600; cursor: pointer; }
.my-item:hover { border-color: var(--purple); }
.my-empty { color: var(--muted); font-size: 14px; }

/* ── Buttons ────────────────────────────────────────────────────────── */
.btn { border-radius: 6px; border: 1px solid transparent; padding: 8px 16px; cursor: pointer; font-weight: 600; font-size: 14px; line-height: 1.2; }
.btn.primary { background: var(--purple); color: #fff; }
.btn.primary:hover { background: var(--purple-hover); }
.btn.secondary { background: #fff; color: var(--err-fg); border-color: var(--border-strong); }
.btn.secondary:hover { border-color: var(--err-fg); }
.btn.large { padding: 12px 22px; font-size: 15px; }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn:focus-visible, .day-tab:focus-visible, .my-item:focus-visible, .btn-signout:focus-visible { outline: 2px solid var(--purple); outline-offset: 2px; }

/* ── Day picker ─────────────────────────────────────────────────────── */
.days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; margin-bottom: 12px; }
.day-tab { display: flex; flex-direction: column; align-items: center; gap: 1px; background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 8px 4px; cursor: pointer; color: var(--ink); }
.day-tab:hover { border-color: var(--border-strong); }
.day-tab .dow { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--subtle); }
.day-tab .dom { font-size: 18px; font-weight: 700; line-height: 1.2; }
.day-tab .meta { font-size: 11px; color: var(--muted); white-space: nowrap; }
.day-tab.mine .meta { color: var(--purple); font-weight: 600; }
.day-tab.full .meta { color: var(--err-fg); }
.day-tab.past { opacity: 0.55; }
.day-tab[aria-selected="true"] { background: var(--purple); border-color: var(--purple); color: #fff; }
.day-tab[aria-selected="true"] .dow,
.day-tab[aria-selected="true"] .meta { color: rgba(255, 255, 255, 0.85); }

/* ── Day table ──────────────────────────────────────────────────────── */
.day { overflow: hidden; }
.day-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 6px 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.day-head h2 { font-size: 17px; }
.day-meta { font-size: 13px; color: var(--muted); }
.day-meta strong { color: var(--ink); }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 18px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--subtle); font-weight: 600; background: var(--row-alt); }
tbody tr:last-child td { border-bottom: 0; }
td.spot { font-weight: 700; font-variant-numeric: tabular-nums; width: 1%; white-space: nowrap; }
td.name { color: var(--ink); }
td.name.empty { color: var(--subtle); }
th.action, td.action { text-align: right; width: 1%; white-space: nowrap; }
tr.mine td { background: var(--purple-tint); }
tr.mine td.spot { box-shadow: inset 3px 0 0 var(--purple); }

.pill { display: inline-block; border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: 600; }
.pill.free { background: var(--free-bg); color: var(--free-fg); }
.pill.taken { background: var(--taken-bg); color: var(--taken-fg); }
.pill.you { background: var(--purple); color: #fff; }

.footnote { color: var(--subtle); font-size: 12px; text-align: center; margin: 24px 0 calc(32px + env(safe-area-inset-bottom)); }

/* ── Toast ──────────────────────────────────────────────────────────── */
.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%); width: max-content; max-width: calc(100% - 32px); padding: 10px 16px; border-radius: 8px; font-size: 14px; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15); z-index: 10; background: var(--ink); color: #fff; }
.toast.ok { background: #fff; color: var(--free-fg); border: 1px solid #bfe3d1; }
.toast.error { background: var(--err-bg); color: var(--err-fg); border: 1px solid #efc4c4; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ── Phone ──────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  body { font-size: 14px; }
  .brand-sub, .who-name { display: none; }
  .notice { margin-top: 14px; padding: 14px; }
  .notice h1 { font-size: 16px; }
  .me { grid-template-columns: 1fr; }
  .me-who { border-right: 0; border-bottom: 1px solid var(--border); }
  .me > div { padding: 12px 14px; }
  .days { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scroll-padding-inline: 16px; margin: 0 -16px 12px; padding: 2px 16px 4px; scrollbar-width: none; }
  .days::-webkit-scrollbar { display: none; }
  .day-tab { flex: 0 0 72px; scroll-snap-align: start; }
  .day-head { padding: 12px 14px; }
  th, td { padding: 10px 10px; }
  th:first-child, td:first-child { padding-left: 14px; }
  th:last-child, td:last-child { padding-right: 14px; }
  th { font-size: 11px; }
  .btn { padding: 8px 12px; }
}
