/* Setup view inherits the site's dark theme from /styles.css.
   The run view paints its own full-screen state colors. */
:root {
  /* Namespaced so these don't shadow the site-wide --yellow (etc.) tokens
     from /styles.css, which .brand-mark, .signal and .status rely on. */
  --cue-green: #0f7a3d;
  --cue-yellow: #8a6800; /* darkened from #a67c00: white text was 3.82:1, below 4.5:1 for small text */
  --cue-red: #a41c1c;
}

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

/* The Run view sets `display: grid` at the same specificity as the
   browser's default `[hidden] { display: none }`, so source order alone
   decided the winner. This rule guarantees `hidden` always wins, for the
   Run view and any other section, regardless of what display value it
   otherwise declares. */
[hidden] { display: none !important; }

body { line-height: 1.5; }
main { width: min(880px, calc(100% - 40px)); margin-inline: auto; padding-bottom: 80px; }

.setup-head { padding: 40px 0 24px; }
.back-link { color: var(--muted); font-size: 14px; text-decoration: none; }
.back-link:hover { color: var(--cyan); }
.setup-head h1 { margin: 12px 0 0; font-size: clamp(36px, 6vw, 56px); }
.lede { max-width: 60ch; color: var(--muted); }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { color: var(--muted); font-size: 12px; letter-spacing: .06em; text-transform: uppercase; }
.block-title {
  color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap;
}
input:not([type="checkbox"]), textarea {
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--text); font: inherit; width: 100%;
}
input:focus-visible, textarea:focus-visible { outline: 2px solid var(--cyan); outline-offset: 1px; }
textarea { resize: vertical; min-height: 60px; }
.title-field { margin-bottom: 24px; }
/* Checkboxes (Include edit rights, Sync toggle) must keep their intrinsic
   size — the width:100% above is meant only for text fields, and applying
   it to a checkbox stretched it to fill the whole flex row, shoving its
   label far away and wrapping the label text (see include-edit-field and
   sync-toggle-row below). */
input[type="checkbox"] {
  width: 16px; height: 16px; min-width: 16px; flex: 0 0 auto; padding: 0; margin: 0;
}

.block-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.block-card {
  display: grid; gap: 12px; padding: 16px;
  border: 1px solid var(--line); border-radius: 14px; background: var(--surface);
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-areas: "name name order" "note note note" "seconds green yellow";
}
.block-card.dragging { opacity: .4; }
.block-card.drop-target { border-color: var(--cyan); }
.block-card .name { grid-area: name; }
.block-card .note { grid-area: note; }
.block-card .seconds { grid-area: seconds; }
.block-card .green { grid-area: green; }
.block-card .yellow { grid-area: yellow; }
.block-card .order { grid-area: order; display: flex; gap: 6px; justify-content: flex-end; align-items: end; }
.icon-button {
  width: 34px; height: 34px; border: 1px solid var(--line-bright); border-radius: 8px;
  background: var(--surface-hover); color: var(--text); cursor: pointer; font-size: 14px;
}
.icon-button:hover:not(:disabled) { border-color: var(--cyan); color: var(--cyan); }
.icon-button:disabled { opacity: .35; cursor: default; }

.setup-actions { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 20px 0; flex-wrap: wrap; }
.total-line { margin: 0; color: var(--muted); font-size: 14px; }
.defaults { border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; background: var(--surface); }
.defaults summary { cursor: pointer; color: var(--muted); font-size: 14px; }
.defaults-grid { display: grid; gap: 12px; margin-top: 14px; }
.defaults-grid.one { grid-template-columns: 1fr; max-width: 220px; }
.block-card.is-auto .green input, .block-card.is-auto .yellow input { color: var(--muted); }
.hint { color: var(--muted); font-size: 13px; }
.hint code { background: var(--surface-hover); padding: 1px 5px; border-radius: 5px; }

.setup-footer { display: flex; align-items: center; gap: 14px; margin-top: 28px; flex-wrap: wrap; }
.setup-footer a { color: var(--muted); font-size: 14px; text-decoration: none; margin-left: auto; }
.share-hint { margin-top: 10px; }

.include-edit-field {
  display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px;
  white-space: nowrap;
}

.sync-toggle-row {
  display: flex; align-items: center; gap: 8px; margin-top: 16px; font-size: 14px;
}
.sync-toggle-row span { white-space: normal; }
.sync-status { margin: 6px 0 0; color: var(--muted); font-size: 13px; }

