:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --panel: #ffffff;
  --ink: #16201c;
  --muted: #64716d;
  --line: #d9dfdb;
  --accent: #116a63;
  --accent-ink: #ffffff;
  --warn: #925a12;
  --danger: #9f2f2f;
  --ok: #17693b;
  --soft-accent: #e5f2ef;
  --soft-warn: #fff2d6;
  --soft-danger: #f8e4e1;
  --shadow: 0 12px 30px rgba(27, 40, 35, 0.08);
}

* {
  box-sizing: border-box;
}

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

button,
input,
select {
  font: inherit;
}

.app-shell {
  width: min(100%, 760px);
  margin: 0 auto;
  padding: 16px;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 2px 14px;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 10vw, 3.4rem);
  line-height: 0.96;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 12px;
  font-size: 1rem;
}

.icon-button,
.small-button {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  min-height: 44px;
  border-radius: 8px;
  cursor: pointer;
}

.icon-button {
  min-width: 58px;
  padding: 0 10px;
  font-size: 0.82rem;
  font-weight: 800;
}

.small-button {
  padding: 0 14px;
  font-weight: 750;
}

.field-option-button {
  width: 100%;
  margin-top: 8px;
}

.field-option-button.active {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
}

.status-panel,
.section-block {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 14px;
}

.status-panel {
  border-left: 6px solid var(--accent);
}

.status-panel.standard,
.status-panel.ok {
  border-left-color: var(--ok);
  background: #f8fffa;
}

.status-panel.warning {
  border-left-color: var(--warn);
  background: var(--soft-warn);
}

.status-panel.danger {
  border-left-color: var(--danger);
  background: var(--soft-danger);
}

.status-kicker {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
  text-transform: uppercase;
}

#resultTitle {
  margin-bottom: 6px;
  font-size: 1.35rem;
}

#resultDetail {
  margin-bottom: 0;
  color: var(--muted);
}

.segmented {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.segmented label {
  min-width: 0;
}

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

.segmented span {
  display: grid;
  min-height: 48px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9faf8;
  color: var(--muted);
  font-size: 0.94rem;
  font-weight: 750;
  text-align: center;
}

.segmented input:checked + span {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
}

.field-grid {
  display: grid;
  gap: 12px;
}

#decisionField,
#lkwField {
  order: 0;
}

#strokeForm.wake-up-mode #decisionField {
  order: -1;
}

#strokeForm.wake-up-mode #lkwField {
  order: -2;
}

.field span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 750;
}

.field input,
.field select {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fbfcfb;
  color: var(--ink);
}

.field select {
  appearance: none;
}

.datetime-control {
  display: grid;
  grid-template-columns: minmax(142px, 1.45fr) 62px 62px 68px;
  gap: 8px;
}

.datetime-control .date-wheel {
  min-width: 0;
}

.datetime-control.invalid input,
.datetime-control.invalid select,
.datetime-control.invalid .date-wheel {
  border-color: var(--danger);
  background: #fff7f6;
}

.field-error {
  display: block;
  min-height: 1.1rem;
  margin-top: 5px;
  color: var(--danger);
  font-size: 0.78rem;
  font-style: normal;
  font-weight: 750;
}

.time-row {
  display: grid;
  grid-template-columns: minmax(142px, 1.45fr) 62px 62px 68px auto;
  gap: 8px;
}

