/* Glow: Day & Night.
   One idea carries the design: the sky follows the real time of day,
   and the orb is your progress (a sun ring by day, a waxing moon by night). */

:root {
  --font-display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --font-body: "Atkinson Hyperlegible", "Segoe UI", system-ui, sans-serif;

  /* Day */
  --ink: #2B2350;
  --ink-soft: #66598A;
  --line: rgba(43, 35, 80, 0.16);
  --accent: #F26B2A;
  --accent-ink: #FFFFFF;
  --sheet: #FDFBFF;
  --field: #F3EEF9;
  --main-bg: #2B2350;
  --main-ink: #FFF4EA;
  --soft-bg: rgba(255, 255, 255, 0.55);

  --radius-sheet: 28px;
  --radius-pill: 999px;
  --radius-photo: 18px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);

  color-scheme: light;
}

body[data-time="night"] {
  --ink: #ECEAFF;
  --ink-soft: #ABA8DB;
  --line: rgba(236, 234, 255, 0.18);
  --accent: #B9ADFF;
  --accent-ink: #191D55;
  --sheet: #1B2060;
  --field: #262C74;
  --main-bg: #F5EFD6;
  --main-ink: #191D55;
  --soft-bg: rgba(255, 255, 255, 0.08);
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.5;
  color: var(--ink);
  background: #FFE3C4;
  transition: color 0.8s ease;
}

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

button {
  cursor: pointer;
}

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---------- the sky ---------- */

.sky {
  position: fixed;
  inset: 0;
  z-index: -1;
  transition: opacity 1.2s ease;
}

.sky-day {
  background:
    radial-gradient(120% 60% at 50% 18%, rgba(255, 214, 150, 0.85), rgba(255, 214, 150, 0) 60%),
    linear-gradient(180deg, #FFC9A3 0%, #FFE3C4 38%, #DCEEF5 78%, #C4E3F1 100%);
}

.sky-night {
  opacity: 0;
  background:
    radial-gradient(90% 50% at 50% 16%, rgba(185, 173, 255, 0.22), rgba(185, 173, 255, 0) 65%),
    linear-gradient(180deg, #0E1340 0%, #1A1F5C 55%, #2B2870 100%);
}

body[data-time="night"] .sky-night {
  opacity: 1;
}

.stars {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.stars circle {
  fill: #F5EFD6;
}

/* ---------- layout ---------- */

.app {
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 22px calc(120px + env(safe-area-inset-bottom));
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
}

.greet {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 19px;
  color: var(--ink-soft);
}

.mode {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--soft-bg);
}

.mode svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
}

/* ---------- hero: the orb ---------- */

.hero {
  display: grid;
  justify-items: center;
  text-align: center;
  padding-top: 4px;
}

.orb-wrap {
  width: min(64vw, 248px);
  aspect-ratio: 1;
}

.orb {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.orb .ring {
  transition: stroke-dashoffset 1.1s var(--ease);
}

.orb .lit {
  transition: d 1.1s var(--ease);
}

.orb-wrap.celebrate .orb {
  animation: swell 1.4s var(--ease);
}

.orb-wrap.celebrate .halo {
  animation: bloom 1.4s var(--ease);
}

@keyframes swell {
  40% { transform: scale(1.06); }
}

@keyframes bloom {
  40% { opacity: 1; transform: scale(1.12); }
}

.orb .halo {
  transform-origin: center;
  transform-box: fill-box;
  opacity: 0.85;
}

.orb {
  transform-origin: center;
}

.day {
  margin: 2px 0 0;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(52px, 15vw, 68px);
  line-height: 0.95;
  letter-spacing: -0.03em;
  font-variation-settings: "opsz" 96;
}

.day small {
  font-size: 0.36em;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--ink-soft);
  margin-left: 0.18em;
}

.sub {
  margin: 10px 0 0;
  max-width: 32ch;
  color: var(--ink-soft);
  font-size: 16px;
}

/* ---------- routine ---------- */

.routine {
  margin-top: 30px;
}

.routine-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.routine-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 24px;
  letter-spacing: -0.01em;
}

.count {
  margin: 0;
  color: var(--ink-soft);
  font-size: 15px;
}

.steps {
  list-style: none;
  margin: 0;
  padding: 0;
}

.step {
  position: relative;
}

/* The routine is a sequence, so a line joins the steps in order. */
.step + .step::before {
  content: "";
  position: absolute;
  left: 21px;
  top: -14px;
  height: 28px;
  width: 2px;
  background: var(--line);
}

