:root {
  color-scheme: light;
  --bg: #f3f3f1;
  --surface: #fcfcfb;
  --surface-2: #f0efec;
  --border: #deddd8;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #6b6a65;
  --accent: #2a78d6;
  --accent-bg: #2a78d6;
  --accent-ink: #ffffff;
  --accent-soft: #e5effb;
  --danger: #b42323;
  --danger-soft: #fbeaea;
  --success: #1d6b36;
  --success-soft: #e6f4ea;
  --warn: #8f5a0b;
  --warn-soft: #fbf0dc;
  --grid: #e4e3de;
  --series-1: #2a78d6;
  --series-2: #1e8a4c;
  --focus: #2a78d6;
  --radius: 10px;
  --shadow: 0 1px 2px rgb(0 0 0 / 6%);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #111110;
    --surface: #1a1a19;
    --surface-2: #232321;
    --border: #34332f;
    --text: #ffffff;
    --text-2: #c3c2b7;
    --muted: #a09f96;
    --accent: #6aa8f0;
    --accent-bg: #2a78d6;
    --accent-ink: #ffffff;
    --accent-soft: #1d2e44;
    --danger: #f08080;
    --danger-soft: #3a1d1d;
    --success: #74c98d;
    --success-soft: #1b3324;
    --warn: #e0a84a;
    --warn-soft: #3a2c14;
    --grid: #2d2d2a;
    --series-1: #3987e5;
    --series-2: #4cb36e;
    --focus: #6aa8f0;
    --shadow: none;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111110;
  --surface: #1a1a19;
  --surface-2: #232321;
  --border: #34332f;
  --text: #ffffff;
  --text-2: #c3c2b7;
  --muted: #a09f96;
  --accent: #6aa8f0;
  --accent-bg: #2a78d6;
  --accent-ink: #ffffff;
  --accent-soft: #1d2e44;
  --danger: #f08080;
  --danger-soft: #3a1d1d;
  --success: #74c98d;
  --success-soft: #1b3324;
  --warn: #e0a84a;
  --warn-soft: #3a2c14;
  --grid: #2d2d2a;
  --series-1: #3987e5;
  --series-2: #4cb36e;
  --focus: #6aa8f0;
  --shadow: none;
}

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

/* Hidden means hidden, even for elements a layout rule gives a display value
   (e.g. table rows shown as cards on phones). Search and filters rely on it. */
[hidden] {
  display: none !important;
}

/* The page behind an open popup stays put. The gutter keeps it from shifting
   sideways when its scrollbar goes away. */
html {
  scrollbar-gutter: stable;
}

