/* AI Builders Club site and ABC_Meeting_Time. Club colors: navy, cyan, lime. Light theme follows the device. */

:root {
  color-scheme: dark;
  --bg: #0b1220;
  --surface: #111a2e;
  --surface-2: #18233d;
  --line: #243150;
  --line-strong: #35456b;
  --text: #e8eef8;
  --muted: #9fb0c9;
  --accent: #22d3ee;
  --accent-ink: #032029;
  --free: #a3e635;
  --cell: #1b2643;
  --heat-min: #1b2643;
  --heat-max: #a3e635;
  --half-line: #40527e;
  --hour-line: #5d73a8;
  --hl: #22d3ee;
  --danger: #fb7185;
  --ok: #a3e635;
  --warn: #fbbf24;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
}

@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg: #f5f7fb;
    --surface: #ffffff;
    --surface-2: #eef2f8;
    --line: #dde3ee;
    --line-strong: #c4cedd;
    --text: #0f172a;
    --muted: #4b5a70;
    --accent: #0e7490;
    --accent-ink: #ffffff;
    --free: #15803d;
    --cell: #e6ebf3;
    --heat-min: #e6ebf3;
    --heat-max: #15803d;
    --half-line: #aab6cb;
    --hour-line: #7d8ba5;
    --hl: #0e7490;
    --danger: #be123c;
    --ok: #15803d;
    --warn: #b45309;
    --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 10px 30px rgba(15, 23, 42, 0.07);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html {
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0 auto;
  max-width: 1180px;
  padding: 0 max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
  color: var(--text);
  font: 15px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

h1, h2, h3 { line-height: 1.2; margin: 0 0 8px; }
h1 { font-size: clamp(26px, 5vw, 38px); letter-spacing: -0.02em; }
h2 { font-size: 18px; }
h3 { font-size: 15px; margin-top: 18px; }
p { margin: 0 0 10px; }
a { color: var(--accent); }

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

.skip { position: absolute; left: -9999px; }
.skip:focus { left: 16px; top: 8px; z-index: 10; background: var(--surface); padding: 8px 12px; border-radius: 8px; }

.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 14px; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- site chrome ---------- */

.site-header { display: flex; align-items: center; justify-content: space-between; gap: 10px 16px; padding: 16px 0 10px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; }
.brand img { border-radius: 50%; }
.wordmark { font-weight: 800; font-size: 21px; letter-spacing: -0.03em; }
.wm-accent { color: var(--accent); }

.tabs { display: flex; gap: 4px; padding: 4px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); }
.tabs a { padding: 8px 14px; border-radius: 9px; color: var(--muted); text-decoration: none; font-weight: 650; font-size: 14px; white-space: nowrap; }
.tabs a:hover { color: var(--text); }
.tabs a[aria-current="page"] { background: var(--surface-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--accent); }

.kicker { margin: 0 0 6px; font-size: 12px; font-weight: 750; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); }
.site-footer { color: var(--muted); font-size: 13px; text-align: center; padding: 40px 0 44px; }
.footer-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 18px; margin-bottom: 8px; }
.footer-links a { color: var(--muted); }
.footer-links a:hover { color: var(--text); }
main:focus { outline: none; }
.loading { color: var(--muted); padding: 40px 0; }

/* ---------- controls ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 42px; padding: 0 16px;
  border-radius: 10px; border: 1px solid var(--line-strong);
  background: var(--surface-2); color: var(--text);
  font: inherit; font-weight: 650; text-decoration: none; cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.btn:hover { border-color: var(--accent); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.big { width: 100%; min-height: 50px; font-size: 16px; }
.btn.small { min-height: 34px; padding: 0 12px; font-size: 13px; }
.btn.danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn.linkish { background: none; border-color: transparent; color: var(--muted); font-weight: 500; text-decoration: underline; text-underline-offset: 3px; padding: 0 6px; }
.btn.linkish:hover { color: var(--text); }

input[type="text"], select {
  width: 100%; min-height: 46px; padding: 0 12px;
  border-radius: 10px; border: 1px solid var(--line-strong);
  background: var(--bg); color: var(--text);
  font: inherit; font-size: 16px; /* 16px keeps phones from zooming in */
}
select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 36px;
  background-repeat: no-repeat;
  background-position: right 13px center;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%239fb0c9' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  cursor: pointer;
}
@media (prefers-color-scheme: light) {
  select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%234b5a70' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); }
}
input[type="text"]::placeholder { color: var(--muted); opacity: 0.8; }
input[type="text"]:focus, select:focus { border-color: var(--accent); }

