:root {
  color-scheme: light;
  --bg: #f3efe8;
  --bg-2: #d7efe8;
  --paper: rgba(255, 252, 248, 0.94);
  --ink: #14282e;
  --muted: #5c7278;
  --line: rgba(20, 40, 46, 0.12);
  --lagoon: #0f6e68;
  --lagoon-2: #14867e;
  --on-lagoon: #f3fffc;
  --sand: #f4e7d6;
  --coral: #c24b38;
  --good: #1d7a4e;
  --shadow: 0 16px 40px rgba(20, 40, 46, 0.06);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Songti TC", "Noto Serif TC", serif;
  --sans: "Avenir Next", "Segoe UI", "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  --radius: 22px;
  --tab: 76px;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101718;
  --bg-2: #163330;
  --paper: rgba(22, 36, 38, 0.94);
  --ink: #e7f3f0;
  --muted: #b7ccc8;
  --line: rgba(231, 243, 240, 0.14);
  --lagoon: #3ecfb8;
  --lagoon-2: #8ef0e2;
  --on-lagoon: #062421;
  --sand: #2a3330;
  --coral: #ff9b8c;
  --good: #8ddec0;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.28);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(900px 420px at -10% -20%, var(--bg-2), transparent 60%),
    radial-gradient(680px 360px at 110% 0%, var(--sand), transparent 55%);
}
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--lagoon); text-decoration-thickness: 1px; text-underline-offset: 3px; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; letter-spacing: -0.03em; line-height: 1.15; margin: 0; }
h1 { font-size: clamp(2rem, 7vw, 3.1rem); }
h2 { font-size: 1.35rem; }
p { margin: 0; }
::placeholder { color: var(--muted); }
:focus-visible { outline: 2px solid var(--lagoon); outline-offset: 2px; }
::selection { background: rgba(15, 110, 104, 0.22); }

.skip {
  position: absolute;
  left: 12px;
  top: -40px;
  background: var(--ink);
  color: var(--bg);
  padding: 8px 12px;
  border-radius: 10px;
  z-index: 5;
}
.skip:focus { top: 12px; }

.lock {
  min-height: 100dvh;
  width: min(440px, calc(100% - 40px));
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 14px;
  padding: 28px 0 48px;
}
.lock img { width: 64px; height: 64px; }
.lock form { display: flex; flex-direction: column; gap: 12px; }
.lock .lang { align-self: flex-start; }

.boot-mark {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  font-family: var(--serif);
  font-size: 2rem;
  margin: 0;
}

.shell { min-height: 100dvh; }
.sidebar { display: none; }
.maincol { width: min(880px, 100%); margin: 0 auto; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(14px + env(safe-area-inset-top)) 20px 8px;
}
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.brand strong { display: block; font-family: var(--serif); font-size: 1.15rem; letter-spacing: -0.03em; }
.brand small { display: block; color: var(--muted); font-size: 0.82rem; }
.lang { display: flex; padding: 3px; border: 1px solid var(--line); border-radius: 999px; background: var(--paper); }
.lang button {
  border: 0;
  background: transparent;
  border-radius: 999px;
  min-width: 44px;
  min-height: 36px;
  color: var(--muted);
}
.lang button.is-on { background: var(--ink); color: var(--bg); }
.content {
  padding: 8px 20px calc(var(--tab) + env(safe-area-inset-bottom) + 56px);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 3;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  align-items: end;
  padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
}
.tab, .tab-log {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.72rem;
  min-height: 48px;
  justify-content: flex-end;
}
.tab svg, .navlink svg { width: 22px; height: 22px; }
.tab.is-on, .navlink.is-on { color: var(--ink); }
.tab-log {
  width: 56px;
  height: 56px;
  margin: -22px auto 0;
  border-radius: 50%;
  background: var(--lagoon);
  color: var(--on-lagoon);
  justify-content: center;
  box-shadow: 0 10px 24px rgba(15, 110, 104, 0.28);
}
.tab-log svg { width: 26px; height: 26px; }
.tab-log.is-on { background: var(--lagoon-2); }

