:root {
  --brand: #36AB9C;
  --brand-dark: #2B867A;
  --accent: #F58A48;
  --ink: #0F172A;
  --text: #334155;
  --muted: #64748B;
  --line: #E5E7EB;
  --soft: #F7F7F7;
  --soft-teal: #EFFAF8;
  --soft-orange: #FFF4EC;
  --soft-yellow: #FFF8E8;
  --card: #FFFFFF;
  --danger: #9F1239;
  --r: 18px;
  --shadow: 0 12px 34px rgba(15, 23, 42, 0.08);
  --focus: 0 0 0 4px rgba(54, 171, 156, 0.24);
  --font: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(54,171,156,.14), transparent 32rem),
    linear-gradient(180deg, #FFFFFF 0%, var(--soft) 100%);
  color: var(--ink);
  font-family: var(--font);
  line-height: 1.5;
}

body.large-text { font-size: 118%; }

body.large-text h1 { font-size: clamp(1.9rem, 8vw, 2.55rem); }
body.large-text h2 { font-size: clamp(1.68rem, 6.4vw, 2.35rem); }
body.large-text h3 { font-size: 1.24rem; }
body.large-text .lede { font-size: 1.16rem; }
body.large-text .small { font-size: 1.05rem; }
body.large-text .micro { font-size: .94rem; }
body.large-text .choice-card span { font-size: .98rem; }
body.large-text .step-label { font-size: .86rem; }
body.large-text .action.compact { font-size: 1rem; }
body.large-text .tab-btn { font-size: 1.02rem; }
body.large-text input[type="text"],
body.large-text textarea { font-size: 1.08rem; }


.app-loading {
  min-height: 56vh;
  display: grid;
  place-items: center;
  padding: 2rem 1rem;
  text-align: center;
}

.app-loading-card {
  width: min(22rem, 100%);
  display: grid;
  justify-items: center;
  gap: .75rem;
  padding: 1.25rem;
  border-radius: 1.5rem;
  background: rgba(255,255,255,.82);
  border: 1px solid rgba(229,231,235,.8);
  box-shadow: var(--shadow);
}

.app-loading-icon {
  width: 5rem;
  height: 5rem;
  border-radius: 1.45rem;
  object-fit: cover;
  box-shadow: 0 10px 24px rgba(15,23,42,.10);
}

.app-loading-title {
  margin: .15rem 0 0;
  font-size: 1.15rem;
  font-weight: 850;
  letter-spacing: -.01em;
}

.app-loading-text {
  margin: 0;
  color: var(--muted);
  font-size: .95rem;
  line-height: 1.45;
}

.app-loading-dots {
  display: inline-flex;
  gap: .28rem;
  align-items: center;
  justify-content: center;
  margin-top: .2rem;
  min-height: .5rem;
}

.app-loading-dots span {
  width: .42rem;
  height: .42rem;
  border-radius: 999px;
  background: var(--brand);
  opacity: .45;
  animation: sg-load-pulse 1.15s ease-in-out infinite;
}

.app-loading-dots span:nth-child(2) { animation-delay: .15s; }
.app-loading-dots span:nth-child(3) { animation-delay: .3s; }

@keyframes sg-load-pulse {
  0%, 80%, 100% { opacity: .35; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-.16rem); }
}

body.low-stimulation {
  --brand: #2F8F84;
  --brand-dark: #256E66;
  --accent: #B96F45;
  --ink: #111827;
  --text: #334155;
  --muted: #526172;
  --line: #D9E1E8;
  --soft: #FAFAF9;
  --soft-teal: #F6FAF8;
  --soft-orange: #FAF3ED;
  --soft-yellow: #FAF6E8;
  --shadow: none;
  --focus: 0 0 0 4px rgba(47, 143, 132, 0.18);
  background: #FAFAF9;
}

body.low-stimulation .brand-mark,
body.low-stimulation .panel,
body.low-stimulation .saved-card,
body.low-stimulation .app-tabs,
body.low-stimulation .install-device {
  box-shadow: none;
}

