/* ---- Fonts (self-hosted from @fontsource/poppins) ---------------------- */

@font-face { font-family: 'Poppins'; font-weight: 400; font-display: swap; src: url('/assets/fonts/poppins-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'Poppins'; font-weight: 500; font-display: swap; src: url('/assets/fonts/poppins-latin-500-normal.woff2') format('woff2'); }
@font-face { font-family: 'Poppins'; font-weight: 600; font-display: swap; src: url('/assets/fonts/poppins-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'Poppins'; font-weight: 700; font-display: swap; src: url('/assets/fonts/poppins-latin-700-normal.woff2') format('woff2'); }

/* ---- Tokens ------------------------------------------------------------ */

:root {
  color-scheme: light;
  /* Brand colours (--brand, --brand-hover, --brand-text, --on-brand, --focus,
     --topbar, --topbar-text, --topbar-accent, --target) come from
     /assets/brand.css, generated from the BRAND_* settings in .env. */
  --topbar-muted: #a7a7b0;
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-muted: #fafafb;
  --text: #17171c;
  --text-muted: #5d5e67;
  --border: #e3e3e8;
  --border-strong: #c9c9d1;
  --success-bg: #e9f6ee;
  --success-text: #17643a;
  --warning-bg: #fdf1e4;
  --warning-text: #8a4300;
  --danger: #b3000b;
  --danger-solid: #b3000b;
  --pill-live-bg: #e3f4ea; --pill-live-text: #17643a;
  --pill-soon-bg: #fdf0dc; --pill-soon-text: #8a4a00;
  --pill-closed-bg: #ececf0; --pill-closed-text: #4c4d55;
  --shadow: 0 1px 2px rgb(16 16 24 / 6%), 0 1px 1px rgb(16 16 24 / 4%);
  --radius: 8px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #111114;
    --surface: #1a1a1f;
    --surface-muted: #16161a;
    --text: #ececf1;
    --text-muted: #a2a3ad;
    --border: #2c2c33;
    --border-strong: #3d3d46;
    --success-bg: #14301f; --success-text: #8bd8a8;
    --warning-bg: #3a2610; --warning-text: #f5c07d;
    --danger: #ff7a80;
    --danger-solid: #d6232c;
    --pill-live-bg: #14301f; --pill-live-text: #8bd8a8;
    --pill-soon-bg: #3a2610; --pill-soon-text: #f5c07d;
    --pill-closed-bg: #2a2a31; --pill-closed-text: #b9bac3;
    --shadow: none;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111114;
  --surface: #1a1a1f;
  --surface-muted: #16161a;
  --text: #ececf1;
  --text-muted: #a2a3ad;
  --border: #2c2c33;
  --border-strong: #3d3d46;
  --success-bg: #14301f; --success-text: #8bd8a8;
  --warning-bg: #3a2610; --warning-text: #f5c07d;
  --danger: #ff7a80;
  --danger-solid: #d6232c;
  --pill-live-bg: #14301f; --pill-live-text: #8bd8a8;
  --pill-soon-bg: #3a2610; --pill-soon-text: #f5c07d;
  --pill-closed-bg: #2a2a31; --pill-closed-text: #b9bac3;
  --shadow: none;
}

/* ---- Base -------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 400 15px/1.6 'Poppins', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

h1, h2, h3 { line-height: 1.25; margin: 0; font-weight: 600; }
h1 { font-size: 1.85rem; letter-spacing: -0.01em; }
h2 { font-size: 1.1rem; }
p { margin: 0; }
a { color: var(--brand-text); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

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

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

.muted { color: var(--text-muted); }
.small { font-size: 0.82rem; }
.mono { font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace; font-size: 0.85rem; }
.prewrap { white-space: pre-wrap; overflow-wrap: anywhere; }
.break { overflow-wrap: anywhere; }
[hidden] { display: none !important; }

/* ---- Top bar & breadcrumb ---------------------------------------------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  /* On a phone the admin links don't fit beside the brand, so they move to
     a second row rather than squeezing or pushing the page sideways. */
  flex-wrap: wrap;
  gap: 8px 16px;
  min-height: 56px;
  padding: 8px 16px;
  background: var(--topbar);
  color: var(--topbar-text);
  border-bottom: 3px solid var(--brand);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
  white-space: nowrap;
}
.brand-name { font-weight: 700; font-size: 0.8rem; letter-spacing: 0.16em; text-transform: uppercase; }
.brand-divider { width: 1px; height: 16px; background: currentColor; opacity: 0.35; }
.brand-product { font-weight: 500; font-size: 1rem; color: var(--brand); }
.topbar .brand-product { color: var(--topbar-accent); }

.topbar-tools { display: flex; align-items: center; gap: 8px; margin-left: auto; }

.icon-button {
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: inherit;
  cursor: pointer;
}
.topbar .icon-button { border-color: color-mix(in srgb, currentColor 25%, transparent); }
.icon-button:hover { background: rgb(127 127 140 / 14%); }
.icon-button.small { width: 30px; height: 30px; color: var(--text-muted); }
.icon-button.small svg { width: 16px; height: 16px; }
.icon-button.is-done { color: var(--success-text); background: var(--success-bg); }

.menu { position: relative; }
.menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 10;
  min-width: 180px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 8px 24px rgb(0 0 0 / 14%);
}
.check { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--brand); }

.admin-nav { display: flex; align-items: center; gap: 14px; white-space: nowrap; font-size: 0.88rem; }
.admin-nav a, .admin-nav .link-button { color: var(--topbar-text); text-decoration: none; }
.admin-nav a:hover, .admin-nav .link-button:hover { text-decoration: underline; }

.crumbs {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-muted);
  font-size: 0.85rem;
}
.crumbs ol { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; min-width: 0; }
.crumbs li { color: var(--text-muted); overflow-wrap: anywhere; }
.crumbs li + li::before { content: '/'; margin-right: 6px; color: var(--border-strong); }
.crumbs [aria-current] { color: var(--text); font-weight: 500; }
.crumbs a { color: var(--text-muted); text-decoration: none; }
.crumbs a:hover { color: var(--text); text-decoration: underline; }

