/* Facilitator console /admin. Phone-first: one column for one hand at 360-430 px; a wider screen just centres
   the same 480 px column. The primary action (Reveal results / Reopen) sits in a bar fixed to the bottom of
   the screen, in the thumb zone. Chrome and tokens come from /shared/atp.css. */

:root {
  --danger: #B42318;       /* 6.5:1 on white */
  --on-danger: #FFFFFF;
  --field-line: #5A6472;   /* input borders: 3:1+ against the panel */
  --tint-open: #E3F4F1;
  --tint-revealed: #FDF0E6;
  --tint-closed: #ECEEF1;
  --col: 480px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --danger: #F97066;
    --on-danger: #16191D;
    --field-line: #9AA3B0;
    --tint-open: #15302C;
    --tint-revealed: #2A2118;
    --tint-closed: #252A31;
  }
}
:root[data-theme="dark"] {
  --danger: #F97066;
  --on-danger: #16191D;
  --field-line: #9AA3B0;
  --tint-open: #15302C;
  --tint-revealed: #2A2118;
  --tint-closed: #252A31;
}

/* Page frame */
.adm-head {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: var(--col);
  margin: 0 auto;
  padding: 10px 16px 0;
}
.adm-logo { height: 28px; }

/* The logo's wordmark is dark; on the dark theme it sits on a small light chip (as on the participant page). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .adm-logo {
    height: 36px;
    padding: 4px 8px;
    border-radius: 8px;
    background: #FFFFFF;
  }
}
:root[data-theme="dark"] .adm-logo {
  height: 36px;
  padding: 4px 8px;
  border-radius: 8px;
  background: #FFFFFF;
}
.adm-title {
  flex: 1;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
}
.adm-signout {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 4px;
  color: var(--fg);
  font-size: 14px;
  text-underline-offset: 3px;
}
.adm-offline {
  position: sticky;
  top: 8px;
  z-index: 5;
  width: fit-content;
  max-width: calc(100% - 32px);
  margin: 8px auto 0;
  text-align: center;
}
.adm {
  max-width: var(--col);
  margin: 0 auto;
  padding: 12px 16px 40px;
}
.adm p { margin: 0; }
.adm h1 { font-size: 26px; line-height: 1.2; }
.adm h2 { font-size: 16px; line-height: 1.3; }
.adm-loading { padding: 32px 0; color: var(--muted); }

.view {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.adm-back,
.adm-link {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--fg);
  font-size: 15px;
  font-weight: 500;
  text-underline-offset: 3px;
}
.adm-back { margin-bottom: -12px; text-decoration: none; }
.adm-wide {
  width: 100%;
  min-height: 52px;
  font-size: 16px;
}
.adm-error {
  padding: 10px 14px;
  border: 1.5px solid var(--danger);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--danger);
  font-weight: 600;
}
.adm-error:empty,
.adm-note:empty,
.copy-status:empty { display: none; }
.adm-note { color: var(--fg); font-weight: 600; }
.copy-status { font-size: 14px; color: var(--fg); }
.hint { font-size: 14px; color: var(--muted); }
.label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
}
.cards {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.card-actions .btn { flex: 1 1 140px; min-height: 48px; }

/* Status pill: the state is always in the text; colour only reinforces it. */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  padding: 4px 14px;
  border: 1.5px solid var(--grey);
  border-radius: 999px;
  background: var(--tint-closed);
  color: var(--fg);
  font-size: 15px;
  font-weight: 700;
}
.pill::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--grey);
}
.pill.is-open { border-color: var(--teal); background: var(--tint-open); }
.pill.is-open::before { background: var(--teal); }
.pill.is-revealed { border-color: var(--orange); background: var(--tint-revealed); }
.pill.is-revealed::before { background: var(--orange); }
.pill-sm { padding: 1px 10px; font-size: 13px; }

/* Sessions list */
.list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.list-head .btn { min-height: 48px; }
.sess-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.sess {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
}
.sess-main {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
  color: var(--fg);
  text-decoration: none;
}
.sess-group {
  color: var(--navy);
  font-size: 17px;
  font-weight: 700;
  line-height: 1.3;
  overflow-wrap: anywhere;
}
.sess-meta {
  color: var(--muted);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.sess-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
  font-size: 14px;
  font-weight: 600;
}
.sess-display {
  display: flex;
  align-items: center;
  min-height: 48px;
  padding: 0 16px;
  border-top: 1px solid var(--line);
  color: var(--fg);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
}
.sess-display::after { content: "\2197" / ""; margin-left: 6px; }
@media (hover: hover) {
  .sess-main:hover .sess-group,
  .sess-display:hover { text-decoration: underline; text-underline-offset: 3px; }
}

/* Form */
.adm-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.field label { font-size: 15px; font-weight: 600; }
.field input,
.field textarea {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border: 1.5px solid var(--field-line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--fg);
  font: inherit;
  font-size: 16px; /* 16px stops iOS zooming into the field */
}
.field textarea { min-height: 72px; resize: vertical; }
.field [aria-invalid="true"] { border-color: var(--danger); border-width: 2px; }
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* Success screen */
.ready-group {
  color: var(--navy);
  font-size: 18px;
  font-weight: 700;
  overflow-wrap: anywhere;
}
.ready-code {
  color: var(--navy);
  font-size: 44px;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: 0.12em;
  font-variant-numeric: tabular-nums;
}
.ready-url {
  font-size: 18px;
  font-weight: 600;
  overflow-wrap: anywhere;
}
.ready-display { font-size: 15px; }
.ready-display a { color: var(--fg); font-weight: 700; overflow-wrap: anywhere; text-underline-offset: 3px; }