body.low-stimulation .panel,
body.low-stimulation .saved-card,
body.low-stimulation .install-card,
body.low-stimulation .install-device,
body.low-stimulation .printable-bridge,
body.low-stimulation .empty-state,
body.low-stimulation .saved-item {
  background: #FFFFFF;
  border-color: var(--line);
}

body.low-stimulation .hero-panel,
body.low-stimulation .saved-panel,
body.low-stimulation .result-bridge,
body.low-stimulation .reset-card {
  background: #FFFFFF;
}

body.low-stimulation .kicker,
body.low-stimulation .saved-count {
  background: #F4F1EA;
  color: #6F4A37;
}

body.low-stimulation .action {
  box-shadow: none;
}

body.low-stimulation .action.orange {
  background: var(--accent);
  box-shadow: none;
}

body.low-stimulation .action.secondary,
body.low-stimulation .tab-btn.active,
body.low-stimulation .chip[aria-pressed="true"] {
  background: #F1F7F5;
  box-shadow: none;
}

body.low-stimulation .step-box,
body.low-stimulation .step-box.orange,
body.low-stimulation .step-box.yellow {
  background: #FFFFFF;
  border-color: var(--line);
  box-shadow: none;
}

body.low-stimulation .step-box { border-left: 4px solid #B8DAD4; }
body.low-stimulation .step-box.orange { border-left-color: #D6B299; }
body.low-stimulation .step-box.yellow { border-left-color: #DDD0A5; }

body.low-stimulation .notice {
  background: #FFFFFF;
  border-color: #9DCBC4;
}

body.low-stimulation .app-tabs {
  background: #FFFFFF;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

body.high-contrast {
  --brand: #00796B;
  --brand-dark: #004D45;
  --accent: #C65312;
  --ink: #020617;
  --text: #0F172A;
  --muted: #1F2937;
  --line: #64748B;
  --soft: #F8FAFC;
  --soft-teal: #E0F2F1;
  --soft-orange: #FFE8D6;
  --soft-yellow: #FFF3BF;
  --shadow: 0 10px 28px rgba(2, 6, 23, 0.13);
  --focus: 0 0 0 4px rgba(0, 77, 69, 0.36);
}

body.high-contrast {
  background: #FFFFFF;
}

body.high-contrast .panel,
body.high-contrast .saved-card,
body.high-contrast .install-device,
body.high-contrast .saved-item {
  border-color: var(--line);
  background: #FFFFFF;
}

body.high-contrast .hero-panel,
body.high-contrast .saved-panel,
body.high-contrast .install-card,
body.high-contrast .result-bridge {
  background: #FFFFFF;
  border-color: var(--line);
}

body.high-contrast .kicker,
body.high-contrast .saved-count {
  background: #FFF1E6;
  color: #7C2D12;
  border: 1px solid #C65312;
}

body.high-contrast .action {
  background: var(--brand-dark);
  color: #FFFFFF;
  box-shadow: none;
}
body.high-contrast .action:hover { background: #003C36; }
body.high-contrast .action.secondary {
  background: #DFF4F1;
  color: #003C36;
  border-color: #00796B;
}
body.high-contrast .action.ghost {
  background: #FFFFFF;
  color: #020617;
  border: 2px solid var(--line);
}
body.high-contrast .action.orange {
  background: #B4470F;
  color: #FFFFFF;
}
body.high-contrast .action.danger {
  background: #FFF1F2;
  color: #881337;
  border: 2px solid #BE123C;
}
body.high-contrast .chip {
  border: 2px solid var(--line);
  color: #020617;
}
body.high-contrast .chip[aria-pressed="true"] {
  border-color: #004D45;
  background: #DFF4F1;
  color: #003C36;
  box-shadow: inset 0 0 0 2px #00796B;
}
body.high-contrast input[type="text"],
body.high-contrast textarea {
  border: 2px solid var(--line);
}
body.high-contrast .step-box,
body.high-contrast .step-box.orange,
body.high-contrast .step-box.yellow,
body.high-contrast .notice,
body.high-contrast .printable-bridge,
body.high-contrast .empty-state {
  border-color: var(--line);
}
body.high-contrast .app-tabs {
  border: 2px solid var(--line);
  background: #FFFFFF;
  box-shadow: 0 12px 28px rgba(2,6,23,.16);
}
body.high-contrast .tab-btn { color: #1F2937; }
body.high-contrast .tab-btn.active {
  background: #DFF4F1;
  color: #003C36;
  box-shadow: inset 0 0 0 2px #00796B;
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: -4rem;
  z-index: 10;
  padding: .65rem .85rem;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
}
.skip-link:focus { top: 1rem; }

.site-header,
.site-footer {
  width: min(980px, calc(100% - 2rem));
  margin: 0 auto;
}

.site-header {
  display: flex;
  align-items: center;
  gap: .9rem;
  padding: 1.1rem 0 .35rem;
}

.brand-mark {
  display: block;
  width: 3rem;
  height: 3rem;
  flex: 0 0 auto;
  border-radius: 1rem;
  object-fit: cover;
  box-shadow: var(--shadow);
  background: #fff;
}

.eyebrow {
  margin: 0 0 -.2rem;
  color: var(--brand-dark);
  font-size: .82rem;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(1.65rem, 7vw, 2.25rem); line-height: 1.05; }
h2 { font-size: clamp(1.42rem, 5.5vw, 2rem); line-height: 1.12; margin-bottom: .65rem; }
h3 { font-size: 1.08rem; line-height: 1.25; margin-bottom: .45rem; }

#app {
  width: min(980px, calc(100% - 2rem));
  margin: 0 auto;
  padding: .75rem 0 1.5rem;
}

#app:focus,
#app:focus-visible {
  outline: none !important;
  box-shadow: none !important;
}

* { -webkit-tap-highlight-color: rgba(54,171,156,.12); }

.site-footer {
  color: var(--muted);
  font-size: .92rem;
  text-align: center;
  padding: .5rem 0 1.4rem;
}

.panel {
  background: rgba(255,255,255,.94);
  border: 1px solid rgba(229,231,235,.9);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: clamp(1rem, 4vw, 1.45rem);
  margin: .75rem 0 1rem;
}

.hero-panel {
  background: linear-gradient(135deg, #ffffff 0%, var(--soft-teal) 100%);
}

.kicker {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  border-radius: 999px;
  padding: .3rem .65rem;
  background: var(--soft-orange);
  color: #9A4D16;
  font-weight: 800;
  font-size: .8rem;
  margin-bottom: .7rem;
}

.lede { color: var(--text); font-size: 1.02rem; max-width: 62ch; }
.small { color: var(--muted); font-size: .92rem; }
.micro { color: var(--muted); font-size: .8rem; }

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .72rem;
  margin-top: 1rem;
}

@media (min-width: 720px) { .grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 430px) {
  .grid { grid-template-columns: 1fr; }
  .grid.three { gap: .58rem; }
}

button,
.button-link {
  font: inherit;
}

.action,
.chip,
.soft-link {
  border: 0;
  cursor: pointer;
  touch-action: manipulation;
}

.action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 3.1rem;
  padding: .82rem 1rem;
  border-radius: var(--r);
  background: var(--brand);
  color: #fff;
  font-weight: 800;
  text-align: center;
  box-shadow: 0 8px 18px rgba(54,171,156,.18);
}

.action:hover { background: var(--brand-dark); }
.action.secondary { background: #EEF8F6; color: var(--brand-dark); border: 1px solid rgba(54,171,156,.28); box-shadow: none; }
.action.orange { background: var(--accent); box-shadow: 0 8px 18px rgba(245,138,72,.17); }
.action.ghost { background: #fff; color: var(--text); border: 1px solid var(--line); box-shadow: none; }
.action.danger { background: #FFF1F2; color: var(--danger); border: 1px solid #FECDD3; box-shadow: none; }
.action.compact { min-height: 2.55rem; padding: .58rem .85rem; font-size: .92rem; }

.choice-card {
  min-height: 4.8rem;
  justify-content: flex-start;
  text-align: left;
  flex-direction: column;
  align-items: flex-start;
  gap: .18rem;
}
.choice-card strong { display: block; color: inherit; }
.choice-card span { display: block; opacity: .88; font-weight: 600; font-size: .84rem; }

.comfort-strip {
  display: grid;
  gap: .5rem;
  margin: .9rem 0 .35rem;
}
.comfort-strip .action { min-height: 3.3rem; }

@media (max-width: 430px) {
  .panel { border-radius: 20px; }
  .choice-card { min-height: auto; padding: .78rem .9rem; border-radius: 16px; }
  .choice-card span { font-size: .8rem; line-height: 1.42; }
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: .55rem;
  margin: 1rem 0 0;
}
.toolbar .action { width: auto; flex: 1 1 10rem; }

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: .55rem;
  margin: .85rem 0 1rem;
}

.chip {
  min-height: 2.55rem;
  padding: .58rem .8rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  font-weight: 750;
}

.chip[aria-pressed="true"] {
  border-color: rgba(54,171,156,.55);
  background: var(--soft-teal);
  color: var(--brand-dark);
  box-shadow: inset 0 0 0 1px rgba(54,171,156,.18);
}

input[type="text"], textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: .9rem 1rem;
  color: var(--ink);
  background: #fff;
  font: inherit;
}
textarea { min-height: 6rem; resize: vertical; }
label { display: block; color: var(--text); font-weight: 800; margin: .85rem 0 .4rem; }

input:focus,
textarea:focus,
button:focus-visible,
a:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.reset-card {
  border: 1px solid rgba(54,171,156,.28);
  background: linear-gradient(180deg, #fff 0%, #fbfffe 100%);
}

.step-box {
  border-radius: 18px;
  padding: 1rem;
  margin: .75rem 0;
  background: var(--soft-teal);
  border: 1px solid rgba(54,171,156,.22);
}
.step-box.orange { background: var(--soft-orange); border-color: rgba(245,138,72,.24); }
.step-box.yellow { background: var(--soft-yellow); border-color: rgba(245,138,72,.18); }
.step-label {
  display: block;
  color: var(--muted);
  font-size: .75rem;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
  margin-bottom: .25rem;
}
.step-box p { margin: 0; }

.list { padding-left: 1.15rem; margin: .45rem 0 0; color: var(--text); }
.list li { margin: .28rem 0; }

.notice {
  border-left: 4px solid var(--brand);
  border-radius: 16px;
  padding: .8rem .9rem;
  background: #fff;
  color: var(--text);
  margin: .8rem 0;
}


.printable-bridge {
  margin-top: 1rem;
  padding: .9rem;
  border-radius: 18px;
  border: 1px solid rgba(54,171,156,.18);
  background: rgba(255,255,255,.76);
  display: grid;
  gap: .75rem;
}
.printable-bridge h3 {
  margin: 0 0 .25rem;
  font-size: 1rem;
}
.printable-bridge p {
  margin: 0;
  color: var(--text);
  font-size: .9rem;
}
.printable-bridge .bridge-link {
  width: 100%;
  text-decoration: none;
}
.result-bridge {
  background: linear-gradient(135deg, #FFFFFF 0%, var(--soft-teal) 100%);
}
@media (min-width: 720px) {
  .printable-bridge {
    grid-template-columns: 1fr auto;
    align-items: center;
  }
  .printable-bridge .bridge-link { width: auto; }
}

.saved-list { display: grid; gap: .75rem; }
.saved-item {
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: .9rem;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}
.saved-item:hover { border-color: rgba(54,171,156,.5); }
.saved-item p { margin-bottom: 0; }

.timer-display {
  font-size: clamp(2.6rem, 14vw, 4.4rem);
  line-height: 1;
  font-weight: 900;
  text-align: center;
  margin: 1rem 0;
  color: var(--brand-dark);
}

.divider { height: 1px; background: var(--line); margin: 1.2rem 0; }

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .75rem 0;
  border-bottom: 1px solid var(--line);
}
.setting-row:last-child { border-bottom: 0; }


.install-card {
  margin: .9rem 0;
  border: 1px solid rgba(54,171,156,.22);
  border-radius: 20px;
  background: linear-gradient(135deg, #FFFFFF 0%, var(--soft-teal) 100%);
  overflow: hidden;
}

.install-card summary {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: .25rem .8rem;
  align-items: center;
  padding: .95rem 1rem;
  cursor: pointer;
  list-style: none;
}

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

.install-card summary::after {
  content: '+';
  display: inline-grid;
  place-items: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 999px;
  background: #fff;
  color: var(--brand-dark);
  font-weight: 900;
  box-shadow: inset 0 0 0 1px rgba(54,171,156,.20);
}

.install-card[open] summary::after { content: '–'; }

.install-title {
  color: var(--ink);
  font-size: 1.05rem;
  font-weight: 900;
}

.install-summary {
  grid-column: 1 / -1;
  color: var(--text);
  font-size: .92rem;
}

.install-steps {
  padding: 0 1rem 1rem;
}

.install-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr));
  gap: .75rem;
  margin-top: .75rem;
}

.install-device {
  border: 1px solid rgba(229,231,235,.9);
  border-radius: 16px;
  padding: .85rem;
  background: rgba(255,255,255,.82);
}

.install-device h3 { margin-bottom: .35rem; }
.install-device ol { margin: 0; padding-left: 1.25rem; color: var(--text); }
.install-device li + li { margin-top: .25rem; }


@media print {
  body { background: #fff; }
  .site-header, .site-footer, .toolbar, .no-print { display: none !important; }
  #app { width: 100%; padding: 0; }
  .panel { box-shadow: none; border: 1px solid #ddd; }
}


/* Modern app section tabs */
.app-tabs {
  position: sticky;
  bottom: calc(.7rem + env(safe-area-inset-bottom, 0px));
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .35rem;
  width: min(34rem, 100%);
  margin: 1.1rem auto 0;
  padding: .35rem;
  border: 1px solid rgba(203,213,225,.82);
  border-radius: 999px;
  background: rgba(255,255,255,.92);
  box-shadow: 0 14px 34px rgba(15,23,42,.10);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.tab-btn {
  position: relative;
  min-height: 2.85rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 850;
  cursor: pointer;
  touch-action: manipulation;
}

.tab-btn.active {
  background: var(--soft-teal);
  color: var(--brand-dark);
  box-shadow: inset 0 0 0 1px rgba(54,171,156,.22);
}

.tab-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.tab-badge {
  position: absolute;
  top: .28rem;
  right: .5rem;
  min-width: 1.15rem;
  height: 1.15rem;
  padding: 0 .3rem;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  background: var(--accent);
  color: #fff;
  font-size: .7rem;
  line-height: 1;
  font-weight: 900;
}

.saved-panel {
  background: linear-gradient(180deg, rgba(255,255,255,.98) 0%, rgba(247,253,251,.98) 100%);
}

.saved-header {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  justify-content: space-between;
}

.saved-count {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2rem;
  padding: .35rem .7rem;
  border-radius: 999px;
  background: var(--soft-orange);
  color: #9A4D16;
  font-size: .82rem;
  font-weight: 900;
}

.empty-state {
  border: 1px dashed rgba(54,171,156,.34);
  border-radius: 20px;
  padding: 1rem;
  background: rgba(255,255,255,.72);
}

.empty-state .action {
  margin-top: .75rem;
  width: auto;
}

.saved-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 17rem), 1fr));
  gap: .8rem;
  margin-top: 1rem;
}

.saved-card {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  border: 1px solid rgba(229,231,235,.95);
  border-radius: 20px;
  padding: .95rem;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 8px 20px rgba(15,23,42,.045);
}

.saved-card-main {
  flex: 1 1 auto;
}

.saved-card h3 {
  margin-bottom: .3rem;
}

.saved-card .micro {
  margin-bottom: .4rem;
}

.saved-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: .45rem;
  margin-top: .85rem;
}

.saved-actions .action {
  width: 100%;
}

.saved-toolbar {
  margin-top: 1rem;
}

@media (min-width: 560px) {
  .saved-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 860px) {
  .app-tabs {
    margin-top: 1.25rem;
  }
}

@media (max-width: 430px) {
  .app-tabs {
    width: 100%;
    border-radius: 22px;
    bottom: calc(.5rem + env(safe-area-inset-bottom, 0px));
  }
  .tab-btn {
    min-height: 2.7rem;
    font-size: .9rem;
  }
  .saved-header {
    display: block;
  }
  .saved-count {
    margin: .2rem 0 .7rem;
  }
}


@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.001ms !important;
  }
}
