:root {
  color-scheme: light;
  --paper: #fbf7ec;
  --paper-deep: #f2ecdc;
  --card: #ffffff;
  --ink: #361d18;
  --muted: #8a7c76;
  --line: #e6dfd2;
  --ember: #ff4b24;
  --ember-dark: #dc2f28;
  --amber: #ffad38;
  --blue: #1b72d8;
  --shadow: 0 18px 50px rgba(74, 42, 28, .09);
  --ring-size: min(78vw, 390px);
  font-family: Inter, ui-rounded, "SF Pro Rounded", "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--paper); }

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 50% -10%, rgba(255, 192, 83, .16), transparent 30rem),
    var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

button, input { font: inherit; }
button { color: inherit; }

button:focus-visible, input:focus-visible, a:focus-visible {
  outline: 3px solid rgba(27, 114, 216, .32);
  outline-offset: 3px;
}

.app-shell {
  width: min(100%, 560px);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 20px calc(112px + env(safe-area-inset-bottom));
  position: relative;
}

.app-header {
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--ink);
  text-decoration: none;
  font-size: 1.35rem;
  font-weight: 850;
  letter-spacing: -.04em;
}

.brand-mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  background: linear-gradient(145deg, var(--amber), var(--ember));
  box-shadow: 0 8px 18px rgba(255, 75, 36, .22);
}

.brand-mark svg, .app-icon-large svg { width: 22px; fill: white; }
.header-actions { display: flex; align-items: center; gap: 8px; }

.streak {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(255,255,255,.7);
  border: 1px solid rgba(93, 61, 48, .08);
  color: #6f5e57;
  font-size: .79rem;
  font-weight: 750;
}

.streak span { color: var(--ember); }

