:root {
  --bg: #f4f7fb;
  --card: #ffffff;
  --text: #14213d;
  --muted: #6b7a90;
  --line: #e2e8f0;
  --brand: #1d4ed8;
  --brand-soft: #dbe6ff;
  --mine: #2563eb;
  --all: #16a34a;
  --all-soft: #dcfce7;
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
}

.wrap { max-width: 720px; margin: 0 auto; padding: 16px; }

h1 { font-size: 1.5rem; margin: 0; }
h2 { font-size: 1.05rem; margin: 0 0 8px; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: 0 1px 3px rgba(20, 33, 61, .08);
}

button, .btn {
  font: inherit;
  border: 0;
  border-radius: 10px;
  padding: 12px 18px;
  background: var(--brand);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
button:active { transform: scale(.98); }
button.secondary { background: var(--brand-soft); color: var(--brand); }
button.ghost { background: transparent; color: var(--brand); padding: 8px 10px; }
button:disabled { opacity: .4; cursor: default; }
.full { width: 100%; }

input[type=text] {
  font: inherit;
  width: 100%;
  padding: 13px 14px;
  border-radius: 10px;
  border: 2px solid var(--line);
  background: #fff;
  margin-bottom: 12px;
}
input[type=text]:focus { outline: none; border-color: var(--brand); }

/* Header */
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}
.top .who { font-size: .9rem; color: var(--muted); }
.top .who button { padding: 0; font-weight: 500; font-size: .9rem; background: none; color: var(--brand); }

/* Tabs */
.tabs {
  display: flex;
  background: #e6ecf5;
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 14px;
}
.tabs button {
  flex: 1;
  background: transparent;
  color: var(--muted);
  padding: 10px;
}
.tabs button.active { background: #fff; color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.1); }

/* Week nav */
.weeknav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.weeknav .label { font-weight: 600; }
.weeknav button { background: var(--brand-soft); color: var(--brand); padding: 8px 14px; }

.hint { font-size: .85rem; color: var(--muted); margin-bottom: 10px; }
.status { font-size: .8rem; color: var(--muted); min-height: 1.2em; text-align: right; }

/* Grid */
.grid {
  display: grid;
  grid-template-columns: 44px repeat(7, 1fr);
  gap: 3px;
  user-select: none;
  -webkit-user-select: none;
}
.grid .dayhead {
  text-align: center;
  font-size: .75rem;
  color: var(--muted);
  padding-bottom: 4px;
  line-height: 1.15;
}
.grid .dayhead b { display: block; color: var(--text); font-size: .95rem; }
.grid .dayhead.today b { color: var(--brand); }
.grid .hour {
  font-size: .72rem;
  color: var(--muted);
  text-align: right;
  padding-right: 4px;
  align-self: center;
}
.cell {
  height: 34px;
  border-radius: 6px;
  background: #edf1f7;
  touch-action: none;
  cursor: pointer;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .72rem;
  font-weight: 700;
}
.cell.past { opacity: .35; cursor: default; }
.cell.on { background: var(--mine); }
.cell.all { background: var(--all) !important; color: #fff; }
.cell.all::after { content: "✓"; font-size: .9rem; }
.cell.team { color: #1e3a8a; }

/* Best times */
.best { list-style: none; padding: 0; margin: 0; }
.best li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  margin-bottom: 6px;
  background: #f1f5fb;
}
.best li.everyone { background: var(--all-soft); }
.best .when { font-weight: 600; }
.best .count { font-size: .85rem; color: var(--muted); text-align: right; }
.best li.everyone .count { color: var(--all); font-weight: 700; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  background: #eef2f8;
  border-radius: 999px;
  padding: 5px 11px;
  font-size: .85rem;
}
.chip.me { background: var(--brand-soft); color: var(--brand); font-weight: 600; }

.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: .8rem; color: var(--muted); margin-top: 10px; }
.legend span::before {
  content: "";
  display: inline-block;
  width: 12px; height: 12px;
  border-radius: 3px;
  margin-right: 5px;
  vertical-align: -2px;
  background: var(--sw);
}

/* Modal / sheet */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 10;
}
@media (min-width: 600px) { .overlay { align-items: center; } }
.sheet {
  background: #fff;
  width: 100%;
  max-width: 460px;
  border-radius: 18px 18px 0 0;
  padding: 22px 18px 26px;
  max-height: 85vh;
  overflow: auto;
}
@media (min-width: 600px) { .sheet { border-radius: 18px; } }
.sheet .pick { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.sheet .pick button { background: var(--brand-soft); color: var(--brand); padding: 9px 14px; }
.sheet ul { padding-left: 18px; margin: 4px 0 12px; }

.banner {
  background: var(--all-soft);
  border: 1px solid #bbf7d0;
}
.linkbox {
  display: flex;
  gap: 8px;
  align-items: center;
  background: #fff;
  border-radius: 10px;
  padding: 6px 6px 6px 12px;
  border: 1px solid var(--line);
  margin-top: 8px;
}
.linkbox code { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .85rem; }
.linkbox button { padding: 8px 14px; }

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #14213d;
  color: #fff;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: .9rem;
  z-index: 20;
}

.hidden { display: none !important; }

.hero { text-align: center; padding: 28px 8px 12px; }
.hero .oar { font-size: 3rem; }
.steps { padding-left: 20px; margin: 0; }
.steps li { margin-bottom: 6px; }
.myteams a { display: block; padding: 10px 0; border-bottom: 1px solid var(--line); color: var(--brand); text-decoration: none; font-weight: 600; }
.myteams a:last-child { border-bottom: 0; }
