:root {
  --text-xs: 0.78rem; --text-sm: 0.9rem; --text-base: 1rem; --text-lg: 1.2rem; --text-xl: 1.6rem; --text-2xl: 2rem;
  --font-display: 'Cabinet Grotesk', 'Satoshi', system-ui, sans-serif;
  --font-body: 'Satoshi', 'Helvetica Neue', system-ui, sans-serif;
  --bg: #0c1218; --surface: #131b23; --surface-2: #18222b; --surface-3: #1d2932; --surface-4: #27353f;
  --border: #2c3b46; --divider: #1c2731;
  --text: #e3ebf0; --muted: #98abb5; --faint: #667984;
  --accent: #e8a35a; --accent-ink: #1a1006; --accent-soft: rgba(232, 163, 90, 0.14);
  --water: #52c1dd; --water-soft: rgba(82, 193, 221, 0.14);
  --gen: #3fc58f; --warn: #e3b04b; --warn-soft: rgba(227, 176, 75, 0.14);
  --radius: 18px; --radius-sm: 12px;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { background: var(--bg); color: var(--text); font-family: var(--font-body); font-size: 16px; -webkit-font-smoothing: antialiased; overflow-x: hidden; }
body { min-height: 100dvh; padding-bottom: calc(76px + var(--safe-b)); }
a { color: inherit; }
img { display: block; max-width: 100%; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
.num { font-variant-numeric: tabular-nums; }

/* Top bar */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + var(--safe-t)) 16px 10px; background: rgba(12, 18, 24, 0.86); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-bottom: 1px solid var(--divider); }
.brand { display: flex; align-items: center; gap: 11px; text-decoration: none; min-width: 0; }
.brand-badge { width: 44px; height: 44px; flex: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text strong { font-family: var(--font-display); font-weight: 800; font-size: 1.3rem; letter-spacing: -0.01em; }
.brand-sub { font-size: var(--text-xs); color: var(--muted); font-weight: 500; }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; border: 1px solid var(--border); color: var(--muted); background: var(--surface); }
.icon-btn.spin svg { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.app { max-width: 560px; margin: 0 auto; padding: 14px 14px 8px; display: grid; gap: 14px; }

/* Panels */
.panel { background: var(--surface); border: 1px solid var(--divider); border-radius: var(--radius); padding: 18px 16px; min-width: 0; }
.panel-title { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.panel-title h2 { font-family: var(--font-display); font-size: var(--text-lg); font-weight: 800; letter-spacing: -0.01em; }
.meta { font-size: var(--text-xs); color: var(--muted); white-space: nowrap; }
.note { font-size: var(--text-sm); color: var(--muted); line-height: 1.5; }
.note strong { color: var(--text); }
.fade-in { animation: fade 0.35s ease both; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* Dam chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.chip { flex: 1 1 auto; padding: 11px 12px; border-radius: 12px; background: var(--surface-3); border: 1px solid transparent; color: var(--muted); font-size: 1rem; font-weight: 500; text-align: center; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.chip.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 700; }
.chip .star { font-size: 0.8rem; color: var(--accent); }

/* Pick */
.pick-row { display: flex; gap: 16px; align-items: center; }
.pick-img { flex: none; width: 112px; height: 140px; border-radius: 16px; overflow: hidden; background: #fff; display: grid; place-items: center; }
.pick-img img { width: 100%; height: 100%; object-fit: cover; }
.pick-main { min-width: 0; flex: 1; }
.pick-weight { font-family: var(--font-display); font-size: var(--text-2xl); font-weight: 800; line-height: 1; }
.pick-weight small { font-size: 0.55em; font-weight: 700; }
.pick-color { font-family: var(--font-display); font-size: 1.45rem; font-weight: 700; color: var(--accent); margin: 4px 0 10px; line-height: 1.1; }
.why { list-style: none; display: grid; gap: 6px; font-size: var(--text-sm); color: var(--muted); line-height: 1.4; }
.why strong { color: var(--text); font-weight: 700; }
.k { font-size: var(--text-xs); font-weight: 700; color: var(--faint); text-transform: uppercase; letter-spacing: 0.05em; margin: 18px 0 8px; }
.alts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.alt { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 5px 12px 5px 5px; border-radius: 999px; border: 1px solid var(--border); text-decoration: none; font-weight: 600; font-size: 0.98rem; }
.alt img { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; background: #fff; flex: none; }
.alt span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.later { margin-top: 14px; padding: 12px 14px; border-radius: 12px; background: var(--warn-soft); border: 1px solid rgba(227,176,75,.35); font-size: var(--text-sm); line-height: 1.45; color: var(--text); display: flex; gap: 10px; align-items: flex-start; }
.later svg { flex: none; color: var(--warn); margin-top: 2px; }
.later strong { color: var(--warn); }
.buy { display: flex; gap: 10px; margin-top: 16px; }
.btn { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 14px 16px; border-radius: 14px; font-weight: 700; font-size: 1rem; text-decoration: none; border: 1px solid var(--border); background: transparent; color: var(--text); text-align: center; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn .p { font-weight: 500; opacity: 0.75; }
.btn.block { width: 100%; }
.btn:active { transform: scale(0.985); }

.fav-btn { display: inline-flex; align-items: center; gap: 6px; font-size: var(--text-xs); font-weight: 700; color: var(--muted); padding: 6px 10px; border-radius: 999px; border: 1px solid var(--border); }
.fav-btn.on { color: var(--accent-ink); background: var(--accent); border-color: transparent; }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--surface-2); border-radius: 12px; padding: 10px 12px; min-width: 0; }
.stat .v { font-family: var(--font-display); font-weight: 800; font-size: 1.25rem; line-height: 1.1; }
.stat .v small { font-size: 0.7em; font-weight: 700; color: var(--muted); }
.stat .l { font-size: var(--text-xs); color: var(--muted); margin-top: 2px; }

/* Today bars */
.bars { display: grid; grid-template-columns: repeat(24, 1fr); gap: 2px; align-items: end; height: 84px; margin-top: 6px; }
.bar { background: var(--water); opacity: 0.55; border-radius: 3px 3px 1px 1px; min-height: 3px; }
.bar.past { opacity: 0.22; }
.bar.now { opacity: 1; background: var(--accent); }
.bar-axis { display: flex; justify-content: space-between; font-size: 0.7rem; color: var(--faint); margin-top: 6px; }

/* Flow cards */
.dam-card { display: block; text-decoration: none; background: var(--surface); border: 1px solid var(--divider); border-radius: var(--radius); padding: 16px; }
.dam-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.dam-name { font-family: var(--font-display); font-weight: 800; font-size: 1.2rem; }
.dam-sub { font-size: var(--text-xs); color: var(--muted); margin-top: 2px; }
.dam-cfs { text-align: right; }
.dam-cfs .v { font-family: var(--font-display); font-weight: 800; font-size: 1.5rem; line-height: 1; }
.dam-cfs .l { font-size: var(--text-xs); color: var(--muted); }
.dam-pick { display: flex; align-items: center; gap: 12px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--divider); }
.dam-pick img { width: 44px; height: 44px; border-radius: 10px; object-fit: cover; background: #fff; flex: none; }
.dam-pick .t { font-weight: 700; }
.dam-pick .t b { color: var(--accent); }
.dam-pick .s { font-size: var(--text-xs); color: var(--muted); margin-top: 2px; }
.dam-pick .chev { margin-left: auto; color: var(--faint); }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: var(--text-xs); font-weight: 700; padding: 4px 9px; border-radius: 999px; background: var(--surface-3); color: var(--muted); }
.pill.gen { background: rgba(63,197,143,.14); color: var(--gen); }
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.gen .dot { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.stale { margin-top: 10px; font-size: var(--text-xs); color: var(--warn); }

/* Shop */
.hero-shop { display: grid; gap: 10px; }
.dealers { list-style: none; display: grid; }
.dealer { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 0; border-bottom: 1px solid var(--divider); }
.dealer:last-child { border-bottom: 0; }
.dealer-name { font-weight: 700; }
.dealer-addr { font-size: var(--text-sm); color: var(--muted); margin-top: 2px; }
.map-btn { flex: none; display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--border); text-decoration: none; font-size: var(--text-sm); font-weight: 700; color: var(--water); }
details summary { cursor: pointer; font-weight: 700; color: var(--muted); padding: 12px 0 4px; list-style: none; }
details summary::-webkit-details-marker { display: none; }
details summary::after { content: ' +'; }
details[open] summary::after { content: ' −'; }

/* Catch */
.rules { list-style: none; display: grid; gap: 10px; }
.rules li { display: flex; gap: 10px; font-size: var(--text-sm); line-height: 1.45; color: var(--muted); }
.rules li b { color: var(--text); }
.rules .n { flex: none; width: 24px; height: 24px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 800; font-size: 0.8rem; display: grid; place-items: center; }
.field { display: grid; gap: 6px; margin-bottom: 12px; }
.field label { font-size: var(--text-xs); font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.field input, .field select { width: 100%; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; color: var(--text); padding: 13px 14px; font-size: 1rem; font-family: inherit; appearance: none; -webkit-appearance: none; }
.field select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2398abb5' stroke-width='2.5'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; background-size: 16px; padding-right: 40px; }
.field input:focus, .field select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.skeleton { background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.3s infinite; border-radius: 12px; }
@keyframes shimmer { to { background-position: -200% 0; } }

.foot { text-align: center; font-size: var(--text-xs); color: var(--faint); line-height: 1.6; padding: 6px 10px 4px; }
.foot a { color: var(--muted); }
.foot strong { color: var(--muted); }

/* Tab bar */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; grid-template-columns: repeat(4, 1fr);
  padding: 6px 8px calc(6px + var(--safe-b)); background: rgba(19, 27, 35, 0.94); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-top: 1px solid var(--divider); }
.tabbar a { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 7px 0; text-decoration: none; color: var(--faint); font-size: 0.72rem; font-weight: 700; border-radius: 12px; }
.tabbar svg { width: 24px; height: 24px; }
.tabbar a.active { color: var(--accent); }

@media (min-width: 700px) { .app { padding-top: 22px; } }

/* v2 */
.tabbar { grid-template-columns: repeat(5, 1fr); padding-left: 4px; padding-right: 4px; }
.tabbar a { font-size: 0.66rem; white-space: nowrap; letter-spacing: -0.01em; }
.tabbar svg { width: 23px; height: 23px; }
.tagline { font-family: var(--font-display); font-weight: 700; font-style: italic; color: var(--accent); font-size: 1rem; margin: -6px 0 14px; }
.weather-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.price { font-size: var(--text-sm); color: var(--gen); font-weight: 700; margin-top: -4px; margin-bottom: 8px; }

/* Flow charts */
.chart-dam { margin-bottom: 0; }
.chart-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 10px; }
.chart-head h2 { font-family: var(--font-display); font-weight: 800; font-size: 1.2rem; }
.chart-head .dam-sub { margin-top: 2px; }
.band { display: grid; grid-template-columns: 40px 1fr auto; align-items: center; gap: 12px; padding: 11px 10px; border-radius: 12px; border: 1px solid transparent; }
.band + .band { margin-top: 4px; }
.band.now { background: var(--accent-soft); border-color: var(--accent); }
.band.later { background: var(--warn-soft); border-color: rgba(227,176,75,.4); }
.head-dot { justify-self: center; border-radius: 50%; background: linear-gradient(145deg, #c9a46a, #7d5a2c); box-shadow: inset -2px -2px 3px rgba(0,0,0,.35); }
.band-w { font-family: var(--font-display); font-weight: 800; font-size: 1.15rem; }
.band-g { font-size: var(--text-xs); color: var(--muted); margin-top: 1px; }
.band-c { text-align: right; font-weight: 700; font-size: var(--text-sm); }
.band-tag { display: inline-block; font-size: 0.66rem; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; padding: 2px 7px; border-radius: 6px; margin-left: 6px; vertical-align: 2px; }
.band.now .band-tag { background: var(--accent); color: var(--accent-ink); }
.band.later .band-tag { background: var(--warn); color: #1d1405; }
.static-tag { font-size: var(--text-xs); color: var(--faint); }

/* Custom */
.custom-hero { border-radius: 16px; overflow: hidden; background: #fff; display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; margin-bottom: 16px; }
.custom-hero img { width: 100%; aspect-ratio: 1; object-fit: cover; }
.steps { list-style: none; display: grid; gap: 12px; margin-bottom: 16px; }
.steps li { display: flex; gap: 12px; align-items: flex-start; }
.steps .n { flex: none; width: 28px; height: 28px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 800; display: grid; place-items: center; font-size: 0.85rem; }
.steps b { display: block; font-size: 1rem; }
.steps span.s { font-size: var(--text-sm); color: var(--muted); line-height: 1.4; }

/* Catch log */
.countdown { display: flex; align-items: center; gap: 14px; padding: 14px; border-radius: 14px; background: var(--accent-soft); border: 1px solid rgba(232,163,90,.35); margin-bottom: 16px; }
.countdown .big { font-family: var(--font-display); font-weight: 800; font-size: 2.2rem; color: var(--accent); line-height: 1; }
.countdown .t { font-size: var(--text-sm); line-height: 1.4; }
.countdown .t b { display: block; font-size: 1rem; }
.photo-drop { display: grid; place-items: center; gap: 6px; height: 190px; border-radius: 14px; border: 1.5px dashed var(--border); background: var(--surface-2); color: var(--muted); font-weight: 700; cursor: pointer; overflow: hidden; position: relative; margin-bottom: 12px; text-align: center; }
.photo-drop img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.photo-drop input { display: none; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: var(--text-sm); color: var(--muted); line-height: 1.45; margin: 4px 0 14px; }
.check input { width: 20px; height: 20px; flex: none; margin-top: 1px; accent-color: var(--accent); }
.status { margin-top: 12px; padding: 12px 14px; border-radius: 12px; font-size: var(--text-sm); line-height: 1.45; }
.status.ok { background: rgba(63,197,143,.12); color: var(--gen); }
.status.err { background: var(--warn-soft); color: var(--warn); }
.log-item { display: grid; grid-template-columns: 76px 1fr; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--divider); align-items: center; }
.log-item:last-child { border-bottom: 0; }
.log-item .ph { width: 76px; height: 76px; border-radius: 12px; background: var(--surface-3); object-fit: cover; }
.log-item .a { font-weight: 800; }
.log-item .b { font-size: var(--text-sm); color: var(--accent); font-weight: 700; margin-top: 2px; }
.log-item .c { font-size: var(--text-xs); color: var(--muted); margin-top: 3px; }
.link-btn { color: var(--faint); font-size: var(--text-xs); font-weight: 700; text-decoration: underline; }

.btn { white-space: nowrap; }
.weather-row { margin: -2px 0 10px; }
.fav-btn { white-space: nowrap; flex: none; }
.panel-title h2 { min-width: 0; }

/* v3: header order + light mode */
.brand-sub { text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.68rem; font-weight: 700; color: #b9c6cd; }
.brand-text strong { font-size: 1.35rem; color: #f3ece0; }
.top-actions { display: flex; gap: 8px; }
.topbar .icon-btn { background: #131b23; border-color: #2c3b46; color: #98abb5; }

[data-theme="light"] {
  --bg: #f3f0ea; --surface: #ffffff; --surface-2: #f6f3ee; --surface-3: #ece7df; --surface-4: #e0d9ce;
  --border: #d6cdbf; --divider: #e6dfd4;
  --text: #1a2128; --muted: #55606a; --faint: #7b858e;
  --accent: #b05a17; --accent-ink: #ffffff; --accent-soft: rgba(176, 90, 23, 0.10);
  --water: #0f7f9b; --water-soft: rgba(15, 127, 155, 0.10);
  --gen: #11804f; --warn: #9a5b00; --warn-soft: rgba(196, 128, 20, 0.12);
}
[data-theme="light"] html, [data-theme="light"] body { background: var(--bg); }
[data-theme="light"] .tabbar { background: rgba(255, 255, 255, 0.95); border-top-color: var(--border); }
[data-theme="light"] .tabbar a { color: #7b858e; }
[data-theme="light"] .tabbar a.active { color: var(--accent); }
[data-theme="light"] .panel, [data-theme="light"] .dam-card { box-shadow: 0 1px 3px rgba(40, 30, 15, 0.06); border-color: var(--divider); }
[data-theme="light"] .later { border-color: rgba(196, 128, 20, 0.35); }
[data-theme="light"] .bar { opacity: 0.7; }
[data-theme="light"] .bar.past { opacity: 0.25; }
[data-theme="light"] .status.ok { background: rgba(17, 128, 79, 0.10); }
[data-theme="light"] .pill.gen { background: rgba(17, 128, 79, 0.12); }
[data-theme="light"] .field select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2355606a' stroke-width='2.5'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); }
