:root {
  --bg: #f3efe6;
  --bg-2: #e7e0d2;
  --paper: #fffcf6;
  --ink: #1c1915;
  --muted: #6f675c;
  --line: #e4d9c8;
  --accent: #b8431f;
  --accent-ink: #fff8f4;
  --green: #1f6a4e;
  --shadow: 0 18px 50px rgba(48, 32, 16, 0.08);
  --radius: 18px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: "Segoe UI", system-ui, sans-serif;
  --safe-b: env(safe-area-inset-bottom);
  --tab: calc(64px + var(--safe-b));
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #141311;
  --bg-2: #221f1b;
  --paper: #221f1b;
  --ink: #f6f1e8;
  --muted: #b7ad9f;
  --line: #3a342c;
  --accent: #ef7a45;
  --accent-ink: #1c100c;
  --green: #8fd0b0;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
h1, h2, h3 { font-family: var(--serif); font-weight: 560; letter-spacing: -0.03em; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.btn, .iconbtn, .chip {
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: 999px;
  min-height: 44px;
  padding: 0 16px;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--accent); }
.iconbtn { width: 44px; padding: 0; }
.chip { min-height: 36px; padding: 0 12px; }
.chip.on, .nav button.active, .tabbar button.active { background: var(--ink); color: var(--bg); border-color: var(--ink); }

.site-nav, .site-foot {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.site-nav { min-height: 76px; }
.site-nav nav, .actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.site-nav a { text-decoration: none; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); font-family: var(--serif); font-size: 28px; text-decoration: none; }
.mark {
  width: 28px; height: 28px; border-radius: 9px; background: var(--accent); position: relative; display: inline-block;
}
.mark:before { content: ""; position: absolute; width: 10px; height: 10px; border-radius: 50%; background: var(--accent-ink); left: 9px; top: 6px; }
.mark:after { content: ""; position: absolute; left: 6px; right: 6px; height: 2px; background: var(--accent-ink); bottom: 7px; }

.marketing { width: min(1120px, calc(100% - 32px)); margin: 0 auto 64px; }
.hero { display: grid; grid-template-columns: 1.2fr .8fr; gap: 32px; align-items: center; padding: 18px 0 28px; }
.kicker { text-transform: uppercase; letter-spacing: .14em; font-size: 12px; color: var(--muted); margin: 0 0 8px; }
.hero h1 { font-size: clamp(42px, 6vw, 76px); line-height: .95; margin: 0 0 16px; }
.lead { font-size: 19px; max-width: 62ch; }
.marketing h2 { font-size: 36px; margin: 28px 0 14px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid.two { grid-template-columns: 1fr 1fr; }
.card, .band {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.card h3 { margin: 0 0 6px; font-size: 24px; }
.card p, .band p { margin: 0; color: var(--muted); }
.feature-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.feature-list li { display: grid; gap: 2px; padding: 12px 0; border-top: 1px solid var(--line); }
.feature-list span { color: var(--muted); }
.band { margin-top: 28px; }
.site-foot { min-height: 72px; color: var(--muted); }
.prose { width: min(760px, calc(100% - 32px)); margin: 18px auto 64px; }
.prose h1 { font-size: 48px; }
.phone {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 32px;
  padding: 16px;
  box-shadow: var(--shadow);
  min-height: 420px;
}
.phone-top, .phone-row { display: flex; justify-content: space-between; gap: 12px; }
.phone-top { color: var(--muted); margin-bottom: 18px; }
.phone-cap { font-family: var(--serif); font-size: 42px; margin-bottom: 16px; }
.phone-row { border-left: 4px solid var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--paper)); border-radius: 14px; padding: 12px; margin-top: 8px; }
.phone-row.c2 { border-color: #1f4e79; }
.phone-row.c3 { border-color: var(--green); }
.phone-row small { color: var(--muted); }

.book { width: min(560px, calc(100% - 28px)); margin: 24px auto 48px; display: grid; gap: 12px; }
.book-form, .stack { display: grid; gap: 12px; }
label { display: grid; gap: 6px; font-size: 14px; color: var(--muted); }
input, select, textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  min-height: 44px;
  padding: 10px 12px;
}
input[type="checkbox"], input[type="radio"] {
  width: 18px;
  height: 18px;
  min-height: 18px;
  padding: 0;
  accent-color: var(--accent);
}
input[type="color"] { width: 64px; min-height: 44px; padding: 4px; }
label.checks, .side-cals label, label.chip {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  width: auto;
}
textarea { min-height: 90px; resize: vertical; }
.slots { display: flex; flex-wrap: wrap; gap: 8px; }
.hp { position: absolute; left: -9999px; }
.muted, .hint { color: var(--muted); }
.booting { padding: 48px 20px; font-family: var(--serif); font-size: 42px; }

.shell { min-height: 100dvh; display: grid; grid-template-columns: 232px 1fr; }
.side {
  padding: 18px 14px;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: color-mix(in srgb, var(--bg-2) 55%, var(--bg));
}
.nav, .tabbar { display: grid; gap: 6px; }
.nav button, .tabbar button {
  text-align: left;
  border: 0;
  background: transparent;
  min-height: 44px;
  border-radius: 12px;
  padding: 0 12px;
  color: var(--ink);
}
.side-cals { display: grid; gap: 6px; }
.side-cals label { color: var(--ink); }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.sync { margin-top: auto; color: var(--muted); font-size: 13px; }
.main { min-width: 0; display: flex; flex-direction: column; }
.top { position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(10px); padding: max(10px, env(safe-area-inset-top)) 16px 10px; border-bottom: 1px solid var(--line); }
.top-row { display: flex; align-items: center; gap: 8px; }
.top-row h1 { flex: 1; font-size: 28px; margin: 0; text-transform: capitalize; }
.quick { display: flex; gap: 8px; margin-top: 10px; }
.quick input { border-radius: 999px; background: var(--paper); }
#view { padding: 16px 16px calc(var(--tab) + 16px); }
.tabbar {
  display: none;
  position: fixed;
  left: 0; right: 0; bottom: 0;
  grid-template-columns: repeat(5, 1fr);
  background: var(--paper);
  border-top: 1px solid var(--line);
  padding-bottom: var(--safe-b);
  z-index: 6;
}
.tabbar button { text-align: center; font-size: 12px; padding: 6px 2px; }

.cap, .notice, .deadline, .block, .month, .agenda-day, .panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.cap { padding: 16px; display: flex; justify-content: space-between; gap: 12px; align-items: end; margin-bottom: 12px; }
.cap b { font-family: var(--serif); font-size: 34px; display: block; line-height: 1; }
.notice { padding: 12px 14px; margin-bottom: 12px; display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.banner { display: flex; justify-content: space-between; gap: 10px; align-items: center; margin-bottom: 12px; color: var(--muted); }
.allday { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.pill { border: 0; border-radius: 999px; min-height: 36px; padding: 0 12px; background: var(--bg-2); color: var(--ink); }
.timeline { position: relative; margin-left: 52px; }
.hour { height: 56px; border-top: 1px solid var(--line); position: relative; }
.hour span { position: absolute; left: -52px; top: -8px; width: 44px; text-align: right; color: var(--muted); font-size: 12px; }
.block {
  position: absolute;
  left: 6px; right: 8px;
  padding: 6px 8px;
  overflow: hidden;
  text-align: left;
  border-left: 4px solid var(--c, var(--accent));
  background: color-mix(in srgb, var(--c, var(--accent)) 16%, var(--paper));
  border-radius: 12px;
}
.block small, .meta { color: var(--muted); display: block; }
.block.done { opacity: .55; text-decoration: line-through; }
.now { position: absolute; left: 0; right: 0; height: 2px; background: var(--accent); z-index: 3; box-shadow: 0 0 0 1px var(--accent); }
.now:before { content: ""; position: absolute; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); top: -4px; left: -2px; }
.list { display: grid; gap: 8px; }
.item {
  display: grid;
  grid-template-columns: 10px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--paper);
  text-align: left;
  width: 100%;
}
.week-grid { display: none; }
.week-cols { display: grid; grid-template-columns: 52px repeat(7, 1fr); }
.week-head, .week-col { min-width: 0; }
.week-head-row { position: sticky; top: 118px; z-index: 4; background: var(--bg); padding-bottom: 4px; }
.week-head { text-align: center; font-size: 13px; padding-bottom: 6px; }
.week-head.on { color: var(--accent); font-weight: 700; }
.week-col { position: relative; border-left: 1px solid var(--line); background-image: repeating-linear-gradient(to bottom, var(--line) 0 1px, transparent 1px 48px); }
.month { display: grid; grid-template-columns: repeat(7, 1fr); overflow: hidden; }
.month b, .cell { min-height: 86px; padding: 6px; border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.month b { min-height: 0; text-align: center; color: var(--muted); font-weight: 560; font-family: var(--sans); position: sticky; top: 118px; background: var(--paper); z-index: 2; }
.cell { background: transparent; text-align: left; border-right: 0; border-bottom: 0; }
.cell.off { color: var(--muted); }
.cell.on { box-shadow: inset 0 0 0 2px var(--accent); }
.dots { display: flex; gap: 3px; margin-top: 6px; }
.agenda-day { padding: 12px; margin-bottom: 10px; }
.agenda-day h3 { margin: 0 0 8px; font-size: 20px; }
.panel { padding: 16px; margin-bottom: 12px; display: grid; gap: 10px; }
.panel h2 { margin: 0; font-size: 26px; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.checks { display: flex; flex-wrap: wrap; gap: 8px; }
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tab) + 8px);
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--bg);
  border-radius: 999px;
  padding: 10px 14px;
  z-index: 20;
  display: flex;
  gap: 10px;
  align-items: center;
}
.sheet-back { position: fixed; inset: 0; background: rgba(22, 16, 12, .46); z-index: 30; display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: min(640px, 100%); max-height: 92dvh; overflow: auto; background: var(--paper); border-radius: 22px 22px 0 0; padding: 16px 16px calc(16px + var(--safe-b)); display: grid; gap: 10px; }
.sheet h2 { margin: 0; }
.sheet-actions { display: flex; flex-wrap: wrap; gap: 8px; }

@media (min-width: 900px) {
  .week-grid { display: block; }
  .week-agenda { display: none; }
  #view { padding-bottom: 28px; }
  .sheet-back { align-items: center; }
  .sheet { border-radius: 22px; max-height: min(88dvh, 820px); }
}
@media (max-width: 899px) {
  .shell { grid-template-columns: 1fr; }
  .side { display: none; }
  .tabbar { display: grid; }
  .hero, .grid, .grid.two, .split { grid-template-columns: 1fr; }
  .site-nav { width: min(1120px, calc(100% - 20px)); }
  .hero h1 { font-size: 46px; }
  .top-row h1 { font-size: 22px; }
  .quick { flex-direction: column; }
}
