:root {
  --bg: #fff7f2;
  --surface: #ffffff;
  --ink: #2f2740;
  --muted: #827a90;
  --line: #f1e3dc;
  --rose: #e2688d;
  --rose-deep: #cf5079;
  --rose-soft: #fde7ee;
  --apricot: #f7b79a;
  --apricot-soft: #feeee4;
  --mint: #5fb596;
  --mint-soft: #e3f4ec;
  --lilac-soft: #eee9fb;
  --lilac: #8d7bd0;
  --hero-from: #fbd9cf;
  --hero-to: #fbe3ea;
  --danger: #c93f4f;
  --shadow: 0 10px 30px rgba(190, 120, 110, .14);
  --radius: 22px;
  --radius-sm: 14px;
  --gutter: 18px;
  --tabbar: 66px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1d1826;
    --surface: #282133;
    --ink: #f4eef7;
    --muted: #a99fb8;
    --line: #382f46;
    --rose: #ef86a6;
    --rose-deep: #e2688d;
    --rose-soft: #3d2634;
    --apricot: #f7b79a;
    --apricot-soft: #3d2d2a;
    --mint: #7fd0b2;
    --mint-soft: #22382f;
    --lilac-soft: #2f2a45;
    --lilac: #b0a2ea;
    --hero-from: #3a2533;
    --hero-to: #2a2136;
    --danger: #ff8b97;
    --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  }
}

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

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

body {
  margin: 0;
  min-height: calc(100dvh + env(safe-area-inset-top, 0px));
  background: var(--bg);
  color: var(--ink);
  font-family: ui-rounded, "SF Pro Rounded", "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, p, ol, fieldset { margin: 0; padding: 0; }
ol { list-style: none; }
fieldset { border: 0; min-width: 0; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }

.page {
  position: relative;
  max-width: 520px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top, 0px) + 22px) var(--gutter) 28px;
}

.page::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 230px;
  background: linear-gradient(160deg, var(--hero-from), var(--hero-to));
  border-radius: 0 0 36px 36px;
  z-index: -1;
}

.page.with-tabbar { padding-bottom: calc(var(--tabbar) + env(safe-area-inset-bottom, 0px) + 28px); }

.icon { width: 22px; height: 22px; flex: none; }

.hero { padding: 6px 4px 20px; }
.hero-hello { color: var(--muted); font-size: 15px; }
.hero-name { font-size: 28px; line-height: 1.15; font-weight: 800; letter-spacing: -.01em; overflow-wrap: anywhere; }
.hero-small .hero-name { font-size: 25px; }

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}

.label { color: var(--muted); font-size: 13px; }
.value { font-size: 16px; font-weight: 700; }
.muted { color: var(--muted); font-size: 14px; }
.center { text-align: center; }

.main-top { display: flex; align-items: flex-start; gap: 12px; }
.main-facts { flex: 1; min-width: 0; }
.main-age { font-size: 27px; font-weight: 800; line-height: 1.2; margin: 2px 0 14px; }
.main-row { display: flex; flex-wrap: wrap; gap: 10px 22px; }
.main-art { width: 104px; height: 104px; flex: none; background: var(--rose-soft); border-radius: 50%; }

.term {
  display: block;
  width: 100%;
  height: 10px;
  margin-top: 20px;
  border: 0;
  border-radius: 999px;
  overflow: hidden;
  background: var(--line);
  appearance: none;
  -webkit-appearance: none;
}
.term::-webkit-progress-bar { background: var(--line); border-radius: 999px; }
.term::-webkit-progress-value { background: linear-gradient(90deg, var(--apricot), var(--rose)); border-radius: 999px; }
.term::-moz-progress-bar { background: linear-gradient(90deg, var(--apricot), var(--rose)); border-radius: 999px; }

.trimesters { display: grid; grid-template-columns: repeat(3, 1fr); margin-top: 8px; }
.trimesters li { text-align: center; font-size: 12px; color: var(--muted); }
.trimesters li.now { color: var(--rose-deep); font-weight: 700; }