.date-wheel,
.time-wheel {
  position: relative;
  height: 72px;
  overflow-y: auto;
  padding-block: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  scroll-snap-type: y mandatory;
  scroll-padding-block: 14px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.date-wheel::-webkit-scrollbar,
.time-wheel::-webkit-scrollbar {
  display: none;
}

.time-select {
  width: 100%;
  min-height: 72px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  color: var(--ink);
  font-weight: 850;
  text-align: center;
}

.wheel-item {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 44px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 750;
  padding: 0 8px;
  scroll-snap-align: center;
  text-align: center;
  white-space: nowrap;
}

.time-wheel .wheel-item {
  height: 40px;
}

.date-wheel .wheel-item {
  font-size: 0.86rem;
}

.time-wheel.period .wheel-item {
  font-size: 0.9rem;
}

.wheel-item.selected {
  color: var(--ink);
  background: var(--soft-accent);
  font-weight: 850;
}

.sleep-only {
  display: none;
}

.sleep-only.visible {
  display: block;
}

.calculated-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.calculated-line span {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 750;
}

.toggle-list {
  display: grid;
  gap: 10px;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  color: var(--ink);
  font-weight: 700;
}

.toggle input {
  width: 22px;
  height: 22px;
  accent-color: var(--accent);
}

.toggle.disabled {
  color: var(--muted);
  opacity: 0.58;
}

.timeline {
  margin-bottom: 12px;
}

.timeline-empty {
  margin-bottom: 0;
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 12px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

.timeline-track {
  position: relative;
  display: grid;
  gap: 0;
  margin: 4px 0 12px;
  padding-left: 8px;
}

.timeline-track::before {
  content: "";
  position: absolute;
  top: 12px;
  bottom: 12px;
  left: 15px;
  width: 3px;
  border-radius: 999px;
  background: var(--accent);
}

.timeline-marker {
  position: relative;
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 10px;
  align-items: center;
  min-height: 54px;
}

.timeline-dot {
  position: relative;
  z-index: 1;
  display: block;
  width: 15px;
  height: 15px;
  margin-left: 0;
  border: 3px solid var(--panel);
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.timeline-marker.midpoint .timeline-dot {
  background: var(--warn);
  box-shadow: 0 0 0 1px var(--warn);
}

.timeline-marker.decision .timeline-dot {
  background: var(--ok);
  box-shadow: 0 0 0 1px var(--ok);
}

.timeline-marker strong,
.timeline-marker small {
  display: block;
}

.timeline-marker strong {
  color: var(--ink);
  font-size: 0.9rem;
  line-height: 1.2;
}

.timeline-marker small {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.2;
}

.timeline-windows {
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fbfcfb;
}

.timeline-window {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.timeline-window strong {
  color: var(--ink);
  text-align: right;
}

.next-step-output {
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft-accent);
  padding: 12px;
  color: var(--ink);
  font-weight: 800;
}

.guideline-reference {
  margin-bottom: 10px;
  border-left: 3px solid var(--accent);
  padding: 2px 0 2px 10px;
}

.guideline-reference span {
  display: block;
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 850;
  text-transform: uppercase;
}

.guideline-reference p {
  margin-bottom: 0;
  color: var(--ink);
  font-size: 0.88rem;
}

.guideline-table-slot {
  margin-bottom: 10px;
}

.guideline-table-slot:empty {
  display: none;
}

.guideline-table-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  background: #fbfcfb;
}

.guideline-table-header {
  display: grid;
  gap: 8px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.guideline-table-header p {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 850;
  text-transform: uppercase;
}

.guideline-table-header h3 {
  margin: 0;
  font-size: 0.98rem;
}

.guideline-section {
  width: fit-content;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 5px 8px;
  background: var(--soft-accent);
  color: var(--accent);
  font-size: 0.74rem;
  font-weight: 850;
}

.guideline-table-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(72px, 1fr));
}

.guideline-table-row + .guideline-table-row {
  border-top: 1px solid var(--line);
}

.guideline-rating,
.guideline-recommendation {
  padding: 12px;
}

.guideline-rating {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 5px;
  border-right: 1px solid var(--line);
}

.guideline-rating:nth-child(2) {
  border-right: 0;
}

.guideline-rating span,
.guideline-recommendation span {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 850;
  text-transform: uppercase;
}

.guideline-rating strong {
  display: grid;
  min-width: 44px;
  min-height: 44px;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 1rem;
}

.guideline-recommendation {
  grid-column: 1 / -1;
  border-top: 1px solid var(--line);
}

.guideline-recommendation p {
  margin: 5px 0 0;
  color: var(--ink);
  font-size: 0.9rem;
}

.evt-tool-link {
  display: inline-grid;
  grid-template-columns: 34px 1fr 24px;
  align-items: center;
  gap: 12px;
  width: fit-content;
  max-width: 100%;
  min-height: 58px;
  margin: 12px 0 18px;
  padding: 10px 16px;
  border: 2px solid var(--accent);
  border-radius: 8px;
  background: var(--panel);
  color: var(--accent);
  font-weight: 850;
  text-decoration: none;
}

.evt-tool-link span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.evt-tool-link:focus-visible {
  outline: 3px solid rgba(17, 106, 99, 0.28);
  outline-offset: 2px;
}

.evt-tool-icon,
.evt-tool-chevron {
  width: 100%;
  height: 34px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.4;
}

.evt-tool-chevron {
  height: 28px;
}

.fine-print {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.about-card {
  margin-bottom: 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.about-card summary {
  display: grid;
  grid-template-columns: 26px 1fr 18px;
  align-items: center;
  gap: 10px;
  min-height: 58px;
  padding: 12px 16px;
  font-weight: 800;
  cursor: pointer;
  list-style: none;
}

.about-card summary::-webkit-details-marker {
  display: none;
}

.about-card summary:hover {
  background: #f9faf8;
}

.about-card summary:focus-visible {
  outline: 3px solid rgba(17, 106, 99, 0.28);
  outline-offset: -3px;
}

.about-summary-icon {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border: 2px solid var(--accent);
  border-radius: 50%;
  color: var(--accent);
  font-family: Georgia, serif;
  font-size: 0.9rem;
  font-weight: 800;
  line-height: 1;
}

.about-chevron {
  width: 10px;
  height: 10px;
  justify-self: end;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg) translate(-2px, -2px);
  transition: transform 160ms ease;
}

.about-card[open] .about-chevron {
  transform: rotate(225deg) translate(-2px, -2px);
}

.about-content {
  display: grid;
  gap: 20px;
  padding: 20px 16px;
  border-top: 1px solid var(--line);
}

.about-heading h2 {
  margin: 0;
  font-size: 1.35rem;
}

.about-section h3 {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 850;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.about-section p {
  margin: 0;
}

.about-section cite {
  font-style: normal;
}

.about-section a {
  color: var(--accent);
  font-weight: 700;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.about-section a:hover {
  text-decoration-thickness: 2px;
}

.about-section a:focus-visible {
  border-radius: 3px;
  outline: 3px solid rgba(17, 106, 99, 0.28);
  outline-offset: 3px;
}

.about-disclaimer {
  padding: 14px;
  border-left: 4px solid var(--accent);
  border-radius: 6px;
  background: var(--soft-accent);
}

.about-disclaimer p {
  font-size: 0.9rem;
}

.hidden {
  display: none;
}

@media (min-width: 640px) {
  .app-shell {
    padding: 24px;
  }

  .segmented {
    grid-template-columns: repeat(2, 1fr);
  }

  .field-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 430px) {
  .datetime-control,
  .time-row {
    grid-template-columns: 1fr 56px 56px 62px;
  }

  .datetime-control .date-wheel {
    grid-column: 1 / -1;
  }

  .time-row .small-button {
    grid-column: 1 / -1;
  }

  .timeline-windows {
    min-width: 0;
  }
}
