:root,
[data-theme="light"] {
  color-scheme: light;
  --canvas: #f8fafc;
  --ink: #18181b;
  --secondary: #3f3f46;
  --muted: #71717a;
  --line: #e4e4e7;
  --panel: #ffffff;
  --fill: #ffffff;
  --hover: #f4f4f5;
  --shadow: 0 1px 2px rgba(9, 9, 11, 0.04);
  --accent: #9e3b24;
  --accent-ink: #ffffff;
  --dot: #10b981;
  --shield: #10b981;
  --duty-bg: #ffffff;
  --duty-ink: #18181b;
  --duty-line: #e4e4e7;
  --duty-accent: #10b981;
  --clash-bg: #fffbeb;
  --clash: #b45309;
  --clash-line: #f59e0b;
  --away-ink: #64748b;
  --ghost: #fafafa;
  --ghost-line: #cbd5e1;
  --ghost-icon: #71717a;
  --badge-bg: #f1f5f9;
  --badge-ink: #334155;
  --badge-icon: #52525b;
  --pill: #f4f4f5;
  --out: #f8fafc;
  --out-ink: #a1a1aa;
  --today-pill: #18181b;
  --today-ink: #ffffff;
}

[data-theme="dark"] {
  color-scheme: dark;
  --canvas: #09090b;
  --ink: #fafafa;
  --secondary: #d4d4d8;
  --muted: #a1a1aa;
  --line: #27272a;
  --panel: #18181b;
  --fill: #18181b;
  --hover: #27272a;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  --accent: #9e3b24;
  --accent-ink: #ffffff;
  --dot: #10b981;
  --shield: #10b981;
  --duty-bg: #18181b;
  --duty-ink: #fafafa;
  --duty-line: #3f3f46;
  --duty-accent: #10b981;
  --clash-bg: #2a2112;
  --clash: #fbbf24;
  --clash-line: #f59e0b;
  --away-ink: #a1a1aa;
  --ghost: #09090b;
  --ghost-line: #3f3f46;
  --ghost-icon: #a1a1aa;
  --badge-bg: #27272a;
  --badge-ink: #e4e4e7;
  --badge-icon: #a1a1aa;
  --pill: #27272a;
  --out: #111113;
  --out-ink: #52525b;
  --today-pill: #fafafa;
  --today-ink: #18181b;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--canvas);
  color: var(--ink);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.4;
  letter-spacing: -0.011em;
}

button, input, select, textarea { font: inherit; color: inherit; }

button { cursor: pointer; }

.skip {
  position: absolute;
  left: 12px;
  top: -48px;
  background: var(--panel);
  color: var(--ink);
  padding: 8px 12px;
  border-radius: 8px;
  z-index: 5;
}

.skip:focus { top: 12px; }

.shell {
  width: min(1320px, calc(100% - 32px));
  margin: 0 auto;
  padding: 20px 0 40px;
}

html.is-embed body { min-height: 0; background: var(--canvas); }
html.is-embed .mast { display: none; }
html.is-embed .shell {
  width: min(1320px, 100%);
  padding: 12px 12px 20px;
}

.mast {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 16px 24px;
  margin-bottom: 16px;
}

.back {
  color: var(--secondary);
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 500;
  background: var(--panel);
}

.back:hover { background: var(--hover); color: var(--ink); }

.mast-copy { flex: 1 1 420px; min-width: 0; }

.kicker {
  margin: 0 0 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

h1, h2, #month-label { font-weight: 600; letter-spacing: -0.03em; }

h1 { margin: 0; font-size: 28px; line-height: 1.1; }

.intro {
  margin: 6px 0 0;
  max-width: 68ch;
  color: var(--secondary);
  font-size: 14px;
}

.who {
  margin: 0 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--secondary);
  font-size: 12px;
}

.who b {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #f0ddd4;
  color: #8d5344;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0;
}

.who span { max-width: 16ch; }

.workspace { display: grid; gap: 12px; min-width: 0; }

