:root {
  --brand-teal: #236B78;
  --brand-teal-hover: #1C5660;
  --brand-navy: #1C2D50;
  --brand-divider: #E2ECEE;
  --brand-row: #F5F9F9;
  --brand-gold: #D4B075;
}

body {
  margin: 0;
  background: white;
  color: #222;
  font-family: system-ui, sans-serif;
  font-size: 1rem;
  line-height: 1.5;
  overflow-wrap: break-word;
}

[hidden] { display: none !important; }

.header-inner, main {
  width: calc(100% - 2rem);
  max-width: 70rem;
  margin-inline: auto;
}

.site-header { border-bottom: 1px solid var(--brand-divider); }
.header-inner { padding-block: 1rem; }
main { margin-block: 2rem; }
.submission-page { max-width: 48rem; }
.participant-page { max-width: 82rem; }
.login-layout, .message-page { max-width: 30rem; }

.header-inner, .header-nav, .row-actions, .setup-actions, .button-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem 1rem;
}

.header-inner { justify-content: space-between; }
.brand {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  color: var(--brand-navy);
  font-weight: 600;
}
.brand-seal { flex-shrink: 0; }
.login-artwork {
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--brand-gold);
}
.login-artwork img { display: block; margin-inline: auto; }
.setup-actions, .button-row { margin-bottom: 1rem; }

h1, h2, h3 {
  color: var(--brand-navy);
  margin: 0 0 1rem;
  font-weight: 600;
  line-height: 1.25;
}

h1 { font-size: 1.75rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.125rem; }
p, ul, ol, dl { margin: 0 0 1rem; }
ul, ol { padding-left: 1.5rem; }
li + li { margin-top: .5rem; }

.page-heading, .counts, .steps { margin-bottom: 1.5rem; }
.page-heading p { margin-bottom: .5rem; }
.back-link { display: inline-block; margin-bottom: 1rem; }
.workspace-grid > * + *, .submission-grid > * + * {
  margin-top: 2rem;
}