.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { border-radius: var(--radius); padding: 16px; }
.tile-icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  margin-bottom: 12px;
  border-radius: 50%;
  background: var(--surface);
}
.tile-value { font-size: 19px; font-weight: 800; line-height: 1.2; }
.tile-label { font-size: 13px; color: var(--muted); margin-top: 2px; }
.tile-rose { background: var(--rose-soft); }
.tile-rose .tile-icon { color: var(--rose-deep); }
.tile-mint { background: var(--mint-soft); }
.tile-mint .tile-icon { color: var(--mint); }
.tile-apricot { background: var(--apricot-soft); }
.tile-apricot .tile-icon { color: #d98558; }
.tile-lilac { background: var(--lilac-soft); }
.tile-lilac .tile-icon { color: var(--lilac); }

.note-card { border-left: 5px solid var(--mint); font-size: 15px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 20px;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: transform .12s ease, opacity .12s ease;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .55; cursor: default; }
.btn:focus-visible, .tab:focus-visible, input:focus-visible { outline: 3px solid var(--apricot); outline-offset: 2px; }
.btn-primary { border-color: transparent; background: linear-gradient(135deg, var(--apricot), var(--rose)); color: #fff; }
.btn-block { display: flex; width: 100%; }
.btn-lg { min-height: 54px; font-size: 17px; }
.btn-quiet { background: transparent; color: var(--muted); margin-bottom: 14px; }

.field { display: block; margin-bottom: 16px; }
.field > span, .segmented legend { display: block; margin-bottom: 6px; font-size: 14px; font-weight: 700; }
.field input {
  width: 100%;
  min-height: 50px;
  padding: 0 14px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--ink);
  font: inherit;
}
.field input.invalid { border-color: var(--danger); }
.hint { display: block; margin-top: 6px; color: var(--muted); font-size: 13px; }
.form-intro { color: var(--muted); font-size: 15px; margin-bottom: 18px; }
.form-error { color: var(--danger); font-size: 14px; margin-bottom: 14px; }

.segmented { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 16px; }
.segmented legend { grid-column: 1 / -1; }
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; inset: 0; }
.segmented span {
  display: grid;
  place-items: center;
  min-height: 48px;
  padding: 6px 8px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  text-align: center;
  font-size: 14px;
  font-weight: 700;
  color: var(--muted);
}
.segmented input:checked + span { border-color: var(--rose); background: var(--rose-soft); color: var(--rose-deep); }
.segmented input:focus-visible + span { outline: 3px solid var(--apricot); outline-offset: 2px; }

.summary-card { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 6px 14px; }
.disclaimer { text-align: center; color: var(--muted); font-size: 13px; padding: 0 10px; }

.login-wrap { min-height: calc(100dvh - 60px); display: flex; flex-direction: column; justify-content: center; gap: 22px; }
.login-brand { text-align: center; }
.login-art { width: 168px; height: 168px; margin: 0 auto 10px; }
.login-brand h1 { font-size: 34px; font-weight: 800; }
.login-brand p { color: var(--muted); max-width: 300px; margin: 6px auto 0; }
.login-card > * + * { margin-top: 14px; }
.login-note { font-size: 13px; }
.link { color: var(--rose-deep); font-size: 14px; }

.tg-wait { display: flex; gap: 12px; align-items: flex-start; padding: 14px; border-radius: var(--radius-sm); background: var(--mint-soft); }
.spinner {
  width: 22px;
  height: 22px;
  flex: none;
  margin-top: 2px;
  border: 3px solid var(--surface);
  border-top-color: var(--mint);
  border-radius: 50%;
  animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.center-card { text-align: center; margin-top: 60px; }
.center-card > * + * { margin-top: 12px; }

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 8px var(--gutter) calc(8px + env(safe-area-inset-bottom, 0px));
  background: var(--surface);
  border-top: 1px solid var(--line);
  z-index: 10;
}
.tab {
  flex: 1;
  max-width: 180px;
  min-height: 50px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}
.tab.active { color: var(--rose-deep); background: var(--rose-soft); }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar) + env(safe-area-inset-bottom, 0px) + 18px);
  transform: translate(-50%, 20px);
  max-width: calc(100% - 36px);
  padding: 12px 18px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  font-size: 14px;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  z-index: 20;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.net-status {
  position: fixed;
  top: env(safe-area-inset-top, 0px);
  left: 0;
  right: 0;
  padding: 6px 12px;
  background: var(--ink);
  color: var(--bg);
  text-align: center;
  font-size: 13px;
  z-index: 20;
}

