:root {
  --bg: #0a0e16; --bg2: #111827; --card: #141b2a; --card2: #1a2335; --line: #26314a;
  --text: #eef2f8; --dim: #9aa6bd; --mint: #5eead4; --gold: #f5c46b; --rose: #fb7185; --sky: #7dd3fc;
  --good: #4ade80; --bad: #f87171;
  --r: 18px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: radial-gradient(1200px 600px at 80% -10%, #1b2a44 0%, transparent 60%),
              radial-gradient(900px 500px at -10% 110%, #13283a 0%, transparent 55%), var(--bg);
  background-attachment: fixed;
  color: var(--text); min-height: 100vh;
  font: 16px/1.45 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button { font: inherit; color: inherit; }
.top {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 18px 10px; backdrop-filter: blur(14px);
  background: rgba(10, 14, 22, .72); border-bottom: 1px solid rgba(255,255,255,.05);
}
.brand { display: flex; gap: 10px; align-items: center; text-decoration: none; font-weight: 700; letter-spacing: .3px; }
.brand img { width: 30px; height: 30px; }
.top nav { display: flex; gap: 4px; }
.top nav a { text-decoration: none; color: var(--dim); padding: 7px 12px; border-radius: 999px; font-size: 14px; }
.top nav a.on { color: var(--text); background: var(--card2); }
main { max-width: 560px; margin: 0 auto; padding: 18px 16px calc(40px + env(safe-area-inset-bottom)); }

.card { background: linear-gradient(180deg, var(--card2), var(--card)); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; margin: 14px 0; }
.hero { text-align: center; padding: 30px 20px 24px; }
.hero h1 { font-size: 30px; line-height: 1.15; margin: 8px 0 8px; letter-spacing: -.5px; }
.hero p { color: var(--dim); margin: 0 0 20px; }
.grad { background: linear-gradient(90deg, var(--mint), var(--gold)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.btn {
  display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%;
  border: 0; border-radius: 14px; padding: 16px 18px; font-weight: 700; font-size: 17px; cursor: pointer; text-decoration: none;
  background: linear-gradient(90deg, var(--mint), #a7f3d0 55%, var(--gold)); color: #06201c;
  box-shadow: 0 10px 30px -12px rgba(94, 234, 212, .6);
}
.btn:active { transform: scale(.985); }
.btn.ghost { background: var(--card2); color: var(--text); border: 1px solid var(--line); box-shadow: none; font-weight: 600; }
.btn.small { padding: 11px 14px; font-size: 15px; width: auto; }
.btn.danger { background: #3a1820; color: #fecaca; border: 1px solid #5b2330; box-shadow: none; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.fine { color: var(--dim); font-size: 13.5px; display: flex; gap: 8px; align-items: flex-start; margin: 8px 0; }
.fine svg { flex: 0 0 16px; margin-top: 2px; opacity: .8; }
.muted { color: var(--dim); }
h2 { font-size: 19px; margin: 0 0 10px; letter-spacing: -.2px; }
h3 { font-size: 15px; margin: 0 0 6px; color: var(--dim); font-weight: 600; text-transform: uppercase; letter-spacing: .8px; }

/* score ring */
.ring { position: relative; width: 168px; height: 168px; margin: 4px auto 6px; }
.ring svg { transform: rotate(-90deg); }
.ring .val { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.ring .num { font-size: 50px; font-weight: 800; letter-spacing: -1.5px; line-height: 1; }
.ring .of { color: var(--dim); font-size: 13px; margin-top: 4px; }
.subscore { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 11px; border-radius: 999px; background: var(--card2); border: 1px solid var(--line); font-size: 13.5px; }
.chip.gold { color: var(--gold); border-color: #4a3c1d; background: #211b0e; }
.chip.warn { color: #fde68a; border-color: #4b3f13; background: #221d0b; }
.chip.up { color: var(--good); } .chip.down { color: var(--bad); }

/* pillars */
.pillars { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pillar { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 13px; }
.pillar .top2 { display: flex; justify-content: space-between; align-items: baseline; }
.pillar b { font-size: 14px; }
.pillar .s { font-size: 22px; font-weight: 800; }
.bar { height: 6px; border-radius: 6px; background: #0c1220; overflow: hidden; margin: 8px 0 8px; }
.bar i { display: block; height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--mint), var(--gold)); }
.pillar p { margin: 0; color: var(--dim); font-size: 13px; line-height: 1.35; }

/* photo + mesh */
.photo { position: relative; border-radius: var(--r); overflow: hidden; background: #000; border: 1px solid var(--line); }
.photo canvas, .photo img { display: block; width: 100%; height: auto; }
.photo .tag { position: absolute; left: 10px; bottom: 10px; }
.scanline { position: absolute; left: 0; right: 0; height: 3px; background: linear-gradient(90deg, transparent, var(--mint), transparent); box-shadow: 0 0 18px 4px rgba(94,234,212,.5); animation: sweep 1.4s ease-in-out infinite alternate; }
@keyframes sweep { from { top: 6%; } to { top: 92%; } }

/* traits */
details.trait { border-top: 1px solid var(--line); }
details.trait:first-of-type { border-top: 0; }
details.trait summary { list-style: none; display: flex; align-items: center; gap: 10px; padding: 12px 2px; cursor: pointer; }
details.trait summary::-webkit-details-marker { display: none; }
.trait .name { flex: 1; min-width: 0; }
.trait .name small { display: block; color: var(--dim); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pill { min-width: 42px; text-align: center; padding: 4px 8px; border-radius: 10px; font-weight: 800; font-size: 14px; }
.pill.hi { background: #0f2c24; color: var(--good); } .pill.mid { background: #2a2410; color: var(--gold); } .pill.lo { background: #2f1519; color: var(--bad); }
.train { font-size: 11px; padding: 3px 7px; border-radius: 8px; text-transform: uppercase; letter-spacing: .5px; font-weight: 700; }
.train.yes { background: #0f2c24; color: var(--mint); } .train.partly { background: #1c2340; color: var(--sky); } .train.no { background: #1d2230; color: #8b95a8; }
.trait .body { padding: 0 2px 14px; color: var(--dim); font-size: 14px; }
.trait .body p { margin: 4px 0; }
details.group > summary { list-style: none; display: flex; justify-content: space-between; align-items: center; cursor: pointer; padding: 2px 0; }
details.group > summary::-webkit-details-marker { display: none; }
details.group > summary::after { content: '+'; color: var(--dim); font-size: 22px; line-height: 1; }
details.group[open] > summary::after { content: '–'; }
details.group > summary h2 { margin: 0; }

/* plan */
.lever { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-top: 1px solid var(--line); }
.lever:first-of-type { border-top: 0; }
.lever .ic { width: 34px; height: 34px; flex: 0 0 34px; border-radius: 10px; display: grid; place-items: center; background: #0f2c24; color: var(--mint); font-weight: 800; }
.lever p { margin: 2px 0 0; color: var(--dim); font-size: 13.5px; }
.check { display: flex; gap: 12px; align-items: flex-start; padding: 9px 0; cursor: pointer; }
.check input { appearance: none; width: 22px; height: 22px; flex: 0 0 22px; border-radius: 7px; border: 2px solid var(--line); margin: 1px 0 0; display: grid; place-items: center; cursor: pointer; }
.check input:checked { background: var(--mint); border-color: var(--mint); }
.check input:checked::after { content: ''; width: 6px; height: 11px; border: solid #06201c; border-width: 0 2.5px 2.5px 0; transform: rotate(45deg) translate(-1px, -1px); }
.check span small { display: block; color: var(--dim); font-size: 12px; }
.check input:checked + span { color: var(--dim); text-decoration: line-through; }
.weektabs { display: flex; gap: 6px; margin: 4px 0 8px; }
.weektabs button { flex: 1; padding: 8px 0; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--dim); font-size: 13.5px; cursor: pointer; }
.weektabs button.on { background: #0f2c24; color: var(--mint); border-color: #1d5248; font-weight: 700; }

/* scan steps */
.steps { display: flex; gap: 6px; margin-bottom: 6px; }
.steps i { flex: 1; height: 4px; border-radius: 4px; background: var(--line); }
.steps i.on { background: linear-gradient(90deg, var(--mint), var(--gold)); }
.guide { display: grid; grid-template-columns: 110px 1fr; gap: 16px; align-items: center; }
.guide svg { width: 110px; height: auto; }
.tips { list-style: none; padding: 0; margin: 0; }
.tips li { display: flex; gap: 9px; align-items: flex-start; padding: 5px 0; font-size: 14.5px; }
.tips li::before { content: ''; flex: 0 0 8px; height: 8px; margin-top: 7px; border-radius: 50%; background: var(--mint); }
.file { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.issues { margin: 10px 0 0; padding: 10px 12px; border-radius: 12px; background: #221d0b; border: 1px solid #4b3f13; color: #fde68a; font-size: 14px; }
.issues p { margin: 3px 0; }
.err { background: #2f1519; border-color: #5b2330; color: #fecaca; }

/* progress */
.weekcard { display: flex; align-items: center; justify-content: space-between; }
.weekcard .w { color: var(--dim); font-weight: 700; letter-spacing: 1px; font-size: 13px; }
.weekcard .big { font-size: 46px; font-weight: 800; letter-spacing: -1px; line-height: 1; }
.delta { font-weight: 800; font-size: 18px; }
.delta.up { color: var(--good); } .delta.down { color: var(--bad); } .delta.flat { color: var(--dim); }
.past { display: flex; gap: 8px; margin-top: 14px; overflow-x: auto; padding-bottom: 4px; }
.past span { flex: 0 0 auto; padding: 8px 12px; border-radius: 12px; background: var(--card); border: 1px solid var(--line); font-weight: 700; }
.past span.last { border-color: #1d5248; color: var(--mint); }
.chart svg { width: 100%; height: auto; display: block; }
.scanrow { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.scanrow:first-of-type { border-top: 0; }
.scanrow img { width: 52px; height: 52px; object-fit: cover; border-radius: 12px; flex: 0 0 52px; }
.scanrow a { flex: 1; text-decoration: none; display: flex; align-items: center; gap: 12px; min-width: 0; }
.scanrow .meta { flex: 1; min-width: 0; }
.scanrow .meta small { display: block; color: var(--dim); font-size: 12.5px; }
.scanrow .sc { font-weight: 800; font-size: 20px; }
.iconbtn { background: none; border: 0; padding: 10px; border-radius: 10px; color: var(--dim); cursor: pointer; }
.iconbtn:hover { background: var(--card2); color: var(--bad); }
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.compare figure { margin: 0; }
.compare img { width: 100%; aspect-ratio: 3/4; object-fit: cover; border-radius: 14px; border: 1px solid var(--line); }
.compare figcaption { text-align: center; color: var(--dim); font-size: 13px; margin-top: 5px; }

input[type=password], input[type=text] { width: 100%; padding: 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg2); color: var(--text); font-size: 16px; margin: 8px 0 12px; }
#toast { position: fixed; left: 50%; bottom: calc(22px + env(safe-area-inset-bottom)); transform: translate(-50%, 30px); opacity: 0; transition: .25s; background: #0f2c24; color: var(--mint); border: 1px solid #1d5248; padding: 10px 16px; border-radius: 12px; font-weight: 600; z-index: 20; pointer-events: none; max-width: 90vw; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
.spin { width: 22px; height: 22px; border-radius: 50%; border: 3px solid rgba(255,255,255,.15); border-top-color: var(--mint); animation: rot .8s linear infinite; }
@keyframes rot { to { transform: rotate(360deg); } }
.center { text-align: center; }
.fade { animation: fade .35s ease both; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .fade, .scanline, .spin { animation: none; } }