html:has(dialog[open]) {
  overflow: hidden;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

h1,
h2,
h3 {
  line-height: 1.25;
  margin: 0;
}

h1 {
  font-size: 1.5rem;
}

h2 {
  font-size: 1.15rem;
}

p {
  margin: 0;
}

a {
  color: var(--accent);
}

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

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

.small {
  font-size: 0.85rem;
}

.nowrap {
  white-space: nowrap;
}

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

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

.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.app-header-inner {
  max-width: 1040px;
  margin: 0 auto;
  padding: 0.75rem 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1.5rem;
}

.brand {
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
}

/* The tabs stay on one line: when the header runs out of room, the account
   controls move to a row of their own instead. */
.app-nav {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.25rem;
  flex: 1 0 auto;
  white-space: nowrap;
}

.app-nav a,
.tabs a {
  color: var(--text-2);
  text-decoration: none;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
}

.app-nav a:hover,
.tabs a:hover {
  background: var(--surface-2);
}

.app-nav a[aria-current="page"],
.tabs a[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.app-user {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.app-user form {
  margin: 0;
}

.app-main {
  max-width: 1040px;
  margin: 0 auto;
  padding: 1.5rem 16px 3rem;
}

.app-main:focus {
  outline: none;
}

.view,
.stack {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.25rem;
}

.page-header p {
  margin-top: 0.25rem;
}

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

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.5rem;
}

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

.filters input,
.filters select {
  width: auto;
  min-width: min(100%, 16rem);
}

/* ---------------------------------------------------------------- Cards */

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

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.card-header p {
  margin-top: 0.2rem;
}

.empty {
  text-align: center;
  padding: 2rem 1.25rem;
}

.badge {
  flex-shrink: 0;
  font-size: 0.8rem;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-2);
  white-space: nowrap;
}

.badge-done {
  background: var(--success-soft);
  color: var(--success);
}

/* Survey status in summaries: the label carries the meaning, colour helps. */
.status-active {
  background: var(--success-soft);
  color: var(--success);
}

.status-upcoming {
  background: var(--accent-soft);
  color: var(--accent);
}

.status-ended {
  background: var(--surface-2);
  color: var(--muted);
}

.alert {
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
}

.alert p + p {
  margin-top: 0.25rem;
}

.alert-error {
  background: var(--danger-soft);
  color: var(--danger);
}

.alert-success {
  background: var(--success-soft);
  color: var(--success);
}

/* Undo, after the message it undoes. */
.alert p .btn {
  vertical-align: middle;
}

.alert-notice {
  background: var(--accent-soft);
  color: var(--text);
}

.alert:focus {
  outline: none;
}

.status-area:empty {
  display: none;
}

.loading {
  padding: 1rem 0;
}

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

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

.field label,
.field .label {
  font-weight: 600;
  font-size: 0.9rem;
}

input,
select,
textarea {
  font: inherit;
  color: inherit;
  width: 100%;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

textarea {
  resize: vertical;
  line-height: 1.45;
}

/* Locked fields (e.g. an answered survey's start date) read as such. */
input:disabled,
select:disabled,
textarea:disabled {
  background: var(--surface-2);
  color: var(--muted);
  cursor: not-allowed;
}

input:disabled + span,
label:has(> input:disabled) {
  color: var(--muted);
}

input[type="checkbox"],
input[type="radio"] {
  width: auto;
}

.field-error {
  color: var(--danger);
  font-size: 0.85rem;
}

.field-error:empty {
  display: none;
}

.choice-control {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.choice-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0 1.25rem;
}

.radio {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 2rem;
}

.password-input {
  display: flex;
  gap: 0.5rem;
}

.show-passwords {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: -0.25rem 0 1rem;
  font-size: 0.9rem;
  color: var(--text-2);
  cursor: pointer;
}

.show-passwords[hidden] {
  display: none;
}

/* Same width for "Show" and "Hide" so the input doesn't shift. */
.password-input .btn {
  min-width: 4.75rem;
}

.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
}

/* A role only admins can change: its own line under the choices. */
.checkbox-group > p {
  flex-basis: 100%;
}

/* A text's languages in a form: the Finnish fields, then each translation
   folded under its own heading. */
.language-section {
  min-width: 0;
  margin: 0 0 1rem;
  padding: 0.5rem 1rem 0;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.language-section > legend {
  margin-left: -0.35rem;
  padding: 0 0.35rem;
  font-weight: 600;
}

details.language-section {
  padding: 0;
}

.language-section > summary {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.65rem 1rem;
  font-weight: 600;
  list-style: none;
  cursor: pointer;
}

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

/* Chevron that turns when the section opens, as in the manage groups. */
.language-section > summary::before {
  content: "";
  flex-shrink: 0;
  width: 0.45rem;
  height: 0.45rem;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg);
  transition: transform 0.15s ease;
}

.language-section[open] > summary::before {
  transform: rotate(45deg);
}

.language-section > summary .muted {
  margin-left: auto;
  font-weight: 400;
}

.language-section > [role="group"] {
  padding: 0 1rem;
}

.language-note {
  margin-bottom: 0.75rem;
}

.btn {
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 1rem;
  background: var(--surface);
  color: var(--text);
}

.btn:hover:not(:disabled) {
  background: var(--surface-2);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.btn-primary {
  background: var(--accent-bg);
  border-color: var(--accent-bg);
  color: var(--accent-ink);
}

.btn-primary:hover:not(:disabled) {
  background: #2167bb;
}

.btn-danger {
  color: var(--danger);
}

/* Only for deletes that take collected answers with them. */
.btn-danger-solid {
  border-color: var(--danger);
  background: var(--danger);
  color: var(--surface);
}

.btn-ghost {
  border-color: transparent;
  background: transparent;
}

.btn-small {
  padding: 0.25rem 0.6rem;
  font-size: 0.85rem;
}

.btn-block {
  width: 100%;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.form-actions p {
  margin-right: auto;
}

/* ---------------------------------------------------------------- Survey scope */

.scope-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.4rem;
  padding: 0.1rem 0.55rem 0.1rem 0.45rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
}

.scope-tag svg {
  width: 0.95rem;
  height: 0.95rem;
  fill: currentColor;
  flex-shrink: 0;
}

.scope-team {
  background: var(--surface-2);
  color: var(--text-2);
}

.scope-personal {
  background: var(--accent-soft);
  color: var(--accent);
}

.survey-personal {
  border-left: 4px solid var(--accent);
}

/* ---------------------------------------------------------------- Theme & language */

.segmented {
  display: flex;
  gap: 2px;
  margin: 0;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 999px;
}

.segmented[hidden] {
  display: none;
}

.segmented button {
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  border: 0;
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
  background: transparent;
  color: var(--text-2);
}

.segmented button:hover {
  background: var(--surface-2);
}

.segmented button[aria-pressed="true"] {
  background: var(--accent-soft);
  color: var(--accent);
}

.theme-switch button {
  display: flex;
  align-items: center;
  padding: 0.2rem 0.4rem;
}

.theme-switch svg {
  width: 1rem;
  height: 1rem;
}

/* picker.js: the choices open under a button showing the current one. */
.picker {
  position: relative;
}

.picker-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.25rem 0.4rem 0.25rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--text-2);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1rem;
  cursor: pointer;
}

.picker-toggle:hover,
.picker.open .picker-toggle {
  background: var(--surface-2);
  color: var(--text);
}

.picker-current {
  display: inline-flex;
  align-items: center;
}

.picker-current svg {
  width: 1rem;
  height: 1rem;
}

.picker-chevron {
  width: 0.75rem;
  height: 0.75rem;
  transition: transform 0.15s ease;
}

.picker.open .picker-chevron {
  transform: rotate(180deg);
}

.picker-ready > .segmented {
  position: absolute;
  top: calc(100% + 0.35rem);
  right: 0;
  z-index: 30;
  background: var(--surface);
  box-shadow: 0 8px 20px rgb(0 0 0 / 14%);
}

.picker-ready:not(.open) > .segmented {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  .picker-chevron {
    transition: none;
  }
}

