:root {
  --surface: #fcf9f8;
  --surface-low: #f6f3f2;
  --surface-mid: #f0eded;
  --surface-high: #e5e2e1;
  --ink: #1b1b1b;
  --muted: #71716d;
  --outline: #c7c7bf;
  --moss: #506354;
  --moss-soft: #d0e5d2;
  --sage: #8c968d;
  --sand: #f9f7f2;
  --sun: #c8b98d;
  --shadow: 0 28px 70px rgb(32 31 30 / 8%);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  display: grid;
  place-items: center;
  margin: 0;
  padding: 24px;
  background:
    linear-gradient(145deg, #dfe7df 0%, #fcf9f8 48%, #e8e4dc 100%);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button {
  border: 0;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.phone {
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-rows: auto auto auto minmax(228px, 1fr) 72px auto auto;
  gap: 18px;
  width: min(100%, 430px);
  min-height: min(900px, calc(100vh - 48px));
  overflow: hidden;
  padding: 22px;
  border: 1px solid rgb(255 255 255 / 74%);
  border-radius: 34px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

#lightCanvas {
  position: absolute;
  inset: 0;
  z-index: -2;
  width: 100%;
  height: 100%;
}

.phone::after {
  position: absolute;
  inset: 0;
  z-index: -1;
  content: "";
  background:
    linear-gradient(180deg, rgb(252 249 248 / 92%) 0 28%, rgb(252 249 248 / 40%) 58%, rgb(252 249 248 / 88%) 100%),
    radial-gradient(circle at 50% 26%, rgb(255 248 218 / 58%), transparent 30%),
    radial-gradient(circle at 50% 40%, rgb(183 204 185 / 32%), transparent 34%);
  pointer-events: none;
}

.topbar,
.panel-header,
.bottom-rail {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar > div {
  min-width: 0;
  text-align: center;
}

.topbar-spacer {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
}

.kicker,
.summary-label,
.panel-label {
  margin: 0;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1,
h2 {
  font-family: "Playfair Display", Georgia, serif;
  font-weight: 700;
}

h1 {
  color: var(--moss);
  font-size: 1.55rem;
  letter-spacing: 0;
}

h2 {
  color: var(--ink);
  font-size: 1.24rem;
  letter-spacing: 0;
}

.icon-button,
.stepper {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border: 1px solid rgb(199 199 191 / 68%);
  border-radius: 50%;
  background: rgb(255 255 255 / 44%);
  color: var(--sage);
  font-size: 1rem;
  font-weight: 800;
  backdrop-filter: blur(20px);
}

.icon-button.active {
  color: var(--moss);
  background: var(--moss-soft);
}

.audio-icon {
  width: 22px;
  height: 22px;
  background: currentColor;
  mask: var(--audio-icon) center / contain no-repeat;
}

.guide-icon {
  width: 21px;
  height: 21px;
  background: currentColor;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='M12 16v-4'/%3E%3Cpath d='M12 8h.01'/%3E%3C/svg%3E") center / contain no-repeat;
}

.icon-button[data-audio-mode="voice"] {
  --audio-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 7a4 4 0 1 1-8 0 4 4 0 0 1 8 0Z'/%3E%3Cpath d='M3 21a7 7 0 0 1 10.5-6.1'/%3E%3Cpath d='M16 8.5a4.5 4.5 0 0 1 0 7'/%3E%3Cpath d='M19 6a8 8 0 0 1 0 12'/%3E%3C/svg%3E");
}

.icon-button[data-audio-mode="chime"] {
  --audio-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10.3 21a2 2 0 0 0 3.4 0'/%3E%3Cpath d='M18 8a6 6 0 0 0-12 0c0 7-3 7-3 9h18c0-2-3-2-3-9'/%3E%3Cpath d='M13.7 4.3a2 2 0 0 0-3.4 0'/%3E%3C/svg%3E");
}

.summary {
  display: flex;
  justify-content: center;
  gap: 0;
  padding: 4px 0;
}

.summary div {
  min-width: 82px;
  padding: 0 15px;
  text-align: center;
}

.summary div + div {
  border-left: 1px solid rgb(199 199 191 / 62%);
}

.summary strong,
.summary span {
  display: block;
}

.summary strong {
  margin-top: 3px;
  color: var(--moss);
  font-size: 1.04rem;
  font-weight: 500;
  overflow-wrap: anywhere;
}

.safety-banner {
  display: grid;
  padding: 10px 12px;
  border: 1px solid rgb(199 199 191 / 68%);
  border-radius: 16px;
  background: rgb(255 255 255 / 42%);
  color: var(--muted);
  text-align: center;
  backdrop-filter: blur(18px);
}

.safety-banner span,
.safety-banner strong {
  display: block;
}

.safety-banner span {
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.safety-banner strong {
  margin-top: 2px;
  color: var(--moss);
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.25;
}

.safety-banner.locked {
  border-color: rgb(168 95 53 / 34%);
  background: rgb(255 247 234 / 78%);
}

.safety-banner.locked strong {
  color: #8b4d2d;
}

.guide-sheet,
.onboarding-sheet,
.confirm-sheet {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  align-items: end;
  padding: 14px;
  background: rgb(27 27 27 / 18%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
}

.guide-sheet.open,
.onboarding-sheet.open,
.confirm-sheet.open {
  opacity: 1;
  pointer-events: auto;
}

.guide-panel,
.onboarding-panel,
.confirm-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  max-height: min(78vh, 680px);
  overflow: hidden;
  border: 1px solid rgb(255 255 255 / 72%);
  border-radius: 24px;
  background: rgb(252 249 248 / 96%);
  box-shadow: 0 24px 64px rgb(32 31 30 / 16%);
  backdrop-filter: blur(26px);
  transform: translateY(16px);
  transition: transform 0.22s ease;
}

.guide-sheet.open .guide-panel,
.onboarding-sheet.open .onboarding-panel,
.confirm-sheet.open .confirm-panel {
  transform: translateY(0);
}

.onboarding-sheet {
  align-items: center;
}

.onboarding-panel {
  grid-template-rows: auto auto auto;
  gap: 18px;
  padding: 22px;
  max-height: min(86vh, 720px);
}

.onboarding-visual {
  display: grid;
  place-items: center;
  min-height: 118px;
  overflow: hidden;
  border: 1px solid rgb(199 199 191 / 48%);
  border-radius: 22px;
  background:
    linear-gradient(180deg, rgb(252 249 248 / 92%), rgb(249 247 242 / 64%)),
    radial-gradient(circle at 50% 28%, rgb(255 248 218 / 68%), transparent 34%),
    radial-gradient(ellipse at 50% 105%, rgb(208 229 210 / 46%), transparent 54%);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 72%);
}

.onboarding-illustration {
  display: block;
  width: min(100%, 336px);
  height: auto;
}

.onboarding-copy {
  display: grid;
  gap: 12px;
}

.onboarding-slide {
  display: none;
  min-height: 190px;
  align-content: start;
  gap: 12px;
}

.onboarding-slide.is-active {
  display: grid;
}

.onboarding-copy h2 {
  max-width: 11em;
  font-size: 1.58rem;
  line-height: 1.08;
}

.onboarding-slide > p:not(.kicker),
.onboarding-note {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.48;
}

.onboarding-points {
  display: grid;
  gap: 10px;
  padding: 4px 0;
}

.onboarding-points div {
  display: grid;
  grid-template-columns: 30px 1fr;
  gap: 10px;
  align-items: start;
}

.onboarding-points span {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 1px solid rgb(199 199 191 / 64%);
  border-radius: 50%;
  color: var(--moss);
  font-size: 0.78rem;
  font-weight: 800;
  background: rgb(255 255 255 / 58%);
}

.onboarding-points p {
  color: var(--ink);
  font-size: 0.88rem;
  line-height: 1.42;
}

.onboarding-note {
  padding: 12px;
  border: 1px solid rgb(168 95 53 / 24%);
  border-radius: 16px;
  background: rgb(255 247 234 / 62%);
}

.onboarding-progress {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: -2px;
}

.onboarding-progress span {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: rgb(80 99 84 / 22%);
}

.onboarding-progress span.is-active {
  width: 24px;
  background: var(--moss);
}

.onboarding-actions {
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
  gap: 10px;
}

.confirm-panel {
  grid-template-rows: auto auto auto;
  gap: 10px;
  padding: 20px;
}

.confirm-panel h2,
.confirm-panel p {
  text-align: center;
}

.confirm-panel > p:not(.kicker) {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.confirm-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 4px;
}

.guide-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 18px 12px;
  border-bottom: 1px solid rgb(199 199 191 / 52%);
}

.guide-content {
  display: grid;
  gap: 12px;
  overflow: auto;
  padding: 16px 18px 20px;
  color: var(--ink);
  font-size: 0.86rem;
  line-height: 1.55;
}

.guide-content ul,
.guide-content ol {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 20px;
}

.guide-content li::marker {
  color: var(--moss);
  font-weight: 700;
}

.hero {
  display: grid;
  place-items: center;
  min-height: 228px;
}

.orb {
  position: relative;
  display: grid;
  place-items: center;
  width: min(70vw, 270px);
  aspect-ratio: 1;
  border-radius: 50%;
}

.orb::before {
  position: absolute;
  inset: 16%;
  border-radius: inherit;
  content: "";
  background:
    radial-gradient(circle, rgb(255 255 255 / 92%) 0 38%, rgb(249 247 242 / 76%) 62%, transparent 72%);
  filter: blur(0.2px);
}

.orb.pulse::before {
  animation: segment-pulse 1.15s ease-out;
}

.progress-ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 0 18px rgb(183 204 185 / 42%));
  transform: rotate(-90deg);
}

.ring-track,
.ring-fill {
  fill: none;
}

.ring-track {
  stroke: var(--surface-high);
  stroke-width: 3;
}

.ring-fill {
  stroke: var(--moss);
  stroke-linecap: round;
  stroke-width: 4;
  stroke-dasharray: 603.19;
  stroke-dashoffset: 603.19;
  transition: stroke-dashoffset 0.5s ease;
}

.timer-copy {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  gap: 6px;
  width: 72%;
  text-align: center;
}

.timer-copy p {
  color: var(--moss);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.timer-copy strong {
  font-family: "Playfair Display", Georgia, serif;
  font-size: clamp(3rem, 14vw, 4rem);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  letter-spacing: 0;
}

.timer-copy span {
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--surface-mid);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.2;
}

.timer-copy em {
  color: var(--moss);
  font-size: 0.7rem;
  font-style: normal;
  font-weight: 800;
  letter-spacing: 0.02em;
  line-height: 1.15;
}

.timer-copy em.soon {
  color: #8b4d2d;
}

.controls {
  display: grid;
  gap: 12px;
  align-self: center;
  justify-items: center;
}

.secondary-actions {
  display: flex;
  justify-content: space-between;
  width: min(100%, 300px);
  padding: 0 12px;
}

.ghost-button,
.start-button {
  min-height: 48px;
  border-radius: 18px;
  font-weight: 700;
}

.ghost-button {
  min-width: 86px;
  background: transparent;
  color: var(--sage);
  font-size: 0.72rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.start-button {
  width: min(100%, 300px);
  background: var(--moss);
  color: #ffffff;
  box-shadow: 0 16px 36px rgb(32 31 30 / 10%);
}

.start-button:disabled {
  background: var(--surface-high);
  color: var(--muted);
  cursor: not-allowed;
  box-shadow: none;
}

.preview-onboarding-button {
  min-height: 28px;
  padding: 0 12px;
  border: 1px solid rgb(199 199 191 / 58%);
  border-radius: 999px;
  background: rgb(255 255 255 / 52%);
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  backdrop-filter: blur(18px);
}

.protocol-panel {
  display: grid;
  gap: 13px;
  padding: 17px;
  border-radius: 18px;
  background: rgb(246 243 242 / 82%);
  box-shadow: 0 8px 36px rgb(32 31 30 / 5%);
  backdrop-filter: blur(22px);
}

.daily-score {
  display: grid;
  place-items: center;
  width: 55px;
  height: 55px;
  border: 1px solid rgb(199 199 191 / 62%);
  border-radius: 16px;
  background: rgb(255 255 255 / 46%);
  color: var(--ink);
}

.daily-score span {
  font-size: 1.14rem;
  font-weight: 700;
  line-height: 1;
}

.daily-score small {
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.guidance {
  display: grid;
  gap: 11px;
  text-align: center;
}

.quiet-note {
  color: var(--muted);
  font-family: "Playfair Display", Georgia, serif;
  font-size: 0.95rem;
  font-style: italic;
}

.week-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  align-items: end;
  height: 58px;
  padding: 12px 10px 0;
  border-top: 1px solid rgb(199 199 191 / 62%);
}

.day-bar {
  display: grid;
  align-content: end;
  justify-items: center;
  gap: 5px;
  height: 100%;
  min-width: 0;
  padding: 0;
  background: transparent;
  color: inherit;
}

.bar-fill {
  width: 5px;
  min-height: 14px;
  border-radius: 999px;
  background: var(--outline);
  opacity: 0.72;
}

.day-bar.active .bar-fill {
  width: 7px;
  background: var(--moss);
  box-shadow: 0 0 10px rgb(183 204 185 / 76%);
  opacity: 1;
}

.day-bar.done .bar-fill {
  background: var(--moss-soft);
  opacity: 1;
}

.day-bar span {
  color: var(--sage);
  font-size: 0.58rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.day-bar.active span {
  color: var(--moss);
}

.day-bar.done span {
  color: var(--moss);
  opacity: 0.72;
}

.mini-time {
  color: var(--muted);
  font-size: 0.54rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.bottom-rail {
  padding: 11px 9px;
  border-top: 1px solid rgb(199 199 191 / 74%);
}

.rail-copy {
  min-width: 0;
  text-align: center;
}

.rail-copy span,
.rail-copy strong {
  display: block;
  overflow-wrap: anywhere;
}

.rail-copy span {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.rail-copy strong {
  margin-top: 2px;
  color: var(--ink);
  font-size: 0.94rem;
}

@media (max-width: 460px) {
  body {
    padding: 0;
    background: var(--surface);
  }

  .phone {
    grid-template-rows: auto auto auto 218px 68px auto auto;
    width: 100%;
    min-height: 100dvh;
    max-height: none;
    gap: 3px;
    overflow-y: auto;
    padding: 8px 20px max(12px, env(safe-area-inset-bottom));
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  h1 {
    font-size: 1.34rem;
  }

  h2 {
    font-size: 1rem;
  }

  .icon-button,
  .stepper,
  .topbar-spacer {
    width: 36px;
    height: 36px;
  }

  .summary {
    padding: 2px 0;
  }

  .summary div {
    min-width: 0;
    padding: 0 12px;
  }

  .summary strong {
    font-size: 0.96rem;
  }

  .hero {
    min-height: 218px;
  }

  .orb {
    width: min(60vw, 220px);
  }

  .timer-copy {
    gap: 5px;
    width: 74%;
  }

  .timer-copy strong {
    font-size: 2.75rem;
  }

  .timer-copy span {
    max-width: 100%;
    padding: 4px 10px;
    font-size: 0.68rem;
    line-height: 1.15;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .timer-copy em {
    max-width: 100%;
    font-size: 0.66rem;
    overflow-wrap: anywhere;
  }

  .safety-banner {
    padding: 6px 10px;
  }

  .safety-banner strong {
    font-size: 0.72rem;
  }

  .controls {
    gap: 0;
    align-self: center;
  }

  .ghost-button,
  .start-button {
    min-height: 44px;
    border-radius: 14px;
  }

  .onboarding-sheet {
    align-items: end;
    padding: 10px;
  }

  .onboarding-panel {
    gap: 12px;
    padding: 16px;
    max-height: 92dvh;
    border-radius: 22px;
  }

  .onboarding-visual {
    min-height: 112px;
    border-radius: 18px;
  }

  .onboarding-illustration {
    width: min(100%, 260px);
  }

  .onboarding-copy {
    gap: 9px;
  }

  .onboarding-slide {
    min-height: 178px;
  }

  .onboarding-copy h2 {
    max-width: none;
    font-size: 1.32rem;
  }

  .onboarding-slide > p:not(.kicker),
  .onboarding-note,
  .onboarding-points p {
    font-size: 0.8rem;
    line-height: 1.36;
  }

  .onboarding-points {
    gap: 7px;
    padding: 0;
  }

  .onboarding-points div {
    grid-template-columns: 26px 1fr;
    gap: 8px;
  }

  .onboarding-points span {
    width: 24px;
    height: 24px;
    font-size: 0.72rem;
  }

  .onboarding-note {
    padding: 10px;
  }

  .onboarding-actions {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .secondary-actions {
    padding: 0;
  }

  .protocol-panel {
    gap: 5px;
    padding: 8px 12px;
  }

  .daily-score {
    width: 42px;
    height: 42px;
  }

  .quiet-note {
    font-size: 0.78rem;
    line-height: 1.25;
  }

  .week-strip {
    height: 58px;
    padding: 8px 10px 0;
  }

  .day-bar {
    gap: 3px;
  }

  .bar-fill {
    max-height: 24px;
    min-height: 10px;
  }

  .day-bar.active .bar-fill {
    max-height: 28px;
  }

  .bottom-rail {
    margin-top: 2px;
    padding: 5px 7px 0;
  }
}

@media (max-height: 760px) {
  .phone {
    grid-template-rows: auto auto auto 206px 64px auto auto;
    gap: 3px;
    padding-top: 8px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }

  .hero {
    min-height: 206px;
  }

  .orb {
    width: min(56vw, 206px);
  }

  .timer-copy strong {
    font-size: 2.6rem;
  }

  .protocol-panel {
    gap: 5px;
    padding: 8px 12px;
  }

  .week-strip {
    height: 56px;
  }
}

@keyframes segment-pulse {
  0% {
    transform: scale(0.96);
    opacity: 0.72;
  }

  45% {
    transform: scale(1.06);
    opacity: 1;
  }

  100% {
    transform: scale(1);
    opacity: 1;
  }
}
