/*
 * Stint week-calendar styles. App-shell layout is inlined in index.html's
 * <head>; this file holds the grid, entry cards, day totals, and popover.
 *
 * House rules (CLAUDE.md §perf): animate only transform / opacity (plus
 * background-color / border-color on hover); transitions ≤ ~150ms.
 */

/* --- app header (Stint Redesign v2) --- */
.brand { display: flex; align-items: center; gap: 9px; flex: none; }
.brand .logo {
  width: 26px; height: 26px; border-radius: 8px; flex: none;
  background: var(--accent); color: var(--accent-ink);
  display: flex; align-items: center; justify-content: center;
}
.brand .wordmark { font-size: 16px; font-weight: 700; letter-spacing: -0.02em; }

/* segmented Calendar / Reports control */
.seg { display: flex; gap: 2px; flex: none; padding: 2px; border-radius: 9px; background: var(--btn-bg); }
.seg-btn {
  height: 24px; padding: 0 12px; border: none; border-radius: 7px;
  background: transparent; color: var(--text2);
  font: inherit; font-size: 12px; font-weight: 600; cursor: pointer;
  transition: background-color 120ms, color 120ms;
}
.seg-btn.is-active { background: var(--seg-active); color: var(--text); box-shadow: var(--seg-shadow); }

/* ghost buttons (week nav + tools) */
.ghost {
  height: 26px; padding: 0 11px; border: 1px solid var(--border); border-radius: 7px;
  background: transparent; color: var(--text2);
  font: inherit; font-size: 12px; font-weight: 600; cursor: pointer;
  transition: background-color 120ms, border-color 120ms;
}
.ghost:hover { background: var(--hover); }
.ghost.nav-arrow { width: 26px; padding: 0 0 2px; font-size: 15px; line-height: 1; }

.weeknav { display: flex; align-items: center; gap: 6px; flex: none; }
.weeknav #range {
  font-size: 13px; font-weight: 600; min-width: 150px; text-align: center;
  font-variant-numeric: tabular-nums;
}

.hint {
  flex: 1; min-width: 0; text-align: center; font-size: 11.5px; color: var(--text3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* week totals: label + layered (planned + logged) progress bar */
.week-total { display: flex; flex-direction: column; gap: 5px; align-items: flex-end; flex: none; }
.wt-label { font-family: var(--font-mono); font-size: 11.5px; line-height: 1; }
.wt-label .wt-logged { color: var(--green); font-weight: 600; }
.wt-label .wt-planned { color: var(--text3); }
.wt-bar { width: 132px; height: 3px; border-radius: 2px; background: var(--track); position: relative; overflow: hidden; }
.wt-bar-sched, .wt-bar-logged {
  position: absolute; inset: 0; width: 100%; border-radius: 2px;
  transform: scaleX(0); transform-origin: left; transition: transform 120ms;
}
.wt-bar-sched { background: var(--sched-fill); }
.wt-bar-logged { background: var(--green); }

/* tools cluster (workspace / teams / project / theme / whoami / signout / avatar) */
.tools { display: flex; align-items: center; gap: 8px; flex: none; }
.tools select {
  font: inherit; font-size: 12px; font-weight: 600; cursor: pointer;
  height: 26px; padding: 0 8px; max-width: 15ch;
  background: transparent; color: var(--text2);
  border: 1px solid var(--border); border-radius: 7px;
}
.tools select[data-single] { display: none; } /* hidden until a team exists */
.status { font-size: 11.5px; color: var(--text3); }
#whoami { max-width: 16ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#presence { color: var(--green); font-variant-numeric: tabular-nums; }
.avatar {
  width: 28px; height: 28px; border-radius: 50%; flex: none;
  background: var(--avatar-bg); color: var(--text2);
  display: flex; align-items: center; justify-content: center;
  font-size: 10.5px; font-weight: 600;
}

/* sync indicator */
.sync-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--over); /* offline by default */
  transition: background-color 150ms;
}
.sync-dot.online { background: var(--ok); }
.sync-dot:not(.online) { animation: dot-pulse 1.4s ease-in-out infinite; }
@keyframes dot-pulse { 50% { opacity: 0.35; } }