.login-top {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

/* ---------------------------------------------------------------- Answer scale */

/* An answered survey, folded: when the next window opens, and a way back in. */
.survey-done {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
}

/* ---------------------------------------------------------------- Answer wizard */

/* One question at a time: the survey, progress, the question, Back / Next. */
.wizard {
  width: 100%;
  max-width: 40rem;
  margin: 0 auto;
}

.wizard {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* "← All surveys" above the card, where a way out is looked for, apart from
   Back / Next. Lined up with the card's left edge. */
.wizard-exit {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  width: 100%;
  max-width: 40rem;
  min-height: 2.75rem;
  margin: -0.75rem auto 0;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
}

.wizard-exit:hover {
  color: var(--accent);
}

.wizard-exit:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* "Mielentila saved." after finishing a survey, above the next one. */
.wizard-note {
  margin: -0.25rem 0 0;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  background: var(--success-soft);
  color: var(--success);
  font-weight: 600;
}

/* The survey's name and scope on one line, smaller than the question. */
.wizard-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem 0.75rem;
}

.wizard-head h2 {
  margin: 0;
  font-size: 1.05rem;
}

.wizard-head .scope-tag {
  margin-bottom: 0;
}

/* One segment per question: filled once answered, outlined where we are. */
.wizard-progress {
  display: flex;
  gap: 4px;
}

.wizard-progress span {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: var(--border);
}

.wizard-progress span.done {
  background: var(--accent-bg);
}

.wizard-progress span.current {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.wizard .question {
  border-top: 0;
  padding: 0.75rem 0 0.25rem;
}

.wizard .question legend {
  margin-bottom: 1.25rem;
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.3;
}

.wizard-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: auto;
  padding-top: 0.75rem;
}

.wizard-next {
  min-width: 9rem;
  margin-left: auto;
}

/* Each question slides in, unless motion is turned down. */
.wizard-step {
  animation: wizard-in 0.18s ease-out;
}

@keyframes wizard-in {
  from {
    opacity: 0;
    transform: translateX(12px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .wizard-step {
    animation: none;
  }
}

.wizard-all-done {
  font-size: 1.15rem;
  font-weight: 600;
}

.question {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 0;
  padding: 1rem 0;
  min-width: 0;
}

.question legend {
  font-weight: 600;
  padding: 0;
  margin-bottom: 0.6rem;
  float: left;
  width: 100%;
}

.question legend + * {
  clear: both;
}

/* Slider: a range input with a filled track. --fill is set from script.
   A dashed line marks the neutral middle, across the track and under the
   thumb; the input and its track share its centre, so the dashes line up. */

.slider {
  --fill: 50%;
  --thumb: 1.75rem;
  --neutral: repeating-linear-gradient(var(--muted) 0 3px, transparent 3px 6px) center / 2px var(--thumb) no-repeat;
  display: block;
  width: 100%;
  height: var(--thumb);
  margin: 0;
  padding: 0;
  border: 0;
  background: var(--neutral);
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  touch-action: pan-y;
}

.slider:focus-visible {
  outline: none;
}

.slider::-webkit-slider-runnable-track {
  height: 0.5rem;
  border-radius: 999px;
  background: var(--neutral), linear-gradient(to right, var(--accent-bg) var(--fill), var(--surface-2) var(--fill));
  box-shadow: inset 0 0 0 1px var(--border);
}

/* Filled from --fill here too: a progress bar would cover the line. */
.slider::-moz-range-track {
  height: 0.5rem;
  border-radius: 999px;
  background: var(--neutral), linear-gradient(to right, var(--accent-bg) var(--fill), var(--surface-2) var(--fill));
  box-shadow: inset 0 0 0 1px var(--border);
}

.slider::-moz-range-progress {
  background: transparent;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: var(--thumb);
  height: var(--thumb);
  margin-top: calc((0.5rem - var(--thumb)) / 2);
  border-radius: 50%;
  border: 3px solid var(--surface);
  background: var(--accent-bg);
  box-shadow: 0 0 0 1px var(--accent-bg), 0 1px 3px rgb(0 0 0 / 25%);
}

.slider::-moz-range-thumb {
  width: var(--thumb);
  height: var(--thumb);
  box-sizing: border-box;
  border-radius: 50%;
  border: 3px solid var(--surface);
  background: var(--accent-bg);
  box-shadow: 0 0 0 1px var(--accent-bg), 0 1px 3px rgb(0 0 0 / 25%);
}

.slider:focus-visible::-webkit-slider-thumb {
  box-shadow: 0 0 0 1px var(--accent-bg), 0 0 0 4px var(--focus);
}

.slider:focus-visible::-moz-range-thumb {
  box-shadow: 0 0 0 1px var(--accent-bg), 0 0 0 4px var(--focus);
}

/* Not answered yet: empty track and a hollow thumb. */
.slider.untouched::-webkit-slider-runnable-track {
  background: var(--neutral), var(--surface-2);
}

.slider.untouched::-moz-range-track {
  background: var(--neutral), var(--surface-2);
}

.slider.untouched::-webkit-slider-thumb {
  background: var(--surface);
  border-color: var(--muted);
  box-shadow: none;
}

.slider.untouched::-moz-range-thumb {
  background: var(--surface);
  border-color: var(--muted);
  box-shadow: none;
}

/* Answers grouped by survey (My answers, Manage → Answers). */
.answer-groups {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.answer-group {
  padding: 0;
  overflow: hidden;
}

.answer-group > summary {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  list-style: none;
  cursor: pointer;
}

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

/* Chevron that turns when the group opens. */
.answer-group > summary::before {
  content: "";
  flex-shrink: 0;
  width: 0.5rem;
  height: 0.5rem;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg);
  transition: transform 0.15s ease;
}

.answer-group[open] > summary::before {
  transform: rotate(45deg);
}

.answer-group > summary:hover {
  background: var(--surface-2);
}

.answer-group-heading {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.2rem;
  flex: 1;
  min-width: 0;
}

.answer-group-heading .scope-tag {
  margin-bottom: 0.15rem;
}

.answer-group-title {
  font-weight: 600;
  font-size: 1.05rem;
}

.answer-group-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.3rem;
  flex-shrink: 0;
  text-align: right;
}

.answer-group-body {
  border-top: 1px solid var(--border);
}

/* Manage: what a delete takes along, deactivated users, the row just saved. */
.delete-effects {
  margin: 0 0 0.75rem;
  padding-left: 1.25rem;
}

.delete-effects li + li {
  margin-top: 0.25rem;
}

.delete-note {
  margin-bottom: 1rem;
}

/* Deleting a survey with answers: the loss first, in red, then the way out. */
.delete-warning {
  border: 1px solid var(--danger);
}

.delete-alternative {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  margin-bottom: 1rem;
}

.delete-confirm label {
  font-weight: 400;
}

/* Deleted items stay in the management lists, marked and dimmed. */
.badge-deleted {
  background: var(--danger-soft);
  color: var(--danger);
}

.manage-table tr.is-deleted > td:not(.row-actions) {
  color: var(--muted);
}

/* Why a deleted item can't be restored here, above its date and button. */
.restore-note {
  display: block;
  max-width: 18rem;
  margin: 0 0 0.25rem auto;
  white-space: normal;
  text-align: right;
}

tr.just-saved > * {
  background: var(--accent-soft);
  animation: just-saved 3s ease-out 1s forwards;
}

@keyframes just-saved {
  to {
    background: transparent;
  }
}

@media (prefers-reduced-motion: reduce) {
  tr.just-saved > * {
    animation: none;
  }
}

.answer-group-status {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.6rem 1.25rem;
  border-top: 1px solid var(--border);
}

.answer-group-status:empty {
  display: none;
}

.answer-group-status .loading {
  padding: 0;
}

/* Room for placeholders that say what can be searched. */
.filters input[type="search"] {
  min-width: min(100%, 24rem);
}

/* Open all / Close all, at the end of the filter row. */
.filters-tools {
  display: flex;
  gap: 0.25rem;
  margin-left: auto;
}

/* Manage lists grouped the same way: the table sits under the header. */
.manage-group > .table-wrap {
  border-top: 1px solid var(--border);
}

/* Summaries: the surveys listed on the left, the chosen one on the right.
   On narrow screens the two take turns (see .showing-survey below). */
.summary-layout {
  display: grid;
  grid-template-columns: minmax(16rem, 19rem) minmax(0, 1fr);
  gap: 1.25rem;
  align-items: start;
}

/* The list stays in view, scrolling on its own, while the survey scrolls by. */
.summary-list {
  position: sticky;
  top: 1rem;
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.summary-list-filters {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.summary-list-selects {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.summary-list-filters input,
.summary-list-filters select {
  padding: 0.4rem 0.55rem;
  font-size: 0.9rem;
}

.summary-list-selects select {
  flex: 1 1 7rem;
  width: auto;
  min-width: 0;
}

.summary-list-groups {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.summary-list-empty {
  margin: 0.25rem 0.5rem;
}

/* Coaches: a heading per status. */
.summary-list-heading {
  margin: 0.5rem 0.65rem 0.25rem;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}

.summary-list-section:first-child .summary-list-heading {
  margin-top: 0;
}

/* Researchers: a heading per team that folds its surveys away. */
.summary-list-group + .summary-list-group {
  border-top: 1px solid var(--border);
  padding-top: 0.25rem;
}

.summary-list-group > summary {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.65rem;
  border-radius: 8px;
  list-style: none;
  cursor: pointer;
}

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

.summary-list-group > summary::before {
  content: "";
  flex-shrink: 0;
  width: 0.4rem;
  height: 0.4rem;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg);
  transition: transform 0.15s ease;
}

.summary-list-group[open] > summary::before {
  transform: rotate(45deg);
}

.summary-list-group > summary:hover {
  background: var(--surface-2);
}

.summary-list-group-name {
  flex: 1 1 auto;
  min-width: 0;
  font-weight: 600;
  line-height: 1.3;
}

.summary-list-counts {
  display: inline-flex;
  flex-shrink: 0;
  gap: 0.5rem;
  color: var(--text-2);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}

.summary-list-count {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.summary-list-group > .summary-list-items {
  padding: 0.1rem 0 0.4rem 0.9rem;
}

.summary-list-items {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* A survey in the list: its name and answer count, then its dates. */
.summary-link {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0 0.75rem;
  padding: 0.45rem 0.65rem;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
}

.summary-link:hover {
  background: var(--surface-2);
}

.summary-link[aria-current="page"] {
  background: var(--accent-soft);
}

.summary-link-title {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.summary-link.summary-ended .summary-link-title {
  color: var(--text-2);
}

.summary-link-answers {
  align-self: center;
  color: var(--text-2);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

.summary-link-meta {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--muted);
  font-size: 0.82rem;
}

/* Status as a dot beside its name; the name says it, the colour helps. */
.status-dot {
  flex-shrink: 0;
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: var(--muted);
}

.status-dot[data-status="active"] {
  background: var(--success);
}

.status-dot[data-status="upcoming"] {
  background: var(--accent);
}

/* Hollow */
.status-dot[data-status="ended"] {
  box-sizing: border-box;
  background: transparent;
  border: 1.5px solid var(--muted);
}

/* The chosen survey. */
.summary-pane {
  padding: 0;
  min-width: 0;
}

.summary-pane-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1.25rem;
  border-bottom: 1px solid var(--border);
}

.summary-pane-heading {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.summary-pane-heading h2 {
  font-size: 1.35rem;
}

.summary-pane-heading h2:focus {
  outline: none;
}

.summary-pane-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.35rem;
}

.summary-pane-body {
  padding: 1.25rem;
}

/* Back to the list, where the two take turns. */
.summary-back {
  display: none;
}

/* My progress on phones: a dropdown of the topics in place of the list. */
.progress-picker {
  display: none;
}

/* With both kinds, the chosen topic's team or personal icon over the closed
   dropdown, in front of its name. */
.progress-picker-field {
  position: relative;
}

.progress-picker-icon {
  position: absolute;
  top: 50%;
  left: 0.7rem;
  display: flex;
  transform: translateY(-50%);
  pointer-events: none;
}

.progress-picker-icon .topic-icon {
  margin-right: 0;
}

.progress-picker-field.with-icon select {
  padding-left: 2.1rem;
}

/* With both kinds, the list's team and personal headings are scope tags. */
.progress-list-heading {
  margin: 0.75rem 0.4rem 0.35rem;
  font-size: 1rem;
}

.summary-list-section:first-child .progress-list-heading {
  margin-top: 0.1rem;
}

.progress-list-heading .scope-tag {
  margin-bottom: 0;
}

/* A team or personal icon, coloured as the scope tags: in front of the
   chosen topic in the closed dropdown. */
.topic-icon {
  display: inline-flex;
  margin-right: 0.45rem;
  vertical-align: -0.15em;
}

.topic-icon svg {
  width: 1rem;
  height: 1rem;
  fill: currentColor;
}

.topic-team {
  color: var(--text-2);
}

.topic-personal {
  color: var(--accent);
}

/* Narrow screens: the list, or the survey chosen from it (with a way back). */
@media (max-width: 760px) {
  .summary-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .summary-list {
    position: static;
    max-height: none;
    overflow: visible;
  }

  .summary-layout.showing-survey > .summary-list,
  .summary-layout:not(.showing-survey) > .summary-pane {
    display: none;
  }

  .summary-layout:not(.showing-survey) .summary-link[aria-current="page"] {
    background: none;
  }

  .summary-back {
    display: inline-block;
    flex-basis: 100%;
  }

  .progress-picker {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
  }

  .progress-picker label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-2);
  }

  /* The count under the filters, so they keep the row's width. */
  .summary-list-selects > [aria-live] {
    flex-basis: 100%;
  }

  .summary-pane-side {
    flex-direction: row;
    align-items: center;
    gap: 0.75rem;
  }

  .summary-pane-head,
  .summary-pane-body {
    padding: 1rem;
  }
}

.scale-ends {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 0.35rem;
  font-size: 0.85rem;
  color: var(--text-2);
}

.scale-ends > :last-child {
  text-align: right;
}

/* An end label with a description: tap to open it below the slider. */
.scale-end.has-description {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin: -0.4rem 0;
  padding: 0.4rem 0;
  border: 0;
  background: none;
  font: inherit;
  color: inherit;
  cursor: pointer;
  text-decoration: underline dotted;
  text-underline-offset: 3px;
}

.scale-end.has-description svg {
  flex-shrink: 0;
  width: 0.95rem;
  height: 0.95rem;
  color: var(--accent);
}

.scale-end.has-description:hover,
.scale-end.has-description[aria-expanded="true"] {
  color: var(--accent);
}

.scale-description {
  position: relative;
  scroll-margin-bottom: 1rem;
  margin-top: 0.7rem;
  padding: 0.7rem 0.85rem;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--text);
  font-size: 0.9rem;
  line-height: 1.45;
}

.scale-description[hidden] {
  display: none;
}

.scale-description p {
  margin-top: 0.2rem;
}

/* Little pointer towards the end the description belongs to. */
.scale-description::before {
  content: "";
  position: absolute;
  top: -6px;
  left: 1.25rem;
  border: 6px solid transparent;
  border-top: 0;
  border-bottom-color: var(--accent-soft);
}

.scale-description[data-side="end"]::before {
  left: auto;
  right: 1.25rem;
}

.question > .muted {
  margin-top: 0.35rem;
}

/* ---------------------------------------------------------------- Tables */

.table-wrap {
  overflow-x: auto;
  padding: 0;
}

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

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

thead th {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  font-weight: 600;
}

tbody tr:last-child > * {
  border-bottom: 0;
}

tbody th {
  font-weight: 500;
}

.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.row-actions {
  text-align: right;
  white-space: nowrap;
}

.row-actions .btn + .btn {
  margin-left: 0.4rem;
}

.heat {
  background: color-mix(in srgb, var(--series-1) var(--heat), transparent);
}

/* ---------------------------------------------------------------- Summaries */

.multiples {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}

.multiple {
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.85rem 0.85rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.multiple figcaption {
  font-weight: 600;
  font-size: 0.92rem;
}

/* Small multiples open a detail view when clicked. */
.multiple.clickable {
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.multiple.clickable:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.multiple-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
}

.multiple-open {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.9rem;
  height: 1.9rem;
  margin: -0.35rem -0.35rem 0 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.multiple-open:hover,
.multiple.clickable:hover .multiple-open {
  color: var(--accent);
  background: var(--accent-soft);
}

.multiple-open svg {
  width: 1rem;
  height: 1rem;
}

.chart .bar {
  fill: var(--series-1);
  pointer-events: none;
}

.chart .bar.active {
  fill-opacity: 0.75;
}

.chart rect.hit:focus-visible {
  stroke: var(--focus);
  stroke-width: 2;
}

/* Detail view of one question. */
/* Two classes, so it wins over the base .dialog width defined later. */
.dialog.dialog-wide {
  width: min(900px, calc(100vw - 32px));
}

.detail-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1rem;
}

/* Settings: sharing all answers, then the team's topics one by one. */
.settings-card {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-width: 40rem;
}

.sharing-team {
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.sharing-team h3 {
  font-size: 1rem;
}

.sharing-team > p {
  margin-top: 0.25rem;
}

.sharing-topics {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin: 1rem 0 0;
  padding: 0;
  list-style: none;
}

.sharing p {
  margin-top: 0.25rem;
}

/* "Change password": a link to its own page, looking like a button. */
.settings-action {
  align-self: flex-start;
  text-decoration: none;
}

.sharing-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 600;
  cursor: pointer;
}

.sharing-switch input {
  position: absolute;
  opacity: 0;
  width: 2.5rem;
  height: 1.5rem;
  margin: 0;
  cursor: pointer;
}

.switch-track {
  position: relative;
  flex-shrink: 0;
  width: 2.5rem;
  height: 1.5rem;
  border-radius: 999px;
  background: var(--border);
  transition: background 0.15s ease;
}

.switch-track::after {
  content: "";
  position: absolute;
  top: 0.2rem;
  left: 0.2rem;
  width: 1.1rem;
  height: 1.1rem;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 1px 2px rgb(0 0 0 / 25%);
  transition: transform 0.15s ease;
}

.sharing-switch input:checked + .switch-track {
  background: var(--accent-bg);
}

.sharing-switch input:checked + .switch-track::after {
  transform: translateX(1rem);
}

.sharing-switch input:focus-visible + .switch-track {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* Covered by sharing all answers, or saving. */
.sharing-switch:has(input:disabled),
.sharing-switch input:disabled {
  cursor: not-allowed;
}

.sharing-switch input:disabled + .switch-track {
  opacity: 0.6;
}

/* Detail view tabs: Team average | Athletes. */
.detail-tabs {
  display: flex;
  gap: 0.25rem;
  margin: -0.25rem 0 1rem;
  border-bottom: 1px solid var(--border);
}

.detail-tab {
  margin-bottom: -1px;
  padding: 0.5rem 0.9rem;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--text-2);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.detail-tab:hover {
  color: var(--text);
}

.detail-tab[aria-selected="true"] {
  border-bottom-color: var(--accent);
  color: var(--accent);
}

.athletes-note {
  margin-bottom: 0.75rem;
}

.athletes-table {
  margin-bottom: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.athletes-table tr.selected > * {
  background: var(--accent-soft);
}

.athlete-pick {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

.athlete-pick:hover {
  text-decoration: underline;
}

/* The team average behind one athlete's line. */
.chart .compare-line {
  fill: none;
  stroke: var(--muted);
  stroke-width: 2;
  stroke-dasharray: 5 4;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.25rem;
  margin-top: 0.4rem;
  font-size: 0.85rem;
  color: var(--text-2);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.legend-swatch {
  width: 1.25rem;
  height: 0;
  border-top: 2px solid var(--series, var(--series-1));
}

.legend-swatch.compare {
  border-top: 2px dashed var(--muted);
}

/* A 4-field is square, so it is kept from growing past a comfortable size. */
.four-field-chart {
  max-width: 420px;
  margin-inline: auto;
}

.chart .four-field-frame {
  fill: var(--surface-2);
  stroke: var(--border);
}

.chart .four-field-axis {
  stroke: var(--border);
  stroke-width: 1.5;
}

.chart .axis-name {
  fill: var(--text-2);
  font-weight: 600;
}

/* The latest point stands out from the earlier ones by its colour too. */
.chart .latest-ring {
  fill: none;
  stroke: var(--series-2);
  stroke-width: 1.5;
  opacity: 0.6;
  pointer-events: none;
}

.chart .marker.latest {
  fill: var(--series-2);
}

.chart .marker.latest.active {
  r: 8px;
}

.legend-dot {
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 50%;
  background: var(--series-1);
}

.legend-dot.earlier {
  opacity: 0.4;
}

.legend-dot.latest {
  background: var(--series-2);
  box-shadow:
    0 0 0 2px var(--surface),
    0 0 0 3.5px var(--series-2);
}

/* Each athlete's averages in a 4-field: see-through, so points close together
   still show. A point several share is larger, with their number in it. */
.chart .marker.athlete {
  fill-opacity: 0.7;
  stroke-width: 1.5;
}

.chart .marker.athlete.active {
  fill-opacity: 1;
}

.chart .marker.athlete.many.active {
  r: 10px;
}

.chart .marker-count {
  fill: #fff;
  font-size: 10px;
  font-weight: 700;
  pointer-events: none;
}

.legend-dot.athlete {
  opacity: 0.7;
}

/* A quarter's number, as in the explanations under the charts. */
.chart .quadrant-number {
  fill: var(--muted);
  font-size: 15px;
  font-weight: 700;
}

/* What the 4-field's quarters mean; the latest answer's one stands out. */
.quadrant-guide {
  margin-top: 1.5rem;
}

.quadrant-guide h3 {
  margin: 0 0 0.6rem;
  font-size: 1rem;
}

.quadrant-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
  gap: 0.6rem;
  margin: 0 0 0.6rem;
  padding: 0;
  list-style: none;
}

.quadrant-item {
  display: flex;
  gap: 0.7rem;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-2);
}

.quadrant-item p {
  margin: 0;
}

.quadrant-item.current {
  border-color: var(--series-2);
  background: var(--success-soft);
  color: var(--text);
}

.quadrant-badge {
  flex-shrink: 0;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 50%;
  background: var(--surface-2);
  font-size: 0.85rem;
  font-weight: 700;
  line-height: 1.6rem;
  text-align: center;
}

.quadrant-item.current .quadrant-badge {
  background: var(--series-2);
  color: var(--surface);
}

.quadrant-item .quadrant-current {
  margin-bottom: 0.15rem;
  color: var(--success);
  font-weight: 600;
}

/* The 4-field beside the line chart, one above the other on phones. */
.category-note {
  margin-bottom: 0.75rem;
}

/* In a summary, the question by question charts follow the category's. */
.summary-section-title {
  margin: 1.75rem 0 0.75rem;
  font-size: 1rem;
}

.category-charts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
  gap: 1.5rem;
  align-items: start;
}

.category-figure {
  margin: 0;
  min-width: 0;
}

.category-figure figcaption {
  margin-bottom: 0.4rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-2);
}

.category-figure .four-field-chart,
.category-figure .occasions-chart,
.category-figure .chart-legend,
.four-field-head,
.four-field-window {
  max-width: 420px;
}

/* The 4-field's title, with the choice between the team's and each
   athlete's averages beside it (researchers only). */
.four-field-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem 1rem;
  margin-bottom: 0.4rem;
}

.four-field-head figcaption {
  margin-bottom: 0;
}

.four-field-head .segmented {
  width: fit-content;
}

/* Each as wide as its words, also on phones, where the theme and language
   switches' buttons share their width evenly. */
.four-field-head .segmented button {
  flex: none;
  white-space: nowrap;
}

.four-field-window {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
  font-size: 0.85rem;
  color: var(--text-2);
}

.four-field-window select {
  flex: 1 1 auto;
  width: auto;
  min-width: 0;
  padding: 0.3rem 0.5rem;
  font-size: 0.85rem;
}

.chart .midline {
  stroke: var(--border);
  stroke-width: 1.5;
}

.occasions-chart .marker {
  stroke-width: 1.5;
}

.legend-line {
  width: 1.5rem;
  height: 4px;
  flex-shrink: 0;
  overflow: visible;
}

.legend-line line {
  stroke: var(--series);
  stroke-width: 2.5;
}

/* A category's questions are told apart by colour, the same in every chart
   of it: the lines, their dots and the legend take the colour from here. */
.chart,
.legend-line,
.series-1 {
  --series: var(--series-1);
}

.series-2 {
  --series: var(--series-2);
}

/* The scale legend in the detail view: both ends side by side. */
.scale-legend {
  margin: 0 0 1rem;
}

.scale-legend-ends {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: 0.75rem;
  margin-top: 0.6rem;
}

.scale-legend-end {
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.scale-legend-head {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.scale-legend-value {
  flex-shrink: 0;
  min-width: 1.6rem;
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 700;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.scale-legend-end p {
  margin-top: 0.35rem;
  line-height: 1.45;
}

.detail-head h2 {
  margin: 0.15rem 0 0;
}

/* Focused only so the popup starts at the question; not a control. */
.detail-head h2:focus {
  outline: none;
}

.team-view {
  display: flex;
  flex-direction: column;
}

.stat-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.stat-tile {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.detail-chart-title {
  margin: 0.5rem 0 0.25rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-2);
}

.detail .chart + .detail-chart-title {
  margin-top: 1rem;
}

.detail-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.change-up {
  color: var(--success);
}

.change-down {
  color: var(--danger);
}

.stat-value {
  font-size: 1.35rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.chart {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.chart .grid {
  stroke: var(--grid);
  stroke-width: 1;
}

.chart .axis-label {
  fill: var(--text-2);
  font-size: 12px;
}

.chart .series-line {
  fill: none;
  stroke: var(--series);
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.chart .marker {
  fill: var(--series);
  stroke: var(--surface);
  stroke-width: 2;
  pointer-events: none;
}

.chart .marker.active {
  r: 6px;
}

.chart .hit {
  fill: transparent;
  cursor: pointer;
}

.chart .hit:focus {
  outline: none;
}

.chart .hit:focus-visible {
  stroke: var(--focus);
  stroke-width: 2;
}

.table-toggle {
  margin-top: 1rem;
}

.table-toggle summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 600;
  font-size: 0.92rem;
}

.table-toggle .table-wrap {
  margin-top: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.table-toggle .table-wrap > p {
  padding: 0.5rem 0.9rem;
  border-top: 1px solid var(--border);
}

.tooltip {
  position: fixed;
  z-index: 10;
  max-width: 260px;
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  background: var(--text);
  color: var(--surface);
  font-size: 0.82rem;
  pointer-events: none;
}

.tooltip[hidden] {
  display: none;
}

/* ---------------------------------------------------------------- Dialog */

.dialog {
  width: min(520px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overscroll-behavior: contain;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0;
  background: var(--surface);
  color: var(--text);
}

.dialog::backdrop {
  background: rgb(0 0 0 / 45%);
}

.dialog-form {
  padding: 1.25rem;
}

.dialog-form h2 {
  margin-bottom: 1rem;
}

/* Adding several users: the team and groups they share side by side, then
   a row for each person, numbered, with its own errors under its fields. */
.bulk-lead {
  margin: -0.5rem 0 1rem;
}

.bulk-shared {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0 1.25rem;
}

/* A field with a list of matches under it, over what follows. */
.combo {
  position: relative;
}

.combo-list {
  position: absolute;
  z-index: 10;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 15rem;
  overflow-y: auto;
  margin: 0;
  padding: 0.25rem;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 20px rgb(0 0 0 / 14%);
}

.combo-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.6rem;
  border-radius: 6px;
  cursor: pointer;
}

.combo-option:hover {
  background: var(--surface-2);
}

.combo-option[aria-selected="true"] {
  background: var(--accent-soft);
  color: var(--accent);
}

.combo-create {
  color: var(--accent);
  font-weight: 600;
}

.combo-plus {
  font-size: 1.1rem;
  line-height: 1;
}

.combo-hint {
  margin: 0.35rem 0 0;
}

.combo-hint-new {
  color: var(--accent);
}

.bulk-intro {
  margin-top: 0.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.bulk-intro h3 {
  margin: 0 0 0.25rem;
  font-size: 1rem;
}

.bulk-intro p {
  margin: 0 0 0.75rem;
}

.bulk-rows {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.bulk-row {
  display: grid;
  grid-template-columns: 2rem minmax(0, 1fr) minmax(0, 1fr) 2.25rem;
  gap: 0.5rem;
  align-items: start;
}

.bulk-head {
  margin-bottom: 0.3rem;
  font-size: 0.9rem;
}

.bulk-number {
  padding-top: 0.55rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.bulk-cell {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}

.bulk-cell:has(.field-error:not(:empty)) input {
  border-color: var(--danger);
}

.bulk-remove {
  min-height: 2.4rem;
  font-size: 1.2rem;
  line-height: 1;
}

.bulk-more {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  margin: 0.75rem 0 0.5rem 2.5rem;
}

.bulk-pasted {
  margin: 0;
}

.bulk-pasted:empty {
  display: none;
}

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

  /* Name over email, the number and the remove button beside both. */
  .bulk-head {
    display: none;
  }

  .bulk-row {
    grid-template-columns: 1.5rem minmax(0, 1fr) 2.25rem;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid var(--border);
  }

  .bulk-row > .bulk-cell + .bulk-cell {
    grid-column: 2;
  }

  .bulk-remove {
    grid-column: 3;
    grid-row: 1;
  }

  .bulk-more {
    margin-left: 0;
  }
}

/* ---------------------------------------------------------------- Export */

/* The choices on the left, and the file they make beside them, in view while
   the choices scroll by; one above the other on narrow screens. */
.export-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(16rem, 22rem);
  gap: 1.25rem;
  align-items: start;
  max-width: 60rem;
}

.export-form h2:not(:first-child) {
  margin-top: 0.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.export-form h2,
.export-result h2 {
  margin-bottom: 1rem;
}

.export-result {
  position: sticky;
  top: 1rem;
}

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

  .export-result {
    position: static;
  }
}

.export-dates {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
  gap: 0 1rem;
}

/* What the file will hold, updated as the choices change. */
.export-preview {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-height: 4.5rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}

.export-preview .loading {
  padding: 0;
}

.export-columns {
  overflow-wrap: anywhere;
}

/* ---------------------------------------------------------------- Login */

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 16px;
}

.login-card {
  width: min(380px, 100%);
}

.login-card h1 {
  margin-bottom: 0.25rem;
}

.login-card form > p {
  margin-bottom: 1.25rem;
}

.app-user a.btn {
  text-decoration: none;
  text-align: center;
}

.password-help ul {
  margin: 0.25rem 0 0;
  padding-left: 1.1rem;
}

.login-install {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
  text-align: center;
}

.install-hint {
  max-width: 22rem;
}

/* On the login page the install button stands out: installing is what we
   want athletes to do. */
.login-install .install-app {
  border-color: var(--border);
  background: var(--surface);
  padding: 0.5rem 1.25rem;
}

.offline-card p {
  margin: 0.5rem 0 1.25rem;
}

.offline-card .btn {
  display: block;
  text-align: center;
  text-decoration: none;
}

.login-secondary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.75rem;
}

.login-secondary button {
  margin-left: auto;
}

/* ---------------------------------------------------------------- Phones */

/* Only used in the phone layout below. */
.menu-toggle {
  display: none;
}

.nav-icon {
  flex-shrink: 0;
  width: 1.15rem;
  height: 1.15rem;
}

/* Wider screens: each tab's icon before its label, and a tab shown as its
   icon alone (Settings), its label kept for screen readers. On phones the
   icons sit above the labels in the tab bar. */
@media (min-width: 641px) {
  .app-nav a {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
  }

  .app-nav a.nav-icon-only {
    padding: 0.35rem 0.5rem;
  }

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

@media (max-width: 640px) {
  :root {
    --bottom-nav: calc(3.75rem + env(safe-area-inset-bottom));
  }

  body {
    -webkit-tap-highlight-color: transparent;
  }

  .card {
    padding: 1rem;
  }

  .card.table-wrap,
  .card.answer-group,
  .card.summary-pane {
    padding: 0;
  }

  h1 {
    font-size: 1.35rem;
  }

  /* Compact top bar: app name and a menu button. */
  .app-header {
    position: sticky;
    top: 0;
    z-index: 20;
  }

  .app-header-inner {
    flex-wrap: nowrap;
    justify-content: space-between;
    min-height: 3.25rem;
    padding: 0.25rem 8px 0.25rem 16px;
  }

  .menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.75rem;
    height: 2.75rem;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--text);
    cursor: pointer;
  }

  .menu-toggle:hover,
  .app-header.menu-open .menu-toggle {
    background: var(--surface-2);
  }

  .menu-toggle svg {
    width: 1.5rem;
    height: 1.5rem;
  }

  /* The menu: theme, language, username and log out, with full-size targets. */
  .app-user {
    display: none;
  }

  .app-header.menu-open .app-user {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    padding: 1rem 16px 1.25rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 12px 24px rgb(0 0 0 / 14%);
  }

  .app-user .app-username {
    order: -1;
    font-weight: 600;
    color: var(--text);
  }

  .app-user .segmented,
  .app-user .btn {
    width: 100%;
  }

  /* The menu has room for every theme and language choice at once. */
  .app-user .picker-toggle {
    display: none;
  }

  .app-user .picker-ready > .segmented {
    display: flex;
    position: static;
    background: transparent;
    box-shadow: none;
  }

  .app-user .btn {
    min-height: 2.75rem;
    border-color: var(--border);
  }

  .segmented button {
    flex: 1;
    min-width: 2.75rem;
    min-height: 2.75rem;
    justify-content: center;
    font-size: 0.9rem;
  }

  /* Main navigation becomes a tab bar within thumb reach. */
  .app-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 20;
    flex-wrap: nowrap;
    gap: 0;
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--surface);
    border-top: 1px solid var(--border);
  }

  .app-nav a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.15rem;
    min-height: 3.75rem;
    padding: 0.25rem;
    border-radius: 0;
    font-size: 0.75rem;
    text-align: center;
  }

  .app-nav a:hover {
    background: transparent;
  }

  .app-nav a[aria-current="page"] {
    background: transparent;
    box-shadow: inset 0 2px 0 var(--accent);
  }

  .single-view {
    --bottom-nav: env(safe-area-inset-bottom);
  }

  .single-view .app-nav {
    display: none;
  }

  .nav-icon {
    display: block;
    width: 1.5rem;
    height: 1.5rem;
  }

  .app-main {
    padding: 1rem 16px calc(var(--bottom-nav) + 1.5rem);
  }

  /* Bigger slider: a 44px touch area and a larger thumb. */
  .slider {
    --thumb: 2rem;
    height: 2.75rem;
  }

  .question {
    padding: 0.85rem 0;
  }

  /* An opened description scrolls into view clear of the tab bar. */
  .scale-description {
    scroll-margin-bottom: calc(var(--bottom-nav) + 7.5rem);
  }

  /* Bigger tap target for the description buttons. */
  .scale-end.has-description {
    margin: -0.65rem 0;
    padding: 0.65rem 0;
  }

  /* The wizard fills the screen between "All surveys" and the tab bar, so
     Back and Next sit at the bottom, within thumb reach. */
  .wizard {
    min-height: calc(100dvh - 3.25rem - var(--bottom-nav) - 2.5rem - 2rem);
  }

  .wizard .question legend {
    font-size: 1.35rem;
  }

  .wizard-actions .btn {
    min-height: 3rem;
    font-size: 1rem;
  }

  .wizard-next {
    flex: 1;
  }

  .form-actions p {
    margin-right: 0;
    text-align: center;
    width: 100%;
  }

  .btn-small {
    min-height: 2.5rem;
    padding: 0.4rem 0.8rem;
  }

  /* Manage tables: each row becomes a small labelled card. */
  .manage-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }

  .manage-table tr {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
  }

  .manage-table tbody tr:last-child {
    border-bottom: 0;
  }

  .manage-table td {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 0;
    border: 0;
    text-align: right;
  }

  .manage-table td::before {
    content: attr(data-label);
    flex-shrink: 0;
    color: var(--muted);
    font-size: 0.85rem;
    text-align: left;
  }

  /* The first column is the item's name: shown as its title. */
  .manage-table td:first-child {
    font-weight: 600;
    text-align: left;
  }

  .manage-table td:first-child::before {
    display: none;
  }

  .manage-table td.row-actions {
    justify-content: flex-end;
    padding-top: 0.25rem;
  }

  .manage-table td.row-actions::before {
    display: none;
  }

  .filters-tools {
    margin-left: 0;
  }

  .answer-group > summary {
    flex-wrap: wrap;
    padding: 0.9rem 1rem;
  }

  .answer-group-side {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding-left: 1.5rem;
  }

  .table-toggle summary {
    padding: 0.6rem 0;
  }

  /* Filters stack full width. */
  .filters select,
  .filters input {
    flex: 1 1 100%;
    min-width: 0;
  }

  /* The chart is what the popup is for: first on a phone, figures after. */
  .team-view > .detail-main-chart {
    order: -1;
    margin-bottom: 1rem;
  }

  .stat-tiles {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
  }

  /* An odd last tile takes the whole row instead of leaving a gap. */
  .stat-tile:last-child:nth-child(odd) {
    grid-column: 1 / -1;
  }

  .stat-tile {
    padding: 0.5rem 0.7rem;
  }

  .stat-tile .small {
    font-size: 0.78rem;
  }

  .stat-tile .stat-value {
    font-size: 1.15rem;
  }

  .answers-toggle > summary {
    padding: 0.75rem 1rem;
  }

  .dialog.dialog-wide .dialog-form {
    padding: 1rem;
  }

  .dialog,
  .dialog.dialog-wide {
    width: calc(100vw - 16px);
    max-height: calc(100dvh - 16px);
  }
}