/* .button.ghost sets a transparent background at the same specificity as
   the site-wide .button:hover (styles.css), which — depending on stylesheet
   load order — can win the background while :hover's dark text colour still
   applies, leaving unreadable dark-on-transparent text. Pin the hover state
   explicitly for every ghost button outside the run view (which already has
   its own higher-specificity .run .button:hover rule below). */
.button.ghost:hover, .button.ghost:focus-visible {
  background: var(--cyan); color: var(--bg); border-color: var(--cyan);
}

.shares-list {
  list-style: none; margin: 14px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px;
}
.share-row {
  display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted);
}
.share-row .share-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.button { cursor: pointer; font-family: inherit; }
.button.primary { background: var(--cyan); border-color: var(--cyan); color: var(--bg); }
.button.primary:hover:not(:disabled) { transform: translateY(-2px); }
.button:disabled { opacity: .4; cursor: default; transform: none; }
.button.small { padding: 6px 14px; font-size: 13px; }
.button.ghost { background: transparent; }
.danger-text { color: var(--muted); }
.danger-text:hover, .danger-text:focus-visible {
  color: #ff6b6b !important; border-color: #ff6b6b !important; background: rgba(255, 107, 107, .12) !important;
}


.notice {
  position: sticky; top: 0; z-index: 5; display: flex; gap: 16px; align-items: center;
  justify-content: center; flex-wrap: wrap; padding: 12px 20px;
  background: var(--surface-hover); border-bottom: 1px solid var(--line-bright); font-size: 14px;
}
.notice-actions { display: flex; gap: 8px; }
/* Belt-and-suspenders on top of the JS in showView(): the notice must never
   be able to paint over the full-screen run view, no matter what triggers
   it (e.g. a hashchange while a meeting is live). */
body.running .notice { display: none; }

@media (max-width: 640px) {
  .block-card { grid-template-columns: 1fr 1fr; grid-template-areas: "name order" "note note" "seconds seconds" "green yellow"; }
}

/* ---------- Run view ---------- */
body.running { overflow: hidden; }
body.running main { width: 100%; padding: 0; }

.run {
  position: fixed; inset: 0; display: grid; gap: 0;
  grid-template-columns: 1fr minmax(240px, 24vw);
  grid-template-rows: 1fr auto;
  grid-template-areas: "main side" "controls controls";
  background: var(--bg); transition: background-color .3s ease;
}
.run[data-state="green"] { background: var(--cue-green); }
.run[data-state="yellow"] { background: var(--cue-yellow); }
.run[data-state="red"] { background: var(--cue-red); }

.run-main { grid-area: main; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; text-align: center; min-width: 0; }
.speaker-name { margin: 0; font-size: clamp(24px, 4vw, 44px); font-weight: 750; letter-spacing: -.02em; overflow-wrap: anywhere; }
.clock {
  margin: 8px 0; font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: clamp(72px, 18vw, 260px); line-height: 1; font-variant-numeric: tabular-nums;
  font-weight: 700; letter-spacing: -.04em;
}
.speaker-note {
  margin: 0; max-width: min(70ch, 92%); font-size: clamp(16px, 2.2vw, 26px); opacity: .85; white-space: pre-wrap;
  overflow-wrap: normal; word-break: normal; max-height: 30vh; overflow-y: auto;
}
.speaker-note p { margin: 0 0 .6em; }
.speaker-note p:last-child { margin-bottom: 0; }
.speaker-note .note-h { font-weight: 800; font-size: 1.1em; margin: 0 0 .5em; }
.speaker-note ul, .speaker-note ol {
  margin: 0 0 .6em; padding-left: 1.3em; text-align: left; display: inline-block;
}
.speaker-note ul:last-child, .speaker-note ol:last-child { margin-bottom: 0; }
.speaker-note li { margin: .15em 0; }
.speaker-note code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: .9em;
  background: color-mix(in srgb, currentColor 18%, transparent);
  padding: .1em .35em; border-radius: 4px;
}

