/* Meku design tokens (docs/spec/21 §4.2). Text on every theme gradient keeps >= 4.5:1. */
:root {
  --meku-ink: #1f1b2e;
  --meku-ink-soft: #4a4458;
  --meku-bg: #fdf2f6;
  --meku-surface: #ffffff;
  --meku-line: #eadfe6;
  --meku-accent: #c93a6e;
  --meku-accent-text: #b8285c;
  --meku-on-accent: #ffffff;
  --meku-radius: 24px;
  --g-econ-a: #ffe9dc; --g-econ-b: #ffd6d2;
  --g-tech-a: #ece6ff; --g-tech-b: #dcefff;
  --g-fin-a: #ddf7ee; --g-fin-b: #d3f1f3;
  --g-energy-a: #fff6cc; --g-energy-b: #ffe6cc;
  --g-policy-a: #f1e6ff; --g-policy-b: #ffe3ee;
  --g-sus-a: #e6f2df; --g-sus-b: #daf5ea;
  --g-other-a: #ffe4ee; --g-other-b: #efe4ff;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --meku-ink: #f5eff8;
    --meku-ink-soft: #cfc4d6;
    --meku-bg: #17121f;
    --meku-surface: #221a2c;
    --meku-line: #3a2f45;
    --meku-accent: #f06a98;
    --meku-accent-text: #ff9cbf;
    --meku-on-accent: #17121f;
    --g-econ-a: #3a2620; --g-econ-b: #3a2229;
    --g-tech-a: #2a2440; --g-tech-b: #1e2b3d;
    --g-fin-a: #1c3330; --g-fin-b: #1b3036;
    --g-energy-a: #3a3420; --g-energy-b: #3a2c1e;
    --g-policy-a: #2e2440; --g-policy-b: #3a2231;
    --g-sus-a: #24321f; --g-sus-b: #1e3329;
    --g-other-a: #3a2230; --g-other-b: #2c2440;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: system-ui, -apple-system, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", sans-serif;
  color: var(--meku-ink);
  background: var(--meku-bg);
  line-height: 1.7;
  -webkit-text-size-adjust: 100%;
  font-feature-settings: "palt";
}
a { color: var(--meku-accent-text); }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 1.25em; height: 1.25em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.icon.big { width: 56px; height: 56px; color: var(--meku-accent-text); }
.sr, .skip:not(:focus) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip:focus { position: fixed; top: 8px; left: 8px; z-index: 50; background: var(--meku-surface); padding: 8px 12px; border-radius: 12px; }
:focus-visible { outline: 3px solid var(--meku-accent); outline-offset: 2px; }
button { font: inherit; color: inherit; touch-action: manipulation; cursor: pointer; }

/* Header */
.bar {
  display: flex; align-items: center; gap: 12px;
  padding: calc(8px + env(safe-area-inset-top)) calc(16px + env(safe-area-inset-right)) 8px calc(16px + env(safe-area-inset-left));
  background: var(--meku-bg);
}
.logo { margin: 0; font-size: 26px; font-weight: 800; letter-spacing: -0.02em; line-height: 1; }
.logo a { color: var(--meku-ink); text-decoration: none; }
.logo a::after { content: ""; display: inline-block; width: 8px; height: 8px; margin-left: 3px; border-radius: 50%; background: var(--meku-accent); }
.progress { display: flex; gap: 6px; margin-left: auto; }
.progress .dot { width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--meku-accent); background: transparent; transition: background-color .2s; }
.progress .dot.on { background: var(--meku-accent); }
.days { font-size: 12px; color: var(--meku-ink-soft); white-space: nowrap; }
.saved-btn {
  display: inline-flex; align-items: center; gap: 4px; min-height: 40px; padding: 0 12px;
  border: 1px solid var(--meku-line); border-radius: 999px; background: var(--meku-surface); font-size: 14px; font-weight: 700;
}
.progress[hidden] + .days + .saved-btn, .progress[hidden] ~ .saved-btn { margin-left: auto; }

