:root {
  --bg: #ffffff;
  --surface: #f4f6f9;
  --fg: #1b2430;
  --muted: #5b6573;
  --border: #d9dee5;
  --primary: #0088c6;
  --primary-fg: #ffffff;
  --accent: #f19e2c;
  --danger: #c62828;
  --warn-bg: #fff4e0;
  --error-bg: #fdecea;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11161d;
    --surface: #1a212b;
    --fg: #e8edf3;
    --muted: #a3adba;
    --border: #2c3542;
    --primary: #00ade6;
    --primary-fg: #0b1218;
    --danger: #ef5350;
    --warn-bg: #3a2c12;
    --error-bg: #3b1a1a;
  }
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--fg);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  line-height: 1.5;
}

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

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

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}

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

.brand img {
  display: block;
  height: 32px;
  width: auto;
}

.hero,
.page {
  flex: 1;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 40px 16px 64px;
}

.hero {
  padding-top: 64px;
}

.hero h1,
.page h1 {
  font-size: clamp(1.7rem, 5vw, 2.4rem);
  line-height: 1.2;
  margin: 0 0 16px;
}

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

.soon {
  color: var(--muted);
  border-left: 4px solid var(--accent);
  padding-left: 12px;
}

.footer {
  padding: 24px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
  border-top: 1px solid var(--border);
}

.footer img {
  max-width: 200px;
  height: auto;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-block;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 12px 20px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  color: var(--primary-fg);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: progress;
}

.btn-secondary {
  background: transparent;
  border-color: var(--border);
  color: var(--fg);
}

.btn-sm {
  padding: 8px 14px;
  font-size: 0.95rem;
}

.btn-block {
  display: block;
  width: 100%;
}

.icon-btn {
  display: inline-flex;
  padding: 6px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.icon-btn:hover {
  background: var(--surface);
  color: var(--fg);
}

/* ---------- Modal ---------- */

.modal {
  width: min(560px, calc(100% - 32px));
  max-height: calc(100dvh - 32px);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--bg);
  color: var(--fg);
  box-shadow: 0 20px 60px rgb(0 0 0 / 0.25);
}

.modal[open] {
  display: flex;
  flex-direction: column;
}

.modal::backdrop {
  background: rgb(10 14 20 / 0.55);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border);
}

.modal-head h2 {
  margin: 0;
  font-size: 1.25rem;
}

.modal-body {
  overflow-y: auto;
  padding: 16px 20px 20px;
}

.step {
  margin-bottom: 20px;
}

.step h3,
#done h3 {
  margin: 0 0 8px;
  font-size: 1.05rem;
}

.step > .hint {
  margin: 0 0 12px;
}

.step-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.counter {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.file-drop {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 14px 16px;
  border: 1.5px dashed var(--border);
  border-radius: 10px;
  cursor: pointer;
  font-weight: 500;
}

.file-drop:hover,
.file-drop:focus-within,
#document:focus-visible + .file-drop {
  border-color: var(--primary);
}

.file-drop .file-name {
  color: var(--primary);
  overflow-wrap: anywhere;
}

.file-drop.has-file {
  border-style: solid;
}

.file-drop.has-file .file-name {
  color: var(--fg);
}

.btn-link {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font: inherit;
  padding: 0;
}

/* ---------- Form ---------- */

fieldset {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin: 0 0 20px;
  min-width: 0;
}

legend {
  font-weight: 700;
  padding: 0 6px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 14px;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0 16px;
}

@media (min-width: 620px) {
  .grid-2 {
    grid-template-columns: 1fr 1fr;
  }
}

label {
  font-weight: 500;
}

input:not([type='checkbox']):not([type='radio']) {
  font: inherit;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--fg);
  width: 100%;
}

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

input[aria-invalid='true'] {
  border-color: var(--danger);
}

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

.hint {
  color: var(--muted);
  font-size: 0.9rem;
}

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

.radios label,
.check {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  font-weight: 400;
  margin-bottom: 8px;
}

.radios input,
.check input {
  margin-top: 4px;
}

.admin-card {
  background: var(--surface);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 12px;
}

.admin-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.hp {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  opacity: 0;
}

.captcha:empty {
  display: none;
}

.captcha {
  margin: 8px 0 12px;
}

#remaining:empty {
  display: none;
}

/* ---------- Banners ---------- */

.banner {
  border-radius: 10px;
  padding: 12px 16px;
  margin: 0 0 20px;
  background: var(--surface);
}

.banner p {
  margin: 0 0 8px;
}

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

.banner-warn {
  background: var(--warn-bg);
}

.banner-error {
  background: var(--error-bg);
}


/* ---------- Segmented choice ---------- */

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  margin-bottom: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}

.segmented label {
  position: relative;
  display: flex;
  justify-content: center;
  padding: 8px 10px;
  border-radius: 7px;
  font-weight: 500;
  text-align: center;
  cursor: pointer;
}

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

.segmented label:has(input:checked) {
  background: var(--bg);
  color: var(--primary);
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.15);
}

.segmented label:has(input:focus-visible) {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

/* ---------- Letter ---------- */

.substep {
  margin: 18px 0 8px;
  font-size: 0.95rem;
}

.letter-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  margin: 4px 0 6px;
}