.step-btn {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  width: 100%;
  padding: 12px 4px;
  border: 0;
  background: none;
  text-align: left;
  border-radius: 16px;
}

.mark {
  flex: none;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid var(--line);
  background: var(--soft-bg);
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

.mark svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: var(--accent-ink);
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 24;
  stroke-dashoffset: 24;
  transition: stroke-dashoffset 0.35s var(--ease) 0.05s;
}

.step-btn[aria-pressed="true"] .mark {
  background: var(--accent);
  border-color: var(--accent);
}

.step-btn[aria-pressed="true"] .mark svg {
  stroke-dashoffset: 0;
}

.step-text {
  display: grid;
  gap: 2px;
  padding-top: 2px;
}

.step-title {
  font-weight: 700;
  font-size: 18px;
}

.step-btn[aria-pressed="true"] .step-title {
  text-decoration: line-through;
  text-decoration-thickness: 2px;
  text-decoration-color: var(--accent);
}

.step-detail {
  color: var(--ink-soft);
  font-size: 15px;
}

.new {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 9px;
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 13px;
  font-weight: 700;
  vertical-align: 2px;
}

.extra {
  margin-top: 6px;
}

.extra .mark {
  border-style: dashed;
  background: none;
}

.note {
  margin: 10px 0 0 60px;
  color: var(--ink-soft);
  font-size: 15px;
}

.done-line {
  margin: 14px 0 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
}

.start {
  display: grid;
  gap: 12px;
  padding: 20px;
  border-radius: 24px;
  background: var(--soft-bg);
  border: 1px solid var(--line);
}

.start h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 24px;
}

.start p {
  margin: 0;
  color: var(--ink-soft);
}

.foot {
  margin: 34px 0 0;
  text-align: center;
  color: var(--ink-soft);
  font-size: 15px;
}

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 52px;
  padding: 0 24px;
  border-radius: var(--radius-pill);
  border: 0;
  font-weight: 700;
  font-size: 17px;
  transition: transform 0.15s ease, opacity 0.2s ease;
}

.btn:active {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.btn svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linejoin: round;
}

.btn-main {
  background: var(--main-bg);
  color: var(--main-ink);
}

.btn-soft {
  background: var(--soft-bg);
  color: var(--ink);
  border: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.link {
  border: 0;
  background: none;
  padding: 4px 2px;
  color: inherit;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: center;
  gap: 12px;
  padding: 14px 22px calc(14px + env(safe-area-inset-bottom));
}

.dock .btn {
  flex: 1;
  max-width: 230px;
  box-shadow: 0 10px 30px -12px rgba(43, 35, 80, 0.45);
}

/* ---------- sheets ---------- */

.sheet {
  width: 100%;
  max-width: 560px;
  max-height: 90dvh;
  margin: auto auto 0;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sheet) var(--radius-sheet) 0 0;
  background: var(--sheet);
  color: var(--ink);
  overflow: hidden;
}

.sheet[open] {
  display: flex;
  flex-direction: column;
  animation: rise 0.38s var(--ease);
}

.sheet::backdrop {
  background: rgba(14, 19, 64, 0.5);
}

@keyframes rise {
  from { transform: translateY(40px); opacity: 0; }
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 22px 10px;
}

.sheet-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 24px;
  letter-spacing: -0.01em;
}

.close {
  border: 1px solid var(--line);
  background: none;
  border-radius: var(--radius-pill);
  padding: 8px 16px;
  font-weight: 700;
  font-size: 15px;
}

.sheet-body {
  padding: 6px 22px calc(24px + env(safe-area-inset-bottom));
  overflow-y: auto;
}

.sheet-body h3 {
  margin: 26px 0 8px;
  font-family: var(--font-display);
  font-size: 19px;
}

.sheet-body p {
  margin: 0 0 10px;
}

.muted {
  color: var(--ink-soft);
}

/* compare slider */

.compare {
  position: relative;
  aspect-ratio: 9 / 13;
  max-height: 52dvh;
  margin: 0 auto;
  border-radius: var(--radius-photo);
  overflow: hidden;
  background: var(--field);
  touch-action: pan-y;
}

.compare img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  user-select: none;
  -webkit-user-drag: none;
}

.compare .after {
  clip-path: inset(0 0 0 var(--pos, 50%));
}

.compare .divider {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--pos, 50%);
  width: 3px;
  margin-left: -1.5px;
  background: #FFFFFF;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}

.compare .divider::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 34px;
  height: 34px;
  margin: -17px 0 0 -17px;
  border-radius: 50%;
  background: #FFFFFF;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
}

.compare input[type="range"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: ew-resize;
}

