:root {
  color-scheme: light;
  --ink: #14181d;
  --navy: #102033;
  --cream: #f6f3ec;
  --paper: #fffdf8;
  --amber: #e2a30b;
  --line: #102033;
  --danger: #3b0a06;
  --danger-bg: #fde8e4;
  --ok: #14532d;
  --ok-bg: #e7f6ec;
  --muted: #243040;
}

* { box-sizing: border-box; }

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

[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-size: 18px;
  line-height: 1.45;
}

.skip {
  position: absolute;
  left: 8px;
  top: 8px;
  transform: translateY(-150%);
  background: #fff;
  color: var(--navy);
  padding: 12px 16px;
  min-height: 48px;
  z-index: 20;
  border: 2px solid var(--navy);
  border-radius: 12px;
  font-weight: 800;
  text-decoration: none;
}

.skip:focus { transform: none; }

.app-shell {
  max-width: 40rem;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--cream);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--navy);
  color: #f7f4ee;
  padding: 10px 16px 12px;
  padding-top: calc(10px + env(safe-area-inset-top));
  border-bottom: 4px solid var(--amber);
}

.brand-kicker {
  margin: 0 0 2px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #fff;
}

h1 {
  margin: 0;
  font-family: Georgia, "Iowan Old Style", Palatino, serif;
  font-size: 32px;
  line-height: 1;
  font-weight: 700;
}

main {
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
}

.wrap { padding: 16px 16px 4px; }

h2 {
  margin: 8px 0 8px;
  font-family: Georgia, "Iowan Old Style", Palatino, serif;
  font-size: 26px;
  line-height: 1.2;
  scroll-margin-top: 96px;
}

h3 {
  margin: 0 0 8px;
  font-size: 20px;
  scroll-margin-top: 96px;
}

.lede, .hint {
  margin: 0 0 12px;
  color: var(--ink);
}

.hint { color: var(--muted); font-size: 16px; }

.kicker {
  margin: 0 0 6px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.disclaimer {
  margin: 0 0 16px;
  padding: 12px 14px;
  background: #fff6d8;
  color: #1a1204;
  border: 2px solid #1a1204;
  border-radius: 12px;
  font-size: 17px;
  line-height: 1.4;
  font-weight: 600;
}

label, legend {
  display: block;
  font-weight: 800;
  margin: 12px 0 6px;
  padding: 0;
}

fieldset {
  border: 0;
  margin: 0;
  padding: 0;
  min-inline-size: 0;
}

input[type="text"],
input[type="tel"],
input[type="datetime-local"],
textarea {
  width: 100%;
  min-height: 56px;
  padding: 12px 14px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  color: var(--ink);
  font: 700 20px/1.3 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  scroll-margin-top: 96px;
}

#caller-number {
  min-height: 64px;
  font-size: 24px;
}

textarea {
  min-height: 120px;
  font-size: 18px;
  font-weight: 600;
  resize: vertical;
}

::placeholder {
  color: #4a5562;
  opacity: 1;
  font-weight: 600;
}

input[aria-invalid="true"],
textarea[aria-invalid="true"] {
  border-color: var(--danger);
  background: var(--danger-bg);
}

.choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.choice {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  padding: 12px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  font-weight: 800;
  cursor: pointer;
}

.choice input {
  width: 24px;
  height: 24px;
  margin: 0;
  accent-color: #9a3412;
  flex: 0 0 auto;
}

.choice.is-selected {
  background: var(--navy);
  color: #fff;
  box-shadow: inset 0 0 0 3px var(--amber);
}

.time-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 4px 0 8px;
}

.time-copy { min-width: 0; }

.time-kicker {
  margin: 0;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.time-label {
  margin: 0;
  font-weight: 800;
  font-size: 18px;
}

.profile-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0 14px;
  padding: 10px 12px;
  border: 2px solid var(--navy);
  border-radius: 12px;
  background: var(--paper);
}

.profile-summary p {
  margin: 0;
  font-weight: 800;
  flex: 1;
  min-width: 0;
}

