/* IBI Palmistry — night-indigo and gold, light and dark. Phone first: edge-to-edge below 640px. */
:root {
  --ts: 1;
  --bg: #faf6ee; --bg2: #f1eadb; --card: #ffffff; --ink: #1d1530; --muted: #5b5274; --line: rgba(29, 21, 48, .12);
  --gold: #9a6a12; --gold-2: #c08a26; --gold-ink: #ffffff; --accent: #0369a1; --danger: #b42318;
  --shadow: 0 6px 24px rgba(40, 24, 80, .08);
  --l-life: #0e9f5a; --l-head: #0b84c6; --l-heart: #d6336c; --l-fate: #c98a00; --l-sun: #e8590c; --l-mercury: #7048e8; --l-marriage: #c2255c;
  --radius: 16px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0f0b24; --bg2: #17112f; --card: #1c1538; --ink: #f3eefc; --muted: #b9aed8; --line: rgba(255, 255, 255, .10);
  --gold: #ecbe5c; --gold-2: #f6d58a; --gold-ink: #1a1206; --accent: #35c0ed; --danger: #ff7b72;
  --shadow: 0 8px 30px rgba(0, 0, 0, .35);
  --l-life: #4ade80; --l-head: #38bdf8; --l-heart: #ff5c8a; --l-fate: #facc15; --l-sun: #fb923c; --l-mercury: #a78bfa; --l-marriage: #f472b6;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: calc(16px * var(--ts)) / 1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  min-height: 100dvh;
}
:root[data-theme="dark"] body { background: radial-gradient(1200px 600px at 80% -10%, #2a1a5e 0%, transparent 60%), var(--bg); }
h1, h2, h3 { font-family: Georgia, "Times New Roman", serif; line-height: 1.2; margin: 0 0 .4em; }
h1 { font-size: calc(28px * var(--ts)); }
h2 { font-size: calc(20px * var(--ts)); }
a { color: var(--accent); }
small { font-size: calc(13px * var(--ts)); }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 8px; top: 8px; z-index: 99; background: var(--card); padding: 8px; }
.grow { flex: 1; }
.center { text-align: center; }
.c-life { color: var(--l-life); } .c-head { color: var(--l-head); } .c-heart { color: var(--l-heart); } .c-fate { color: var(--l-fate); }

/* header */
.top {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px;
  padding: 8px 16px; padding-top: max(8px, env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.app-version-badge {
  font: 700 calc(12px * var(--ts)) / 1 system-ui, sans-serif; padding: 4px 7px; border-radius: 999px;
  background: var(--gold); color: var(--gold-ink); letter-spacing: .02em; flex: 0 0 auto;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; min-width: 0; }
.logo { height: 34px; width: auto; }
.logo-light { display: none; }
:root[data-theme="light"] .logo-dark { display: none; }
:root[data-theme="light"] .logo-light { display: block; }
.brand-name { font: 700 calc(20px * var(--ts)) Georgia, serif; color: var(--gold); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top .btn { white-space: nowrap; flex: 0 0 auto; }
.top .switch, .top .icon-btn { flex: 0 0 auto; }
.icon-btn {
  min-width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--card);
  color: var(--ink); font-size: 20px; cursor: pointer;
}
/* the switch */
.switch { position: relative; display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.track { width: 48px; height: 28px; border-radius: 999px; background: var(--bg2); border: 1px solid var(--line); position: relative; transition: background .2s; }
.knob { position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--gold); transition: transform .2s; }
.switch input:checked + .track { background: color-mix(in srgb, var(--gold) 30%, var(--bg2)); }
.switch input:checked + .track .knob { transform: translateX(20px); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }
.sw-ico { font-size: 16px; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 18px;
  border-radius: 12px; border: 1px solid transparent; font: 600 calc(16px * var(--ts)) / 1.2 system-ui, sans-serif;
  cursor: pointer; text-decoration: none; transition: transform .08s, filter .2s;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-lg { min-height: 52px; padding: 12px 22px; font-size: calc(17px * var(--ts)); }
.btn-sm { min-height: 38px; padding: 6px 12px; font-size: calc(14px * var(--ts)); }
.btn-gold { background: linear-gradient(180deg, var(--gold-2), var(--gold)); color: var(--gold-ink); box-shadow: 0 4px 18px color-mix(in srgb, var(--gold) 35%, transparent); }
:root[data-theme="light"] .btn-gold { background: var(--gold); }
.btn-ghost { background: var(--card); color: var(--ink); border-color: var(--line); }
.btn-danger-ghost { background: var(--card); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }

/* layout */
main { max-width: 860px; margin: 0 auto; padding: 16px; }
.view { display: flex; flex-direction: column; gap: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); min-width: 0; }
.card.flush { padding: 0; overflow: hidden; }
.pad { padding: 16px 20px 20px; }
.hint { color: var(--muted); margin: 0 0 12px; font-size: calc(15px * var(--ts)); }
.micro { color: var(--muted); font-size: calc(13px * var(--ts)); margin: 10px 0 0; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.actions { display: flex; gap: 10px; margin-top: 12px; }
.actions.wrap { flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-bottom: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span { font-weight: 600; font-size: calc(14px * var(--ts)); }
.field small { color: var(--muted); font-weight: 400; }
input[type=text], input[type=date], select {
  width: 100%; min-height: 48px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--bg); color: var(--ink); font: calc(16px * var(--ts)) system-ui, sans-serif;
}
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.seg button { min-height: 48px; border: 0; background: var(--bg); color: var(--ink); font: 600 calc(15px * var(--ts)) system-ui, sans-serif; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-checked="true"] { background: var(--gold); color: var(--gold-ink); }

/* hero */
.hero { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 20px; align-items: center; padding: 12px 4px; }
.kicker { text-transform: uppercase; letter-spacing: .12em; font-size: calc(12px * var(--ts)); color: var(--gold); font-weight: 700; margin: 0 0 6px; }
.hero h1 { font-size: calc(36px * var(--ts)); }
.lead { font-size: calc(17px * var(--ts)); color: var(--muted); margin: 0 0 16px; }
.cta { display: flex; gap: 12px; flex-wrap: wrap; }
.hero-art { position: relative; aspect-ratio: 200/240; max-width: 320px; width: 100%; justify-self: center; border-radius: 24px; overflow: hidden;
  background: radial-gradient(circle at 50% 45%, color-mix(in srgb, var(--gold) 22%, transparent), transparent 65%); }
.palm-svg { width: 100%; height: 100%; }
.palm-outline { fill: color-mix(in srgb, var(--gold) 16%, transparent); stroke: var(--gold); stroke-width: 2; }
.pl { fill: none; stroke-width: 3.2; stroke-linecap: round; stroke-dasharray: 160; stroke-dashoffset: 160; animation: draw 2.4s ease forwards; }
.pl-heart { stroke: var(--l-heart); animation-delay: .2s; } .pl-head { stroke: var(--l-head); animation-delay: .7s; }
.pl-life { stroke: var(--l-life); animation-delay: 1.2s; } .pl-fate { stroke: var(--l-fate); animation-delay: 1.7s; }
@keyframes draw { to { stroke-dashoffset: 0; } }
.scan-beam { position: absolute; left: 0; right: 0; height: 3px; top: 0; background: linear-gradient(90deg, transparent, var(--gold-2), transparent);
  box-shadow: 0 0 18px 6px color-mix(in srgb, var(--gold) 55%, transparent); animation: beam 2.6s ease-in-out infinite; }
@keyframes beam { 0% { top: 4%; } 50% { top: 94%; } 100% { top: 4%; } }
@media (prefers-reduced-motion: reduce) { .scan-beam, .cam-beam, .pl, .bar i { animation: none !important; } .pl { stroke-dashoffset: 0; } }

.tips { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.tips li { display: flex; gap: 12px; align-items: flex-start; }
.tips li > span { font-size: 26px; line-height: 1; }
.tips b { display: block; } .tips small { color: var(--muted); }
.legend-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 18px; }
.legend-grid > div { display: grid; grid-template-columns: 18px minmax(0, 1fr); column-gap: 8px; }
.legend-grid small { grid-column: 2; color: var(--muted); }
.dot { width: 14px; height: 14px; border-radius: 50%; background: var(--c); margin-top: 5px; box-shadow: 0 0 8px var(--c); }
.disclaimer { color: var(--muted); font-size: calc(13px * var(--ts)); text-align: center; margin: 4px 12px 8px; }

/* photo */
.photo-wrap { position: relative; background: #000; display: flex; justify-content: center; overflow: hidden; }
.photo-wrap img, .photo-wrap canvas { display: block; max-width: 100%; max-height: 70dvh; width: auto; height: auto; }
.photo-wrap.result canvas { cursor: pointer; }
.scanning img { filter: saturate(.8) brightness(.85); }
.scan-grid { position: absolute; inset: 0; background-image: linear-gradient(color-mix(in srgb, var(--gold) 18%, transparent) 1px, transparent 1px), linear-gradient(90deg, color-mix(in srgb, var(--gold) 18%, transparent) 1px, transparent 1px); background-size: 32px 32px; mix-blend-mode: screen; pointer-events: none; }
.bar { height: 6px; border-radius: 999px; background: var(--bg2); overflow: hidden; margin: 12px auto 14px; max-width: 360px; }
.bar i { display: block; height: 100%; width: 40%; border-radius: inherit; background: var(--gold); animation: slide 1.4s ease-in-out infinite; }
@keyframes slide { 0% { transform: translateX(-100%); } 100% { transform: translateX(260%); } }

/* result */
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--bg); color: var(--ink); font: 600 calc(14px * var(--ts)) system-ui, sans-serif; cursor: pointer; }
.chip i { width: 12px; height: 12px; border-radius: 50%; background: var(--c); box-shadow: 0 0 6px var(--c); }
.chip[aria-pressed="true"] { border-color: var(--c); box-shadow: 0 0 0 2px color-mix(in srgb, var(--c) 40%, transparent) inset; }
.chip.off { opacity: .5; }
.toggles { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 12px; }
.mini-switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: calc(14px * var(--ts)); min-height: 36px; }
.mini-switch input { position: absolute; opacity: 0; }
.mini-switch span { width: 38px; height: 22px; border-radius: 999px; background: var(--bg2); border: 1px solid var(--line); position: relative; }
.mini-switch span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--muted); transition: transform .2s; }
.mini-switch input:checked + span::after { transform: translateX(16px); background: var(--gold); }
.mini-switch input:focus-visible + span { outline: 2px solid var(--accent); }
.headline-card h1 { font-size: calc(30px * var(--ts)); }
.badges { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0; }
.badge { padding: 5px 11px; border-radius: 999px; background: var(--bg2); border: 1px solid var(--line); font-size: calc(14px * var(--ts)); font-weight: 600; }
.badge.gold { background: color-mix(in srgb, var(--gold) 18%, var(--card)); border-color: color-mix(in srgb, var(--gold) 50%, transparent); }
.stamp { color: var(--muted); font-size: calc(13px * var(--ts)); margin: 6px 0 0; }
.section-nav { position: sticky; top: 61px; z-index: 10; display: flex; gap: 8px; overflow-x: auto; padding: 8px 2px; background: var(--bg); scrollbar-width: none; }
.section-nav::-webkit-scrollbar { display: none; }
.section-nav a { flex: 0 0 auto; padding: 7px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--ink); text-decoration: none; font-weight: 600; font-size: calc(14px * var(--ts)); }
.card[id^="s"] { scroll-margin-top: 120px; }
.traits { display: grid; gap: 10px; margin: 14px 0; }
.trait { display: grid; grid-template-columns: minmax(0, 9rem) minmax(0, 1fr) 2.6rem; gap: 10px; align-items: center; }
.trait b { font-size: calc(15px * var(--ts)); overflow-wrap: anywhere; }
.trait .meter { height: 10px; border-radius: 999px; background: var(--bg2); overflow: hidden; }
.trait .meter i { display: block; height: 100%; background: linear-gradient(90deg, var(--gold), var(--gold-2)); border-radius: inherit; }
.trait em { font-style: normal; color: var(--muted); font-size: calc(14px * var(--ts)); text-align: right; }
.trait small { grid-column: 1 / -1; color: var(--muted); margin-top: -6px; }
.two-lists { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.two-lists h3 { font-size: calc(16px * var(--ts)); font-family: system-ui, sans-serif; }
.two-lists ul { margin: 0; padding-left: 20px; }
.now-rows { display: grid; gap: 12px; }
.now-row { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 12px; align-items: start; }
.now-row > span { font-size: 24px; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; background: var(--bg2); }
.now-row b { display: block; }
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 21px; top: 8px; bottom: 8px; width: 2px; background: linear-gradient(var(--gold), color-mix(in srgb, var(--gold) 15%, transparent)); }
.timeline li { position: relative; display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 12px; padding: 8px 0; }
.timeline .ti { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-size: 22px; background: var(--card); border: 2px solid var(--gold); z-index: 1; }
.timeline .when { color: var(--gold); font-weight: 700; font-size: calc(14px * var(--ts)); }
.timeline b { display: block; font-size: calc(17px * var(--ts)); }
.timeline p { margin: 2px 0 0; color: var(--muted); }
.from { display: inline-block; margin-top: 4px; font-size: calc(12px * var(--ts)); color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; }
.vital { display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: 14px; align-items: center; padding: 12px 14px; margin-bottom: 14px; border-radius: 14px; border: 1px solid color-mix(in srgb, var(--l-life) 45%, transparent); background: color-mix(in srgb, var(--l-life) 9%, var(--card)); }
.vital-score { width: 72px; height: 72px; border-radius: 50%; display: grid; place-content: center; text-align: center; border: 3px solid var(--l-life); }
.vital-score b { font-size: calc(26px * var(--ts)); line-height: 1; }
.vital-score small { color: var(--muted); }
.vital p { margin: 4px 0; }
.eng-list { display: grid; gap: 8px; margin: 8px 0 14px; }
.eng { display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: 10px; align-items: start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; }
.eng input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--gold); }
.eng small { display: block; color: var(--muted); }
.eng:has(input:checked) { border-color: var(--gold); background: color-mix(in srgb, var(--gold) 10%, var(--card)); }
.eng.off { opacity: .55; cursor: not-allowed; }
.modal-body .field { margin-bottom: 10px; }
.modal-body input[readonly] { color: var(--muted); }
.line-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.line-card { text-align: left; border: 1px solid var(--line); border-left: 5px solid var(--c); border-radius: 12px; background: var(--bg); color: var(--ink); padding: 12px 14px; font: inherit; cursor: pointer; min-width: 0; }
.line-card h3 { font-family: system-ui, sans-serif; font-size: calc(16px * var(--ts)); display: flex; justify-content: space-between; gap: 8px; }
.line-card .obs { color: var(--muted); font-size: calc(14px * var(--ts)); margin: 0 0 6px; }
.line-card p { margin: 0; }
.line-card.missing { opacity: .7; cursor: default; }
.tag { font: 600 calc(12px * var(--ts)) system-ui, sans-serif; padding: 2px 8px; border-radius: 999px; background: var(--bg2); color: var(--muted); white-space: nowrap; }
.mounts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 12px; }
.mount { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.mount b { display: flex; justify-content: space-between; gap: 6px; }
.mount p { margin: 4px 0 0; color: var(--muted); font-size: calc(14px * var(--ts)); }
.lucky { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 12px; }
.lucky div { text-align: center; padding: 12px 6px; border-radius: 12px; background: var(--bg2); }
.lucky small { display: block; color: var(--muted); }
.lucky b { font-size: calc(18px * var(--ts)); }
.advice { margin: 8px 0 0; padding-left: 20px; }
.advice li { margin-bottom: 6px; }

/* history */
.hist-list { display: grid; gap: 10px; }
.hist { display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 8px; border: 1px solid var(--line); border-radius: 14px; background: var(--bg); }
.hist img, .hist .noimg { width: 64px; height: 64px; object-fit: cover; border-radius: 10px; background: var(--bg2); display: grid; place-items: center; font-size: 28px; }
.hist button.open { all: unset; cursor: pointer; display: block; min-width: 0; }
.hist button.open:focus-visible { outline: 2px solid var(--accent); }
.hist b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hist small { color: var(--muted); display: block; }

/* footer */
.foot { text-align: center; color: var(--muted); padding: 12px 16px calc(24px + env(safe-area-inset-bottom)); font-size: calc(14px * var(--ts)); }
.foot p { margin: 4px 0; }

/* camera */
.camera { position: fixed; inset: 0; z-index: 60; background: #000; color: #fff; overflow: hidden; }
.camera video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.camera video.mirror { transform: scaleX(-1); }
.hand-guide { position: absolute; left: 50%; top: 50%; width: min(78vw, 56dvh); height: min(98vw, 70dvh); transform: translate(-50%, -48%); pointer-events: none; }
.hand-guide path { fill: rgba(236, 190, 92, .08); stroke: #ecbe5c; stroke-width: 2.2; stroke-dasharray: 7 6; filter: drop-shadow(0 0 6px rgba(236, 190, 92, .7)); }
.cam-beam { position: absolute; left: 8%; right: 8%; height: 3px; top: 10%; background: linear-gradient(90deg, transparent, #f6d58a, transparent); box-shadow: 0 0 22px 8px rgba(236, 190, 92, .45); animation: beam 3s ease-in-out infinite; pointer-events: none; }
.cam-top, .cam-bottom { position: absolute; left: 0; right: 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; }
.cam-top { top: 0; padding-top: max(12px, env(safe-area-inset-top)); background: linear-gradient(rgba(0, 0, 0, .65), transparent); }
.cam-top p { margin: 0; text-align: center; font-weight: 600; font-size: calc(16px * var(--ts)); text-shadow: 0 1px 4px #000; flex: 1; }
.cam-bottom { bottom: 0; padding-bottom: max(20px, env(safe-area-inset-bottom)); background: linear-gradient(transparent, rgba(0, 0, 0, .7)); }
.cam-btn { width: 52px; height: 52px; border-radius: 50%; border: 1px solid rgba(255, 255, 255, .35); background: rgba(0, 0, 0, .45); color: #fff; font-size: 22px; cursor: pointer; display: grid; place-items: center; flex: 0 0 auto; }
.cam-btn.ghost { visibility: hidden; }
.shutter { width: 78px; height: 78px; border-radius: 50%; border: 4px solid #fff; background: transparent; padding: 5px; cursor: pointer; }
.shutter span { display: block; width: 100%; height: 100%; border-radius: 50%; background: #ecbe5c; transition: transform .1s; }
.shutter:active span { transform: scale(.9); }
.flash { animation: flash .3s ease; }
@keyframes flash { 0% { background: #fff; } 100% { background: #000; } }

/* drawer */
.scrim { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, .45); }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; z-index: 50; width: min(340px, 88vw); background: var(--card); border-left: 1px solid var(--line); display: flex; flex-direction: column; padding-top: env(safe-area-inset-top); }
.drawer-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.drawer-nav { overflow-y: auto; padding: 8px; display: flex; flex-direction: column; }
.drawer-nav > button, .drawer-nav > a { all: unset; display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 0 12px; border-radius: 10px; cursor: pointer; color: var(--ink); font-size: calc(16px * var(--ts)); }
.drawer-nav > button:hover, .drawer-nav > a:hover { background: var(--bg2); }
.drawer-nav > button:focus-visible, .drawer-nav > a:focus-visible { outline: 2px solid var(--accent); }
.drawer-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 52px; padding: 0 12px; font-size: calc(16px * var(--ts)); }
.drawer-row select { width: auto; min-height: 40px; }
.drawer hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; width: 100%; }

/* install bar */
.install-bar { position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 30; max-width: 560px; margin: 0 auto;
  display: grid; grid-template-columns: 44px minmax(0, 1fr) auto auto; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 16px;
  background: var(--card); border: 1px solid var(--line); box-shadow: 0 10px 40px rgba(0, 0, 0, .3); }
.install-bar img { border-radius: 10px; }
.install-bar small { display: block; color: var(--muted); }

/* modal */
.modal { position: fixed; inset: 0; z-index: 70; background: rgba(0, 0, 0, .55); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-box { background: var(--card); color: var(--ink); border-radius: 18px; width: min(520px, 100%); max-height: calc(100dvh - 32px); display: flex; flex-direction: column; border: 1px solid var(--line); }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 14px 16px 6px; }
.modal-head h2 { margin: 0; }
.modal-body { padding: 6px 16px 12px; overflow-y: auto; }
.modal-body ol, .modal-body ul { padding-left: 20px; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; padding: 12px 16px 16px; border-top: 1px solid var(--line); }
.modal-foot:empty { display: none; }

.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 90; background: var(--ink); color: var(--bg);
  padding: 12px 18px; border-radius: 12px; max-width: calc(100vw - 32px); box-shadow: 0 8px 30px rgba(0, 0, 0, .3); font-size: calc(15px * var(--ts)); }

/* tablets / small laptops */
@media (max-width: 820px) {
  .hero { grid-template-columns: minmax(0, 1fr); }
  .hero-art { max-width: 240px; order: -1; }
  .hero h1 { font-size: calc(30px * var(--ts)); }
}
/* phones: edge-to-edge — no outer gutters, square full-width cards */
@media (max-width: 640px) {
  main { padding: 0; }
  .view { gap: 8px; }
  .card { border-radius: 0; border-left: 0; border-right: 0; box-shadow: none; padding: 18px 16px; }
  .pad { padding: 14px 16px 18px; }
  .hero { padding: 16px; }
  .top { padding-left: 10px; padding-right: 10px; gap: 8px; }
  .logo { height: 28px; }
  .brand-name { font-size: calc(17px * var(--ts)); }
  .grid2, .tips, .legend-grid, .two-lists, .line-cards, .mounts { grid-template-columns: minmax(0, 1fr); }
  .cta .btn, .actions .btn { flex: 1 1 100%; }
  .actions { flex-direction: column; }
  .actions.wrap { flex-direction: row; }
  .actions.wrap .btn { flex: 1 1 calc(50% - 5px); padding-left: 8px; padding-right: 8px; }
  .section-nav { top: 57px; padding: 8px 10px; }
  .trait { grid-template-columns: minmax(0, 7.5rem) minmax(0, 1fr) 2.4rem; }
  .modal { padding: 0; align-items: flex-end; }
  .modal-box { border-radius: 18px 18px 0 0; width: 100%; max-height: 92dvh; }
  .modal-foot .btn { flex: 1 1 100%; }
  .install-bar { left: 0; right: 0; bottom: 0; border-radius: 16px 16px 0 0; padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
  .photo-wrap img, .photo-wrap canvas { max-height: 64dvh; }
}
@media (max-width: 480px) {
  .top > .switch { display: none; }          /* the dark-mode switch stays in the menu */
  .logo { height: 24px; }
  .top .btn-sm { padding: 6px 10px; }
}
@media (max-width: 400px) {
  .top { gap: 6px; padding-left: 8px; padding-right: 8px; }
  .brand { gap: 6px; }
  .app-version-badge { padding: 4px 5px; }
  .brand-name { font-size: calc(16px * var(--ts)); }
  .top .btn-sm { padding: 6px 8px; }
  .top .icon-btn { min-width: 42px; }
  .lucky { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}

/* print / PDF */
@media print {
  .top, .foot, .actions, .section-nav, .chips, .toggles, .install-bar, .drawer, .scrim, .toast, #vHome, #vHistory { display: none !important; }
  body { background: #fff !important; color: #000; }
  .card { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
  .photo-wrap { background: #fff; }
  .photo-wrap canvas { max-height: 120mm; }
}