/* running-timer pill (header) — visible only while tracking */
.timer-pill {
  display: flex; align-items: center; gap: 10px; flex: 0 1 auto; min-width: 0;
  background: var(--accent); color: var(--accent-ink);
  border-radius: 999px; padding: 5px 7px 5px 14px;
}
.timer-pill[hidden] { display: none; }
.tp-dot {
  width: 7px; height: 7px; border-radius: 50%; flex: none;
  background: var(--accent-ink); animation: tp-pulse 1.6s ease-in-out infinite;
}
@keyframes tp-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }
.tp-title {
  font-size: 12.5px; font-weight: 700; max-width: 170px; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tp-elapsed { font-family: var(--font-mono); font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.tp-stop {
  width: 24px; height: 24px; border: none; border-radius: 50%; padding: 0; flex: none;
  cursor: pointer; background: rgba(0, 0, 0, 0.18); color: var(--accent-ink);
  display: flex; align-items: center; justify-content: center;
  transition: background-color 120ms;
}
.tp-stop:hover { background: rgba(0, 0, 0, 0.34); }

/* --- week grid --- */
.week-grid {
  display: grid;
  gap: 1px;
  background: var(--border-card);
  min-height: 100%;
  position: relative; /* anchor the empty-state overlay */
}
/* Column track keyed on the rendered day count (5 = work week, 7 = +weekend). */
.week-grid[data-days="5"] { grid-template-columns: 64px repeat(5, minmax(0, 1fr)); }
.week-grid[data-days="7"] { grid-template-columns: 64px repeat(7, minmax(0, 1fr)); }

/* --- time ruler (left gutter) --- */
.time-gutter {
  position: relative;
  flex: none; /* keep the full-day height so labels line up with the day grid */
}
.hour-label {
  position: absolute;
  right: 10px;
  transform: translateY(-50%); /* centre the label on its hour gridline */
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text3);
  white-space: nowrap;
}

.week-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 0 24px;
  text-align: center;
  color: var(--text3);
  font-size: 13px;
  pointer-events: none;
}
.week-empty[hidden] { display: none; }

.col {
  background: var(--bg);
  display: flex;
  flex-direction: column;
  min-width: 0;
}
/* Today's column gets a faint accent tint behind the gridlines. */
.col.is-today .col-body { background-color: var(--today-tint); }

.col-head {
  position: sticky;
  top: 0;
  z-index: 2;
  height: 74px; /* fixed so the time-gutter header aligns → labels match gridlines */
  background: var(--bg);
  padding: 10px 12px 9px;
  border-bottom: 1px solid var(--border-card);
}

.col-date { display: flex; align-items: baseline; gap: 6px; }
.col-name { font-size: 12.5px; font-weight: 600; color: var(--text); }
.col-head.is-today .col-name { color: var(--accent); }
.col-num { font-family: var(--font-mono); font-size: 11.5px; color: var(--text-faint); }
.col-today {
  display: none;
  font-size: 9px; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase;
  color: var(--accent);
}
.col-head.is-today .col-today { display: inline; }

.col-sum { font-family: var(--font-mono); font-size: 11px; margin-top: 7px; line-height: 1; }
.col-sum .sum-logged { color: var(--green); font-weight: 600; }
.col-sum .sum-logged.zero { color: var(--text-faint); }
.col-sum .sum-logged.over { color: var(--red); }
.col-sum .sum-scheduled { color: var(--text3); }

.sum-bar {
  position: relative;
  height: 3px;
  margin-top: 6px;
  border-radius: 2px;
  background: var(--track);
  overflow: hidden;
}
.sum-bar-sched, .sum-bar-fill {
  position: absolute;
  inset: 0;
  border-radius: 2px;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 120ms;
}
.sum-bar-sched { background: var(--sched-fill); }
.sum-bar-fill { background: var(--green); }
.sum-bar-fill.over { background: var(--red); }

/* --- day body + entry cards --- */
.col-body {
  position: relative;
  /* The full-day height (set inline = DAY_MINUTES * PX_PER_MIN) is authoritative;
     `flex: none` stops the fixed-height column from shrinking it to the viewport,
     so the grid overflows and the day actually scrolls (all 24h reachable). */
  flex: none;
  /* faint hour gridlines every 60min (60 * PX_PER_MIN = 60px) */
  background-image: linear-gradient(to bottom, var(--gridline) 1px, transparent 1px);
  background-size: 100% 60px;
}

.entry {
  position: absolute;
  left: 5px;
  right: 7px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 2px;
  padding: 6px 7px 6px 9px;
  border: 1px solid var(--border-card);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  background: var(--entry-bg);
  box-shadow: var(--card-shadow);
  overflow: hidden;
  cursor: grab;                 /* draggable to reschedule; click still edits */
  touch-action: none;           /* a press on a card means "move it", not scroll */
  transition: background-color 120ms, border-color 120ms;
}

