:root {
  --bg: #F3F5FA;
  --surface: #FFFFFF;
  --well: #E9EDF5;
  --ink: #16203A;
  --muted: #5A6583;
  --line: #D9DFEB;
  --night: #27306B;
  --night-soft: #E4E7F6;
  --sun: #FFC53D;
  --sun-pale: #FFF4D1;
  --sun-deep: #E38B00;
  --danger: #B3261E;
  --display: "Bricolage Grotesque", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --body: "Instrument Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --cell-h: 20px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 400 16px/1.5 var(--body);
}
h1, h2, h3 { font-family: var(--display); line-height: 1.1; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 1.25rem; font-weight: 700; }
p { margin: 0; }
a { color: var(--night); }
button, select, input { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--night); outline-offset: 2px; border-radius: 4px; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
[hidden] { display: none !important; }

/* ---------- top bar */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 14px 24px; max-width: 1360px; margin: 0 auto;
}
.brand {
  font: 700 1.35rem/1 var(--display); color: var(--ink); text-decoration: none;
  display: inline-flex; align-items: center; gap: 9px;
}
.brand-mark { width: 30px; height: 20px; position: relative; display: inline-block; }
.brand-mark::before, .brand-mark::after {
  content: ""; position: absolute; top: 0; width: 20px; height: 20px; border-radius: 50%;
}
.brand-mark::before { left: 0; background: var(--sun); }
.brand-mark::after { right: 0; background: var(--night); mix-blend-mode: multiply; }
.top-controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.top-controls label { display: inline-flex; align-items: center; gap: 8px; font-size: 0.875rem; color: var(--muted); }