@media (prefers-reduced-motion: reduce) {
  .btn, .toast { transition: none; }
  .spinner { animation-duration: 2.5s; }
}

.main-art { width: 112px; height: 112px; background: none; }

.fruit-card { display: flex; align-items: center; gap: 14px; color: inherit; text-decoration: none; background: var(--mint-soft); }
.fruit-art { width: 120px; height: 120px; flex: none; background: var(--surface); border-radius: 50%; }
.fruit-text { min-width: 0; }
.fruit-line { font-size: 19px; font-weight: 800; line-height: 1.25; margin: 6px 0 2px; }
.chip { display: inline-block; padding: 3px 10px; border-radius: 999px; background: var(--surface); color: var(--mint); font-size: 12px; font-weight: 700; }
.more { margin-top: 8px; color: var(--rose-deep); font-size: 14px; font-weight: 700; }

.text-card h2, .look-card h2 { display: flex; align-items: center; gap: 8px; font-size: 17px; font-weight: 800; margin-bottom: 8px; }
.text-card p, .look-card p { font-size: 15px; }
.tone-rose h2 .icon { color: var(--rose-deep); }
.tone-mint { background: var(--mint-soft); box-shadow: none; }
.tone-mint h2 .icon { color: var(--mint); }
.tone-apricot { background: var(--apricot-soft); box-shadow: none; }
.tone-apricot h2 .icon { color: #d98558; }
.note-card .label { margin-bottom: 4px; font-weight: 700; color: var(--mint); }

.weekbar {
  display: flex;
  gap: 8px;
  margin: 0 calc(var(--gutter) * -1) 16px;
  padding: 4px var(--gutter) 8px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.weekbar::-webkit-scrollbar { display: none; }
.weekbar a {
  flex: none;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--surface);
  color: var(--muted);
  font-weight: 700;
  text-decoration: none;
  border: 2px solid transparent;
}
.weekbar a.mine { border-color: var(--apricot); color: var(--ink); }
.weekbar a.on { background: linear-gradient(135deg, var(--apricot), var(--rose)); color: #fff; border-color: transparent; }

.fruit-hero { text-align: center; }
.fruit-big { width: 180px; height: 180px; margin: 0 auto 6px; background: var(--mint-soft); border-radius: 50%; }
.fruit-hero .fruit-line { font-size: 22px; margin-bottom: 14px; }
.sizes { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin: 0 0 10px; }
.sizes div { padding: 12px 8px; border-radius: var(--radius-sm); background: var(--bg); }
.sizes dt { color: var(--muted); font-size: 12px; }
.sizes dd { margin: 2px 0 0; font-size: 19px; font-weight: 800; }

.look-card { display: flex; align-items: center; gap: 14px; }
.look-card img { width: 132px; height: 132px; flex: none; }
@media (max-width: 360px) {
  .look-card, .fruit-card { flex-direction: column; text-align: center; }
}

.pager { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 14px; }

.fruit-hero .btn { margin-top: 14px; }
.sheet {
  width: min(440px, calc(100% - 24px));
  max-height: calc(100dvh - 24px);
  padding: 20px;
  border: 0;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  overflow-y: auto;
}
.sheet::backdrop { background: rgba(47, 39, 64, .55); }
.sheet h2 { text-align: center; font-size: 20px; font-weight: 800; }
.share-canvas { display: block; width: min(100%, 250px); height: auto; margin: 14px auto; border-radius: 18px; box-shadow: var(--shadow); }
.themes { display: flex; justify-content: center; gap: 14px; margin-bottom: 16px; }
.theme { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--surface); box-shadow: 0 0 0 2px var(--line); cursor: pointer; }
.theme.on { box-shadow: 0 0 0 3px var(--rose); }
.theme-mint { background: #cfeadb; }
.theme-rose { background: #f8c9d6; }
.theme-night { background: #2f2740; }
.share-actions > * + * { margin-top: 10px; }
