:root {
  --bg: #f4efe1;
  --panel: #fffaf0;
  --ink: #1d1a2b;
  --muted: #5d586e;
  --line: #1d1a2b;
  --cell: #e8e1cc;
  --on: #2f7d4a;
  --maybe: #d9a400;
  --accent: #e0563b;
  --heat: 47, 125, 74; /* rgb of --on for the group heatmap */
  --shadow: #1d1a2b;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14121d;
    --panel: #1f1c2c;
    --ink: #f1ecdc;
    --muted: #a7a1b8;
    --line: #f1ecdc;
    --cell: #2c2840;
    --on: #5fd38a;
    --maybe: #f5c542;
    --accent: #ff7a5c;
    --heat: 95, 211, 138;
    --shadow: #000;
  }
}
:root[data-theme="dark"] {
  --bg: #14121d; --panel: #1f1c2c; --ink: #f1ecdc; --muted: #a7a1b8; --line: #f1ecdc;
  --cell: #2c2840; --on: #5fd38a; --maybe: #f5c542; --accent: #ff7a5c; --heat: 95, 211, 138; --shadow: #000;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 22px/1.2 "VT323", ui-monospace, monospace;
}
.wrap { max-width: 760px; margin: 0 auto; padding: 24px 16px 48px; }

.top { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
h1 { font: 22px/1.5 "Press Start 2P", monospace; margin: 0; letter-spacing: 1px; }
h1 span { color: var(--accent); }
h2 { font: 12px/1.6 "Press Start 2P", monospace; margin: 24px 0 8px; }
.who { margin: 0; color: var(--muted); overflow-wrap: anywhere; }

.panel {
  background: var(--panel);
  border: 3px solid var(--line);
  box-shadow: 6px 6px 0 var(--shadow);
  padding: 16px;
}
.status { text-align: center; }

.tabs { display: flex; gap: 0; }
.tabs button {
  font: 11px "Press Start 2P", monospace;
  padding: 12px 14px;
  border: 3px solid var(--line);
  border-bottom: none;
  background: var(--cell);
  color: var(--ink);
  cursor: pointer;
  margin-right: -3px;
}
.tabs button[aria-selected="true"] { background: var(--panel); position: relative; top: 3px; }

.name { display: block; margin-bottom: 8px; }
.name input {
  display: block; width: 100%; max-width: 320px; margin-top: 4px;
  font: inherit; color: var(--ink); background: var(--bg);
  border: 3px solid var(--line); padding: 4px 8px; border-radius: 0;
}
.hint { margin: 8px 0 12px; color: var(--muted); }
.hint strong { color: var(--ink); font-weight: normal; }

.grid {
  display: grid;
  grid-template-columns: 52px repeat(7, 1fr);
  gap: 3px;
  user-select: none;
  -webkit-user-select: none;
}
#grid-mine { touch-action: none; }
.grid .head, .grid .hour { font-size: 18px; color: var(--muted); display: flex; align-items: center; }
.grid .head { justify-content: center; padding-bottom: 2px; }
.grid .hour { justify-content: flex-end; padding-right: 6px; }
.cell {
  height: 26px; border: 2px solid var(--line); background: var(--cell);
  padding: 0; cursor: pointer; border-radius: 0;
}
.cell.on { background: var(--on); }
.week-label { font: 10px/1.6 "Press Start 2P", monospace; margin: 14px 0 6px; color: var(--muted); }
.week-label:first-child { margin-top: 0; }
.grid .head.today { color: var(--accent); }
.cell.past { opacity: .3; cursor: not-allowed; }
.cell.maybe { background: var(--maybe); }
#grid-group .cell.has-maybe { box-shadow: inset 0 -6px 0 var(--maybe); }
.legend { display: flex; gap: 16px; flex-wrap: wrap; margin: 0 0 10px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { display: inline-block; width: 18px; height: 14px; border: 2px solid var(--line); background: var(--cell); }
.legend i.on { background: var(--on); }
.legend i.maybe { background: var(--maybe); }
.legend i.strip { box-shadow: inset 0 -5px 0 var(--maybe); background: rgba(var(--heat), .6); }
.cell.sel { outline: 3px solid var(--accent); outline-offset: -1px; }
.cell:focus-visible { outline: 3px solid var(--accent); }

.actions { display: flex; gap: 12px; align-items: center; margin-top: 16px; flex-wrap: wrap; }
.btn {
  font: 11px "Press Start 2P", monospace; padding: 12px 16px; cursor: pointer;
  border: 3px solid var(--line); background: var(--cell); color: var(--ink);
  box-shadow: 3px 3px 0 var(--shadow); border-radius: 0;
}
.btn:active { transform: translate(3px, 3px); box-shadow: none; }
.btn.primary { background: var(--accent); color: #fff; }
.btn:disabled { opacity: .5; cursor: default; }
.save-state { color: var(--muted); }
.link { margin-top: 16px; background: none; border: none; padding: 0; color: var(--muted); font: inherit; text-decoration: underline; cursor: pointer; }

.detail { margin-top: 12px; min-height: 2.4em; }
.best, .people { margin: 0; padding-left: 1.4em; }
.best li, .people li { margin: 2px 0; }
.people .me { color: var(--accent); }
.empty { color: var(--muted); }

@media (max-width: 480px) {
  body { font-size: 20px; }
  h1 { font-size: 16px; }
  .grid { grid-template-columns: 40px repeat(7, 1fr); gap: 2px; }
  .grid .head, .grid .hour { font-size: 16px; }
  .cell { height: 24px; }
  .tabs button { padding: 10px; font-size: 10px; }
}