/* ---------- controls */
select, input[type=text], input[type=password], input[type=url] {
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
  padding: 9px 11px; min-height: 42px; max-width: 100%;
}
select { padding-right: 28px; }
input[type=text], input[type=password], input[type=url] { width: 100%; }
.btn {
  border: 1px solid var(--line); background: var(--surface); border-radius: 8px;
  padding: 9px 15px; min-height: 42px; cursor: pointer; font-weight: 500;
}
.btn:hover { border-color: var(--night); }
.btn.primary { background: var(--night); border-color: var(--night); color: #fff; font-weight: 600; }
.btn.primary:hover { background: #1C2456; }
.btn.quiet { border-color: transparent; background: transparent; color: var(--night); padding: 6px 8px; min-height: 0; text-decoration: underline; }
.btn:disabled { opacity: 0.5; cursor: default; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--surface); }
.seg button {
  border: 0; background: transparent; padding: 8px 14px; min-height: 40px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px; font-weight: 500;
}
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed=true] { background: var(--night); color: #fff; }
.swatch { width: 14px; height: 14px; border-radius: 3px; display: inline-block; border: 1px solid rgba(22,32,58,.25); flex: none; }
.swatch.y { background: var(--sun); }
.swatch.m { background: repeating-linear-gradient(135deg, var(--sun) 0 3px, var(--sun-pale) 3px 6px); }
.swatch.busy { background: repeating-linear-gradient(135deg, #8E97B0 0 2px, var(--well) 2px 5px); }
.swatch.no { background: #6B7592; }
input[type=date] { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; min-height: 42px; }
.range { display: grid; gap: 8px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.modeseg { margin-bottom: 12px; }
.pick h2 { font-size: 1.5rem; margin-bottom: 14px; }
.pick-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.pick-card { text-align: left; background: var(--surface); border: 2px solid var(--line); border-radius: 18px; padding: 24px; cursor: pointer; display: grid; gap: 8px; min-height: 150px; align-content: start; }
.pick-card:hover { border-color: var(--night); }
.pick-card b { font: 700 1.375rem/1.2 var(--display); }
.pick-card span { color: var(--muted); }
.chosen { grid-column: 1 / -1; display: grid; gap: 8px; padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.chosen-top { display: flex; align-items: center; gap: 10px; }
.chosen-top b { font: 700 1.125rem/1.2 var(--display); }
.decided { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px 18px; margin-bottom: 16px; }
.decided.set { background: var(--sun); border-color: var(--sun); display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 18px 22px; }
.decided.set h2 { font-size: 1.625rem; margin: 2px 0 4px; }
.org-time { margin-bottom: 12px; }
a.btn { text-decoration: none; display: inline-flex; align-items: center; color: var(--ink); }
input[type=number] { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; min-height: 42px; }
input[type=email] { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; min-height: 42px; width: 100%; }
.organizer { margin-bottom: 24px; }
.contacts { border-collapse: collapse; width: 100%; font-size: 0.9375rem; }
.contacts th { text-align: left; font-weight: 600; color: var(--muted); font-size: 0.8125rem; padding: 6px 12px 6px 0; border-bottom: 1px solid var(--line); }
.contacts td { padding: 8px 12px 8px 0; border-bottom: 1px solid var(--line); }
.call { position: fixed; inset: 0; z-index: 50; background: var(--ink); display: grid; grid-template-rows: auto minmax(0, 1fr); }
.call-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; color: #fff; font-family: var(--display); }
.call-body { min-height: 0; display: grid; }
.call-body rtk-meeting { width: 100%; height: 100%; }
.call-join { place-self: center; background: var(--surface); border-radius: 18px; padding: 24px; width: min(420px, calc(100vw - 28px)); }
.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.check input { margin-top: 5px; width: 16px; height: 16px; flex: none; }
.check span { display: grid; gap: 2px; }
.times { grid-column: 1 / -1; display: grid; gap: 12px; border-top: 1px solid var(--line); padding-top: 24px; min-width: 0; }
.times-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.times .cell { cursor: pointer; touch-action: none; }
.times .legend { margin-bottom: 0; }
.blockmode .cell:not(.y):not(.m):not(.void):not(.busy) { background: #6B7592; }
.blockmode .cell.pv-off { background: var(--night) !important; }
.field { display: grid; gap: 6px; }
.field > span { font-weight: 600; font-size: 0.9375rem; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
.error { color: var(--danger); font-weight: 500; }

/* ---------- home */
.home { max-width: 1040px; margin: 0 auto; padding: 24px 24px 72px; }
.home-head { max-width: 30ch; margin: 24px 0 32px; }
.home-head h1 { font-size: clamp(2.25rem, 6vw, 3.75rem); font-weight: 700; letter-spacing: -0.03em; }
.home-head p { margin-top: 14px; font-size: 1.125rem; color: var(--muted); max-width: 44ch; }
.create { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 32px; background: var(--surface); border-radius: 18px; padding: 28px; border: 1px solid var(--line); }
.create-side { display: grid; gap: 18px; align-content: start; }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.cal-head strong { font-family: var(--display); font-size: 1.125rem; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; touch-action: none; user-select: none; }
.cal .dow { text-align: center; font-size: 0.8125rem; color: var(--muted); padding: 4px 0; }
.cal button {
  aspect-ratio: 1; border: 0; border-radius: 50%; background: transparent; cursor: pointer;
  font-weight: 500; min-width: 0; padding: 0;
}
.cal button:hover:not(:disabled) { background: var(--well); }
.cal button.today { box-shadow: inset 0 0 0 1.5px var(--night); }
.cal button.on, .cal button.on:hover { background: var(--sun); font-weight: 700; }
.cal button:disabled { color: #B4BCCF; cursor: default; }
.recent { margin-top: 36px; }
.recent ul { list-style: none; padding: 0; margin: 10px 0 0; display: flex; gap: 8px; flex-wrap: wrap; }
.recent a { display: inline-block; padding: 8px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; text-decoration: none; color: var(--ink); }

/* ---------- event */
.event { max-width: 1360px; margin: 0 auto; padding: 8px 24px 72px; }
.event-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin: 12px 0 20px; }
.event-head h1 { font-size: clamp(1.75rem, 4vw, 2.75rem); font-weight: 700; letter-spacing: -0.025em; }
.share { display: flex; gap: 8px; align-items: center; }
.share input { width: 260px; background: var(--well); border-color: transparent; }

.best { background: var(--night); color: #fff; border-radius: 18px; padding: 20px 22px; margin-bottom: 24px; }
.best-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.best-head label { font-size: 0.875rem; display: inline-flex; gap: 8px; align-items: center; color: #C9CFF0; }
.best select { color: var(--ink); min-height: 36px; padding: 5px 26px 5px 9px; }
.best-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.slot-card { background: #fff; color: var(--ink); border-radius: 12px; padding: 14px 16px; display: grid; gap: 8px; align-content: start; }
.slot-card.full { box-shadow: inset 0 5px 0 var(--sun); }
.slot-when { font: 700 1.0625rem/1.25 var(--display); }
.slot-count { font-size: 0.875rem; color: var(--muted); }
.slot-card.full .slot-count { color: #8A5600; font-weight: 600; }
.slot-people { list-style: none; margin: 0; padding: 0; display: grid; gap: 3px; font-size: 0.875rem; }
.slot-people li { display: flex; justify-content: space-between; gap: 10px; }
.slot-people .late { color: var(--night); font-weight: 600; }
.slot-people .out { color: var(--muted); text-decoration: line-through; }
.slot-actions { display: flex; gap: 4px 16px; flex-wrap: wrap; margin-top: 2px; }
.slot-actions .btn { padding: 4px 0; }
.best-empty { color: #C9CFF0; }

.cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 20px; min-width: 0; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.tools { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.status { font-size: 0.875rem; color: var(--muted); min-height: 1.4em; }
details.more { border-top: 1px solid var(--line); padding: 10px 0; }
details.more:last-of-type { border-bottom: 1px solid var(--line); margin-bottom: 14px; }
details.more summary { cursor: pointer; font-weight: 600; padding: 4px 0; }
details.more .inner { display: grid; gap: 12px; padding: 10px 0 6px; }
.signin { display: grid; gap: 14px; max-width: 420px; }

/* ---------- grid */
.grid-scroll { overflow-x: auto; margin: 0 -4px; padding: 0 4px 4px; }
.grid { display: grid; gap: 0; user-select: none; -webkit-user-select: none; min-width: min-content; }
.g-corner, .g-day { position: sticky; top: 0; background: var(--surface); z-index: 2; padding-bottom: 12px; }
.g-day { text-align: center; font-size: 0.8125rem; line-height: 1.2; color: var(--muted); border-left: 1px solid transparent; }
.g-day b { display: block; color: var(--ink); font: 700 0.9375rem/1.2 var(--display); }
.g-time {
  position: sticky; left: 0; background: var(--surface); z-index: 1;
  font-size: 0.75rem; color: var(--muted); text-align: right; padding-right: 8px; height: var(--cell-h);
  line-height: 1; padding-top: 2px; white-space: nowrap;
}
.cell { height: var(--cell-h); background: var(--well); border-left: 1px solid var(--surface); border-top: 1px solid rgba(255,255,255,.6); }
.cell.hour { border-top: 1px solid #B9C2D6; }
.cell.void { background: transparent; border-color: transparent; }
.g-gap { grid-column: 1 / -1; height: 14px; }
.mine .cell:not(.void) { cursor: pointer; touch-action: none; }
.cell.y { background: var(--sun); }
.cell.m { background: repeating-linear-gradient(135deg, var(--sun) 0 4px, var(--sun-pale) 4px 8px); }
.cell.busy:not(.y):not(.m) { background: repeating-linear-gradient(135deg, #A7AFC6 0 2px, var(--well) 2px 6px); }
.cell.busy.y, .cell.busy.m { box-shadow: inset 0 0 0 2px #6B7592; }
.cell.pv-on { background: var(--sun-deep) !important; }
.cell.pv-off { background: #CBD2E2 !important; }
.cell.all { box-shadow: inset 0 0 0 2px var(--night); }
.legend { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 0.8125rem; color: var(--muted); margin-bottom: 10px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.ramp { display: inline-flex; }
.ramp i { width: 16px; height: 14px; display: block; }

/* ---------- people */
.people { list-style: none; padding: 0; margin: 0 0 14px; display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px; }
.person { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; cursor: pointer; background: var(--surface); text-align: left; width: 100%; display: grid; gap: 5px; }
.person[aria-pressed=true] { border-color: var(--night); background: var(--night-soft); }
.person-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.person-top b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person-top span { font-size: 0.8125rem; color: var(--muted); white-space: nowrap; }
/* A 24-hour strip of that person's day: dark at night, bright by day, marker at their time right now. */
.daystrip {
  height: 6px; border-radius: 3px; position: relative;
  background: linear-gradient(90deg, var(--night) 0 22%, var(--sun) 32% 72%, var(--night) 84% 100%);
}
.daystrip i { position: absolute; top: -3px; width: 3px; height: 12px; background: var(--ink); border-radius: 2px; box-shadow: 0 0 0 1.5px #fff; transform: translateX(-1px); }

.tip {
  position: fixed; z-index: 20; background: var(--ink); color: #fff; border-radius: 10px; padding: 10px 12px;
  font-size: 0.8125rem; line-height: 1.4; max-width: 260px; pointer-events: none;
}
.tip b { display: block; font-size: 0.875rem; }
.tip .tip-no { color: #A9B2CF; }

@media (max-width: 900px) {
  .cols, .create { grid-template-columns: minmax(0, 1fr); }
  .top, .home, .event { padding-left: 14px; padding-right: 14px; }
  .panel, .create { padding: 16px; border-radius: 14px; }
  .share input { display: none; }
}
@media (prefers-reduced-motion: no-preference) {
  .cell { transition: background-color 80ms linear; }
}