.profile-summary .btn {
  width: auto;
  min-width: 108px;
  flex: 0 0 auto;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 10px 0;
}

.stack:empty { display: none; }

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 56px;
  min-width: 0;
  padding: 14px 16px;
  border-radius: 14px;
  border: 2px solid var(--navy);
  background: var(--paper);
  color: var(--navy);
  font: 800 18px/1.25 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
  white-space: normal;
  -webkit-tap-highlight-color: rgba(226, 163, 11, 0.45);
}

.btn-large {
  min-height: 64px;
  font-size: 20px;
}

.btn-primary {
  background: var(--navy);
  color: #f7f4ee;
}

.btn-now {
  width: auto;
  min-width: 132px;
  flex: 0 0 auto;
  background: var(--amber);
  color: var(--navy);
}

.btn-now.is-current {
  background: var(--navy);
  color: #f7f4ee;
}

.btn:active { transform: translateY(1px); }

.btn.is-copied {
  background: var(--ok);
  border-color: var(--ok);
  color: #fff;
}

.packet {
  margin: 0 0 12px;
  max-height: 9.5rem;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding: 14px;
  background: var(--paper);
  color: var(--ink);
  border: 2px solid var(--navy);
  border-radius: 12px;
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 16px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  -webkit-user-select: text;
  user-select: text;
}

.action-card {
  margin: 0 0 14px;
  padding: 14px;
  background: var(--paper);
  border: 2px solid var(--navy);
  border-left: 8px solid var(--amber);
  border-radius: 14px;
  scroll-margin-top: 96px;
}

.action-card .btn { margin-top: 8px; }

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

.next {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
}

.steps {
  margin: 0 0 8px;
  padding-left: 1.2rem;
}

.steps li { margin: 8px 0; }

.hint a {
  color: var(--navy);
  font-weight: 800;
}

.error, .status {
  margin: 10px 0;
  padding: 12px 14px;
  border-radius: 12px;
  border: 2px solid var(--navy);
  font-weight: 700;
  scroll-margin-top: 96px;
}

.error {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: var(--danger);
}

.status:empty { display: none; }

.status {
  background: var(--ok-bg);
  color: #062814;
  border-color: #062814;
}

.history {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.history-row { display: flex; gap: 8px; }

.history-open,
.history-remove {
  min-height: 56px;
  border: 2px solid var(--navy);
  border-radius: 12px;
  background: var(--paper);
  color: var(--navy);
  font: 800 16px/1.2 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  padding: 10px 12px;
  cursor: pointer;
  touch-action: manipulation;
}

.history-open {
  flex: 1;
  min-width: 0;
  text-align: left;
}

.history-remove { min-width: 96px; }

.empty { margin: 0 0 8px; font-weight: 700; }

.fold {
  margin: 8px 0 14px;
  border: 2px solid var(--navy);
  border-radius: 12px;
  background: var(--paper);
  padding: 4px 14px 12px;
}

.fold summary {
  min-height: 56px;
  display: flex;
  align-items: center;
  font-weight: 800;
  cursor: pointer;
}

.fold[open] summary { margin-bottom: 8px; }

.stay { margin-top: 4px; }

html:not(.js) .app-ui { display: none; }

.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;
}

:focus { outline: none; }

:focus-visible {
  outline: 3px solid #9a3412;
  outline-offset: 2px;
}

button, a, label, summary, input, textarea {
  touch-action: manipulation;
}

@media (min-width: 800px) {
  body {
    background: var(--navy);
    padding: 24px 16px 40px;
  }

  .app-shell {
    min-height: calc(100vh - 64px);
    border-radius: 18px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
    overflow: hidden;
  }

  .topbar { border-radius: 18px 18px 0 0; }
}

@media (max-width: 359px) {
  h1 { font-size: 28px; }
  h2 { font-size: 22px; }
  .btn-large { font-size: 18px; }
  .time-row { align-items: stretch; }
  .btn-now { min-width: 112px; }
}

@media (prefers-reduced-motion: reduce) {
  .btn:active { transform: none; }
}
