:root {
  --bg: #0f1115;
  --surface: #181b22;
  --surface-2: #20242d;
  --border: #2b303b;
  --text: #e8eaed;
  --muted: #9aa3b2;
  --accent: #5b8cff;
  --accent-press: #3f6fe0;
  --avail: #34c759;
  --avail-soft: #1e3a26;
  --black: #ff453a;
  --black-soft: #3a1e1c;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
  --radius: 14px;
  font-synthesis: none;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: radial-gradient(1200px 600px at 80% -10%, #1b2030 0%, var(--bg) 55%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: baseline;
  gap: 14px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: rgba(15, 17, 21, 0.85);
  backdrop-filter: blur(10px);
  z-index: 20;
}
.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 700;
  font-size: 20px;
  color: var(--text);
  text-decoration: none;
}
.brand-mark { font-size: 22px; }
.tagline { color: var(--muted); font-size: 14px; }

main {
  max-width: 1040px;
  margin: 0 auto;
  padding: 28px 24px 80px;
}

.footer {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding: 24px;
  border-top: 1px solid var(--border);
}

.loading { color: var(--muted); padding: 60px 0; text-align: center; }

/* ---------- cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 20px; }
.card h2 { margin: 0 0 4px; font-size: 18px; }
.card .sub { color: var(--muted); font-size: 14px; margin: 0 0 18px; }

.hero {
  text-align: center;
  padding: 36px 22px 8px;
}
.hero h1 { font-size: 34px; margin: 0 0 10px; line-height: 1.15; }
.hero p { color: var(--muted); font-size: 16px; max-width: 560px; margin: 0 auto 6px; }

/* ---------- forms ---------- */
label { display: block; font-size: 13px; color: var(--muted); margin: 14px 0 6px; font-weight: 600; }
input[type="text"], input[type="email"], textarea, select {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 11px 12px;
  font-size: 15px;
  font-family: inherit;
}
textarea { resize: vertical; min-height: 64px; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }

.row { display: flex; gap: 14px; flex-wrap: wrap; }
.row > div { flex: 1; min-width: 160px; }

.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 10px;
  padding: 11px 18px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.05s ease, background 0.15s ease, border-color 0.15s ease;
}
.btn:hover { border-color: var(--accent); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: white; }
.btn.primary:hover { background: var(--accent-press); }
.btn.ghost { background: transparent; }
.btn.small { padding: 7px 12px; font-size: 13px; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 20px; }

.toggle {
  display: flex; align-items: center; gap: 10px; cursor: pointer;
  margin: 14px 0; user-select: none;
}
.toggle input { width: auto; }
.switch {
  width: 44px; height: 26px; border-radius: 14px; background: var(--surface-2);
  border: 1px solid var(--border); position: relative; transition: background 0.15s;
}
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px;
  border-radius: 50%; background: var(--muted); transition: left 0.15s, background 0.15s;
}
.toggle input:checked + .switch { background: var(--accent); border-color: var(--accent); }
.toggle input:checked + .switch::after { left: 20px; background: white; }
.toggle input { position: absolute; opacity: 0; }

/* ---------- date picker chips ---------- */
.date-picker { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.date-chip {
  padding: 8px 12px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface-2); cursor: pointer; font-size: 14px; user-select: none;
}
.date-chip.selected { background: var(--accent); border-color: var(--accent); color: white; }
.hint { color: var(--muted); font-size: 12px; margin-top: 8px; }

/* ---------- share box ---------- */
.share {
  display: flex; gap: 10px; align-items: center; margin-top: 8px;
  background: var(--surface-2); border: 1px dashed var(--border);
  border-radius: 10px; padding: 10px 12px;
}
.share input { background: transparent; border: none; padding: 0; font-size: 14px; }
.share input:focus { outline: none; }