.icon-button, .sheet-close {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: rgba(255,255,255,.82);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.icon-button svg { width: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }

.view { display: none; animation: view-in .28s ease both; }
.view.active { display: block; }
@keyframes view-in { from { opacity: 0; transform: translateY(6px); } }

.hero-copy { text-align: center; margin: 8px auto 16px; }
.eyebrow {
  margin: 0 0 5px;
  color: var(--ember-dark);
  font-size: .76rem;
  font-weight: 850;
  letter-spacing: .12em;
  text-transform: uppercase;
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 6px; font-size: clamp(1.75rem, 7vw, 2.35rem); line-height: 1.08; letter-spacing: -.045em; }
h2 { margin-bottom: 0; font-size: 1.35rem; letter-spacing: -.03em; }
.hero-note, .page-heading p { color: var(--muted); font-size: .97rem; line-height: 1.5; }
.hero-note { margin-bottom: 0; }

.quick-settings { display: flex; justify-content: center; gap: 10px; margin: 18px 0 12px; }
.setting-chip {
  min-height: 43px;
  padding: 0 15px;
  border: 1px solid rgba(79, 55, 43, .06);
  border-radius: 14px;
  background: rgba(239, 233, 220, .8);
  font-weight: 850;
  cursor: pointer;
  display: inline-flex;
  gap: 8px;
  align-items: center;
}
.setting-chip svg { width: 16px; fill: none; stroke: #a5978e; stroke-width: 2; }

.timer-wrap {
  width: var(--ring-size);
  height: var(--ring-size);
  max-width: 430px;
  max-height: 430px;
  margin: 10px auto 18px;
  position: relative;
  display: grid;
  place-items: center;
  filter: drop-shadow(0 18px 30px rgba(83, 56, 39, .06));
}

.timer-ring { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.timer-track, .timer-progress { fill: none; stroke-width: 13; }
.timer-track { stroke: #e7e1d6; }
.timer-progress {
  stroke: url(#ringGradient);
  stroke-linecap: round;
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
  transition: stroke-dashoffset .8s ease;
}
.timer-wrap:not(.running) .timer-progress { opacity: .2; stroke-dashoffset: 4; }
.timer-wrap::before {
  content: "";
  position: absolute;
  inset: 22px;
  border-radius: 50%;
  background: rgba(255,255,255,.94);
  box-shadow: inset 0 0 0 1px rgba(99, 73, 57, .04);
}
.timer-center { position: relative; z-index: 2; width: 68%; text-align: center; display: grid; gap: 8px; }
.timer-status { color: var(--muted); font-size: .92rem; }
.timer-value { font-size: clamp(2.1rem, 10vw, 3.5rem); line-height: 1; letter-spacing: -.05em; font-variant-numeric: tabular-nums; }
.timer-caption { color: #6f5d55; font-size: .86rem; font-weight: 700; }
.timer-orbit {
  position: absolute;
  inset: 0;
  transform: rotate(0deg);
  transition: transform .8s ease;
  z-index: 3;
}
.orbit-mark {
  position: absolute;
  width: 42px;
  height: 42px;
  left: calc(50% - 21px);
  top: -1px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--amber), var(--ember));
  border: 5px solid var(--paper);
  box-shadow: 0 8px 20px rgba(255, 75, 36, .24);
}
.orbit-mark svg { width: 20px; fill: white; transform: rotate(0deg); }

.time-summary { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; text-align: center; margin: -4px 0 18px; }
.time-summary div { display: grid; gap: 4px; }
.time-summary div + div { border-left: 1px solid var(--line); }
.time-summary span { color: var(--muted); font-size: .74rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.time-summary strong { font-size: .95rem; }

.primary-button, .secondary-button {
  border: 0;
  border-radius: 18px;
  min-height: 58px;
  padding: 0 24px;
  font-weight: 850;
  cursor: pointer;
}
.primary-button {
  width: 100%;
  color: white;
  background: linear-gradient(115deg, #ff681e, #ff3f20 58%, #d72e2a);
  box-shadow: 0 13px 28px rgba(231, 60, 33, .2);
  font-size: 1.04rem;
}
.primary-button:active { transform: translateY(1px); }
.secondary-button { min-height: 46px; background: #f3ede2; }
.full-width { width: 100%; }

.water-section { margin-top: 30px; }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 12px; }
.section-heading.compact { align-items: center; }
.text-button, .inline-link { border: 0; background: transparent; color: var(--ember-dark); font-size: .82rem; font-weight: 800; cursor: pointer; padding: 6px 0; }
.water-card, .content-card, .plan-card, .install-card {
  border-radius: 24px;
  background: rgba(255,255,255,.92);
  box-shadow: var(--shadow);
  border: 1px solid rgba(86, 57, 43, .05);
}
.water-card { min-height: 150px; padding: 22px; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 16px; }
.water-copy { display: grid; gap: 7px; }
.water-copy span, .water-copy small { color: var(--muted); }
.water-copy strong { color: var(--blue); font-size: 2rem; letter-spacing: -.05em; }
.water-controls { display: flex; align-items: center; gap: 8px; }
.round-action { width: 39px; height: 39px; display: grid; place-items: center; border-radius: 50%; border: 2px solid var(--blue); background: white; color: var(--blue); cursor: pointer; }
.round-action svg { width: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.water-gauge { width: 78px; height: 78px; position: relative; display: grid; place-items: center; }
.water-gauge > svg:first-child { position: absolute; inset: 0; transform: rotate(-90deg); }
.gauge-track, .gauge-progress { fill: none; stroke-width: 6; }
.gauge-track { stroke: #ded8ce; }
.gauge-progress { stroke: var(--blue); stroke-linecap: round; stroke-dasharray: 100; stroke-dashoffset: 100; transition: stroke-dashoffset .35s ease; }
.bottle { width: 28px; fill: none; stroke: #b0a59d; stroke-width: 1.8; }

.page-heading { margin: 26px 0 22px; }
.page-heading h1 { margin-bottom: 8px; }
.page-heading p { max-width: 34rem; }
.plan-card, .content-card { padding: 22px; margin-bottom: 16px; }
.accent-card { background: linear-gradient(145deg, #ffe2aa, #ffd0a1 50%, #ffb896); }
.card-kicker { display: block; color: #79584b; font-size: .72rem; font-weight: 850; letter-spacing: .09em; text-transform: uppercase; }
.plan-main { display: flex; align-items: baseline; gap: 13px; margin: 12px 0 20px; }
.plan-main strong { font-size: 3.25rem; letter-spacing: -.07em; }
.plan-main span { max-width: 150px; color: #684b42; line-height: 1.35; }
.weekday-picker { display: grid; grid-template-columns: repeat(7, 1fr); gap: 7px; margin-top: 18px; }
.weekday-picker button { aspect-ratio: 1; border-radius: 50%; border: 1px solid var(--line); background: #f8f4eb; font-weight: 800; cursor: pointer; }
.weekday-picker button.active { color: white; background: var(--ink); border-color: var(--ink); }
.schedule-card { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; text-align: center; gap: 8px; }
.schedule-card div { display: grid; gap: 5px; }
.schedule-card strong { font-size: 1.55rem; }
.schedule-card small { color: var(--muted); }
.schedule-arrow { color: var(--ember); font-size: 1.5rem; }

.history-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; margin-bottom: 20px; }
.mini-stat { min-height: 100px; padding: 15px 12px; background: white; border-radius: 19px; box-shadow: 0 10px 30px rgba(74,42,28,.06); display: grid; align-content: center; gap: 8px; }
.mini-stat span { color: var(--muted); font-size: .72rem; line-height: 1.2; }
.mini-stat strong { font-size: 1.45rem; }
.history-list { display: grid; gap: 11px; }
.history-item { padding: 17px; border-radius: 19px; background: white; display: grid; grid-template-columns: auto 1fr auto; gap: 13px; align-items: center; border: 1px solid rgba(86,57,43,.05); }
.history-icon { width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center; background: #fff0da; color: var(--ember-dark); font-weight: 900; }
.history-copy { display: grid; gap: 4px; }
.history-copy strong { font-size: .95rem; }
.history-copy span, .history-item > span { color: var(--muted); font-size: .8rem; }
.empty-state { padding: 45px 26px; border: 1px dashed #d6ccbc; border-radius: 24px; text-align: center; color: var(--muted); }
.empty-state strong { display: block; color: var(--ink); margin-bottom: 7px; }

.install-card { padding: 18px; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 13px; }
.app-icon-large { width: 58px; height: 58px; border-radius: 18px; background: linear-gradient(145deg, var(--amber), var(--ember)); display: grid; place-items: center; }
.install-card > div:nth-child(2) { display: grid; gap: 4px; }
.install-card span { color: var(--muted); font-size: .82rem; }
.preferences-card { margin-top: 17px; padding: 0; overflow: hidden; }
.preferences-card button { width: 100%; min-height: 62px; padding: 0 18px; display: flex; align-items: center; justify-content: space-between; border: 0; background: white; cursor: pointer; text-align: left; }
.preferences-card button + button { border-top: 1px solid var(--line); }
.preferences-card b { font-size: 1.5rem; color: var(--muted); }
.preferences-card .danger-row { color: #b32d2d; }
.privacy-note { margin: 19px 8px; color: var(--muted); font-size: .83rem; line-height: 1.5; }

.bottom-nav {
  position: fixed;
  z-index: 20;
  left: 50%;
  bottom: max(12px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(calc(100% - 28px), 526px);
  height: 76px;
  padding: 8px 7px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border: 1px solid rgba(82, 56, 43, .08);
  border-radius: 27px;
  background: rgba(255,255,255,.91);
  box-shadow: 0 18px 48px rgba(66, 38, 26, .16);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}
.nav-item { border: 0; background: transparent; border-radius: 20px; display: grid; place-items: center; align-content: center; gap: 4px; color: #81736c; cursor: pointer; font-size: .7rem; font-weight: 780; }
.nav-item svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.nav-item:first-child svg { fill: currentColor; stroke: none; }
.nav-item.active { color: var(--ember); background: #fff2e9; }

.sheet-backdrop { position: fixed; z-index: 50; inset: 0; background: rgba(34, 28, 27, .42); backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px); }
.bottom-sheet {
  position: fixed;
  z-index: 51;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(100%, 580px);
  max-height: 92vh;
  overflow-y: auto;
  padding: 12px 24px calc(24px + env(safe-area-inset-bottom));
  border-radius: 28px 28px 0 0;
  background: var(--paper);
  box-shadow: 0 -20px 60px rgba(33, 23, 18, .2);
  animation: sheet-up .28s cubic-bezier(.22,.8,.35,1) both;
}
@keyframes sheet-up { from { transform: translate(-50%, 30px); opacity: 0; } }
.sheet-handle { width: 46px; height: 5px; margin: 0 auto 14px; border-radius: 99px; background: #cfc6bb; }
.sheet-header { display: grid; grid-template-columns: 42px 1fr 42px; align-items: center; text-align: center; margin-bottom: 20px; }
.sheet-header h2 { font-size: 1.35rem; }
.sheet-close { font-size: 1.7rem; line-height: 1; }
.form-group { padding: 17px 0; border-top: 1px solid var(--line); }
.form-group label { display: block; margin-bottom: 11px; font-weight: 800; }
.protocol-options { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.protocol-options button { min-height: 46px; border-radius: 14px; border: 1px solid var(--line); background: white; font-weight: 850; cursor: pointer; }
.protocol-options button.active { color: white; background: var(--ink); border-color: var(--ink); }
input[type="datetime-local"], .input-suffix { width: 100%; min-height: 54px; border: 1px solid var(--line); border-radius: 15px; background: white; color: var(--ink); }
input[type="datetime-local"] { padding: 0 14px; }
.input-suffix { display: flex; align-items: center; padding: 0 15px; }
.input-suffix input { min-width: 0; flex: 1; border: 0; outline: 0; font-weight: 800; }
.input-suffix span { color: var(--muted); }
.sheet-save { margin-top: 10px; }
.compact-sheet { text-align: center; padding-top: 14px; }
.compact-sheet h2 { margin: 8px 0; }
.compact-sheet p { color: var(--muted); line-height: 1.5; }
.compact-sheet .primary-button { margin: 16px 0 9px; }
.confirm-icon { width: 60px; height: 60px; margin: 6px auto 15px; display: grid; place-items: center; border-radius: 50%; background: #ffe3bc; color: var(--ember-dark); font-size: 1.7rem; font-weight: 900; }
.install-steps { margin: 24px 0; padding-left: 24px; text-align: left; color: #675953; line-height: 1.6; }
.install-steps li + li { margin-top: 10px; }

.toast {
  position: fixed;
  z-index: 80;
  left: 50%;
  bottom: calc(102px + env(safe-area-inset-bottom));
  transform: translate(-50%, 18px);
  width: max-content;
  max-width: calc(100% - 40px);
  padding: 12px 17px;
  border-radius: 999px;
  color: white;
  background: #34231f;
  font-size: .82rem;
  font-weight: 750;
  opacity: 0;
  pointer-events: none;
  transition: .25s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

[hidden] { display: none !important; }

@media (min-width: 760px) {
  body { padding: 28px 0; }
  .app-shell { min-height: calc(100vh - 56px); border-radius: 38px; box-shadow: 0 30px 90px rgba(67, 43, 29, .14); background: rgba(251,247,236,.82); }
  .bottom-nav { bottom: 32px; }
  .timer-wrap { --ring-size: 350px; }
}

@media (max-width: 390px) {
  .app-shell { padding-left: 16px; padding-right: 16px; }
  .streak { display: none; }
  .water-card { padding: 18px 15px; }
  .water-controls { gap: 5px; }
  .round-action { width: 36px; height: 36px; }
  .water-gauge { width: 69px; height: 69px; }
  .quick-settings { gap: 7px; }
  .setting-chip { padding: 0 11px; font-size: .86rem; }
  .install-card { grid-template-columns: auto 1fr; }
  .install-card .secondary-button { grid-column: 1 / -1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