/* Drag-to-move (spec §13). transform isn't in the transition list above, so the
   card follows the pointer with no lag; only opacity/shadow are eased. */
.entry.dragging {
  z-index: 5;
  opacity: 0.9;
  cursor: grabbing;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.4);
}
.entry.resizing { z-index: 5; cursor: ns-resize; box-shadow: 0 10px 28px rgba(0, 0, 0, 0.4); }
/* Lift the source column so a card dragged into a neighbour paints above it. */
.col.col-dragging { position: relative; z-index: 5; }

/* card head: title + project on the left, ×/play controls on the right */
.entry-head { display: flex; align-items: flex-start; gap: 4px; }
.entry-titlewrap { flex: 1; min-width: 0; }
.entry-title {
  font-size: 12px; font-weight: 600; color: var(--text); line-height: 1.3;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.entry-project {
  font-size: 10.5px; margin-top: 1px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.entry-ctrls { display: flex; gap: 3px; flex: none; }
.entry-x, .entry-play {
  width: 20px; height: 20px; border: none; border-radius: 6px; padding: 0;
  cursor: pointer; font: inherit; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  transition: background-color 120ms, color 120ms;
}
.entry-x { background: transparent; color: var(--text3); font-size: 13px; }
.entry-x:hover { color: var(--red); background: rgba(255, 93, 81, 0.12); }
.entry-play { background: var(--btn-bg); color: var(--btn-fg); font-size: 9px; }
.entry-play:hover { background: var(--accent); color: var(--accent-ink); }
.entry.running .entry-play { background: var(--accent); color: var(--accent-ink); }

.entry-foot {
  display: flex; align-items: center; gap: 4px;
  font-family: var(--font-mono); font-size: 10.5px; line-height: 1;
  font-variant-numeric: tabular-nums;
}
.entry-foot .logged { color: var(--green); font-weight: 600; }
.entry-foot .logged.zero { color: var(--text-faint); }
.entry-foot .planned { color: var(--text3); }
.entry.running .logged { color: var(--accent); }
.note-flag { color: var(--text3); font-size: 11px; }

.entry.running { background: var(--running-bg); border-color: var(--running-border); box-shadow: var(--running-shadow); }
.entry.done { opacity: 0.6; }

/* Short cards drop detail progressively so the title stays legible (classes set
   in JS from the card's known height; the colored left stripe keeps the project
   readable even when its name is hidden). */
.entry.short .entry-project { display: none; }
.entry.xshort .entry-project,
.entry.xshort .entry-foot { display: none; }
.entry.xshort { justify-content: center; gap: 0; }

/* Current-time line across today's column. */
.now-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 0;
  border-top: 2px solid var(--red);
  z-index: 3;
  pointer-events: none;
}
.now-dot {
  position: absolute;
  left: -1px;
  top: -4px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--red);
}

/* Provisional block while drag-creating on empty time. */
.entry-ghost {
  position: absolute;
  left: 5px;
  right: 7px;
  border: 1.5px dashed var(--accent);
  border-radius: 8px;
  background: rgba(232, 130, 92, 0.12);
  pointer-events: none;
  z-index: 4;
}

/* Resize grip: bottom-right corner (clear of the left-aligned controls). */
.entry-resize {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 18px;
  height: 14px;
  cursor: ns-resize;
  touch-action: none;
}
.entry:hover .entry-resize::after {
  content: "";
  position: absolute;
  right: 3px;
  bottom: 3px;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--text3);
  border-bottom: 2px solid var(--text3);
  opacity: 0.6;
}

/* timer buttons in the edit popover (restyled with the popover in §6) */
.tbtn {
  font: inherit;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text2);
  border-radius: 6px;
  padding: 4px 8px;
  transition: background-color 120ms, border-color 120ms;
}
.tbtn:hover { background: var(--hover); }