.counts > div { display: flex; flex-wrap: wrap; gap: .5rem; }
.counts dd { margin: 0; font-weight: 600; }
.muted, .table-secondary { color: #595959; }
.small, .table-secondary { font-size: .875rem; }

a { color: var(--brand-teal); }
a, .text-button { text-underline-offset: .15em; }
:focus-visible { outline: 2px solid var(--brand-teal); outline-offset: 3px; }

input, select, button, .button {
  box-sizing: border-box;
  max-width: 100%;
  min-height: 2.75rem;
  padding: .5rem .75rem;
  border: 1px solid #888;
  border-radius: .2rem;
  font: inherit;
}

input, select {
  width: 100%;
  background: white;
  color: inherit;
}

.stack-form, .device-grid p { max-width: 30rem; }
.stack-form label, .device-grid label {
  display: block;
  margin-bottom: .5rem;
  font-weight: 600;
}
.stack-form br { display: none; }

.filters {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 10rem) minmax(0, 16rem) auto;
  align-items: end;
  gap: .5rem .75rem;
  margin-bottom: .75rem;
}
.filters p { min-width: 0; margin: 0; }
.filters label {
  display: block;
  margin-bottom: .25rem;
  color: #595959;
  font-size: .875rem;
  font-weight: 400;
}
.filters input, .filters select { min-width: 0; border-color: #aaa; }
.filters .filter-actions { display: flex; align-items: center; gap: .75rem; }
.filters .filter-actions a { display: inline-flex; align-items: center; min-height: 2.75rem; }
#clear-filters[hidden] { display: inline-flex !important; visibility: hidden; }

@media (width < 48rem) {
  .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters .filter-search, .filters .filter-actions { grid-column: 1 / -1; }
}

.invite-dialog {
  box-sizing: border-box;
  width: 34rem;
  max-width: calc(100% - 2rem);
  max-height: calc(100dvh - 2rem);
  margin: auto;
  padding: 1.5rem;
  overflow: auto;
  border: 1px solid #888;
  border-radius: .2rem;
  background: white;
  color: inherit;
}
.invite-dialog::backdrop { background: rgb(0 0 0 / 45%); }
.invite-dialog .invite-note { margin-bottom: 0; }

button, .button {
  display: inline-block;
  background: #f5f5f5;
  color: inherit;
  text-align: center;
  white-space: normal;
  overflow-wrap: anywhere;
}

button:enabled, .button { cursor: pointer; }
button:enabled:hover, .button:hover { background: #eaeaea; }
button:disabled { color: #666; cursor: default; }
.text-button { background: transparent; border-color: transparent; text-decoration: underline; }
.primary { background: var(--brand-teal); border-color: var(--brand-teal); color: white; }
.primary:enabled:hover, a.primary:hover { background: var(--brand-teal-hover); }
.primary:disabled { background: #ddd; border-color: #888; color: #595959; }

.header-nav form, .row-actions form { display: inline; }
.created-link, .participant-name, .task-name, .table-secondary { display: block; }
.participant-name, .task-name { font-weight: 600; }
.table-secondary { overflow-wrap: anywhere; }
.created-link { margin-block: .5rem; overflow-wrap: anywhere; }

.table-scroll { overflow-x: auto; margin-bottom: 1rem; }
.table-scroll table { width: 100%; min-width: 40em; border-collapse: collapse; }
.participants-panel tbody tr:nth-child(odd) { background: white; }
.participants-panel tbody tr:nth-child(even) { background: var(--brand-row); }
th, td {
  padding: .75rem 1rem;
  border-bottom: 1px solid #ddd;
  text-align: left;
  vertical-align: top;
}
th { font-weight: 600; }

.steps [aria-current="step"] { color: var(--brand-teal); font-weight: bold; }
.notice { margin-bottom: 1.5rem; padding-left: 1rem; border-left: 3px solid #888; }
.notice.danger { border-color: #a12622; }
.recorder-body, .playback-details { margin-top: 1rem; }
.recorder-activity { display: flex; align-items: center; gap: .5rem; margin-bottom: .75rem; font-size: .875rem; overflow-wrap: anywhere; }
.activity-spinner { width: 1rem; height: 1rem; flex: 0 0 1rem; border: 2px solid var(--brand-teal); border-right-color: transparent; border-radius: 50%; animation: recorder-spin .8s linear infinite; }
@keyframes recorder-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .activity-spinner { animation: none; } }
.privacy-note { margin-top: 1.5rem; }
#capture-timer { margin-top: 1rem; font-variant-numeric: tabular-nums; font-weight: 600; }
progress { max-width: 100%; }

.camera-stage video, .submission-video {
  display: block;
  width: 640px;
  max-width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: contain;
}

#camera-preview { transform: scaleX(-1); }
.participant-page { max-width: 48rem; }
.wizard-welcome, .participant-grid { margin-block: clamp(1rem, 5vh, 3rem); }
.wizard-welcome h1, .participant-page #question-title { font-size: clamp(1.75rem, 4vw, 2.5rem); line-height: 1.25; }
.wizard-welcome .prose { margin-block: 2rem; }
#wizard-progress { color: #595959; font-size: .875rem; }
.participant-grid > *, .recorder-body { min-width: 0; }
.participant-page .task-panel { padding: 0; }
.participant-page .task-panel .prose { font-size: 1.125rem; line-height: 1.65; }
#shared-instructions { margin-block: 2rem; font-size: .875rem; }
summary { cursor: pointer; }
.recorder-panel { background: white; padding: 0; }
.recorder-heading { display: flex; align-items: baseline; gap: 1rem; }
.recorder-heading h2 { flex: 1; }
.recorder-heading .status { font-size: .875rem; }
.camera-stage { width: 100%; max-width: 28rem; margin: 1.5rem auto; background: #f2f2f2; border-radius: .25rem; overflow: hidden; }
.camera-stage video { width: 100%; }
.camera-placeholder { display: grid; place-items: center; aspect-ratio: 16 / 9; color: #595959; }
.camera-placeholder p { margin: 0; }
.stop-button { background: #a12622; border-color: #a12622; color: white; }
.stop-button:enabled:hover { background: #801e1b; }
.mic-check label, .mic-check progress, .mic-check span { display: block; }
.mic-check progress { width: 100%; }
.mic-check span { font-size: .875rem; }
.recorder-panel .notice { overflow-wrap: anywhere; }
.participant-page[data-state="ready"] .camera-stage { max-width: 8rem; margin: 1rem 0; }
.participant-page[data-state="recording"] .recorder-panel {
  display: grid;
  grid-template-columns: clamp(3.5rem, 15vw, 8rem) minmax(0, 1fr);
  align-items: center;
  gap: .5rem 1rem;
  padding: .75rem max(.75rem, env(safe-area-inset-right)) max(.75rem, env(safe-area-inset-bottom)) max(.75rem, env(safe-area-inset-left));
  border-top: 1px solid #ddd;
}
.participant-page.floating-recorder[data-state="recording"] .recorder-panel {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 2;
}
html { scroll-padding-bottom: var(--recording-clearance, 0px); }
.participant-page.floating-recorder[data-state="recording"] { padding-bottom: var(--recording-clearance, 0px); }
.participant-page[data-state="recording"] .recorder-heading {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%);
}
.participant-page[data-state="recording"] .camera-stage { margin: 0; grid-column: 1; grid-row: 1; }
.participant-page[data-state="recording"] #capture-controls { grid-column: 2; grid-row: 1; min-width: 0; }
.capture-info { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.participant-page[data-state="recording"] #capture-timer { margin: 0; flex-shrink: 0; }
.participant-page[data-state="recording"] #timer-text { display: block; font-size: clamp(1.75rem, 4vw, 2.5rem); font-weight: 700; line-height: 1.1; }
#timer-label { display: block; font-size: .75rem; font-weight: 400; }
.participant-page[data-state="recording"] #stop-recording { min-height: 44px; padding-inline: .75rem; }
.participant-page[data-state="recording"] #capture-description { display: none; }
.participant-page[data-state="recording"] .recorder-body { grid-column: 1 / -1; max-height: 20vh; max-height: 20dvh; overflow-y: auto; }
.participant-page[data-state="recording"] .recorder-body:not(:has(.notice:not([hidden]), .recorder-activity:not([hidden]))) { display: none; }
.participant-page[data-state="recording"] .recorder-body .notice { margin: 0; font-size: .875rem; }
.participant-page[data-state="recording"] #recording-message { max-height: 20vh; max-height: 20dvh; overflow-y: auto; }
@media (min-width: 800px) {
  .participant-page[data-state="recording"] .recorder-panel { padding-inline: max(1rem, calc((100vw - 46rem) / 2)); }
}
.prose, .privacy-note, .invite-note { max-width: 65ch; }
.prose h2, .prose h3 { margin-top: 1.5rem; }
.prose img { max-width: 100%; height: auto; }
.prose pre { white-space: pre-wrap; }

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

.task-workspace { max-width: 52rem; }
.task-form label { display: block; margin-bottom: .5rem; font-weight: 600; }
.task-form input { width: 100%; }
.task-form textarea { display: block; width: 100%; min-height: 14rem; font: inherit; }
.task-form textarea[hidden] { display: none; }
.task-form .ql-toolbar { display: flex; flex-wrap: wrap; gap: .2rem; }
.task-form .ql-container { min-height: 14rem; font: inherit; }
.task-form .ql-editor { min-height: 14rem; font: inherit; line-height: 1.5; }
.task-form .ql-snow a { color: var(--brand-teal); }
.task-form .ql-editor:focus-visible { outline: 2px solid var(--brand-teal); outline-offset: -2px; }
.task-form .ql-toolbar button { min-height: 1.75rem; }
.task-form .ql-toolbar .ql-picker { max-width: 100%; }
.task-list { list-style: none; padding: 0; margin: 0; }
.task-list li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .5rem 1rem; padding: 1rem 0; border-bottom: 1px solid #ddd; }
.task-list li:last-child { border-bottom: 0; }
.task-list .muted { display: block; }

.subtask-card { padding: 1rem; margin: 1rem 0; }
.subtask-card .button-row { margin-top: 1rem; flex-wrap: wrap; }
.subtask-card input, .subtask-card select { max-width: 100%; }
