/* Neutral grays on purpose: a colored UI would bias how swatches are perceived. */
:root {
  --bg: #ececea; --card: #f8f8f7; --ink: #1d1d1c; --muted: #6b6b68; --line: #d5d5d2;
  --accent: #2d2d2c; --accent-ink: #fff; --ok: #2e7d4f; --warn: #a15c00; --bad: #b3261e;
  --radius: 14px; --tab-h: 62px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #2a2a29; --card: #343433; --ink: #ececea; --muted: #a5a5a1; --line: #4a4a48; --accent: #ececea; --accent-ink: #1d1d1c; --ok: #7bc796; --warn: #e3a94e; --bad: #f08a80; }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 12px); line-height: 1.45; font-size: 16px; }
body.noscroll { overflow: hidden; }
body.logged-out .tabbar, body.logged-out .topbar .icon-btn { display: none; }
a { color: inherit; }
h1 { font-size: 1.5rem; margin: .2rem 0 .6rem; } h2 { font-size: 1.15rem; margin: .1rem 0 .6rem; } h3 { font-size: 1rem; margin: 1.1rem 0 .4rem; }
p { margin: .4rem 0 .7rem; }
.muted { color: var(--muted); } .small { font-size: .86rem; } .ok { color: var(--ok); font-weight: 600; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; padding: calc(env(safe-area-inset-top) + 8px) 14px 8px; background: var(--bg); background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px); }
.brand { font-weight: 700; text-decoration: none; font-size: 1.1rem; display: flex; align-items: center; gap: .4rem; }
.logo { font-size: 1.4rem; }
main { max-width: 760px; margin: 0 auto; padding: 4px 12px; }
.card { background: var(--card); border-radius: var(--radius); padding: 14px 16px; margin: 12px 0; box-shadow: 0 1px 0 var(--line); }
.card.subtle { background: transparent; box-shadow: none; padding: 6px 4px; }
.notice { background: color-mix(in srgb, var(--warn) 14%, var(--card)); border-radius: 10px; padding: 10px 12px; }
.row { display: flex; align-items: center; } .row.gap { gap: 10px; } .row.wrap { flex-wrap: wrap; } .row.between { justify-content: space-between; } .row.center { align-items: center; } .grow { flex: 1; min-width: 0; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 44px; padding: 0 16px; border-radius: 12px; border: 1.5px solid var(--accent); background: transparent; color: var(--ink); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.ghost { border-color: var(--line); }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.small { min-height: 36px; padding: 0 12px; font-size: .9rem; }
.btn.big { min-height: 60px; font-size: 1.1rem; width: 100%; }
.btn.wide { width: 100%; margin-top: 10px; }
.btn:disabled { opacity: .5; }
.icon-btn { background: none; border: 0; font-size: 1.3rem; min-width: 44px; min-height: 44px; color: var(--ink); text-decoration: none; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
input, select { font: inherit; color: var(--ink); background: var(--bg); border: 1.5px solid var(--line); border-radius: 10px; min-height: 44px; padding: 0 10px; }
input[type=color] { padding: 2px; width: 64px; }
input[type=checkbox] { min-height: 0; width: 20px; height: 20px; accent-color: var(--accent); }
input[type=range] { width: 100%; accent-color: var(--accent); padding: 0; border: 0; background: none; }
.form label { display: flex; flex-direction: column; gap: 4px; margin: 10px 0; font-weight: 600; font-size: .95rem; }
.toggle { display: flex; align-items: center; gap: 8px; font-size: .92rem; margin: 8px 0; cursor: pointer; }
.login { text-align: center; max-width: 380px; margin: 12vh auto; display: flex; flex-direction: column; gap: 10px; }
.logo-big { font-size: 3rem; } .err { color: var(--bad); min-height: 1.2em; }
.hero h1 { font-size: 1.6rem; }
.steps { padding-left: 1.3rem; } .steps li { margin: .35rem 0; }

/* tab bar */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; height: var(--tab-h); text-decoration: none; font-size: .72rem; color: var(--muted); gap: 2px; }
.tabbar a span { font-size: 1.25rem; filter: grayscale(1); }
.tabbar a.active { color: var(--ink); font-weight: 700; } .tabbar a.active span { filter: none; }

/* home */
.home-actions { margin-top: 10px; } .upload { cursor: pointer; }
.section-title { margin: 18px 4px 8px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.proj { background: var(--card); border-radius: var(--radius); overflow: hidden; text-decoration: none; display: flex; flex-direction: column; }
.proj img { width: 100%; aspect-ratio: 1; object-fit: cover; background: var(--line); }
.proj-sw { display: flex; height: 12px; } .proj-sw i { flex: 1; }
.proj-name { padding: 8px 10px; font-weight: 600; font-size: .92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* project */
.proj-head { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-top: 6px; }
.title-input { font-size: 1.2rem; font-weight: 700; background: transparent; border-color: transparent; flex: 1; min-width: 180px; }
.title-input:focus { border-color: var(--line); }
.seg { display: inline-flex; border: 1.5px solid var(--line); border-radius: 12px; overflow: hidden; flex-wrap: wrap; }
.seg button { font: inherit; font-weight: 600; background: transparent; color: var(--ink); border: 0; padding: 0 14px; min-height: 40px; cursor: pointer; }
.seg button.on { background: var(--accent); color: var(--accent-ink); }
.seg.small button { padding: 0 10px; font-size: .9rem; }
.pick-host { margin: 10px 0 4px; display: flex; justify-content: center; }
.picker { position: relative; touch-action: none; user-select: none; -webkit-user-select: none; display: inline-block; max-width: 100%; }
.picker-img { max-width: 100%; max-height: 62vh; border-radius: 10px; display: block; cursor: crosshair; }
.loupe { position: absolute; width: 120px; height: 120px; display: none; pointer-events: none; z-index: 5; filter: drop-shadow(0 3px 6px #0006); }
.marker-layer { position: absolute; inset: 0; pointer-events: none; }
.marker { position: absolute; width: 26px; height: 26px; margin: -13px 0 0 -13px; border-radius: 50%; border: 2.5px solid #fff; box-shadow: 0 0 0 1.5px #000; font-size: .72rem; font-weight: 800; color: #fff; text-shadow: 0 0 3px #000; display: flex; align-items: center; justify-content: center; }
.hint { text-align: center; color: var(--muted); font-size: .86rem; margin: 2px 0 6px; }
.slider-row { display: flex; align-items: center; gap: 10px; margin: 6px 0 10px; font-size: .95rem; } .slider-row input { flex: 1; }
.pal { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.pal-row { display: flex; align-items: center; gap: 12px; padding: 6px; border-radius: 12px; border: 0; background: transparent; color: var(--ink); font: inherit; text-align: left; cursor: pointer; width: 100%; }
.pal-row:active { background: var(--bg); }
.pal-info { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.rec-line { margin-top: 2px; }
.chev { font-size: 1.6rem; color: var(--muted); }
.sw { display: inline-flex; align-items: center; justify-content: center; border-radius: 10px; flex: none; box-shadow: inset 0 0 0 1px #0002; font-size: .7rem; font-weight: 700; vertical-align: middle; }
.chip { display: inline-flex; border-radius: 50%; overflow: hidden; flex: none; box-shadow: inset 0 0 0 1px #0002, 0 0 0 1px #0001; vertical-align: middle; }
.chip i { flex: 1; }
.valstrip .vs { display: flex; height: 44px; border-radius: 8px; overflow: hidden; }
.valstrip .vs.gray { height: 22px; margin-top: 4px; }
.valstrip .vs > div { display: flex; align-items: center; justify-content: center; font-size: .72rem; font-weight: 700; min-width: 22px; }
.wheel svg { width: 100%; max-width: 320px; display: block; margin: 0 auto; }
.rel { padding-left: 0; list-style: none; } .rel li { margin: 8px 0; } .rel .sw { margin-right: 3px; border-radius: 5px; }
.canvas-size label { display: flex; flex-direction: column; font-size: .85rem; font-weight: 600; } .canvas-size input { width: 90px; }
.hist-bars { display: flex; align-items: flex-end; gap: 3px; height: 80px; margin-top: 14px; overflow: hidden; } .hist-bars div { flex: 1; border-radius: 3px 3px 0 0; box-shadow: inset 0 0 0 1px #0002; }
.fam { margin: 10px 0; } .fam-sw { display: flex; gap: 6px; margin-top: 4px; }
.fam-btn { flex: 1; min-height: 56px; border-radius: 10px; border: 0; font: inherit; font-size: .8rem; font-weight: 700; cursor: pointer; box-shadow: inset 0 0 0 1px #0002; }

/* sheet */
.sheet-wrap { position: fixed; inset: 0; z-index: 50; }
.sheet-backdrop { position: absolute; inset: 0; background: #0008; opacity: 0; transition: opacity .2s; }
.sheet { position: absolute; left: 0; right: 0; bottom: 0; max-height: 92vh; background: var(--card); border-radius: 18px 18px 0 0; transform: translateY(100%); transition: transform .22s ease-out; display: flex; flex-direction: column; max-width: 760px; margin: 0 auto; }
.sheet-wrap.open .sheet { transform: none; } .sheet-wrap.open .sheet-backdrop { opacity: 1; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 8px 4px 16px; } .sheet-head h2 { margin: 0; }
.sheet-body { overflow-y: auto; padding: 4px 16px calc(20px + env(safe-area-inset-bottom)); -webkit-overflow-scrolling: touch; }
.compare { display: flex; gap: 10px; } .compare > div { flex: 1; text-align: center; font-size: .82rem; color: var(--muted); }
.big-sw { height: 96px; border-radius: 12px; box-shadow: inset 0 0 0 1px #0002; margin-bottom: 4px; }
.verdict { font-weight: 600; } .v-great, .v-good { color: var(--ok); } .v-ok { color: var(--warn); } .v-far, .v-out { color: var(--bad); }
.recipe { list-style: none; padding: 0; margin: 0; } .recipe li { display: flex; gap: 12px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.howto li { margin: 4px 0; }
.alt { display: flex; align-items: center; gap: 8px; margin: 8px 0; font-size: .92rem; }
.actions { margin-top: 16px; }
details summary { cursor: pointer; font-weight: 600; padding: 6px 0; }
.progress { height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; } .progress i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.buy, .shop, .cal-list { list-style: none; padding: 0; } .buy li { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); } .buy li > div { flex: 1; }
.shop li, .cal-list li { display: flex; align-items: center; gap: 8px; margin: 6px 0; }

/* paints */
.paint-row { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.paint-row:last-child { border-bottom: 0; }
.paint-info { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.paint-row select { width: 118px; min-height: 40px; font-size: .9rem; }
.paint-row.st-none { opacity: .72; } .paint-row.st-out .paint-info b { text-decoration: line-through; }
.fam-title { text-transform: capitalize; }
.caltab { width: 100%; border-collapse: collapse; font-size: .9rem; } .caltab td, .caltab th { padding: 6px 4px; border-bottom: 1px solid var(--line); text-align: left; }
.sticky-step { position: sticky; top: calc(env(safe-area-inset-top) + 56px); z-index: 10; }
.step-label { margin: 0 0 8px; }

/* check */
.choose { display: flex; flex-wrap: wrap; gap: 8px; }
.choice { min-height: 48px; padding: 4px 12px; border-radius: 10px; border: 2px solid transparent; font: inherit; font-size: .85rem; font-weight: 700; cursor: pointer; box-shadow: inset 0 0 0 1px #0002; display: inline-flex; align-items: center; gap: 6px; }
.choice.on { border-color: var(--ink); outline: 2px solid var(--card); outline-offset: -4px; }
.choice.other { background: var(--bg); color: var(--ink); }
.fix { font-size: 1.1rem; font-weight: 700; }
.mix-name { font-weight: 700; border-color: transparent; background: transparent; padding: 0; min-height: 32px; width: 100%; }
.lesson summary { font-size: 1.02rem; }

.spin-wrap { display: flex; align-items: center; gap: 10px; padding: 24px; justify-content: center; color: var(--muted); }
.spinner { width: 22px; height: 22px; border: 3px solid var(--line); border-top-color: var(--ink); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#toast { position: fixed; left: 50%; bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 14px); transform: translateX(-50%) translateY(20px); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; opacity: 0; transition: .2s; z-index: 60; max-width: 90vw; font-size: .92rem; pointer-events: none; }
#toast.show { opacity: 1; transform: translateX(-50%); }