/* Theme chips */
.chips {
  display: flex; gap: 8px; overflow-x: auto; padding: 0 16px 8px; scrollbar-width: none;
  padding-left: calc(16px + env(safe-area-inset-left)); padding-right: calc(16px + env(safe-area-inset-right));
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; min-height: 36px; padding: 0 14px; border-radius: 999px; font-size: 14px; font-weight: 600;
  border: 1px solid var(--meku-line); background: var(--meku-surface); color: var(--meku-ink);
}
.chip.on { background: var(--meku-accent); border-color: var(--meku-accent); color: var(--meku-on-accent); }

/* App layout only when JS runs; without JS the page is a plain document. */
.js body { height: 100vh; height: 100svh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
.js .deck {
  flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  scroll-snap-type: y proximity; scroll-padding-top: 0; -webkit-overflow-scrolling: touch;
  padding: 0 calc(12px + env(safe-area-inset-right)) env(safe-area-inset-bottom) calc(12px + env(safe-area-inset-left));
  outline: none;
}
.js .foot { display: none; }
.js .card-end .foot { display: block; }

.card {
  min-height: 100%;
  scroll-snap-align: start; scroll-snap-stop: always;
  display: flex; flex-direction: column;
  max-width: 440px; margin: 0 auto; padding: 4px 0 12px;
  outline: none;
}
.card-in {
  flex: 1; display: flex; flex-direction: column; gap: 14px;
  padding: 22px 20px 18px; border-radius: var(--meku-radius) var(--meku-radius) 0 0;
  background: linear-gradient(160deg, var(--ga, var(--g-other-a)), var(--gb, var(--g-other-b)));
}
.card-in.center { align-items: center; justify-content: center; text-align: center; border-radius: var(--meku-radius); gap: 18px; }
.card:focus-visible .card-in { box-shadow: 0 0 0 3px var(--meku-accent); }
.theme-econ { --ga: var(--g-econ-a); --gb: var(--g-econ-b); }
.theme-tech { --ga: var(--g-tech-a); --gb: var(--g-tech-b); }
.theme-fin { --ga: var(--g-fin-a); --gb: var(--g-fin-b); }
.theme-energy { --ga: var(--g-energy-a); --gb: var(--g-energy-b); }
.theme-policy { --ga: var(--g-policy-a); --gb: var(--g-policy-b); }
.theme-sus { --ga: var(--g-sus-a); --gb: var(--g-sus-b); }
.theme-other { --ga: var(--g-other-a); --gb: var(--g-other-b); }

.card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--meku-ink-soft); }
.pill { display: inline-block; padding: 3px 12px; border-radius: 999px; background: var(--meku-surface); color: var(--meku-ink); font-weight: 700; font-size: 13px; }
.title { margin: 0; font-weight: 800; line-height: 1.38; letter-spacing: -0.01em; overflow-wrap: anywhere; }
.t-xl { font-size: 30px; }
.t-l { font-size: 26px; }
.t-m { font-size: 23px; }
.t-s { font-size: 21px; }
.lead h3, .points h3 { margin: 0 0 4px; font-size: 12px; font-weight: 800; letter-spacing: .08em; color: var(--meku-accent-text); }
.lead p { margin: 0; font-size: 16px; }
.points ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.pt { display: grid; padding: 10px 14px; border-radius: 16px; background: color-mix(in srgb, var(--meku-surface) 78%, transparent); font-variant-numeric: tabular-nums; }
.pt-value { font-size: 20px; font-weight: 800; line-height: 1.3; overflow-wrap: anywhere; }
.pt-label { font-size: 14px; font-weight: 600; }
.pt-note { font-size: 12px; color: var(--meku-ink-soft); }
.pt-raw { font-size: 15px; }
.meta { margin: auto 0 0; font-size: 13px; color: var(--meku-ink-soft); }