.side {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.summary, .board, .log, dialog {
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.summary {
  display: flex;
  align-items: center;
  gap: 12px 16px;
  min-width: 0;
  padding: 12px 14px;
}

.summary h2, .board h2, .log summary {
  margin: 0;
  flex: none;
  font-size: 14px;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  height: 26px;
  padding: 0 10px;
  border-radius: 8px;
  background: var(--pill);
  color: var(--ink);
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.badge.is-muted { color: var(--muted); background: transparent; }

.board { padding: 12px; min-width: 0; }

.toolbar, .toolbar-left, .toolbar-right, .month-nav, .only-me, .dialog-actions, .warning-actions, .add-person, .mark-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toolbar { justify-content: space-between; flex-wrap: wrap; gap: 10px 16px; }
.toolbar-left, .toolbar-right { flex-wrap: wrap; }

#month-label { min-width: 11ch; text-align: center; font-size: 15px; }

.icon-btn, .btn {
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--fill);
  color: var(--ink);
  padding: 0 12px;
  font-size: 13px;
  font-weight: 500;
}

.icon-btn { width: 32px; padding: 0; font-size: 18px; line-height: 1; }

.btn:hover, .icon-btn:hover { background: var(--hover); }

.btn.primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}

.btn.primary:hover { background: #7d3620; color: var(--accent-ink); border-color: #7d3620; }

.btn.danger { color: #9f1239; background: transparent; }

.btn.quiet {
  height: 28px;
  padding: 0 10px;
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}

.btn.quiet:hover { background: var(--hover); color: var(--ink); }

.only-me {
  position: relative;
  font-weight: 500;
  font-size: 13px;
}

.only-me input {
  appearance: none;
  width: 36px;
  height: 22px;
  margin: 0;
  border-radius: 999px;
  background: #d4d4d8;
  position: relative;
  flex: none;
  cursor: pointer;
}

.only-me input::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  transition: transform 160ms ease;
}

.only-me input:checked { background: var(--accent); }
.only-me input:checked::after { transform: translateX(14px); }

.tip {
  position: absolute;
  z-index: 4;
  left: 0;
  top: calc(100% + 6px);
  width: max-content;
  max-width: 240px;
  padding: 6px 8px;
  border-radius: 8px;
  background: #18181b;
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.35;
  opacity: 0;
  pointer-events: none;
}

.only-me:hover .tip, .only-me:focus-within .tip,
.corner-badge:hover .tip, .corner-badge:focus-visible .tip { opacity: 1; }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  list-style: none;
  margin: 0;
  padding: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.legend li { display: inline-flex; align-items: center; gap: 6px; }

.ico-slot { display: inline-flex; flex: none; }
.ico-duty { color: var(--shield); }
.ico-away { color: var(--ghost-icon); }
.ico-meta { color: var(--badge-icon); }
.ico-clash { color: var(--clash); }

.ico {
  display: block;
  width: 13px;
  height: 13px;
  flex: none;
}

.board-scroll { overflow-x: auto; max-width: 100%; }

.weekdays, .grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(168px, 1fr));
  gap: 8px;
  min-width: 1240px;
}

.weekdays {
  margin: 12px 0 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.weekdays span { padding-left: 8px; }

.day {
  min-height: 108px;
  background: var(--fill);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  cursor: pointer;
}

.day:hover { background: var(--hover); }

.day.is-out { background: var(--out); color: var(--out-ink); }

.day.is-today { border: 1.5px solid var(--accent); }
.day.is-today:hover { border-color: var(--accent); }

.day-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 4px;
}

.day-corner {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 4px;
  min-width: 0;
  flex: 1;
}

.day-num {
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  font-weight: 600;
  cursor: pointer;
}

.today-flag {
  height: 18px;
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--today-ink);
  background: var(--today-pill);
  border-radius: 999px;
  padding: 0 6px;
}

.chips { display: grid; gap: 4px; align-content: start; }

.pill, .corner-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 100%;
  min-width: 0;
  border: 0;
  font-size: 12px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
}

.pill {
  height: 24px;
  padding: 0 8px;
  border-radius: 6px;
  background: var(--pill);
  color: var(--ink);
}

.pill-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pill-duty {
  height: 28px;
  background: var(--duty-bg);
  color: var(--duty-ink);
  border: 1px solid var(--duty-line);
  border-left: 3px solid var(--duty-accent);
  border-radius: 8px;
}

.pill-duty .ico { color: var(--shield); }

.pill-away {
  background: var(--ghost);
  color: var(--away-ink);
  border: 1px dashed var(--ghost-line);
}

.pill-away .ico { color: var(--ghost-icon); }

.corner-badge {
  position: relative;
  z-index: 2;
  height: 20px;
  padding: 0 6px;
  border-radius: 6px;
  background: var(--badge-bg);
  color: var(--badge-ink);
  font-size: 11px;
}

.corner-badge .tip {
  left: auto;
  right: 0;
  top: calc(100% + 4px);
}

.corner-badge .ico { color: var(--badge-icon); }

.clash-box {
  display: grid;
  gap: 4px;
  width: 100%;
  padding: 6px;
  border-radius: 8px;
  background: var(--clash-bg);
  border: 1px solid var(--clash-line);
}

.clash-head {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  color: var(--clash);
  font-size: 11px;
  font-weight: 600;
}

.clash-head .pill-name { color: var(--clash); }

.clash-box .pill { width: 100%; }

.chips .pill { width: 100%; }

.day-modal {
  --shield: #10b981;
  --duty-bg: #ffffff;
  --duty-ink: #18181b;
  --duty-line: #e4e4e7;
  --duty-accent: #10b981;
  --clash-bg: #fffbeb;
  --clash: #b45309;
  --clash-line: #f59e0b;
  --away-ink: #64748b;
  --ghost: #fafafa;
  --ghost-line: #cbd5e1;
  --ghost-icon: #71717a;
  --badge-bg: #f1f5f9;
  --badge-ink: #334155;
  --badge-icon: #52525b;
}