/* ---- Layout ------------------------------------------------------------ */

.main { flex: 1; width: 100%; padding: 32px 16px 48px; }
.main-bare { display: grid; place-items: center; }
.footer { padding: 20px 16px; border-top: 1px solid var(--border); text-align: center; font-size: 0.8rem; color: var(--text-muted); }

.narrow { max-width: 560px; margin: 0 auto; display: grid; gap: 20px; }
.wide { max-width: 1180px; margin: 0 auto; display: grid; gap: 20px; }
.pad { max-width: 1000px; margin: 0 auto; display: grid; gap: 20px; }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head h1 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pad-heading { display: grid; gap: 4px; }
.pad-heading h1 { overflow-wrap: anywhere; }
.pad-meta { color: var(--text-muted); font-size: 0.85rem; }

.pad-grid, .admin-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 340px);
  gap: 20px;
  align-items: start;
}
.admin-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 360px); }
.pad-main, .admin-main, .admin-side { display: grid; gap: 20px; min-width: 0; }

@media (max-width: 860px) {
  .pad-grid, .admin-grid { grid-template-columns: minmax(0, 1fr); }
  h1 { font-size: 1.5rem; }
}

/* ---- Cards & forms ----------------------------------------------------- */

.card {
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  min-width: 0;
}
.card.flush { padding: 0; overflow: hidden; }
.card > h2 + * { margin-top: 0; }
.stack { display: grid; gap: 10px; }
.stack > h2 { margin-bottom: 4px; }

@media (max-width: 560px) {
  .card { padding: 18px; }
}

.prompt { padding-block: 28px; font-size: 1rem; }
.latest-message { display: grid; gap: 8px; }

.label {
  display: block;
  margin-top: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.answer-form .label:first-child { margin-top: 0; }
.answer-form .input { margin: 6px 0 12px; }

.input {
  display: block;
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
.input:focus { outline: 2px solid var(--focus); outline-offset: -1px; border-color: transparent; }
.input[aria-invalid="true"] { border-color: var(--danger); }
textarea.input { resize: vertical; min-height: 96px; }
select.input { appearance: auto; }
.input.small { padding: 5px 8px; font-size: 0.78rem; }
.input-row { display: flex; gap: 8px; }
.input-row .input { flex: 1; min-width: 0; }
.hint { font-size: 0.82rem; color: var(--text-muted); }
.field-error { font-size: 0.85rem; color: var(--danger); }

.form-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 4px; }
.form-status { font-size: 0.88rem; color: var(--text-muted); }
.form-status[data-tone="error"] { color: var(--danger); }
.form-status[data-tone="success"] { color: var(--success-text); }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font: 500 0.9rem/1.4 inherit;
  font-family: inherit;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}
.button:hover { background: var(--surface-muted); border-color: var(--text-muted); }
.button:disabled { opacity: 0.6; cursor: progress; }
.button.primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.button.primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
.button.subtle { background: transparent; }
.button.small { padding: 5px 10px; font-size: 0.82rem; }
.button.small svg { width: 15px; height: 15px; }
.button.block { width: 100%; }
.button.danger { background: var(--danger-solid); border-color: var(--danger-solid); color: #fff; }
.button.danger-outline { color: var(--danger); border-color: currentColor; background: transparent; }
.button.is-done { color: var(--success-text); border-color: currentColor; }

.link-button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--brand-text);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.link-button.danger { color: var(--danger); }

.notice {
  padding: 12px 16px;
  border-radius: 6px;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  font-size: 0.9rem;
}
.notice.success { background: var(--success-bg); border-color: transparent; color: var(--success-text); }
.notice.warning { background: var(--warning-bg); border-color: transparent; color: var(--warning-text); }
.notice ul { margin: 0; padding-left: 18px; }

