:root {
  color-scheme: light dark;
  --bg: #f6f1ea;
  --ink: #1c1712;
  --muted: #6b5f55;
  --line: #e4d8cc;
  --card: #fffdf9;
  --accent: #d35a1f;
  --accent-ink: #fffaf6;
  --danger: #b42318;
  --holiday: #c42b1c;
  --ok: #2f6f4e;
  --shadow: 0 10px 30px rgba(28, 23, 18, 0.06);
  --radius: 18px;
  --pad: 18px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font: ui-sans-serif, system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14110f;
    --ink: #f3ebe3;
    --muted: #b3a79c;
    --line: #2c2622;
    --card: #1c1815;
    --accent: #ee7a3a;
    --accent-ink: #1c110c;
    --danger: #ff7a70;
    --holiday: #ff8a7a;
    --ok: #7dcaa3;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.45;
  padding: calc(12px + var(--safe-t)) 14px calc(20px + var(--safe-b));
}

.shell { max-width: 920px; margin: 0 auto; }
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 18px;
}
.brand {
  display: flex;
  align-items: baseline;
  gap: 8px;
  text-decoration: none;
  color: inherit;
}
.mark {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: var(--accent);
  transform: rotate(12deg);
  display: inline-block;
}
.name {
  font-size: 22px;
  letter-spacing: -0.04em;
  font-weight: 700;
}
.nav { display: flex; gap: 8px; flex-wrap: wrap; }
.nav a, .chip, .ghost, .primary, .danger {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  border-radius: 999px;
  padding: 8px 14px;
  text-decoration: none;
  font: inherit;
  cursor: pointer;
  min-height: 40px;
}
.nav a.is-on, .chip.is-on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.ghost { background: transparent; }

.kicker {
  text-transform: lowercase;
  letter-spacing: 0.16em;
  color: var(--muted);
  font-size: 12px;
  margin: 0 0 6px;
}
h1 { font-size: clamp(28px, 6vw, 44px); letter-spacing: -0.04em; line-height: 1.1; margin: 0 0 10px; }
.lead, .muted { color: var(--muted); }
.hero { padding: 12px 0 28px; }
.cards { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.cards a {
  display: block;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow);
}
.cards h2 { margin: 0 0 6px; font-size: 20px; }

.cal-head, .cal-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}
.cal-nav h2 { margin: 0; font-size: 18px; flex: 1; text-align: center; }
.views { display: flex; gap: 6px; }

.cal-root { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.month-grid, .week-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}
.dow, .cell {
  padding: 8px 6px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  min-height: 88px;
}
.dow { min-height: 0; font-size: 12px; color: var(--muted); text-align: center; }
.cell { cursor: pointer; }
.cell.out { opacity: 0.42; }
.num { font-weight: 650; }
.cell.red .num, .cell.red { color: var(--holiday); }
.cell.today { outline: 2px solid var(--accent); outline-offset: -2px; }
.ev {
  display: block;
  width: 100%;
  text-align: left;
  margin-top: 4px;
  padding: 4px 6px;
  border: 0;
  border-radius: 8px;
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  color: inherit;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ev.done { text-decoration: line-through; opacity: 0.7; }
.ev.cancelled { color: var(--muted); }

.day-list { padding: 8px; }
.day-row {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 10px;
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
}
.day-row time { color: var(--muted); font-size: 13px; }
.empty { padding: 28px 16px; color: var(--muted); text-align: center; }

.sheet {
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--card);
  color: var(--ink);
  width: min(92vw, 420px);
  padding: 0;
  box-shadow: var(--shadow);
}
.sheet::backdrop { background: rgba(20, 16, 12, 0.45); }
.sheet-body { padding: 18px; }
.sheet h3 { margin: 0 0 8px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }

@media (max-width: 640px) {
  .dow { font-size: 11px; }
  .cell { min-height: 64px; padding: 6px 4px; }
  .ev { font-size: 11px; }
}
