:root {
  --eazo-safe-area-top: max(56px, env(safe-area-inset-top, 0px));
  --eazo-safe-area-bottom: max(34px, env(safe-area-inset-bottom, 0px));
  --paper: #f3f2ed;
  --ground: #d8d8d8;
  --ink: #1a1a1a;
  --muted: rgba(26, 26, 26, .56);
  --line: rgba(26, 26, 26, .18);
  --blue: #004890;
  --shadow: 0 18px 50px rgba(26, 26, 26, .08);
  --sky-a: #f3b6c4;
  --sky-b: #f6ddc9;
  --sky-c: #dbe9f3;
  color-scheme: light;
  font-family: "Inter", "Helvetica Neue", Arial, "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--ground); color: var(--ink); }
body { overflow-x: hidden; }
button { font: inherit; color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
img { display: block; }

.app {
  min-height: 100svh;
  padding-top: var(--eazo-safe-area-top);
  padding-bottom: var(--eazo-safe-area-bottom);
  background:
    radial-gradient(circle at 14% 10%, rgba(0, 72, 144, .08), transparent 24rem),
    linear-gradient(180deg, #f8f7f2 0%, #e1e0dc 100%);
}

.shell {
  width: min(100%, 470px);
  margin: 0 auto;
  padding: 10px 16px 16px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* ---------- Top bar ---------- */
.topbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.portrait {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--line);
  background: #ded9d0;
  flex: 0 0 auto;
}
.brand { min-width: 0; }
.kicker {
  font-size: 10px;
  line-height: 1.1;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
h1 {
  margin: 2px 0 0;
  font-size: clamp(18px, 5.2vw, 24px);
  line-height: 1;
  letter-spacing: -.05em;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lang {
  min-height: 40px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .5);
  border-radius: 999px;
  padding: 3px;
  display: inline-flex;
  gap: 2px;
  flex: 0 0 auto;
  align-items: center;
}
.lang .seg {
  min-width: 40px;
  min-height: 34px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  font-size: 12px;
  letter-spacing: -.02em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 8px;
}
.lang .seg.active { background: var(--ink); color: #fff; }

/* ---------- Sky panel ---------- */
.sky-panel {
  border: 1px solid rgba(26, 26, 26, .2);
  background: var(--paper);
  box-shadow: var(--shadow);
}
.sky {
  height: 68px;
  position: relative;
  overflow: hidden;
  border-bottom: 1px solid rgba(26, 26, 26, .2);
  background: linear-gradient(120deg, var(--sky-a), var(--sky-b) 54%, var(--sky-c));
  transition: background 650ms ease;
}
.sky::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0;
  background-image: radial-gradient(circle, rgba(255, 255, 255, .9) 0 1px, transparent 1.6px);
  background-size: 20px 18px;
  transition: opacity 650ms ease;
}
.sky.night::before { opacity: .5; }
.orb {
  position: absolute;
  top: 22px;
  left: calc(var(--progress, 4) * 1%);
  transform: translate(-50%, -50%);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff7ca;
  border: 1px solid rgba(26, 26, 26, .22);
  box-shadow: 0 0 26px rgba(255, 247, 202, .75);
  transition: left 650ms ease, background 650ms ease, box-shadow 650ms ease;
}
.sky.night .orb { background: #d6e6ff; box-shadow: 0 0 20px rgba(214, 230, 255, .5); }
.weather-pill {
  position: absolute;
  right: 10px;
  bottom: 8px;
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid rgba(26, 26, 26, .22);
  background: rgba(255, 255, 255, .5);
  backdrop-filter: blur(8px);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  letter-spacing: -.02em;
}
.weather-pill .wx-icon { font-size: 13px; line-height: 1; }

.timeline {
  height: 30px;
  padding: 0 10px;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  align-items: center;
  gap: 4px;
  border-bottom: 1px solid rgba(26, 26, 26, .14);
  background: rgba(255, 255, 255, .38);
}
.tick {
  min-width: 0;
  font-size: 9.5px;
  color: rgba(26, 26, 26, .42);
  text-align: center;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}
.tick::before {
  content: "";
  display: block;
  width: 3px;
  height: 3px;
  margin: 0 auto 2px;
  border-radius: 50%;
  background: rgba(26, 26, 26, .22);
}
.tick.done, .tick.active { color: var(--ink); }
.tick.done::before { background: var(--blue); }
.tick.active::before { width: 7px; border-radius: 0; background: var(--ink); }

.meters {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.meter {
  min-width: 0;
  padding: 8px 10px 9px;
  border-right: 1px solid rgba(26, 26, 26, .14);
}
.meter:last-child { border-right: 0; }
.meter-head {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  align-items: baseline;
  font-size: 11px;
  letter-spacing: -.02em;
  line-height: 1.1;
  margin-bottom: 6px;
}
.meter-head b { font-weight: 500; }
.meter-head span { color: var(--muted); font-variant-numeric: tabular-nums; }
.bar { height: 3px; background: rgba(26, 26, 26, .12); overflow: hidden; }
.fill {
  height: 100%;
  width: calc(var(--v) * 10%);
  background: var(--blue);
  transition: width 520ms cubic-bezier(.2, 1.5, .32, 1);
}

/* ---------- Controls ---------- */
.controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 0 8px;
}
.hour-block { display: flex; align-items: baseline; gap: 9px; min-width: 0; }
.hour {
  font-size: 26px;
  line-height: 1;
  letter-spacing: -.06em;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.moment-label {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.control-buttons { display: flex; gap: 6px; flex: 0 0 auto; }
.ghost {
  min-height: 40px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .38);
  padding: 0 12px;
  font-size: 12px;
  letter-spacing: -.02em;
}
.ghost:disabled { color: rgba(26, 26, 26, .24); background: transparent; cursor: default; }

.instruction {
  margin: 0 0 9px;
  padding: 0 2px;
  font-size: 12.5px;
  line-height: 1.3;
  color: rgba(26, 26, 26, .72);
  letter-spacing: -.02em;
}

/* ---------- Choices ---------- */
.choices {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  transition: transform 300ms ease, opacity 300ms ease;
}
.choices.sliding { transform: translateY(8px); opacity: .4; pointer-events: none; }
.choice {
  min-width: 0;
  border: 1px solid rgba(26, 26, 26, .22);
  background: rgba(255, 255, 255, .5);
  padding: 6px;
  box-shadow: 0 8px 28px rgba(26, 26, 26, .045);
  text-align: left;
  display: grid;
  gap: 5px;
}
.choice:disabled { cursor: default; }
.print {
  aspect-ratio: 2 / 3;
  width: auto;
  height: 22vh;
  max-height: 200px;
  min-height: 120px;
  margin: 0 auto;
  max-width: 100%;
  overflow: hidden;
  position: relative;
  border: 1px solid rgba(26, 26, 26, .16);
  background: #ded9d0;
}
.print img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: saturate(.94) contrast(.98);
}
.print .hour-stamp {
  position: absolute;
  left: 6px;
  bottom: 5px;
  color: rgba(255, 255, 255, .92);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 4px rgba(0, 0, 0, .5);
  z-index: 2;
}
.print .fallback {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 8px;
  font-size: 10px;
  line-height: 1.3;
  color: var(--muted);
  background: repeating-linear-gradient(135deg, #e6e1d8, #e6e1d8 8px, #ded9d0 8px, #ded9d0 16px);
}
.print.failed img { display: none; }
.print.failed .fallback { display: flex; }
.caption-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 5px;
}
.caption {
  font-size: 11px;
  line-height: 1.16;
  letter-spacing: -.02em;
  min-height: 25px;
}
.tag {
  display: none;
  color: var(--blue);
  font-size: 10px;
  line-height: 1.15;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.choice.selected {
  outline: 2px solid var(--blue);
  outline-offset: -2px;
  background: #fff;
}
.choice.selected .tag { display: inline; }

/* ---------- Film strip ---------- */
.strip-wrap {
  margin-top: 12px;
  border-top: 1px solid var(--line);
  padding-top: 8px;
}
.strip-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.strip {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 2px;
  -webkit-overflow-scrolling: touch;
}
.strip::-webkit-scrollbar { display: none; }
.frame {
  flex: 0 0 44px;
  display: grid;
  gap: 3px;
  text-align: center;
  font-size: 9px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.thumb {
  aspect-ratio: 2 / 3;
  border: 1px solid rgba(26, 26, 26, .2);
  background: rgba(255, 255, 255, .5);
  overflow: hidden;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; filter: saturate(.94); }

/* ---------- Result ---------- */
.result {
  display: none;
  border: 1px solid rgba(26, 26, 26, .22);
  background: rgba(243, 242, 237, .95);
  box-shadow: var(--shadow);
  padding: 16px;
}
.result.show { display: block; }
.day-title {
  font-size: clamp(30px, 9vw, 44px);
  line-height: .96;
  letter-spacing: -.06em;
  font-weight: 500;
  margin: 0 0 8px;
}
.result-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 14px;
}
.result-meta .wx-icon { font-size: 13px; }
.result-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 6px;
}
.primary, .secondary {
  min-height: 46px;
  border: 1px solid var(--ink);
  padding: 0 12px;
  font-size: 13px;
  letter-spacing: -.02em;
}
.primary { background: var(--ink); color: #fff; grid-column: 1 / -1; }
.secondary { background: transparent; }
.save { grid-column: 1 / -1; }
.toast { min-height: 20px; margin-top: 8px; color: var(--blue); font-size: 12px; }

.detail-toggle {
  margin-top: 12px;
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  background: transparent;
  font-size: 12px;
  letter-spacing: .02em;
}
.detail {
  display: none;
  margin-top: 12px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}
.detail.show { display: block; }
.detail h3 {
  margin: 0 0 8px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  font-weight: 500;
}
.detail .meters { border: 1px solid var(--line); }

.hidden { display: none !important; }

@media (min-width: 740px) {
  .shell { width: min(100%, 720px); }
  .choices { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .sky { height: 88px; }
  .result-actions { grid-template-columns: repeat(3, 1fr); }
  .primary, .save { grid-column: auto; }
}

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