/* Steno dashboard design system (wiki/specs/dashboard-design-system.md).
   Tokens first, then base elements, then the app shell, then components.
   Tokens are prefixed --ui- so they never clash with the live pages' own (live.css). */

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

:root {
  color-scheme: light dark;
  --ui-font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --ui-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --ui-bg: light-dark(#f5f6f8, #0e1014);
  --ui-surface: light-dark(#ffffff, #161920);
  --ui-surface-2: light-dark(#f0f2f5, #1d2129);
  --ui-text: light-dark(#14171c, #e7e9ee);
  --ui-muted: light-dark(#5c6370, #9aa1ad);
  --ui-border: light-dark(#e2e5ea, #262b34);
  --ui-border-strong: light-dark(#cdd2d9, #363c47);

  --ui-accent: light-dark(#3a5bdc, #8aa4ff);
  --ui-accent-hover: light-dark(#2f4cc0, #a3b7ff);
  --ui-accent-fg: light-dark(#ffffff, #0e1014);
  --ui-accent-soft: light-dark(#eaefff, #1e2640);

  --ui-live: light-dark(#12823b, #5fd68b);
  --ui-live-soft: light-dark(#e1f6e8, #11301d);
  --ui-waiting: light-dark(#8a5a00, #f2c35b);
  --ui-waiting-soft: light-dark(#fff4d1, #3a2d07);
  --ui-danger: light-dark(#c0263a, #ff8a8f);
  --ui-danger-soft: light-dark(#fdecee, #3a1519);
  --ui-highlight: light-dark(#fff1b8, #4a3c0a);

  --ui-screen-bg: #0d1013;
  --ui-screen-fg: #f2f4f7;
  --ui-screen-tr: #8fd0ff;

  --ui-radius: 10px;
  --ui-radius-sm: 7px;
  --ui-shadow: 0 1px 2px light-dark(rgb(16 24 40 / 6%), rgb(0 0 0 / 40%));
  --ui-shadow-lg: 0 12px 32px light-dark(rgb(16 24 40 / 16%), rgb(0 0 0 / 55%));
  --ui-focus: 0 0 0 3px light-dark(rgb(58 91 220 / 28%), rgb(138 164 255 / 35%));
}

:root[data-theme="light"] {
  color-scheme: light;
}

:root[data-theme="dark"] {
  color-scheme: dark;
}

@view-transition {
  navigation: auto;
}

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

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

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

body {
  margin: 0;
  background: var(--ui-bg);
  color: var(--ui-text);
  font: 15px/1.55 var(--ui-font);
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
h4 {
  margin: 0 0 0.6rem;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

h1 {
  font-size: 1.75rem;
  font-weight: 700;
}

h2 {
  font-size: 1.15rem;
  font-weight: 650;
}

h3 {
  font-size: 1rem;
  font-weight: 650;
}

p {
  margin: 0 0 0.75rem;
}

small {
  font-size: 0.85rem;
}

a {
  color: var(--ui-accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

code {
  font-family: var(--ui-mono);
  font-size: 0.88em;
  background: var(--ui-surface-2);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

mark {
  background: var(--ui-highlight);
  color: inherit;
  padding: 0.05em 0.3em;
  border-radius: 4px;
}

hr {
  border: 0;
  border-top: 1px solid var(--ui-border);
  margin: 1.5rem 0;
}

ul {
  padding-left: 1.2rem;
}

[hidden] {
  display: none !important;
}

:focus-visible {
  outline: none;
  box-shadow: var(--ui-focus);
}

.muted {
  color: var(--ui-muted);
}

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

/* Buttons: <button>, [role=button] and .btn look the same. Variants: .secondary
   (outlined), .ghost (no border), .danger. */

button,
.btn,
[role="button"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 2.35rem;
  padding: 0.45rem 0.95rem;
  border: 1px solid var(--ui-accent);
  border-radius: var(--ui-radius-sm);
  background: var(--ui-accent);
  color: var(--ui-accent-fg);
  font: inherit;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

button:hover,
.btn:hover,
[role="button"]:hover {
  background: var(--ui-accent-hover);
  border-color: var(--ui-accent-hover);
  text-decoration: none;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

button.secondary,
.btn.secondary,
[role="button"].secondary {
  background: var(--ui-surface);
  color: var(--ui-text);
  border-color: var(--ui-border-strong);
}

button.secondary:hover,
.btn.secondary:hover,
[role="button"].secondary:hover {
  background: var(--ui-surface-2);
  border-color: var(--ui-border-strong);
}

button.ghost,
.btn.ghost {
  background: transparent;
  color: var(--ui-muted);
  border-color: transparent;
}

button.ghost:hover,
.btn.ghost:hover {
  background: var(--ui-surface-2);
  color: var(--ui-text);
  border-color: transparent;
}

button.danger,
.btn.danger {
  background: var(--ui-surface);
  color: var(--ui-danger);
  border-color: color-mix(in srgb, var(--ui-danger) 45%, transparent);
}

button.danger:hover,
.btn.danger:hover {
  background: var(--ui-danger-soft);
  border-color: var(--ui-danger);
}

button.danger-solid {
  background: var(--ui-danger);
  border-color: var(--ui-danger);
  color: #fff;
}

button.danger-solid:hover {
  background: color-mix(in srgb, var(--ui-danger) 85%, black);
  border-color: color-mix(in srgb, var(--ui-danger) 85%, black);
}

.btn-sm,
td button,
td .btn {
  min-height: 1.9rem;
  padding: 0.25rem 0.65rem;
  font-size: 0.85rem;
}

.btn-lg {
  min-height: 2.9rem;
  padding: 0.65rem 1.4rem;
  font-size: 1.05rem;
}

.btn svg,
button svg {
  width: 1.05em;
  height: 1.05em;
  flex: none;
}

/* Inputs */

input:not([type="checkbox"], [type="radio"], [type="hidden"]),
select,
textarea {
  width: 100%;
  min-height: 2.35rem;
  padding: 0.45rem 0.7rem;
  border: 1px solid var(--ui-border-strong);
  border-radius: var(--ui-radius-sm);
  background: var(--ui-surface);
  color: var(--ui-text);
  font: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}

textarea {
  min-height: 6rem;
  resize: vertical;
  line-height: 1.5;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--ui-accent);
  box-shadow: var(--ui-focus);
}

input:disabled,
select:disabled,
textarea:disabled,
input[readonly] {
  background: var(--ui-surface-2);
  color: var(--ui-muted);
}

input[type="checkbox"],
input[type="radio"] {
  accent-color: var(--ui-accent);
  width: 1.05rem;
  height: 1.05rem;
  margin: 0;
}

label {
  font-weight: 550;
}

fieldset {
  border: 0;
  margin: 0;
  padding: 0;
  min-width: 0;
}

legend {
  padding: 0;
  font-weight: 550;
}

/* Tables */

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.93rem;
}

th,
td {
  text-align: left;
  padding: 0.65rem 0.9rem;
  border-bottom: 1px solid var(--ui-border);
  vertical-align: middle;
}

thead th {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ui-muted);
  background: var(--ui-surface-2);
}

tbody tr:last-child td,
tbody tr:last-child th {
  border-bottom: 0;
}

tbody th {
  font-weight: 600;
}

td form {
  margin: 0;
}

td input:not([type="checkbox"], [type="radio"]),
td select {
  min-height: 2rem;
  padding: 0.25rem 0.5rem;
}

.table-box {
  overflow-x: auto;
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius);
  background: var(--ui-surface);
  box-shadow: var(--ui-shadow);
  margin-bottom: 1rem;
}

.cell-actions {
  text-align: right;
  white-space: nowrap;
  width: 1%;
}

.cell-actions .row {
  flex-wrap: nowrap;
  justify-content: flex-end;
}

tr.is-faded td {
  opacity: 0.5;
}

/* Disclosure */

details > summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--ui-accent);
  list-style: none;
}

details > summary::-webkit-details-marker {
  display: none;
}

details > summary::before {
  content: "›";
  display: inline-block;
  width: 1em;
  transition: transform 0.15s;
}

details[open] > summary::before {
  transform: rotate(90deg);
}

details[open] > summary {
  margin-bottom: 0.75rem;
}

/* App shell ---------------------------------------------------------------------------- */

.shell {
  display: grid;
  grid-template-columns: 15.5rem minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  padding: 1.1rem 0.8rem;
  background: var(--ui-surface);
  border-right: 1px solid var(--ui-border);
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.2rem 0.5rem;
  font-size: 1.1rem;
  font-weight: 750;
  letter-spacing: -0.02em;
  color: var(--ui-text);
}

.brand:hover {
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 8px;
  background: var(--ui-accent);
  color: var(--ui-accent-fg);
}

.brand-mark svg {
  width: 1.15rem;
  height: 1.15rem;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.nav-label {
  margin: 0.9rem 0 0.3rem;
  padding: 0 0.6rem;
  font-size: 0.72rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ui-muted);
}

.nav a {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.45rem 0.6rem;
  border-radius: var(--ui-radius-sm);
  color: var(--ui-muted);
  font-weight: 550;
}

.nav a:hover {
  background: var(--ui-surface-2);
  color: var(--ui-text);
  text-decoration: none;
}

.nav a[aria-current="page"] {
  background: var(--ui-accent-soft);
  color: var(--ui-accent);
}

.nav svg,
.icon {
  width: 1.1rem;
  height: 1.1rem;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sidebar-foot {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--ui-border);
}

.account {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.35rem 0.5rem;
  border-radius: var(--ui-radius-sm);
  color: var(--ui-text);
  min-width: 0;
}

.account:hover {
  background: var(--ui-surface-2);
  text-decoration: none;
}

.account span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.88rem;
}

.avatar {
  display: grid;
  place-items: center;
  flex: none;
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 999px;
  background: var(--ui-accent-soft);
  color: var(--ui-accent);
  font-weight: 700;
  font-size: 0.85rem;
  text-transform: uppercase;
}

.sidebar-tools {
  display: flex;
  gap: 0.35rem;
  align-items: center;
}

.sidebar-tools form {
  margin: 0;
}

.icon-button {
  width: 2.25rem;
  min-height: 2.25rem;
  padding: 0;
  background: transparent;
  color: var(--ui-muted);
  border: 1px solid var(--ui-border);
}

.icon-button:hover {
  background: var(--ui-surface-2);
  color: var(--ui-text);
  border-color: var(--ui-border-strong);
}

.logout-button {
  background: transparent;
  color: var(--ui-muted);
  border-color: var(--ui-border);
  font-weight: 550;
  font-size: 0.88rem;
}

.logout-button:hover {
  background: var(--ui-surface-2);
  color: var(--ui-text);
  border-color: var(--ui-border-strong);
}

/* The moon offers dark when light is shown, the sun offers light when dark is shown. */
.theme-toggle .icon-sun {
  display: none;
}

:root[data-theme="dark"] .theme-toggle .icon-sun {
  display: block;
}

:root[data-theme="dark"] .theme-toggle .icon-moon {
  display: none;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun {
    display: block;
  }

  :root:not([data-theme="light"]) .theme-toggle .icon-moon {
    display: none;
  }
}

.content {
  width: 100%;
  max-width: 74rem;
  padding: 2rem clamp(1rem, 4vw, 3rem) 4rem;
}

.content-narrow {
  max-width: 44rem;
}

/* Logged out: one centered card. */
.auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem 1rem;
}

.auth-box {
  width: min(100%, 26rem);
}

.auth-box .brand {
  justify-content: center;
  margin-bottom: 1.25rem;
}

.auth-tools {
  display: flex;
  justify-content: center;
  margin-top: 1rem;
}

@media (max-width: 900px) {
  .shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 1rem;
    padding: 0.6rem 1rem;
    border-right: 0;
    border-bottom: 1px solid var(--ui-border);
  }

  .nav {
    order: 3;
    flex: 1 0 100%;
    flex-direction: row;
    overflow-x: auto;
    gap: 0.25rem;
    margin: 0 -0.25rem;
  }

  .nav a {
    white-space: nowrap;
    padding: 0.35rem 0.6rem;
  }

  .nav-label {
    display: none;
  }

  .sidebar-foot {
    margin: 0 0 0 auto;
    padding: 0;
    border: 0;
    flex-direction: row;
    align-items: center;
  }

  .account span:last-child {
    display: none;
  }

  .content {
    padding-top: 1.25rem;
  }
}

/* Page header -------------------------------------------------------------------------- */

.crumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0 0 0.6rem;
  padding: 0;
  list-style: none;
  font-size: 0.88rem;
  color: var(--ui-muted);
}

.crumbs li + li::before {
  content: "/";
  margin-right: 0.35rem;
  color: var(--ui-border-strong);
}

.crumbs a {
  color: var(--ui-muted);
}

.crumbs a:hover {
  color: var(--ui-text);
}

.page-head {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 1.5rem;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.page-head > div:first-child {
  min-width: 0;
}

.page-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.8rem;
}

.page-title h1 {
  margin: 0;
}

.page-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.9rem;
  margin: 0.45rem 0 0;
  color: var(--ui-muted);
  font-size: 0.93rem;
}

.page-meta > span {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.page-meta .icon {
  width: 1rem;
  height: 1rem;
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.page-actions form {
  margin: 0;
}

.lead {
  color: var(--ui-muted);
  max-width: 46rem;
}

/* Tabs --------------------------------------------------------------------------------- */

.tabs {
  display: flex;
  gap: 0.25rem;
  margin: 0 0 1.5rem;
  border-bottom: 1px solid var(--ui-border);
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs a {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.6rem 0.85rem;
  margin-bottom: -1px;
  border-bottom: 2px solid transparent;
  color: var(--ui-muted);
  font-weight: 600;
  white-space: nowrap;
}

.tabs a:hover {
  color: var(--ui-text);
  text-decoration: none;
}

.tabs a[aria-selected="true"] {
  color: var(--ui-text);
  border-bottom-color: var(--ui-accent);
}

.tab-count {
  font-size: 0.75rem;
  font-weight: 650;
  padding: 0.05rem 0.45rem;
  border-radius: 999px;
  background: var(--ui-surface-2);
  color: var(--ui-muted);
}

/* Without JavaScript every panel shows, one after the other. */
.tab-panel + .tab-panel {
  margin-top: 2.5rem;
}

.js .tab-panel + .tab-panel {
  margin-top: 0;
}

/* Cards and sections ------------------------------------------------------------------- */

.card {
  background: var(--ui-surface);
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius);
  box-shadow: var(--ui-shadow);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.card > :last-child {
  margin-bottom: 0;
}

.card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  margin-bottom: 0.9rem;
}

.card-head h2,
.card-head h3 {
  margin: 0;
}

.card-head p {
  margin: 0;
}

.card-flush {
  padding: 0;
  overflow: hidden;
}

.card-flush > .table-box {
  border: 0;
  border-radius: 0;
  box-shadow: none;
  margin: 0;
}

.card-danger {
  border-color: color-mix(in srgb, var(--ui-danger) 40%, var(--ui-border));
}

.card-danger h2 {
  color: var(--ui-danger);
}

.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  margin: 0 0 0.9rem;
}

.section-head h2 {
  margin: 0;
}

.section-head p {
  margin: 0;
}

.stack > * + * {
  margin-top: 1rem;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr));
  gap: 1rem;
  align-items: start;
}

.empty {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--ui-muted);
  border: 1px dashed var(--ui-border-strong);
  border-radius: var(--ui-radius);
  background: var(--ui-surface);
}

.empty strong {
  display: block;
  color: var(--ui-text);
  font-size: 1.05rem;
  margin-bottom: 0.25rem;
}

.empty p:last-child {
  margin-bottom: 0;
}

.kv {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.4rem 1.25rem;
  margin: 0;
}

.kv dt {
  color: var(--ui-muted);
  font-size: 0.9rem;
}

.kv dd {
  margin: 0;
}

.chips {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  align-items: center;
}

.chip {
  display: inline-block;
  padding: 0.05rem 0.5rem;
  border-radius: 5px;
  background: var(--ui-surface-2);
  border: 1px solid var(--ui-border);
  font-family: var(--ui-mono);
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--ui-text);
}

.arrow {
  color: var(--ui-muted);
}

/* Status pills ------------------------------------------------------------------------- */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  font-weight: 650;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  white-space: nowrap;
  background: var(--ui-surface-2);
  color: var(--ui-muted);
}

.pill::before {
  content: "";
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 999px;
  background: currentColor;
  opacity: 0.8;
}

.pill-live {
  background: var(--ui-live-soft);
  color: var(--ui-live);
}

.pill-live::before {
  animation: pulse 1.6s ease-in-out infinite;
}

.pill-waiting {
  background: var(--ui-waiting-soft);
  color: var(--ui-waiting);
}

@keyframes pulse {
  50% {
    opacity: 0.25;
  }
}

@media (prefers-reduced-motion: reduce) {
  .pill-live::before {
    animation: none;
  }
}

/* Notices and toasts ------------------------------------------------------------------- */

.notice,
.notice-warning {
  display: block;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  border-radius: var(--ui-radius-sm);
  border: 1px solid var(--ui-border);
  background: var(--ui-surface-2);
}

.notice-warning {
  background: var(--ui-waiting-soft);
  border-color: color-mix(in srgb, var(--ui-waiting) 35%, transparent);
  color: var(--ui-text);
}

.notice-warning code {
  background: transparent;
}

.toasts {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: min(24rem, calc(100vw - 2rem));
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.75rem 0.6rem 0.75rem 1rem;
  border-radius: var(--ui-radius);
  background: var(--ui-surface);
  border: 1px solid var(--ui-border);
  border-left: 4px solid var(--ui-accent);
  box-shadow: var(--ui-shadow-lg);
  animation: toast-in 0.2s ease-out;
}

.toast p {
  margin: 0;
  flex: 1;
}

.toast-success {
  border-left-color: var(--ui-live);
}

.toast-error {
  border-left-color: var(--ui-danger);
}

.toast-warning {
  border-left-color: var(--ui-waiting);
}

.toast button {
  min-height: 1.6rem;
  padding: 0 0.4rem;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(0.5rem);
  }
}

/* Forms -------------------------------------------------------------------------------- */

form {
  margin: 0 0 1rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-bottom: 1rem;
}

.field-label label,
.field-label legend {
  display: block;
}

.field-help {
  margin: 0;
  color: var(--ui-muted);
  font-size: 0.85rem;
  font-weight: 400;
  line-height: 1.45;
}

.field-errors,
.errorlist {
  margin: 0.15rem 0 0;
  padding: 0;
  list-style: none;
  color: var(--ui-danger);
  font-size: 0.88rem;
  font-weight: 550;
}

.form-errors {
  padding: 0.65rem 0.9rem;
  margin-bottom: 1rem;
  border-radius: var(--ui-radius-sm);
  background: var(--ui-danger-soft);
}

.field.has-error input,
.field.has-error select,
.field.has-error textarea {
  border-color: var(--ui-danger);
}

/* Checkbox fields: the switch sits next to its label. */
.field-check {
  flex-direction: row;
  align-items: flex-start;
  gap: 0.75rem;
}

.field-check .field-control {
  order: -1;
  padding-top: 0.15rem;
}

.field-check input[type="checkbox"] {
  appearance: none;
  position: relative;
  width: 2.3rem;
  height: 1.3rem;
  border-radius: 999px;
  background: var(--ui-border-strong);
  cursor: pointer;
  transition: background 0.15s;
}

.field-check input[type="checkbox"]::after {
  content: "";
  position: absolute;
  top: 0.15rem;
  left: 0.15rem;
  width: 1rem;
  height: 1rem;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 1px 2px rgb(0 0 0 / 25%);
  transition: transform 0.15s;
}

.field-check input[type="checkbox"]:checked {
  background: var(--ui-accent);
}

.field-check input[type="checkbox"]:checked::after {
  transform: translateX(1rem);
}

.field-check input[type="checkbox"]:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.field-choices > div {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.field-choices label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 400;
}

/* Settings forms: one section per group, label and help on the left. */
.form-section {
  display: grid;
  grid-template-columns: minmax(0, 15rem) minmax(0, 1fr);
  gap: 1rem 2.5rem;
  padding: 1.5rem 0;
  border-top: 1px solid var(--ui-border);
}

.form-section:first-of-type {
  border-top: 0;
  padding-top: 0.25rem;
}

.form-section-head h3 {
  margin: 0 0 0.25rem;
}

.form-section-head p {
  margin: 0;
  color: var(--ui-muted);
  font-size: 0.88rem;
}

.form-section-body > .field:last-child {
  margin-bottom: 0;
}

@media (max-width: 760px) {
  .form-section {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.75rem;
  }
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  padding-top: 1rem;
  margin-top: 0.5rem;
  border-top: 1px solid var(--ui-border);
}

.form-actions-sticky {
  position: sticky;
  bottom: 0;
  margin: 1rem -1.25rem -1.25rem;
  padding: 0.9rem 1.25rem;
  background: color-mix(in srgb, var(--ui-surface) 92%, transparent);
  backdrop-filter: blur(6px);
  border-radius: 0 0 var(--ui-radius) var(--ui-radius);
}

.form-inline {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem;
}

.form-inline .field {
  margin: 0;
  flex: 1 1 12rem;
}

.form-inline > button {
  flex: none;
}

.inline-form {
  display: inline;
  margin: 0;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.row form {
  margin: 0;
}

.copy-row {
  display: flex;
  gap: 0.5rem;
}

.copy-row input {
  min-width: 0;
  font-family: var(--ui-mono);
  font-size: 0.85rem;
}

.segmented {
  display: inline-flex;
  padding: 0.2rem;
  gap: 0.2rem;
  border-radius: var(--ui-radius-sm);
  background: var(--ui-surface-2);
  border: 1px solid var(--ui-border);
}

.segmented label {
  position: relative;
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.9rem;
  border-radius: 5px;
  font-weight: 600;
  color: var(--ui-muted);
  cursor: pointer;
}

.segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented label:has(input:checked) {
  background: var(--ui-surface);
  color: var(--ui-text);
  box-shadow: var(--ui-shadow);
}

.segmented label:has(input:focus-visible) {
  box-shadow: var(--ui-focus);
}

/* Dialogs ------------------------------------------------------------------------------ */

dialog {
  width: min(34rem, calc(100vw - 2rem));
  max-height: calc(100vh - 4rem);
  padding: 0;
  border: 1px solid var(--ui-border);
  border-radius: 14px;
  background: var(--ui-surface);
  color: var(--ui-text);
  box-shadow: var(--ui-shadow-lg);
}

dialog::backdrop {
  background: rgb(10 12 16 / 45%);
  backdrop-filter: blur(2px);
}

dialog[open] {
  animation: dialog-in 0.18s ease-out;
}

@keyframes dialog-in {
  from {
    opacity: 0;
    transform: translateY(0.5rem) scale(0.98);
  }
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem 0;
}

.dialog-head h2 {
  margin: 0;
}

.dialog-body {
  padding: 1rem 1.25rem 1.25rem;
}

.dialog-body form {
  margin: 0;
}

.dialog-confirm {
  width: min(26rem, calc(100vw - 2rem));
}

.dialog-confirm .dialog-body p {
  margin-bottom: 1.25rem;
}

.dialog-confirm .row {
  justify-content: flex-end;
}

/* Events ------------------------------------------------------------------------------- */

.event-group + .event-group {
  margin-top: 2rem;
}

.event-group h2 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ui-muted);
  margin-bottom: 0.75rem;
}

.event-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(19rem, 1fr));
  gap: 0.9rem;
}

.event-card {
  display: flex;
  gap: 1rem;
  align-items: center;
  padding: 1rem 1.1rem;
  margin: 0;
  color: inherit;
  transition: border-color 0.15s, transform 0.15s;
}

.event-card:hover {
  text-decoration: none;
  border-color: var(--ui-border-strong);
  transform: translateY(-1px);
}

.date-tile {
  flex: none;
  display: grid;
  place-items: center;
  width: 3.4rem;
  height: 3.6rem;
  border-radius: 9px;
  background: var(--ui-accent-soft);
  color: var(--ui-accent);
  line-height: 1.05;
  text-align: center;
}

.date-tile strong {
  font-size: 1.35rem;
}

.date-tile span {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
}

.event-card-body {
  min-width: 0;
  flex: 1;
}

.event-card-body strong {
  display: block;
  font-size: 1.02rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.event-card-body small {
  display: block;
  color: var(--ui-muted);
}

.event-card.is-live {
  border-color: color-mix(in srgb, var(--ui-live) 40%, var(--ui-border));
}

.event-card.is-live .date-tile {
  background: var(--ui-live-soft);
  color: var(--ui-live);
}

.event-card.is-ended {
  opacity: 0.75;
}

.event-card.is-ended .date-tile {
  background: var(--ui-surface-2);
  color: var(--ui-muted);
}

/* Rooms -------------------------------------------------------------------------------- */

.room-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(18.5rem, 1fr));
  gap: 0.9rem;
  margin-bottom: 1rem;
}

.room-card {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin: 0;
  border-top: 3px solid var(--ui-border-strong);
}

.room-card[data-state="live"] {
  border-top-color: var(--ui-live);
}

.room-card[data-state="waiting"] {
  border-top-color: var(--ui-waiting);
}

.room-card-head {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  justify-content: space-between;
}

.room-name {
  display: block;
  font-size: 1.12rem;
  font-weight: 700;
  color: var(--ui-text);
}

.room-langs {
  margin-top: 0.3rem;
}

.room-detail {
  margin: 0;
  min-height: 2.6em;
  color: var(--ui-muted);
  font-size: 0.9rem;
}

.room-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.room-actions form {
  margin: 0;
}

.room-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.9rem;
  margin: 0;
  padding-top: 0.7rem;
  border-top: 1px solid var(--ui-border);
  font-size: 0.85rem;
}

.quota-line {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  color: var(--ui-muted);
  font-size: 0.88rem;
}

.meter-line {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.meter-line meter {
  width: 5rem;
  height: 0.5rem;
}

/* Session panel ------------------------------------------------------------------------ */

.session-panel {
  border-left: 4px solid var(--ui-border-strong);
}

.session-panel[data-state="live"] {
  border-left-color: var(--ui-live);
}

.session-panel[data-state="waiting"] {
  border-left-color: var(--ui-waiting);
}

.session-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.1rem;
  margin: 0 0 1rem;
  color: var(--ui-muted);
  font-size: 0.9rem;
}

.screen {
  background: var(--ui-screen-bg);
  color: var(--ui-screen-fg);
  border-radius: var(--ui-radius);
  padding: 1rem 1.25rem;
  margin: 1rem 0;
  font-size: 1.05rem;
  line-height: 1.45;
}

.screen-label {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 0.72rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #8a93a0;
}

.screen p {
  margin: 0.45rem 0;
  color: var(--ui-screen-fg);
}

.screen .tr {
  color: var(--ui-screen-tr);
}

.engine-list {
  margin: 1rem 0 0;
  padding: 0.85rem 1rem;
  border-radius: var(--ui-radius-sm);
  background: var(--ui-surface-2);
  font-size: 0.9rem;
}

.engine-list p {
  margin: 0.15rem 0;
}

.start-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  margin: 0.5rem 0 1rem;
}

.start-form p {
  flex: 1 0 100%;
  margin: 0;
  color: var(--ui-muted);
}

/* Share -------------------------------------------------------------------------------- */

.share {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  align-items: center;
}

.share-qr {
  flex: none;
  display: block;
  padding: 0.5rem;
  border-radius: var(--ui-radius);
  background: #fff;
  border: 1px solid var(--ui-border);
}

.share-qr img {
  display: block;
}

.share-body {
  flex: 1 1 20rem;
  min-width: 0;
}

.share-body label {
  display: block;
  margin-bottom: 0.35rem;
}

.share-body .row {
  margin-top: 0.9rem;
}

/* Programme ---------------------------------------------------------------------------- */

.programme-day + .programme-day {
  margin-top: 1.5rem;
}

.programme-day h3 {
  font-size: 0.85rem;
  color: var(--ui-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.programme td {
  vertical-align: top;
}

.programme-time {
  white-space: nowrap;
  width: 1%;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--ui-muted);
}

.programme-times {
  display: flex;
  flex-wrap: wrap;
  gap: 0 1rem;
}

.programme-times > div {
  flex: 1 1 8rem;
}

/* Contract quotas on the event page (wiki/specs/room-quotas.md). */
.quota-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem 1rem;
  margin: 0;
}

.quota-form label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin: 0;
}

.quota-form input {
  width: 7rem;
}

/* Members ------------------------------------------------------------------------------ */

.person {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.person small {
  display: block;
  color: var(--ui-muted);
}

.link-reveal {
  border: 1px solid color-mix(in srgb, var(--ui-live) 40%, var(--ui-border));
  background: var(--ui-live-soft);
}

.link-reveal p {
  margin-bottom: 0.6rem;
}

.note-after {
  margin-top: 2rem;
}

.card-flush > .card-head {
  padding: 1.25rem 1.25rem 0;
}

.card-flush > .pad {
  padding: 0 1.25rem 1rem;
}

.card-flush > .table-box {
  border-top: 1px solid var(--ui-border);
}

.replay audio {
  width: 100%;
  margin-bottom: 0.25rem;
}

.spaced {
  margin: 1rem 0;
}

/* API connection statuses (backoffice). */
.pill-status-ready {
  background: var(--ui-live-soft);
  color: var(--ui-live);
}

.pill-status-busy {
  background: var(--ui-accent-soft);
  color: var(--ui-accent);
}

.pill-status-degraded {
  background: var(--ui-waiting-soft);
  color: var(--ui-waiting);
}

.pill-status-offline {
  background: var(--ui-danger-soft);
  color: var(--ui-danger);
}

.btn-block {
  width: 100%;
}

.auth-box h1 {
  font-size: 1.4rem;
  margin-bottom: 1.1rem;
}