.compare .tag {
  position: absolute;
  bottom: 12px;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  background: rgba(20, 18, 50, 0.62);
  color: #FFFFFF;
  font-size: 14px;
  font-weight: 700;
  pointer-events: none;
}

.compare .tag-before { left: 12px; }
.compare .tag-after { right: 12px; }

.compare-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

.compare-controls label,
.settings label {
  display: grid;
  gap: 4px;
  font-size: 15px;
  color: var(--ink-soft);
}

select,
input[type="date"],
input[type="text"],
textarea {
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--field);
  color: var(--ink);
}

.angles {
  display: flex;
  gap: 6px;
  margin-top: 12px;
  padding: 4px;
  border-radius: var(--radius-pill);
  background: var(--field);
}

.angles button {
  flex: 1;
  min-height: 40px;
  border: 0;
  border-radius: var(--radius-pill);
  background: none;
  font-weight: 700;
  font-size: 15px;
  color: var(--ink-soft);
}

.angles button[aria-pressed="true"] {
  background: var(--main-bg);
  color: var(--main-ink);
}

.angles button:disabled {
  opacity: 0.35;
  cursor: default;
}

/* notes */

.notes {
  padding: 16px 18px;
  border-radius: 18px;
  background: var(--field);
}

.notes p,
.bubble p {
  margin: 0 0 8px;
}

.notes ul,
.bubble ul {
  margin: 4px 0 10px;
  padding-left: 20px;
}

.notes li,
.bubble li {
  margin-bottom: 4px;
}

.notes > :last-child,
.bubble > :last-child {
  margin-bottom: 0;
}

.waiting {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--ink-soft);
}

.dot-pulse {
  flex: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
  50% { transform: scale(0.6); opacity: 0.5; }
}

/* photo picker */

.tiles {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.tile {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 3 / 4;
  border: 2px dashed var(--line);
  border-radius: var(--radius-photo);
  background: var(--field);
  overflow: hidden;
  font-weight: 700;
  font-size: 15px;
  color: var(--ink-soft);
  cursor: pointer;
}

.tile:focus-within {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

.tile input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.tile img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.tile.has-photo {
  border-style: solid;
  border-color: var(--accent);
}

.tile .tile-name {
  position: relative;
  z-index: 1;
  padding: 2px 10px;
  border-radius: var(--radius-pill);
}

.tile.has-photo .tile-name {
  align-self: end;
  margin-bottom: 8px;
  background: rgba(20, 18, 50, 0.62);
  color: #FFFFFF;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.single-photo {
  display: block;
  width: 100%;
  max-height: 52dvh;
  object-fit: cover;
  border-radius: var(--radius-photo);
}

/* chat */

.ask-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 80px;
}

.bubble {
  max-width: 88%;
  padding: 12px 16px;
  border-radius: 20px;
  background: var(--field);
}

.bubble.user {
  align-self: flex-end;
  background: var(--main-bg);
  color: var(--main-ink);
  border-bottom-right-radius: 6px;
}

.bubble.coach {
  align-self: flex-start;
  border-bottom-left-radius: 6px;
}

.bubble.error {
  border: 1px solid var(--accent);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chips button {
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: none;
  font-size: 15px;
  text-align: left;
}

.ask-form {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

.ask-form textarea {
  resize: none;
  max-height: 140px;
  border-radius: 24px;
  padding: 13px 18px;
}

.fineprint {
  color: var(--ink-soft);
  font-size: 14px;
}

.settings {
  display: grid;
  gap: 16px;
}

.optional {
  font-size: 14px;
}

.sheet-small {
  max-width: 480px;
}

/* toast */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(92px + env(safe-area-inset-bottom));
  max-width: calc(100% - 44px);
  padding: 12px 18px;
  border-radius: 16px;
  background: var(--main-bg);
  color: var(--main-ink);
  font-size: 15px;
  font-weight: 700;
  transform: translate(-50%, 20px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------- login ---------- */

.login {
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: 24px;
}

.login-card {
  display: grid;
  gap: 14px;
  width: 100%;
  max-width: 360px;
  text-align: center;
}

.login-card .orb-wrap {
  width: 120px;
  margin: 0 auto;
}

.login-card h1 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 48px;
  letter-spacing: -0.03em;
}

.login-card p {
  margin: 0;
  color: var(--ink-soft);
}

.login-card input {
  text-align: center;
  font-size: 18px;
}

.error {
  min-height: 1.5em;
  color: var(--ink);
  font-weight: 700;
}

@media (min-width: 720px) {
  .sheet {
    margin: auto;
    border-radius: var(--radius-sheet);
  }
}

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