label, legend { font-weight: 650; display: block; margin-bottom: 6px; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.field { margin-bottom: 20px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-error { color: var(--danger); font-weight: 600; min-height: 0; margin: 0 0 12px; }
.form-error:empty { display: none; }
.notice { background: var(--surface-2); border: 1px solid var(--line); border-left: 3px solid var(--warn); border-radius: 10px; padding: 10px 12px; font-size: 14px; }

.card, .panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card { padding: 22px; }
.panel { padding: 18px; min-width: 0; }

/* ---------- create page ---------- */

.create { max-width: 580px; margin: 12px auto 0; }
.intro { margin: 18px 0 20px; }
.lede { color: var(--muted); font-size: 17px; }

.segmented { position: relative; display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border-radius: 12px; background: var(--bg); border: 1px solid var(--line-strong); }
.segmented.three { grid-template-columns: repeat(3, 1fr); }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label { display: grid; place-items: center; min-height: 40px; margin: 0; border-radius: 8px; color: var(--muted); cursor: pointer; text-align: center; padding: 0 6px; }
.segmented input:checked + label { background: var(--surface-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--accent); }
.segmented input:focus-visible + label { outline: 2px solid var(--accent); outline-offset: 2px; }
.mode-hint { margin: 8px 0 12px; }

.weekday-picker { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.chip { position: relative; margin: 0; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span { display: grid; place-items: center; min-height: 46px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--bg); cursor: pointer; font-weight: 650; }
.chip input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.cal-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.cal-nav .btn { font-size: 20px; line-height: 1; width: 40px; padding: 0; }
.cal-title { margin: 0; font-size: 16px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; user-select: none; -webkit-user-select: none; }
.cal-grid .dow { text-align: center; font-size: 12px; color: var(--muted); padding-bottom: 2px; }
.cal-day { min-height: 42px; border-radius: 9px; border: 1px solid transparent; background: var(--bg); color: var(--text); font: inherit; font-variant-numeric: tabular-nums; cursor: pointer; }
.cal-day:hover:not(:disabled) { border-color: var(--line-strong); }
.cal-day.today { border-color: var(--line-strong); font-weight: 700; }
.cal-day[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 700; }
.cal-day:disabled { opacity: 0.35; cursor: default; }
.days-summary { margin: 10px 0 0; }

details.more summary, details.edit-link summary { cursor: pointer; font-weight: 650; color: var(--muted); padding: 4px 0; }
details.more[open] summary { margin-bottom: 12px; }

.recent { margin-top: 28px; }
.recent-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.recent-list li { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.recent-list a { font-weight: 650; text-decoration: none; color: var(--text); }
.recent-list a:hover { color: var(--accent); }
.recent-list .muted { font-size: 13px; }

/* ---------- home ---------- */

.hero { display: flex; align-items: center; gap: 28px; padding: 28px 0 4px; }
.hero-emblem { width: 132px; height: 132px; border-radius: 50%; flex: none; }
.hero h1 { font-size: clamp(34px, 7vw, 54px); letter-spacing: -0.035em; margin: 0 0 4px; }
.motto { margin: 0 0 8px; font-size: clamp(20px, 3.6vw, 27px); font-weight: 800; letter-spacing: -0.02em; color: var(--free); }
.hero .lede { color: var(--muted); font-size: 17px; margin: 0; }
.cta { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.home-section { margin-top: 36px; }
.home-section h2 { font-size: 20px; margin-bottom: 12px; }
.points { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; }
.points li { padding: 12px 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); font-weight: 600; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.tile { display: grid; align-content: start; gap: 4px; padding: 16px 18px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); color: var(--text); text-decoration: none; }
.tile:hover { border-color: var(--accent); }
.tile-title { font-weight: 750; }
.tile-body { color: var(--muted); font-size: 14px; }

.tool-mark { letter-spacing: -0.03em; overflow-wrap: anywhere; }

/* ---------- poll page ---------- */

.event-head { margin: 12px 0 16px; }
.event-title { overflow-wrap: anywhere; }
.event-meta { color: var(--muted); display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.sep { width: 4px; height: 4px; border-radius: 50%; background: var(--line-strong); display: inline-block; }
.share { display: flex; gap: 8px; margin: 8px 0; }
.share input { flex: 1; min-width: 0; font-size: 14px; color: var(--muted); }
.share .btn { flex: none; }
.tz-notice { margin-top: 10px; }

.switcher { display: none; }

.panel h2 { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.panel h2 .muted { font-size: 14px; font-weight: 500; }

.join-row { display: flex; gap: 8px; }
.join-row input { flex: 1; min-width: 0; }
.join .form-error { margin-top: 10px; }

.me-row { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; }
.me-line { margin: 0; }
.save-status { margin: 0; font-size: 13px; color: var(--muted); }
.save-status.problem { color: var(--warn); font-weight: 600; }
.paint-hint { margin: 6px 0 12px; }
.readout { min-height: 1.5em; margin: 8px 0 0; font-size: 14px; font-weight: 650; color: var(--accent); font-variant-numeric: tabular-nums; }
.readout:empty::before { content: "Point at the grid to see the exact time."; color: var(--muted); font-weight: 500; }
.me-actions { display: flex; justify-content: space-between; gap: 8px; margin: 12px 0 6px; }
details.edit-link { margin-top: 8px; border-top: 1px solid var(--line); padding-top: 10px; }
details.edit-link p { margin-top: 6px; }

.legend { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); margin: 2px 0 10px; }
.legend-bar { flex: 1; max-width: 220px; height: 10px; border-radius: 5px; background: linear-gradient(to right, var(--heat-min), var(--heat-max)); background: linear-gradient(in oklab to right, var(--heat-min), var(--heat-max)); border: 1px solid var(--line); }

.detail { margin: 12px 0 0; padding: 10px 12px; border-radius: 10px; background: var(--bg); border: 1px solid var(--line); font-size: 14px; min-height: 48px; }
.detail p { margin: 0; }
.detail p + p { margin-top: 4px; }
.detail .when { font-weight: 650; }
.detail .free { color: var(--ok); }

.people { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.people li { display: flex; align-items: center; gap: 8px; padding: 4px 6px; border-radius: 8px; }
.people li.solo { background: var(--surface-2); }
.people .pname { background: none; border: 0; padding: 4px 2px; color: var(--text); font: inherit; font-weight: 650; cursor: pointer; text-align: left; display: inline-flex; gap: 6px; align-items: center; overflow-wrap: anywhere; }
.people .pname:hover { color: var(--accent); }
.people .pname[aria-pressed="true"] { color: var(--accent); }
.you-tag { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--accent-ink); background: var(--accent); border-radius: 5px; padding: 1px 5px; }
.people .pmeta { margin-left: auto; color: var(--muted); font-size: 13px; white-space: nowrap; }
.people .remove { min-height: 28px; }
.people-hint { margin: -4px 0 8px; font-size: 13px; }

.best-controls { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.best-controls label { margin: 0; white-space: nowrap; }
.best-controls select { width: auto; min-height: 40px; }
.best { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 8px; }
.best li.empty { padding: 4px 0; font-size: 14px; }
.best button { width: 100%; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; padding: 10px 12px; text-align: left; border-radius: 11px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font: inherit; cursor: pointer; }
.best button:hover { border-color: var(--line-strong); }
.best button[aria-pressed="true"] { border-color: var(--hl); box-shadow: inset 0 0 0 1px var(--hl); }
.best .rank { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); font-weight: 750; font-size: 13px; }
.best .what { display: grid; min-width: 0; }
.best .when { font-weight: 650; }
.best .who { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.best .score { font-weight: 750; font-variant-numeric: tabular-nums; }
.best .score.full { color: var(--ok); }

.owner { margin-top: 20px; }
.roster-card { margin-top: 20px; }
.roster-card h2 { margin-bottom: 4px; }
.owner .delete-poll { margin-top: 8px; }

.message { max-width: 560px; margin: 40px auto; }
.badge:empty { display: none; }
.badge { font-size: 12px; font-weight: 750; background: var(--surface-2); border-radius: 999px; padding: 0 7px; margin-left: 4px; }

/* ---------- the grid ---------- */

.grid-wrap { overflow-x: auto; overscroll-behavior-x: contain; padding-top: 6px; }

table.grid {
  --row: 20px;
  width: 100%;
  min-width: calc(54px + var(--cols, 7) * 38px);
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
table.grid[data-slot="15"] { --row: 16px; }
table.grid[data-slot="60"] { --row: 30px; }

.grid th { font-weight: 500; }
.grid th.corner { width: 54px; }
.grid thead th.day { padding: 0 1px 8px; text-align: center; font-size: 12px; color: var(--muted); line-height: 1.25; }
.grid thead .dow { display: block; font-size: 13px; font-weight: 700; color: var(--text); }
.grid thead .date { display: block; white-space: nowrap; }

.grid th.time { padding: 0 8px 0 0; text-align: right; vertical-align: top; font-size: 11px; color: var(--muted); white-space: nowrap; line-height: 1; touch-action: pan-y; }
.grid th.time .tl { position: relative; top: -0.55em; }
/* The time column stays put when a long poll scrolls sideways. */
.grid th.time, .grid th.corner { position: sticky; left: 0; z-index: 1; background: var(--surface); }

/* Every slot gets a visible line: dashed between slots, solid on the hour. */
.grid td { height: var(--row); padding: 0; background: var(--cell); border-left: 2px solid var(--surface); border-top: 1px dashed var(--half-line); }
.grid tr.hour td { border-top: 1px solid var(--hour-line); }
.grid tbody tr:first-child td { border-top-color: transparent; }
.grid tbody tr:first-child td:nth-child(2) { border-top-left-radius: 6px; }
.grid tbody tr:first-child td:last-child { border-top-right-radius: 6px; }
.grid tbody tr:last-child td:nth-child(2) { border-bottom-left-radius: 6px; }
.grid tbody tr:last-child td:last-child { border-bottom-right-radius: 6px; }
.grid tfoot td { height: 0; background: none; border: 0; }
.grid tfoot th.time { height: 0; }
.grid td:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.grid-paint td { cursor: pointer; touch-action: none; }
.grid-paint td[aria-selected="true"] { background: var(--free); }
@media (hover: hover) {
  .grid-paint:not(.dragging) td:hover { box-shadow: inset 0 0 0 2px var(--accent); }
  .grid-heat td:hover { box-shadow: inset 0 0 0 2px var(--text); }
}

.grid-heat td { position: relative; cursor: default; }
.grid-heat td.all::after { content: ""; position: absolute; top: 50%; left: 50%; width: 4px; height: 4px; margin: -2px 0 0 -2px; border-radius: 50%; background: var(--bg); opacity: 0.85; }
.grid-heat td.dim { opacity: 0.2; }
.grid-heat td.hl { box-shadow: inset 2px 0 0 var(--hl), inset -2px 0 0 var(--hl); }
.grid-heat td.hl.top { box-shadow: inset 2px 0 0 var(--hl), inset -2px 0 0 var(--hl), inset 0 2px 0 var(--hl); }
.grid-heat td.hl.bottom { box-shadow: inset 2px 0 0 var(--hl), inset -2px 0 0 var(--hl), inset 0 -2px 0 var(--hl); }
.grid-heat td.hl.top.bottom { box-shadow: inset 0 0 0 2px var(--hl); }
.grid-heat td.picked { box-shadow: inset 0 0 0 2px var(--text); }

/* ---------- layout ---------- */

@media (min-width: 760px) {
  .event-body {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-areas: "you group" "you best";
    grid-template-rows: auto 1fr;
    gap: 20px;
    align-items: start;
  }
  .panel-you { grid-area: you; }
  .panel-group { grid-area: group; }
  .panel-best { grid-area: best; }
}

@media (max-width: 759px) {
  body { font-size: 15px; }
  .tabs { width: 100%; }
  .tabs a { flex: 1; text-align: center; padding: 8px 4px; }
  .hero { flex-direction: column; align-items: flex-start; gap: 14px; padding-top: 14px; }
  .hero-emblem { width: 96px; height: 96px; }
  .points { grid-template-columns: 1fr 1fr; gap: 6px; }
  .points li { padding: 10px 12px; font-size: 14px; }
  .card { padding: 16px; }
  .panel { padding: 14px; border-radius: 12px; }
  .switcher {
    display: flex; gap: 6px;
    position: sticky; top: 0; z-index: 5;
    margin: 0 -16px 12px; padding: 8px 16px;
    background: var(--bg); border-bottom: 1px solid var(--line);
  }
  .switcher button {
    flex: 1; min-height: 42px; border-radius: 10px;
    border: 1px solid var(--line-strong); background: var(--surface);
    color: var(--muted); font: inherit; font-weight: 650; font-size: 14px; cursor: pointer;
  }
  .switcher button[aria-pressed="true"] { color: var(--text); border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
  .event-body > .panel { display: none; }
  .event-body[data-show="you"] > .panel-you,
  .event-body[data-show="group"] > .panel-group,
  .event-body[data-show="best"] > .panel-best { display: block; }
  .two { grid-template-columns: 1fr; }
  .weekday-picker { gap: 4px; }
  .chip span { min-height: 44px; font-size: 13px; }
  table.grid { --row: 22px; }
  table.grid[data-slot="15"] { --row: 18px; }
  table.grid[data-slot="60"] { --row: 32px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}