.btn:disabled:not(.btn-primary) {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-text {
  background: none;
  border: none;
  padding: 4px 0;
  color: var(--primary);
  font: inherit;
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

/* ---------- Steps ---------- */

.stepper {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 0 0 18px;
  padding: 0;
  list-style: none;
  counter-reset: none;
}

.stepper li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 8px;
  border-top: 3px solid var(--border);
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 500;
  min-width: 0;
}

.stepper li > span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stepper-num {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--surface);
  font-size: 0.8rem;
}

.stepper li.done,
.stepper li.current {
  border-top-color: var(--primary);
  color: var(--fg);
}

.stepper li.current .stepper-num,
.stepper li.done .stepper-num {
  background: var(--primary);
  color: var(--primary-fg);
}

.step-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  margin-top: 8px;
}

.step-nav #next {
  margin-left: auto;
}

.banner-info {
  background: var(--surface);
  border-left: 4px solid var(--primary);
}

.hint.small {
  font-size: 0.85rem;
}

/* On a phone the current step gets its full name; the others shrink with an ellipsis. */
@media (max-width: 480px) {
  .stepper {
    display: flex;
  }

  .stepper li {
    flex: 1 1 0;
  }

  .stepper li.current {
    flex: 0 0 auto;
  }
}


/* ---------- Admins: the open card and a 3D stack of the others ---------- */

#admins {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0 18px;
  align-items: start;
}

#admins.has-stack {
  grid-template-columns: 136px minmax(0, 1fr);
  perspective: 700px;
}

#admins .admin-card:not(.stacked) {
  grid-column: -2;
  grid-row: 1;
  margin-bottom: 12px;
}

/* In the narrow column next to the stack, email and phone go one under the other. */
#admins.has-stack .grid-2 {
  grid-template-columns: 1fr;
}

#admins .admin-card.stacked {
  grid-column: 1;
  grid-row: 1;
  padding: 0;
  margin: 0;
  border: 1px solid var(--border);
  box-shadow: 0 6px 16px rgb(0 0 0 / 0.18);
  transform-origin: left center;
  transform: translate3d(calc(var(--depth) * -8px), calc(var(--depth) * 16px), calc(var(--depth) * -50px))
    rotateY(22deg);
  /* Cards further back are darker, so the stack reads as depth. */
  filter: brightness(calc(1 - var(--depth) * 0.14));
  transition: transform 0.25s ease, box-shadow 0.25s ease, filter 0.25s ease;
}

#admins .admin-card.stacked .admin-fields {
  display: none;
}

/* Hovering the stack fans the cards out so each one is easy to pick. */
#admins:has(.stacked:hover, .stacked :focus-visible) .admin-card.stacked {
  transform: translateY(calc(var(--depth) * 64px)) rotateY(0deg);
  filter: none;
}

#admins .admin-card.stacked:hover {
  box-shadow: 0 8px 22px rgb(0 0 0 / 0.28);
}

.admin-summary {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-radius: 10px;
  background: var(--surface);
  color: var(--fg);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.admin-summary > span {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-summary-num {
  color: var(--muted);
  font-size: 0.75rem;
}

.admin-summary-name {
  font-weight: 600;
  font-size: 0.9rem;
}

.admin-summary-email {
  color: var(--muted);
  font-size: 0.8rem;
}

.admin-card.incomplete .admin-summary-name {
  color: var(--danger);
}

/* Phones: the stack lies above the open card. */
@media (max-width: 480px) {
  #admins.has-stack {
    grid-template-columns: 1fr;
  }

  #admins .admin-card:not(.stacked) {
    grid-row: 2;
    grid-column: 1;
    margin-top: 14px;
  }

  #admins .admin-card.stacked {
    transform-origin: center top;
    transform: translate3d(0, calc(var(--depth) * -9px), calc(var(--depth) * -40px)) rotateX(24deg);
  }

  #admins:has(.stacked:hover, .stacked :focus-visible) .admin-card.stacked {
    transform: translateY(calc(var(--depth) * 62px)) rotateX(0deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  #admins .admin-card.stacked {
    transition: none;
  }
}

/* ---------- Busy overlay with the pumpkin spinner ---------- */

.modal {
  position: fixed;
}

.busy {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(2px);
  border-radius: inherit;
  color: var(--muted);
  font-weight: 500;
}

.busy[hidden] {
  display: none;
}

.busy p {
  margin: 0;
}

#busy-spinner.pulse {
  animation: pulse 0.9s ease-in-out infinite alternate;
}

@keyframes pulse {
  from { opacity: 0.45; }
  to { opacity: 1; }
}

/* ---------- Admins: contact person, partial warning ---------- */

.contact-note {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 8px;
  border-left: 4px solid var(--primary);
  background: color-mix(in srgb, var(--primary) 14%, transparent);
  font-size: 0.92rem;
}

.make-contact {
  margin: -4px 0 10px;
  font-size: 0.92rem;
}

.banner-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  margin-top: 8px;
}

/* ---------- Vchasno instructions ---------- */

.instructions ol {
  margin: 0 0 8px;
  padding-left: 20px;
}

.instructions li {
  margin-bottom: 6px;
}

.modal.modal-sm {
  width: min(460px, calc(100% - 32px));
}