.note-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 8px 8px 8px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.note-bar label {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.note-bar span {
  flex: none;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.note-bar input {
  height: 32px;
  border: 0;
  background: transparent;
  padding: 0;
  box-shadow: none;
}

.log { width: 100%; min-width: 0; }

.log summary {
  list-style: none;
  cursor: pointer;
  padding: 14px 16px;
}

.log summary::-webkit-details-marker { display: none; }

.log summary::after {
  content: "Show";
  float: right;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0;
}

.log[open] summary::after { content: "Hide"; }

.log-body { padding: 0 16px 16px; }

.hint, .status, .empty, .dialog-copy { margin: 6px 0 0; color: var(--muted); font-size: 13px; }

.changes, .people-list { list-style: none; margin: 0; padding: 0; }

.changes { display: grid; margin-top: 8px; }

.changes li {
  display: grid;
  gap: 2px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
}

.change-summary { margin: 0; font-weight: 500; }

.change-meta {
  margin: 0;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.status:empty { display: none; }

input[type="text"], input[type="date"], select, textarea {
  width: 100%;
  height: 36px;
  border: 1px solid var(--line);
  background: var(--fill);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
}

.note-bar input { width: 100%; }

input:focus, select:focus, textarea:focus {
  outline: 2px solid rgba(158, 59, 36, 0.35);
  border-color: transparent;
}

.note-bar input:focus { outline: none; border-color: transparent; }

.modal-back {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 28px 72px;
  background: rgba(9, 9, 11, 0.45);
  backdrop-filter: blur(8px);
}

.day-stage { position: relative; width: min(560px, 100%); }

.modal, .day-modal {
  position: relative;
  width: 100%;
  background: #ffffff;
  color: #18181b;
  border: 1px solid #e4e4e7;
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(9, 9, 11, 0.12);
}

.day-modal:focus { outline: none; }

.day-sheet { padding: 22px 28px 18px; }

.day-sheet h2 {
  margin: 0 36px 14px 0;
  font-size: 22px;
  letter-spacing: -0.03em;
}

.day-sheet h3 {
  margin: 12px 0 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #71717a;
}

.day-rows { display: grid; gap: 6px; }

.mark-row { justify-content: space-between; flex-wrap: wrap; align-items: flex-start; }
.mark-row .pill, .mark-row .corner-badge { flex: 0 0 auto; max-width: none; }
.mark-row .clash-box { flex: 1 1 100%; }
.mark-row select { flex: 1 1 180px; min-width: 140px; }

.callout {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  padding: 8px;
  border: 1px solid #e4e4e7;
  border-radius: 10px;
  background: #fafafa;
}

.callout label { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }

.callout span {
  flex: none;
  font-size: 12px;
  font-weight: 600;
  color: #3f3f46;
}

.callout input {
  height: 32px;
  border: 0;
  background: transparent;
  padding: 0;
}

.edge {
  position: absolute;
  z-index: 3;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #fff;
  color: #1d1d1f;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.16);
  cursor: pointer;
}

.edge-prev { left: -52px; top: 50%; transform: translateY(-50%); }
.edge-next { right: -52px; top: 50%; transform: translateY(-50%); }
.edge-x { top: 12px; right: 12px; width: 32px; height: 32px; box-shadow: none; background: transparent; }
.edge-prev:hover, .edge-next:hover { transform: translateY(-50%) scale(1.06); }

dialog {
  width: min(460px, calc(100vw - 28px));
  padding: 20px;
}

dialog h2 { margin: 0; font-size: 17px; letter-spacing: -0.022em; }

dialog::backdrop { background: rgba(9, 9, 11, 0.45); }

.form-grid { display: grid; gap: 12px; margin-top: 14px; }

.field { display: grid; gap: 4px; font-size: 13px; }

.field span { font-size: 11px; font-weight: 600; color: var(--muted); }

.form-error { color: #9f1239; margin: 12px 0 0; }

.warning {
  margin-top: 12px;
  background: var(--clash-bg);
  border: 1px solid var(--clash-line);
  color: var(--clash);
  border-radius: 8px;
  padding: 12px;
}

.warning p { margin: 0 0 10px; }

.dialog-actions { justify-content: flex-end; margin-top: 16px; }

.dialog-actions .danger { margin-right: auto; }

.add-person { margin-top: 12px; }
.add-person label { flex: 1; }

.people-list { display: grid; gap: 8px; margin-top: 12px; }

.person-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
}

.person-row.is-you {
  display: flex;
  justify-content: space-between;
  padding: 8px 2px;
}

.fixed { color: var(--muted); font-size: 12px; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (max-width: 800px) {
  .side, .summary { display: grid; }
  .summary { align-items: start; }
  .modal-back { padding: 56px 16px; }
  .edge-prev, .edge-next { top: 14px; transform: none; }
  .edge-prev { left: 12px; }
  .edge-next { right: 48px; }
  .edge-prev:hover, .edge-next:hover { transform: none; }
  .day-sheet h2 { margin-top: 28px; }
}

@media (prefers-reduced-motion: reduce) {
  .only-me input::after { transition: none; }
}