.page-head, .hero, .stack, .card { display: flex; flex-direction: column; gap: 10px; }
.eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.72rem;
  color: var(--lagoon);
  font-weight: 600;
}
.lede { color: var(--muted); font-size: 1.05rem; max-width: 42rem; }
.hero-actions, .row-actions, .section-head, .set-top, .period-nav, .confirm, .timebox {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.section-head { justify-content: space-between; }
.section-head a { font-size: 0.95rem; }
.feature-row {
  display: flex;
  gap: 8px;
  padding: 0;
  margin: 8px 0 0;
  list-style: none;
  flex-wrap: wrap;
}
.feature-row li, .pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  color: var(--muted);
  background: var(--paper);
  font-size: 0.85rem;
  font-style: normal;
}
.pills { display: flex; gap: 6px; flex-wrap: wrap; }
.pill { display: inline-flex; align-items: center; gap: 6px; }
.pill b { width: 8px; height: 8px; border-radius: 99px; display: inline-block; }

.statgrid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.statgrid.four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stat {
  background: var(--paper);
  border: 1px solid var(--line);
  border-top: 3px solid var(--lagoon);
  border-radius: 18px;
  padding: 12px 14px 14px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 92px;
}
.stat span, .label, .field > span { color: var(--muted); font-size: 0.82rem; }
.stat b { font-family: var(--serif); font-size: clamp(1.35rem, 4.6vw, 1.7rem); font-weight: 600; letter-spacing: -0.03em; line-height: 1.05; }
.stat b small, .sets-table td small {
  display: block;
  margin-top: 3px;
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--muted);
}
.delta { font-size: 0.8rem; color: var(--muted); }
.delta.up { color: var(--good); }
.delta.down { color: var(--coral); }
.count-line { margin-top: -6px; }
.muted { color: var(--muted); }
.note {
  background: var(--sand);
  border-radius: 14px;
  padding: 10px 12px;
}

.card, .session, .suggestion {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
}
.session {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 12px;
  color: inherit;
  text-decoration: none;
  align-items: center;
}
.session img, .session-mark {
  width: 72px;
  height: 72px;
  border-radius: 16px;
  object-fit: cover;
  background:
    linear-gradient(160deg, var(--bg-2), var(--sand));
}
.session-copy { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.session-copy strong { font-size: 1.02rem; overflow-wrap: anywhere; }
.keep { white-space: nowrap; }
.session-top { display: flex; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 0.85rem; }
.hero-photo, .photo-preview { width: 100%; border-radius: 16px; max-height: 280px; object-fit: cover; }
.photo-card { gap: 12px; }
.suggestion.warn { border-color: var(--coral); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  text-decoration: none;
}
.btn.primary { background: var(--lagoon); color: var(--on-lagoon); border-color: transparent; }
.btn.ghost { background: transparent; }
.btn.danger { background: transparent; color: var(--coral); border-color: color-mix(in srgb, var(--coral) 45%, var(--line)); }
.btn:disabled, .is-busy { opacity: 0.65; }
.seg, .chips { display: flex; gap: 8px; flex-wrap: wrap; }
.seg button, .chip, .stepper button {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  border-radius: 999px;
  min-height: 44px;
  padding: 8px 12px;
}
.seg button.is-on, .chip.is-on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chips { flex-wrap: wrap; }
.chip { white-space: nowrap; }
.effort button { display: flex; flex-direction: column; gap: 0; min-width: 58px; line-height: 1.1; }
.effort small { font-size: 0.72rem; color: inherit; }
.period-nav { justify-content: space-between; }
.period-nav .btn { min-width: 48px; font-size: 1.4rem; }

.field { display: flex; flex-direction: column; gap: 6px; }
.control, .stepper input {
  width: 100%;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper) 70%, var(--bg));
  border-radius: 14px;
  padding: 12px 14px;
  min-height: 48px;
}
textarea.control { resize: vertical; }
.grow { flex: 1; }
.set-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stepper { display: flex; align-items: center; gap: 6px; }
.stepper input { text-align: center; padding-inline: 4px; }
.stepper button { width: 44px; padding: 0; }
.timebox .control { width: 76px; text-align: center; }
.pace { margin: 0; color: var(--lagoon); font-variant-numeric: tabular-nums; }
.savebar {
  position: sticky;
  bottom: calc(var(--tab) + env(safe-area-inset-bottom) - 8px);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 10px;
  border-radius: 18px;
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  border: 1px solid var(--line);
  backdrop-filter: blur(12px);
}
.savebar p { font-variant-numeric: tabular-nums; }
.place-more { border-top: 1px solid var(--line); padding-top: 8px; }
.place-more summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; }
.stack.tight, .card.stack { gap: 12px; }
.check { display: flex; gap: 10px; align-items: flex-start; }
.check input { width: 20px; height: 20px; margin-top: 3px; }
.status { margin: 0; padding-left: 18px; }