/* --- entry popover (Stint Redesign v2) --- */
.entry-popover {
  position: fixed;
  margin: 0;
  width: 284px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--pop-shadow);
}
.entry-popover:popover-open {
  /* appear instantly, scale subtly from the anchor */
  animation: pop-in 120ms ease-out;
}
@keyframes pop-in {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

.pop-form { display: flex; flex-direction: column; gap: 12px; }

.pop-title-input {
  font: inherit; font-size: 13px; font-weight: 600; color: var(--text);
  background: var(--input); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 10px; outline: none; width: 100%;
}
.pop-title-input:focus { border-color: var(--accent); }

/* project chips (2-col) */
.pop-projects { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.proj-chip {
  display: flex; align-items: center; gap: 7px;
  padding: 7px 9px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--border); background: transparent; color: var(--text);
  font: inherit;
  transition: background-color 120ms, border-color 120ms;
}
.proj-chip:hover { border-color: rgba(127, 127, 127, 0.5); }
.proj-chip.selected { border-color: var(--accent); background: var(--today-tint); }
.proj-square { width: 8px; height: 8px; border-radius: 3px; flex: none; }
.proj-name { font-size: 12px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* start / length steppers */
.pop-steppers { display: flex; gap: 10px; }
.stepper { flex: 1; display: flex; flex-direction: column; gap: 5px; }
.stepper-label { font-size: 10px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text3); }
.stepper-ctrl {
  display: flex; align-items: center; justify-content: space-between;
  border: 1px solid var(--border); border-radius: 8px; padding: 3px;
}
.stepper-btn {
  width: 24px; height: 24px; border: none; border-radius: 6px; padding: 0;
  background: transparent; color: var(--text2); cursor: pointer; font: inherit; font-size: 14px;
  transition: background-color 120ms;
}
.stepper-btn:hover { background: var(--hover); }
.stepper-val { font-family: var(--font-mono); font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; }

.pop-row { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text2); }

/* footer: (Delete) + Done */
.pop-footer { display: flex; justify-content: space-between; align-items: center; }
.pop-footer:has(.pop-done:only-child) { justify-content: flex-end; }
.pop-delete {
  border: none; background: transparent; color: var(--red);
  font: inherit; font-size: 12px; font-weight: 600; padding: 7px 10px; border-radius: 7px; cursor: pointer;
  transition: background-color 120ms;
}
.pop-delete:hover { background: rgba(255, 93, 81, 0.12); }
.pop-done {
  border: none; background: var(--accent); color: var(--accent-ink);
  font: inherit; font-size: 12px; font-weight: 700; padding: 7px 16px; border-radius: 8px; cursor: pointer;
  transition: background-color 120ms;
}
.pop-done:hover { filter: brightness(1.08); } /* instant (filter isn't transitioned) */

/* --- reports (full in-page weekly view; Stint Redesign v2) --- */
#reports-view { padding: 24px 28px; }
#reports-view[hidden] { display: none; }
.rep-page { max-width: 1020px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }

/* summary cards */
.rep-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.rep-card { background: var(--panel); border: 1px solid var(--border-card); border-radius: 12px; padding: 16px 18px; }
.rep-card-label { font-size: 10.5px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text3); }
.rep-card-valrow { display: flex; align-items: baseline; gap: 7px; margin-top: 8px; }
.rep-card-value { font-family: var(--font-mono); font-size: 26px; font-weight: 600; letter-spacing: -0.01em; }
.rep-card-denom { font-size: 12px; color: var(--text3); }
.rep-card-barrow { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.rep-card-bar { flex: 1; height: 4px; border-radius: 2px; background: var(--track); position: relative; overflow: hidden; }
.rep-card-fill { position: absolute; inset: 0; border-radius: 2px; transform: scaleX(0); transform-origin: left; transition: transform 150ms; }
.rep-card-pct { font-family: var(--font-mono); font-size: 11px; color: var(--text2); }

/* panels (chart + by-project) */
.rep-panel { background: var(--panel); border: 1px solid var(--border-card); border-radius: 12px; padding: 18px 20px; }
.rep-panel-head { display: flex; align-items: center; justify-content: space-between; }
.rep-panel-title { font-size: 13px; font-weight: 600; }
.rep-legend { display: flex; gap: 14px; align-items: center; }
.rep-legend-item { display: flex; gap: 6px; align-items: center; font-size: 11px; color: var(--text2); }
.rep-legend-sq { width: 8px; height: 8px; border-radius: 3px; }

/* logged-vs-capacity chart */
.rep-bars { display: flex; align-items: flex-end; gap: 12px; margin-top: 18px; }
.rep-bar-col { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.rep-bar-track { position: relative; width: 100%; max-width: 36px; height: 170px; }
.rep-bar-cap { position: absolute; inset: 0; background: var(--track); border-radius: 7px; }
.rep-bar-sched, .rep-bar-logged { position: absolute; left: 0; right: 0; bottom: 0; height: 100%; border-radius: 7px; transform: scaleY(0); transform-origin: bottom; transition: transform 150ms; }
.rep-bar-sched { background: var(--sched-fill); }
.rep-bar-logged { background: var(--green); }
.rep-bar-logged.over { background: var(--red); }
.rep-bar-day { font-family: var(--font-mono); font-size: 11px; color: var(--text2); line-height: 1; }
.rep-bar-val { font-family: var(--font-mono); font-size: 10.5px; color: var(--green); line-height: 1; margin-top: -3px; }
.rep-bar-val.over { color: var(--red); }

/* by project */
.rep-projects { display: flex; flex-direction: column; gap: 12px; margin-top: 14px; }
.rep-prow { display: flex; align-items: center; gap: 12px; }
.rep-psquare { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.rep-pname { font-size: 12.5px; font-weight: 600; width: 96px; flex: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rep-pbar { flex: 1; height: 5px; border-radius: 3px; background: var(--track); position: relative; overflow: hidden; }
.rep-pfill { position: absolute; inset: 0; border-radius: 3px; transform: scaleX(0); transform-origin: left; transition: transform 150ms; }
.rep-plogged { font-family: var(--font-mono); font-size: 11.5px; font-weight: 600; width: 50px; text-align: right; flex: none; }
.rep-ppct { font-family: var(--font-mono); font-size: 11px; color: var(--text3); width: 38px; text-align: right; flex: none; }
.rep-empty { color: var(--text3); font-size: 13px; margin-top: 10px; }

/* --- entry notes (spec §16, inside the erasure guarantee) --- */
.pop-note {
  font: inherit; font-size: 13px; resize: vertical; color: var(--text);
  background: var(--input); border: 1px solid var(--border); border-radius: 8px;
  padding: 7px 9px; width: 100%; box-sizing: border-box; outline: none;
}
.pop-note:focus { border-color: var(--accent); }
.note-preview {
  font-size: 12px; color: var(--text2);
  border-left: 3px solid var(--border); padding: 2px 8px;
  overflow-wrap: anywhere;
}
.note-preview[hidden] { display: none; }
.note-preview code { background: var(--btn-bg); border-radius: 3px; padding: 0 3px; }

/* --- month view (spec §16) --- */
.month-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  grid-auto-rows: minmax(92px, auto);
  gap: 1px;
  background: var(--line);
  border-top: 1px solid var(--line);
}
.month-grid .mhead {
  background: var(--surface);
  font-size: 12px; font-weight: 600; color: var(--ink-soft);
  padding: 6px 8px;
}
.mcell {
  background: var(--surface);
  padding: 6px 8px;
  cursor: pointer;
  display: flex; flex-direction: column; gap: 4px;
  transition: background-color 120ms;
}
.mcell:hover { background: var(--hover); }
.mcell.out .mday { color: var(--ink-soft); opacity: 0.5; }
.mcell.is-today .mday {
  color: var(--accent-ink); background: var(--accent);
  width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center;
}
.mday { font-size: 13px; font-weight: 600; }
.mtotals { font-size: 11px; color: var(--ink-soft); font-variant-numeric: tabular-nums; min-height: 1.1em; }
.mlogged { font-weight: 600; color: var(--ink); }
.mbar { height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; margin-top: auto; }
.mbar-fill {
  height: 100%; border-radius: 2px; background: var(--accent);
  transform: scaleX(0); transform-origin: left;
}

/* --- calendar feed (reports footer) --- */
.rep-feed { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 0 2px; }
.feed-btn {
  font: inherit; font-size: 12px; font-weight: 600; cursor: pointer;
  background: transparent; color: var(--text2);
  border: 1px solid var(--border); border-radius: 7px; padding: 5px 10px;
  transition: background-color 120ms;
}
.feed-btn:hover { background: var(--hover); }
.feed-url { display: flex; gap: 6px; align-items: center; flex: 1; min-width: 0; }
.feed-input {
  flex: 1; min-width: 0; font: inherit; font-family: var(--font-mono); font-size: 11px;
  border: 1px solid var(--border); border-radius: 6px; padding: 4px 8px;
  color: var(--text2); background: var(--input);
}

/* --- teams dialog (spec §16 teams) --- */
.teams-dialog {
  border: none;
  border-radius: 14px;
  padding: 0;
  width: min(520px, 92vw);
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 24px 60px rgba(20, 30, 50, 0.28);
}
.teams-dialog::backdrop { background: rgba(20, 30, 50, 0.35); }
.teams-body { padding: 18px 20px; }
.teams-title { margin: 0 0 12px; font-size: 17px; }
.teams-list { display: flex; flex-direction: column; gap: 8px; }
.team-row {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; padding: 6px 0; border-bottom: 1px solid var(--line);
}
.team-name { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.team-role { color: var(--ink-soft); font-size: 12px; }
.team-actions { display: flex; gap: 6px; }
.teams-body button {
  font: inherit; font-size: 12px; cursor: pointer;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: 7px; padding: 4px 9px;
  transition: background-color 120ms;
}
.teams-body button:hover { background: var(--hover); }
.teams-body button.danger { color: #b91c1c; border-color: #ef9a9a; }
.teams-body button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.teams-create { display: flex; gap: 8px; margin-top: 14px; }
.teams-create input {
  flex: 1; font: inherit; font-size: 13px;
  border: 1px solid var(--line); border-radius: 7px; padding: 5px 9px;
}
.teams-empty, .teams-msg { color: var(--ink-soft); font-size: 13px; }
.teams-msg { min-height: 1.2em; margin: 10px 0 0; }
.teams-actions { display: flex; justify-content: flex-end; margin-top: 14px; }

/* --- auth gate (sign-in / sign-up) --- */
.auth-gate { display: grid; place-items: center; min-height: 100%; padding: 24px; }
.auth-card {
  width: min(360px, 92vw);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px 24px;
  box-shadow: 0 18px 48px rgba(20, 30, 50, 0.12);
  text-align: center;
}
.auth-mark { width: 44px; height: 44px; border-radius: 11px; background: var(--accent); margin: 0 auto 12px; }
.auth-title { margin: 0 0 4px; font-size: 22px; }
.auth-sub { margin: 0 0 18px; color: var(--ink-soft); font-size: 13px; }
.auth-label { display: flex; flex-direction: column; gap: 6px; text-align: left; font-size: 12px; color: var(--ink-soft); margin-bottom: 14px; }
.auth-label input {
  font: inherit; font-size: 15px; color: var(--ink);
  padding: 9px 10px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface);
}
.auth-label input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.auth-card button {
  width: 100%; font: inherit; font-size: 14px; cursor: pointer;
  border: 1px solid var(--line); border-radius: 9px; padding: 9px 12px; margin-top: 8px;
  background: var(--surface); color: var(--ink);
  transition: background-color 120ms, border-color 120ms;
}
.auth-card button:hover { background: var(--hover); }
.auth-card button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.auth-card button.primary:hover { filter: brightness(1.08); } /* instant; accent is orange now */
.auth-card button:disabled { opacity: 0.6; cursor: default; }
.auth-err { color: var(--over); font-size: 13px; margin-top: 12px; min-height: 1em; }

/* On the sign-in gate, show only the brand in the topbar. */
#app.gated .topbar > :not(.brand) { display: none; }

.auth-link {
  width: 100%; background: none; border: none; color: var(--accent);
  font: inherit; font-size: 13px; cursor: pointer; padding: 8px; margin-top: 6px;
}
.auth-link:hover { text-decoration: underline; background: none; }

/* --- narrow screens (phones) --- */
@media (max-width: 640px) {
  /* Reclaim the decorative rail; the app column goes full-width. */
  #app { grid-template-columns: 1fr; }
  .rail { display: none; }

  /* Topbar wraps instead of overflowing; drop the boot status to save room. */
  .topbar { flex-wrap: wrap; row-gap: 6px; padding: 8px 12px; }
  .topbar #range { min-width: 0; white-space: nowrap; }
  .topbar #boot-status { display: none; }

  /* A full week can't fit a phone: give columns a legible min width and let the
     grid scroll horizontally, with the hour gutter pinned to the left. */
  .week-grid[data-days="5"] { grid-template-columns: 44px repeat(5, minmax(92px, 1fr)); }
  .week-grid[data-days="7"] { grid-template-columns: 44px repeat(7, minmax(92px, 1fr)); }
  .time-col { position: sticky; left: 0; z-index: 3; }
  .hour-label { font-size: 10px; right: 6px; }

  /* Anchor the create/edit popover to the top so the on-screen keyboard (which
     covers the bottom ~40%) can't hide the Title field. Overrides the JS-set
     position; disable the scale-in so the centering transform isn't clobbered. */
  .entry-popover {
    top: max(10px, env(safe-area-inset-top)) !important;
    left: 50% !important;
    right: auto !important;
    bottom: auto !important;
    transform: translateX(-50%) !important;
    width: min(340px, 92vw);
    animation: none;
  }
}
