:root {
  --bg: #0d0d0e;
  --bg-2: #171719;
  --bg-3: #202024;
  --line: #2c2c31;
  --text: #f2f2ef;
  --muted: #9a9aa2;
  --accent: #c6ff3f;      /* acid green */
  --accent-ink: #16210a;
  --clash: #ff5d5d;
  --pick: var(--accent);
  --radius: 14px;
  --lane-h: 62px;
  --px-min: 1.7px;        /* horizontal scale of the grid (px per minute) */
  --label-w: 104px;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; overflow-x: hidden; overscroll-behavior-y: none; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  padding-bottom: env(safe-area-inset-bottom);
}
button, .tab, .day-btn, .chip, .seg-btn, .block, .pick-btn, .whoami, summary { touch-action: manipulation; }
a { color: var(--accent); }
button { font-family: inherit; }
.muted { color: var(--muted); }
[hidden] { display: none !important; }

/* ---- top bar ---- */
/* one sticky container for all top chrome — offsets are automatic, no notch overlap */
.appbar {
  position: sticky; top: 0; z-index: 40; background: rgba(13,13,14,.94);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 14px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px;
  background: var(--accent); color: var(--accent-ink); font-weight: 800; letter-spacing: -.5px;
}
.brand-text strong { display: block; font-size: 15px; line-height: 1.1; }
.brand-text small { color: var(--muted); font-size: 12px; }
.whoami {
  border: 1px solid var(--line); background: var(--bg-2); color: var(--text);
  padding: 8px 12px; border-radius: 999px; font-size: 13px; font-weight: 600; cursor: pointer;
  max-width: 46vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.whoami .dot { color: var(--accent); }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.netstatus {
  display: inline-flex; align-items: center; gap: 5px;
  background: #3a2a0e; color: #ffcf6b; border: 1px solid #5a4213;
  padding: 5px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 700; white-space: nowrap;
}
.netstatus::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #ffcf6b; }

/* ---- view tabs ---- */
.tabs {
  display: flex; gap: 4px; padding: 4px 10px 6px;
}
.tab {
  flex: 1; padding: 9px 8px; border: 0; border-radius: 10px; background: transparent;
  color: var(--muted); font-weight: 700; font-size: 13.5px; cursor: pointer;
}
.tab.is-active { background: var(--bg-3); color: var(--text); }

/* ---- day tabs ---- */
.days { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 8px 10px; }
.day-btn {
  border: 1px solid var(--line); background: var(--bg-2); color: var(--muted);
  padding: 11px 8px; border-radius: 11px; font-weight: 700; font-size: 14px; cursor: pointer;
  white-space: nowrap; text-align: center;
}
.day-btn.is-active { background: var(--text); color: #111; border-color: var(--text); }

/* ---- program switch ---- */
.seg { display: flex; gap: 4px; padding: 8px 10px 2px; }
.seg-btn {
  flex: 1; padding: 8px 6px; border: 1px solid var(--line); background: var(--bg-2); color: var(--muted);
  border-radius: 9px; font-weight: 700; font-size: 12.5px; cursor: pointer;
}
.seg-btn.on { background: var(--accent); border-color: var(--accent); color: #111; }

/* ---- grid (rooster) ---- */
.grid-wrap { overflow-x: auto; overflow-y: hidden; padding: 0 0 14px; -webkit-overflow-scrolling: touch; }
.grid-inner { position: relative; }
.ruler {
  position: relative; height: 26px; margin-left: var(--label-w);
  border-bottom: 1px solid var(--line);
}
.tick { position: absolute; top: 4px; font-size: 11px; color: var(--muted); transform: translateX(-50%); white-space: nowrap; }
.tick::before {
  content: ""; position: absolute; left: 50%; top: 18px; height: 8px; width: 1px; background: var(--line);
}
.stage-row { display: flex; align-items: stretch; border-bottom: 1px solid var(--line); }
.stage-name {
  position: sticky; left: 0; z-index: 6; width: var(--label-w); min-width: var(--label-w);
  display: flex; align-items: center; padding: 0 10px; font-weight: 700; font-size: 12.5px;
  background: var(--bg-2); border-right: 1px solid var(--line);
}
.lane { position: relative; height: var(--lane-h); flex: 0 0 auto; }
.lane::after { /* faint hour gridlines via repeating gradient set in JS */ }

.block {
  position: absolute; top: 6px; height: calc(var(--lane-h) - 12px);
  border-radius: 9px; padding: 6px 8px; overflow: hidden; cursor: pointer;
  background: var(--bg-3); border: 1px solid var(--line);
  display: flex; flex-direction: column; justify-content: center; gap: 2px;
}
.block .b-name { font-size: 12px; font-weight: 700; line-height: 1.12; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.block .b-time { font-size: 10.5px; color: var(--muted); }
.block.picked { background: var(--pick); border-color: var(--pick); color: #111; }
.block.picked .b-time { color: #24310a; }
/* activities (Er is meer): bluish tint + category left-accent + emoji */
.block.kind-activity { background: #1a212e; border-left: 3px solid #3a4a63; }
.block.kind-activity.picked { background: var(--pick); border-left-color: #24310a; }
.block.kind-activity[data-cat="music"]   { border-left-color: #7aa2ff; }
.block.kind-activity[data-cat="film"]    { border-left-color: #c792ea; }
.block.kind-activity[data-cat="yoga"]    { border-left-color: #6ee7c7; }
.block.kind-activity[data-cat="dance"]   { border-left-color: #ff8fd0; }
.block.kind-activity[data-cat="ceremony"]{ border-left-color: #e0a86b; }
.block.kind-activity[data-cat="sound"]   { border-left-color: #9d8bff; }
.block.kind-activity[data-cat="workshop"]{ border-left-color: #f0c14b; }
.block.kind-activity[data-cat="talk"]    { border-left-color: #59c1e6; }
.block.kind-activity[data-cat="nature"]  { border-left-color: #7ed957; }
.block.kind-activity[data-cat="food"]    { border-left-color: #ff9d5c; }
.block.kind-activity[data-cat="games"]   { border-left-color: #ffd23f; }
.block.kind-activity[data-cat="comedy"]  { border-left-color: #ff7a7a; }
.block.kind-activity[data-cat="radio"]   { border-left-color: #8fb0c9; }
.block.kind-activity[data-cat="kids"]    { border-left-color: #ffb3c1; }
.block.kind-activity[data-cat="social"]  { border-left-color: #b0b0bb; }
.block .peers { position: absolute; top: 4px; right: 5px; display: flex; gap: 2px; }
.peers .pd { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); }
.block.picked .peers .pd { background: #24310a; }
.block.clash::before {
  content: "⚠"; position: absolute; left: 5px; top: 3px; font-size: 10px; color: var(--clash);
}

/* ---- my planning list ---- */
.view { padding: 12px 12px 40px; }
.daygroup h3 { margin: 18px 4px 8px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.item {
  display: grid; grid-template-columns: 68px 1fr auto; gap: 10px; align-items: center;
  padding: 11px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg-2); margin-bottom: 8px;
}
.item .it-time { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 13px; }
.item .it-time small { display: block; color: var(--muted); font-weight: 500; }
.item .it-name { font-weight: 700; font-size: 15px; }
.item .it-stage { color: var(--muted); font-size: 12.5px; }
.item.clash { border-color: var(--clash); }
.item.clash .it-badge { color: var(--clash); font-size: 11px; font-weight: 700; }
.pick-btn {
  border: 1px solid var(--line); background: var(--bg-3); color: var(--text);
  width: 40px; height: 40px; border-radius: 10px; font-size: 18px; cursor: pointer; line-height: 1;
}
.pick-btn.on { background: var(--accent); border-color: var(--accent); color: #111; }
.empty { text-align: center; color: var(--muted); padding: 48px 20px; }
.empty b { color: var(--text); }

/* ---- group view ---- */
.member {
  border: 1px solid var(--line); border-radius: 12px; background: var(--bg-2); margin-bottom: 10px; overflow: hidden;
}
.member summary { list-style: none; cursor: pointer; padding: 13px 14px; display: flex; align-items: center; justify-content: space-between; }
.member summary::-webkit-details-marker { display: none; }
.member .m-name { font-weight: 700; font-size: 15px; }
.member .m-name .you { color: var(--accent); font-size: 12px; margin-left: 6px; }
.member .m-count { color: var(--muted); font-size: 12.5px; }
.member .m-body { padding: 0 14px 12px; }
.mini {
  display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; border-top: 1px solid var(--line); font-size: 13px;
}
.mini .mi-t { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.overlap-note { color: var(--accent); font-size: 12px; margin: 2px 0 14px; }

/* ---- controls ---- */
/* single horizontal-scroll row on mobile to save vertical space */
.controls {
  display: flex; gap: 6px; padding: 6px 12px 8px; overflow-x: auto; flex-wrap: nowrap;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.controls::-webkit-scrollbar { display: none; }
.chip {
  border: 1px solid var(--line); background: var(--bg-2); color: var(--muted); white-space: nowrap; flex: 0 0 auto;
  padding: 7px 12px; border-radius: 999px; font-size: 12.5px; cursor: pointer; font-weight: 600;
}
.chip.on { background: var(--bg-3); color: var(--text); border-color: #45454d; }
.hint { padding: 0 14px 8px; color: var(--muted); font-size: 11.5px; }

/* ---- toast ---- */
.toast {
  position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--text); color: #111; padding: 10px 16px; border-radius: 999px; font-weight: 700; font-size: 13px;
  z-index: 60; box-shadow: 0 8px 24px rgba(0,0,0,.4); max-width: 90vw;
}

/* ---- modal ---- */
.modal { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: 18px;
  background: rgba(0,0,0,.6); backdrop-filter: blur(4px); }
.modal-card { width: 100%; max-width: 420px; background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 16px; padding: 20px; }
.modal-card h2 { margin: 0 0 6px; font-size: 19px; }
.modal-card input {
  width: 100%; margin-top: 12px; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text); font-size: 16px;
}
.modal-actions { display: flex; gap: 8px; margin-top: 14px; }
.btn { flex: 1; padding: 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg-3);
  color: var(--text); font-weight: 700; font-size: 14px; cursor: pointer; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #111; }
.btn.ghost { background: transparent; }
.modal-restore { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 12px; }
.modal-restore summary { cursor: pointer; font-size: 13px; color: var(--muted); }
.modal-restore input { font-size: 14px; }
.modal-restore .btn { margin-top: 10px; flex: none; width: 100%; }

@media (min-width: 720px) {
  :root { --px-min: 2.1px; --lane-h: 66px; --label-w: 132px; }
  .view { max-width: 860px; margin: 0 auto; }
}