.banner {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 14px;
  background: var(--sand);
}
.banner button { border: 0; background: transparent; font-size: 1.2rem; min-width: 44px; min-height: 44px; }
.banner.bad { background: color-mix(in srgb, var(--coral) 16%, var(--paper)); color: var(--ink); }
.banner.good { background: color-mix(in srgb, var(--good) 18%, var(--paper)); }
.confirm { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.insights, .cues, .days, .blocks { margin: 0; padding: 0; }
.insights, .cues { display: flex; flex-direction: column; gap: 8px; padding-left: 18px; }
.days { list-style: none; display: flex; flex-direction: column; gap: 12px; }
.days > li { border-top: 1px solid var(--line); padding-top: 12px; }
.days header { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.days header span { color: var(--muted); }
.blocks { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.blocks li { display: grid; grid-template-columns: 88px 1fr; gap: 8px; }
.chart-card svg { width: 100%; height: auto; }
.donut-wrap { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.donut { width: 180px; height: auto; flex: none; }
.legend { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.legend li { display: flex; align-items: center; gap: 8px; }
.legend i { width: 10px; height: 10px; border-radius: 99px; display: inline-block; }
.sets-table { width: 100%; border-collapse: collapse; }
.sets-table th, .sets-table td { text-align: left; padding: 8px 4px; border-bottom: 1px solid var(--line); vertical-align: top; }
.sets-table small { display: block; color: var(--muted); }
.empty-block .btn { align-self: flex-start; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (min-width: 720px) {
  .statgrid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .content { padding-inline: 28px; }
}
@media (min-width: 920px) {
  .shell { display: grid; grid-template-columns: 240px 1fr; }
  .sidebar {
    display: flex;
    flex-direction: column;
    gap: 24px;
    position: sticky;
    top: 0;
    height: 100dvh;
    padding: 28px 18px;
    border-right: 1px solid var(--line);
  }
  .sidenav { display: flex; flex-direction: column; gap: 4px; }
  .navlink {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 46px;
    padding: 8px 12px;
    border-radius: 14px;
    color: var(--muted);
    text-decoration: none;
  }
  .navlink.is-on { background: var(--paper); color: var(--ink); }
  .tabbar, .mobile-brand { display: none; }
  .content, .savebar { padding-bottom: 28px; }
  .savebar { bottom: 16px; }
  .topbar { padding-top: 22px; }
}
@media (max-width: 919px) {
  .sidebar { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .is-busy { animation: none; }
}
@media print {
  .tabbar, .sidebar, .topbar, .savebar, .hero-actions, .row-actions { display: none !important; }
  .content { padding: 0; }
  body { background: white; }
}