/* ---------- grid ---------- */
.legend { display: flex; gap: 18px; flex-wrap: wrap; align-items: center; margin: 4px 0 16px; font-size: 13px; color: var(--muted); }
.legend .sw { display: inline-block; width: 14px; height: 14px; border-radius: 4px; vertical-align: -2px; margin-right: 6px; border: 1px solid var(--border); }
.sw.avail { background: var(--avail); }
.sw.black { background: var(--black); }
.sw.heat { background: linear-gradient(90deg, var(--avail-soft), var(--avail)); }

.mode-tabs { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.mode-tab {
  padding: 9px 14px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface-2); cursor: pointer; font-weight: 600; font-size: 14px;
  display: flex; align-items: center; gap: 8px;
}
.mode-tab .dot { width: 11px; height: 11px; border-radius: 50%; }
.mode-tab.active.avail { border-color: var(--avail); box-shadow: inset 0 0 0 1px var(--avail); }
.mode-tab.active.black { border-color: var(--black); box-shadow: inset 0 0 0 1px var(--black); }
.mode-tab.active.erase { border-color: var(--muted); box-shadow: inset 0 0 0 1px var(--muted); }
.dot.avail { background: var(--avail); }
.dot.black { background: var(--black); }
.dot.erase { background: var(--muted); }

.grid-scroll { overflow-x: auto; padding-bottom: 8px; }
.grid {
  display: grid;
  gap: 3px;
  user-select: none;
  touch-action: none;
  width: max-content;
  min-width: 100%;
}
.grid .corner { background: transparent; }
.grid .col-head {
  text-align: center; font-size: 12px; color: var(--muted); padding: 4px 2px; font-weight: 600;
  line-height: 1.25;
}
.grid .row-head {
  font-size: 11px; color: var(--muted); padding-right: 8px; text-align: right;
  white-space: nowrap; align-self: center;
}
.cell {
  height: 26px; min-width: 64px; border-radius: 5px;
  background: var(--surface-2); border: 1px solid var(--border);
  cursor: pointer; transition: background 0.05s;
}
.cell.avail { background: var(--avail); border-color: var(--avail); }
.cell.black { background: var(--black); border-color: var(--black); }

/* heat cells (results) */
.cell.heat { cursor: default; }
.cell.has-blackout { outline: 2px solid var(--black); outline-offset: -2px; }

/* ---------- results ---------- */
.best-list { display: flex; flex-direction: column; gap: 10px; }
.best-item {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 14px;
}
.best-item.win { border-color: var(--avail); background: var(--avail-soft); }
.best-item .when { font-weight: 600; }
.best-item .who { color: var(--muted); font-size: 13px; }
.pill { font-size: 12px; padding: 3px 9px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); }
.pill.win { background: var(--avail); color: #06210f; border-color: var(--avail); font-weight: 700; }

/* ---------- people / activity ---------- */
.people { display: flex; flex-wrap: wrap; gap: 8px; }
.person {
  display: flex; align-items: center; gap: 8px; padding: 7px 11px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; font-size: 14px;
}
.person .av { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; color: white; }
.person.me { border-color: var(--accent); }

.activity { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.activity li { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 13px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.activity li:last-child { border-bottom: none; }
.activity .at { white-space: nowrap; }

.empty { color: var(--muted); font-size: 14px; padding: 10px 0; }
.banner {
  background: var(--avail-soft); border: 1px solid var(--avail); color: #c9f5d4;
  border-radius: 10px; padding: 12px 14px; font-size: 14px; margin-bottom: 16px;
}

/* ---------- toast ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--surface); border: 1px solid var(--accent); color: var(--text);
  padding: 12px 18px; border-radius: 10px; box-shadow: var(--shadow); z-index: 50;
  font-size: 14px; animation: pop 0.18s ease;
}
@keyframes pop { from { opacity: 0; transform: translate(-50%, 8px); } }

@media (max-width: 640px) {
  .hero h1 { font-size: 26px; }
  main { padding: 18px 14px 70px; }
  .tagline { display: none; }
}