.run-side { grid-area: side; padding: 24px 20px; border-left: 1px solid rgba(255, 255, 255, .18); overflow-y: auto; }
.run-side .sync-status { color: inherit; opacity: .85; margin: 0 0 12px; }
.meeting-left { margin: 0 0 16px; font-size: 13px; letter-spacing: .06em; text-transform: uppercase; opacity: .9; }
.queue { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.queue li { display: flex; justify-content: space-between; gap: 12px; font-size: 15px; opacity: .9; }
.queue li .q-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.queue li .q-name { overflow-wrap: anywhere; }
.queue li .q-title {
  font-size: 12px; color: color-mix(in srgb, currentColor 92%, transparent);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.queue li .q-time { font-variant-numeric: tabular-nums; flex: none; }
.queue li.done { opacity: .35; text-decoration: line-through; }
.queue li.current { opacity: 1; font-weight: 700; }

.run-controls { grid-area: controls; display: flex; gap: 10px; justify-content: center; padding: 14px; border-top: 1px solid rgba(255, 255, 255, .18); flex-wrap: wrap; }
.run .button { background: rgba(0, 0, 0, .25); border-color: rgba(255, 255, 255, .35); color: #fff; }
.run .button:hover:not(:disabled) { background: #fff; color: #000; border-color: #fff; }
.run .button.danger { border-color: rgba(255, 107, 107, .5); color: #ff9b9b; }
.run .button.danger:hover:not(:disabled) { background: #ff4d4d; color: #fff; border-color: #ff4d4d; }


@media (max-width: 720px) {
  .run { grid-template-columns: 1fr; grid-template-rows: 1fr auto auto; grid-template-areas: "main" "side" "controls"; }
  .run-side { border-left: none; border-top: 1px solid rgba(255, 255, 255, .18); max-height: 30vh; }
}

/* ---------- Summary ---------- */
.summary { padding: 60px 0; }
.summary h2 { font-size: clamp(32px, 5vw, 52px); }
.summary-total { color: var(--muted); }
.table-scroll { overflow-x: auto; margin-top: 20px; }
.table-scroll .summary-table { margin-top: 0; }
.summary-table { width: 100%; border-collapse: collapse; margin-top: 20px; }
.summary-table th, .summary-table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); }
.summary-table th { color: var(--muted); font-size: 12px; letter-spacing: .06em; text-transform: uppercase; font-weight: 600; }
.summary-table td { font-variant-numeric: tabular-nums; }
.summary-table td.over { color: #ff6b6b; }
.summary-table td.under { color: #4ade80; }
.speaker-totals { margin-top: 36px; }
.speaker-totals h3 { margin: 0 0 8px; font-size: 14px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }

/* ---------- Templates & Bulk Import ---------- */
.template-bar {
  display: flex; align-items: center; gap: 8px; margin: -12px 0 20px; flex-wrap: wrap;
}
.template-label { font-size: 13px; color: var(--muted); }
.pill-button {
  background: var(--surface); color: var(--text); border: 1px solid var(--line);
  padding: 4px 12px; border-radius: 999px; font-size: 12px; cursor: pointer;
  transition: all .15s ease;
}
.pill-button:hover {
  border-color: var(--cyan); color: var(--cyan); transform: translateY(-1px);
}

.setup-add-group { display: flex; gap: 10px; align-items: center; }
.import-box {
  margin: 10px 0 20px; padding: 16px; border: 1px dashed var(--line-bright);
  border-radius: 12px; background: var(--surface);
}
.import-box textarea { margin-top: 6px; font-family: inherit; font-size: 14px; }
.import-actions { display: flex; gap: 8px; margin-top: 10px; }

/* ---------- Overtime Animation ---------- */
@keyframes overtime-pulse {
  0% { box-shadow: inset 0 0 0 0 rgba(255, 77, 77, 0.3); }
  50% { box-shadow: inset 0 0 60px 15px rgba(255, 77, 77, 0.7); }
  100% { box-shadow: inset 0 0 0 0 rgba(255, 77, 77, 0.3); }
}
.run[data-state="red"] {
  animation: overtime-pulse 2s infinite ease-in-out;
}

/* ---------- Shortcuts Dialog ---------- */
.shortcuts-dialog {
  border: 1px solid var(--line-bright); border-radius: 16px; padding: 0;
  background: var(--surface); color: var(--text); max-width: 440px; width: 90%;
  box-shadow: 0 20px 40px rgba(0, 0, 0, .6);
}
.shortcuts-dialog::backdrop {
  background: rgba(0, 0, 0, .75); backdrop-filter: blur(4px);
}
.dialog-content { padding: 24px; }
.dialog-head {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px;
}
.dialog-head h3 { margin: 0; font-size: 20px; }
.shortcuts-list {
  list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px;
}
.shortcuts-list li {
  display: flex; align-items: center; justify-content: space-between; gap: 14px; font-size: 14px;
}
.shortcuts-list kbd {
  background: var(--surface-hover); border: 1px solid var(--line-bright);
  padding: 3px 8px; border-radius: 6px; font-family: monospace; font-size: 13px;
  color: var(--cyan); min-width: 28px; text-align: center;
}