.actions {
  display: flex; gap: 8px; padding: 10px 12px; border-radius: 0 0 var(--meku-radius) var(--meku-radius);
  background: var(--meku-surface); border: 1px solid var(--meku-line); border-top: 0;
}
.act {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 14px;
  border-radius: 999px; border: 1px solid var(--meku-line); background: var(--meku-surface); color: var(--meku-ink);
  font-size: 14px; font-weight: 700; text-decoration: none;
}
.act-main { margin-left: auto; background: var(--meku-accent); border-color: var(--meku-accent); color: var(--meku-on-accent); }
.card-in .act-main { margin-left: 0; }
.act-save.on { color: var(--meku-accent-text); border-color: var(--meku-accent); }
.act-save.on .icon { fill: currentColor; }
.act-save.pop .icon { animation: pop .35s ease-out; }
@keyframes pop { 0% { transform: scale(1); } 45% { transform: scale(1.35); } 100% { transform: scale(1); } }

/* Cards turn up into place like a page being flipped (the name: meku = flip). */
.js .card .card-in { transform-origin: 50% 100%; }
.js .card.in .card-in { animation: flip .45s cubic-bezier(.2, .7, .2, 1) both; }
@keyframes flip { from { opacity: .4; transform: perspective(900px) rotateX(9deg) translateY(14px); } to { opacity: 1; transform: none; } }

.link-btn { display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; padding: 8px; color: var(--meku-accent-text); font-weight: 700; text-decoration: underline; }

/* Saved sheet */
.sheet {
  width: min(520px, 100vw); max-height: 80dvh; margin: auto auto 0; padding: 0; border: 0;
  border-radius: var(--meku-radius) var(--meku-radius) 0 0; background: var(--meku-surface); color: var(--meku-ink);
}
.sheet::backdrop { background: rgb(20 10 30 / 45%); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 16px 8px 20px; }
.sheet-head h2 { margin: 0; font-size: 18px; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border: 0; border-radius: 50%; background: transparent; }
.saved-list { list-style: none; margin: 0; padding: 0 12px; }
.saved-list li { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 0 8px; padding: 10px 8px; border-bottom: 1px solid var(--meku-line); }
.saved-list a { color: var(--meku-ink); font-weight: 700; text-decoration: none; }
.saved-list small { grid-column: 1; color: var(--meku-ink-soft); }
.saved-list .icon-btn { grid-row: 1 / span 2; grid-column: 2; }
.empty { padding: 0 20px; color: var(--meku-ink-soft); }
.sheet-foot { padding: 8px 20px calc(16px + env(safe-area-inset-bottom)); }
.note { margin: 4px 0 0; font-size: 12px; color: var(--meku-ink-soft); }

.hint {
  position: fixed; left: 12px; right: 12px; bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 20;
  max-width: 420px; margin: 0 auto; display: flex; gap: 8px; align-items: flex-start;
  padding: 12px 8px 12px 16px; border-radius: 18px; background: var(--meku-ink); color: var(--meku-bg); font-size: 14px;
}
.hint p { margin: 0; }
.hint .icon-btn { color: inherit; width: 36px; height: 36px; }
.hint[hidden] { display: none; }
.toast {
  position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); z-index: 30; transform: translate(-50%, 12px);
  padding: 10px 18px; border-radius: 999px; background: var(--meku-ink); color: var(--meku-bg); font-size: 14px; font-weight: 700;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.foot { padding: 16px; font-size: 12px; color: var(--meku-ink-soft); text-align: center; }
.foot p { margin: 0; }
.static { max-width: 640px; margin: 0 auto; padding: 16px; }
.static li { margin-bottom: 8px; }

@media (min-width: 720px) {
  .bar, .chips { max-width: 520px; margin: 0 auto; width: 100%; }
}
@media (max-height: 640px) {
  .t-xl { font-size: 26px; } .t-l { font-size: 23px; } .t-m { font-size: 21px; } .t-s { font-size: 19px; }
  .card-in { gap: 10px; padding: 16px 16px 14px; }
  .pt { padding: 8px 12px; } .pt-value { font-size: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
.logo { white-space: nowrap; }
@media (max-width: 374px) {
  .bar { gap: 8px; }
  .logo { font-size: 22px; }
  .progress { gap: 4px; }
  .progress .dot { width: 8px; height: 8px; }
  .days { font-size: 11px; }
  .saved-btn { padding: 0 10px; }
}
@media (max-width: 340px) { .days { display: none; } }