/* Control screen */
.ctl { padding-bottom: 150px; } /* room for the fixed action bar */
.ctl-head { display: flex; flex-direction: column; gap: 4px; }
.ctl-head h1 { overflow-wrap: anywhere; }
.ctl-count {
  color: var(--fg);
  font-size: 26px;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.ctl-n {
  color: var(--navy);
  font-size: 80px;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.ctl-status { display: flex; flex-direction: column; gap: 6px; }
.ctl-code {
  color: var(--navy);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.1em;
}

.toggles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.toggle {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 64px;
  padding: 8px;
  border: 1.5px solid var(--field-line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--fg);
  font: inherit;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}
.toggle-state { color: var(--muted); font-size: 13px; font-weight: 600; }
.toggle[aria-pressed="true"] {
  border-color: var(--btn-bg);
  background: var(--btn-bg);
  color: var(--btn-fg);
}
.toggle[aria-pressed="true"] .toggle-state { color: var(--btn-fg); }
.toggle[aria-pressed="true"] .toggle-state::before { content: "\2713\00a0" / ""; }
.toggle:disabled,
.toggle[aria-disabled="true"] { opacity: 0.6; cursor: progress; }

/* Compare card: the attached comparison, same-group sessions as one-tap rows, file upload. */
.cmp-current {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
  padding: 12px 14px;
  border-left: 4px solid var(--teal);
  border-radius: var(--radius);
  background: var(--tint-open);
}
.cmp-summary {
  flex: 1 1 200px;
  min-width: 0;
  font-weight: 700;
  overflow-wrap: anywhere;
}
.cmp-current .btn { min-height: 44px; }
.cmp-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.cmp-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 48px;
  padding: 8px 14px;
  border: 1.5px solid var(--field-line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--fg);
  font: inherit;
  font-size: 15px;
  text-align: left;
  cursor: pointer;
}
.cmp-row-when { font-weight: 700; font-variant-numeric: tabular-nums; }
.cmp-row-n { color: var(--muted); font-size: 14px; white-space: nowrap; }
.cmp-row[aria-disabled="true"] { opacity: 0.6; cursor: progress; }
@media (hover: hover) {
  .cmp-row:hover:not([aria-disabled="true"]) { border-color: var(--fg); background: var(--btn2-bg-hover); }
}
.field input[type="file"] {
  min-height: 48px;
  padding: 8px;
  font-size: 15px;
}
.field input[type="file"][aria-disabled="true"] { opacity: 0.6; cursor: progress; }

.danger {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
}
.danger summary {
  display: flex;
  align-items: center;
  min-height: 48px;
  padding: 0 16px;
  color: var(--danger);
  font-weight: 700;
  cursor: pointer;
}
.danger[open] { display: flex; flex-direction: column; gap: 12px; padding-bottom: 16px; }
.danger > p,
.danger > .btn { margin: 0 16px; }
.btn-danger {
  border-color: var(--danger);
  background: var(--danger);
  color: var(--on-danger);
}
@media (hover: hover) {
  .btn-danger:hover:not(:disabled) { border-color: var(--danger); background: var(--danger); text-decoration: underline; }
}

/* Bottom action bar (thumb zone) */
.actionbar {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 10;
  padding: 8px 16px calc(12px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.08);
}
.actionbar-inner {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: calc(var(--col) - 32px);
  margin: 0 auto;
}
.actionbar-hint {
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}
.act {
  width: 100%;
  min-height: 60px;
  font-size: 18px;
}
.act.is-reopen {
  border-color: var(--btn2-fg);
  background: var(--btn2-bg);
  color: var(--btn2-fg);
}
/* Busy (aria-disabled while its request runs, or until the first poll lands): looks disabled, keeps focus. */
.act[aria-disabled="true"],
.btn-danger[aria-disabled="true"] { cursor: progress; }
@media (hover: hover) {
  .act.is-reopen:hover:not(:disabled):not([aria-disabled="true"]) { border-color: var(--btn2-fg); background: var(--btn2-bg-hover); }
  .act[aria-disabled="true"]:hover { border-color: var(--btn-bg); background: var(--btn-bg); }
  .act.is-reopen[aria-disabled="true"]:hover { border-color: var(--btn2-fg); background: var(--btn2-bg); }
}

/* Reset dialog */
.dlg {
  width: min(440px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  padding: 20px;
  border: 0;
  border-radius: 16px;
  background: var(--panel);
  color: var(--fg);
}
.dlg::backdrop { background: rgba(0, 0, 0, 0.55); }
.dlg-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.dlg-form p { margin: 0; }
.dlg-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.dlg-head h2 { font-size: 20px; padding-top: 6px; }
.dlg-close {
  flex: none;
  width: 44px;
  height: 44px;
  border: 1px solid var(--field-line);
  border-radius: 50%;
  background: transparent;
  color: var(--fg);
  font: inherit;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}
.dlg-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}
.dlg-actions .btn { flex: 1 1 140px; min-height: 48px; }
#reset-name-hint { overflow-wrap: anywhere; }