.pill {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  vertical-align: middle;
  text-transform: capitalize;
  white-space: nowrap;
}
.pill-live { background: var(--pill-live-bg); color: var(--pill-live-text); }
.pill-soon { background: var(--pill-soon-bg); color: var(--pill-soon-text); }
.pill-closed { background: var(--pill-closed-bg); color: var(--pill-closed-text); }
.pill-owner { background: var(--pill-closed-bg); color: var(--pill-closed-text); }

.row-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; white-space: nowrap; }

/* ---- Participant page -------------------------------------------------- */

.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.count { margin-left: 4px; color: var(--text-muted); font-weight: 500; font-size: 0.9rem; }
.empty { color: var(--text-muted); font-size: 0.9rem; }

.live-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--text-muted);
}
.live-status::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border-strong);
}
.live-status[data-state="live"]::before { background: #1f9d55; box-shadow: 0 0 0 3px rgb(31 157 85 / 18%); }
.live-status[data-state="reconnecting"]::before,
.live-status[data-state="polling"]::before { background: #d98b00; }

.contribution-list, .message-list, .admin-list, .request-list { margin: 0; padding: 0; list-style: none; }

.contribution { padding: 16px 0; border-top: 1px solid var(--border); }
.contribution:first-child { border-top: 0; padding-top: 0; }
.contribution.is-target { margin-inline: -12px; padding-inline: 12px; border-radius: 6px; background: var(--target); }
.contribution-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.contribution-name { font-weight: 600; overflow-wrap: anywhere; }
.contribution-actions { display: flex; gap: 2px; flex-shrink: 0; }
.contribution-body { font-size: 0.95rem; }
.contribution-time { display: block; margin-top: 8px; font-size: 0.78rem; color: var(--text-muted); }

.facilitator h2 { margin-bottom: 12px; }
.message { display: grid; gap: 4px; padding: 12px 0; border-top: 1px solid var(--border); font-size: 0.92rem; }
.message:first-child { border-top: 0; padding-top: 0; }

/* ---- Closed screen ----------------------------------------------------- */

.closed-card { width: 100%; max-width: 440px; display: grid; gap: 16px; padding: 36px 40px; box-shadow: 0 12px 40px rgb(16 16 24 / 10%); }
.closed-card h1 { font-size: 1.45rem; }
.closed-card > p { color: var(--text-muted); font-size: 0.92rem; }
.brand-inline { color: var(--text); }
.brand-inline .brand-name { font-size: 0.75rem; }
.brand-inline .brand-product { color: var(--brand-text); }

@media (max-width: 560px) {
  .closed-card { padding: 24px 20px; }
}

/* ---- Admin ------------------------------------------------------------- */

.table-scroll { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.table th, .table td { padding: 12px 16px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.table th { font-size: 0.75rem; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-muted); background: var(--surface-muted); white-space: nowrap; }
.table tbody tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; }
.table a { text-decoration: none; }
.table a:hover { text-decoration: underline; }

.share { display: grid; gap: 8px; }

.admin-list li { padding: 14px 0; border-top: 1px solid var(--border); display: grid; gap: 6px; }
.admin-list li:first-child { border-top: 0; }
.admin-list li.is-hidden .prewrap { color: var(--text-muted); text-decoration: line-through; }
.admin-list-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

.request-list li { padding: 12px 0; border-top: 1px solid var(--border); display: grid; gap: 6px; }
.request-list li:first-child { border-top: 0; padding-top: 0; }
.inline-actions { display: flex; gap: 8px; }

.live-banner { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.danger-zone h2 { color: var(--danger); }

/* ---- Confirmation dialog ---------------------------------------------- */

.confirm-dialog {
  width: min(420px, calc(100vw - 32px));
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 20px 50px rgb(0 0 0 / 25%);
}
.confirm-dialog::backdrop { background: rgb(10 10 14 / 50%); }
.confirm-dialog p { margin-bottom: 20px; }
.confirm-dialog .form-actions { justify-content: flex-end; }

/* ---- Dashboard folders ------------------------------------------------- */

.folder { display: grid; gap: 10px; }
.folder-name { display: flex; align-items: baseline; gap: 6px; font-size: 1.05rem; }
.folder-name a { color: var(--text); text-decoration: none; }
.folder-name a:hover { color: var(--brand-text); text-decoration: underline; }

/* ---- Folder combobox (full-width suggestions) ------------------------- */

.combobox { position: relative; }
.combobox .input { padding-right: 42px; }
.combobox-toggle {
  position: absolute;
  top: 1px;
  right: 1px;
  bottom: 1px;
  width: 40px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 0 6px 6px 0;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}
.combobox-toggle:hover { color: var(--text); }
.combobox-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 20;
  max-height: 260px;
  margin: 0;
  padding: 4px;
  overflow-y: auto;
  list-style: none;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: 0 8px 24px rgb(0 0 0 / 14%);
}
.combobox-list [role="option"] {
  padding: 8px 12px;
  border-radius: 4px;
  cursor: pointer;
  overflow-wrap: anywhere;
}
.combobox-list [role="option"]:hover { background: var(--surface-muted); }
.combobox-list [role="option"].is-active { background: var(--brand); color: var(--on-brand); }
