/* Layout: single-column phone app inside Telegram. Sticky top bar with the RPM cube colours as a three-segment rule,
   one screen per step, sticky action bar at the bottom. RPM EV screens switch to the navy EV palette. */
:root{
  --bg:#f3f4f2; --surface:#ffffff; --surface-2:#eef0ee; --ink:#141719; --ink-2:#4a5157; --muted:#7a8288; --line:#dfe3e0;
  --green:#109245; --sky:#08bdef; --blue:#1a5fb4; --accent:#1a5fb4; --accent-ink:#ffffff;
  --navy:#0b1430; --navy-2:#13204a; --navy-line:#25345f; --ev-blue:#17b6ee; --chrome:#c9cfdd;
  --ok:#109245; --danger:#c8372d;
  --f-display:"Barlow Condensed","Arial Narrow",Arial,sans-serif;
  --f-body:"Barlow","Noto Sans Khmer","Segoe UI",system-ui,sans-serif;
  --f-km:"Noto Sans Khmer","Barlow","Segoe UI",system-ui,sans-serif;
  --r:12px; --r-sm:8px;
  --shadow:0 1px 2px rgba(20,23,25,.06),0 6px 20px rgba(20,23,25,.06);
}
@media (prefers-color-scheme:dark){:root:not([data-theme="light"]){
  --bg:#0f1214; --surface:#181c1f; --surface-2:#20252a; --ink:#eef1f2; --ink-2:#b5bcc2; --muted:#8a9298; --line:#2b3237;
  --accent:#4f8fe0; --shadow:0 1px 2px rgba(0,0,0,.4); color-scheme:dark}}
:root[data-theme="dark"]{
  --bg:#0f1214; --surface:#181c1f; --surface-2:#20252a; --ink:#eef1f2; --ink-2:#b5bcc2; --muted:#8a9298; --line:#2b3237;
  --accent:#4f8fe0; --shadow:0 1px 2px rgba(0,0,0,.4); color-scheme:dark}

*{box-sizing:border-box}
html,body{height:100%}
body{margin:0;background:var(--bg);color:var(--ink);font-family:var(--f-body);font-size:15px;line-height:1.45;-webkit-font-smoothing:antialiased;-webkit-tap-highlight-color:transparent}
body.km{font-family:var(--f-km);line-height:1.7}
button,input,select,textarea{font:inherit;color:inherit}
button{cursor:pointer}
:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
h1,h2,h3{font-family:var(--f-display);font-weight:700;letter-spacing:.01em;margin:0;text-wrap:balance;line-height:1.1}
body.km h1,body.km h2,body.km h3{font-family:var(--f-km);font-weight:700;line-height:1.45;letter-spacing:0}
img{max-width:100%;display:block}

/* ---------- top bar ---------- */
body::before{content:"";position:fixed;inset:0 0 auto;height:env(safe-area-inset-top,0px);z-index:30;background:var(--surface)}
.top{position:sticky;top:env(safe-area-inset-top,0px);z-index:20;background:var(--surface);border-bottom:1px solid var(--line)}
.top-in{display:flex;align-items:center;gap:10px;min-height:54px;padding-block:8px;padding-left:max(16px,env(safe-area-inset-left,0px));padding-right:max(16px,env(safe-area-inset-right,0px))}
.rule{display:grid;grid-template-columns:1fr 1fr 1fr;height:3px}
.rule i:nth-child(1){background:var(--green)}.rule i:nth-child(2){background:var(--sky)}.rule i:nth-child(3){background:var(--blue)}
.brand{height:26px;width:auto;border-radius:3px;background:#fff;padding:2px 4px}
.top h1{font-size:19px;flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.iconbtn{appearance:none;border:0;background:transparent;width:36px;height:36px;border-radius:50%;display:grid;place-items:center;flex:none;margin-left:-8px}
.iconbtn:hover{background:var(--surface-2)}
.iconbtn svg{width:22px;height:22px}
.lang{appearance:none;border:1px solid var(--line);background:var(--surface);border-radius:999px;padding:4px 10px;font-size:13px;font-weight:600;flex:none}
.spacer{flex:1}

/* ---------- page ---------- */
.page{padding-block:16px 120px;padding-left:max(16px,env(safe-area-inset-left,0px));padding-right:max(16px,env(safe-area-inset-right,0px));max-width:640px;margin:0 auto;display:flex;flex-direction:column;gap:16px}
.lead{color:var(--ink-2);margin:0}
.eyebrow{font-family:var(--f-display);text-transform:uppercase;letter-spacing:.12em;font-size:12px;font-weight:600;color:var(--muted)}
body.km .eyebrow{font-family:var(--f-km);letter-spacing:0;text-transform:none;font-size:13px}
.demo{font-size:12.5px;color:var(--ink-2);background:var(--surface-2);border:1px dashed var(--line);border-radius:var(--r-sm);padding:6px 10px}

/* ---------- home ---------- */
.hello h2{font-size:30px}
.since{display:flex;align-items:center;gap:8px;font-size:13px;color:var(--ink-2)}
.cubes{display:flex;gap:2px;flex:none}.cubes i{width:8px;height:8px;border-radius:1px}
.cubes i:nth-child(1){background:var(--green)}.cubes i:nth-child(2){background:var(--sky)}.cubes i:nth-child(3){background:var(--blue)}
.divs{display:flex;flex-direction:column;gap:10px}
.div{appearance:none;text-align:left;border:1px solid var(--line);background:var(--surface);border-radius:var(--r);padding:16px;display:grid;grid-template-columns:48px 1fr 20px;gap:14px;align-items:center;box-shadow:var(--shadow);transition:transform .12s ease}
.div:active{transform:scale(.985)}
.div .ic{width:48px;height:48px;border-radius:10px;display:grid;place-items:center;color:#fff}
.div .ic svg{width:26px;height:26px}
.div b{display:block;font-family:var(--f-display);font-size:21px;line-height:1.1}
body.km .div b{font-family:var(--f-km);font-size:17px;line-height:1.5}
.div span{display:block;font-size:13.5px;color:var(--ink-2);margin-top:2px}
.div .chev{color:var(--muted)}
.div.c .ic{background:var(--green)} .div.s .ic{background:var(--sky)}
.div.e{background:var(--navy);border-color:var(--navy-line);color:#fff}
.div.e span{color:var(--chrome)} .div.e .chev{color:var(--chrome)}
.div.e .ic{background:transparent}
.div.e .ic img{width:44px;height:auto}
.call{font-size:13.5px;color:var(--ink-2);text-align:center}
.call b{color:var(--ink);font-variant-numeric:tabular-nums;user-select:all}

/* ---------- catalog ---------- */
.search{position:relative}
.search input{width:100%;border:1px solid var(--line);background:var(--surface);border-radius:999px;padding:10px 14px 10px 38px}
.search svg{position:absolute;left:12px;top:50%;transform:translateY(-50%);width:18px;height:18px;color:var(--muted)}
.chips{display:flex;gap:6px;overflow-x:auto;scrollbar-width:none;margin:0 calc(-1 * max(16px,env(safe-area-inset-left,0px)));padding:0 max(16px,env(safe-area-inset-left,0px))}
.chips::-webkit-scrollbar{display:none}
.chip{appearance:none;border:1px solid var(--line);background:var(--surface);border-radius:999px;padding:6px 13px;font-size:13.5px;font-weight:600;white-space:nowrap;flex:none}
.chip[aria-pressed="true"]{background:var(--ink);color:var(--bg);border-color:var(--ink)}
.grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}
.card{appearance:none;text-align:left;border:1px solid var(--line);background:var(--surface);border-radius:var(--r);overflow:hidden;display:flex;flex-direction:column;padding:0;min-width:0}
.card .ph{aspect-ratio:4/3;background:#fff;position:relative}
.card .ph img{width:100%;height:100%;object-fit:contain}
.card .meta{padding:9px 10px 10px;display:flex;flex-direction:column;gap:3px;flex:1}
.card .nm{font-weight:600;font-size:14px;line-height:1.3;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}
.card .sp{font-size:12.5px;color:var(--muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.badge{position:absolute;top:8px;right:8px;background:var(--green);color:#fff;font-size:12px;font-weight:700;border-radius:999px;min-width:24px;height:24px;display:grid;place-items:center;padding:0 7px;font-variant-numeric:tabular-nums}
.empty{color:var(--muted);text-align:center;padding:24px 8px}
.sampletag{position:absolute;left:8px;bottom:8px;font-size:10.5px;font-weight:600;background:rgba(20,23,25,.75);color:#fff;border-radius:4px;padding:1px 6px}

/* ---------- sheet (product detail) ---------- */
.scrim{position:fixed;inset:0;background:rgba(10,12,14,.5);z-index:40;display:flex;align-items:flex-end;justify-content:center}
.sheet{background:var(--surface);width:100%;max-width:640px;max-height:92%;overflow:auto;border-radius:16px 16px 0 0;padding-bottom:calc(16px + env(safe-area-inset-bottom,0px));animation:up .22s cubic-bezier(.2,.8,.2,1)}
@keyframes up{from{transform:translateY(24px);opacity:.6}to{transform:none;opacity:1}}
.sheet .ph{background:#fff;aspect-ratio:4/3;position:relative;border-bottom:1px solid var(--line)}
.sheet .ph img{width:100%;height:100%;object-fit:contain}
.sheet .x{position:absolute;top:10px;right:10px;background:rgba(255,255,255,.9);border:1px solid var(--line);color:#141719}
.sheet .body{padding:16px max(16px,env(safe-area-inset-left,0px)) 0;display:flex;flex-direction:column;gap:12px}
.sheet h2{font-size:24px}
body.km .sheet h2{font-size:19px}
.specs{width:100%;border-collapse:collapse;font-size:13.5px}
.specs th,.specs td{text-align:left;padding:7px 0;border-bottom:1px solid var(--line);vertical-align:top}
.specs th{color:var(--muted);font-weight:500;width:38%;padding-right:10px}
.specs td{font-variant-numeric:tabular-nums}
.qtyrow{display:flex;align-items:center;justify-content:space-between;gap:12px}
.stepper{display:flex;align-items:center;border:1px solid var(--line);border-radius:999px;overflow:hidden}
.stepper button{appearance:none;border:0;background:transparent;width:40px;height:38px;font-size:20px;line-height:1}
.stepper button:hover{background:var(--surface-2)}
.stepper output{min-width:34px;text-align:center;font-weight:700;font-variant-numeric:tabular-nums}

/* ---------- forms ---------- */
.group{background:var(--surface);border:1px solid var(--line);border-radius:var(--r);padding:14px;display:flex;flex-direction:column;gap:10px}
.group h3{font-size:18px}
body.km .group h3{font-size:16px}
.ghead{display:flex;justify-content:space-between;align-items:center;gap:10px}
.opts{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}
.opt{position:relative;display:flex;align-items:center;gap:9px;border:1px solid var(--line);border-radius:var(--r-sm);padding:10px;background:var(--surface);min-height:48px;cursor:pointer;font-size:14px;line-height:1.3}
.opt input{position:absolute;opacity:0;pointer-events:none}
.opt .box{width:20px;height:20px;border-radius:5px;border:1.5px solid var(--muted);flex:none;display:grid;place-items:center}
.opt.radio .box{border-radius:50%}
.opt input:checked + .box{background:var(--accent);border-color:var(--accent)}
.opt input:checked + .box::after{content:"";width:9px;height:5px;border:2px solid var(--accent-ink);border-top:0;border-right:0;transform:rotate(-45deg) translate(1px,-1px)}
.opt.radio input:checked + .box::after{width:8px;height:8px;border:0;border-radius:50%;background:var(--accent-ink);transform:none}
.opt:has(input:checked){border-color:var(--accent);box-shadow:inset 0 0 0 1px var(--accent)}
.opt:has(input:focus-visible){outline:2px solid var(--accent);outline-offset:2px}
.opts.one{grid-template-columns:1fr}
.linkbtn{appearance:none;border:0;background:none;color:var(--accent);font-weight:600;font-size:13.5px;padding:4px 0}
.field{display:flex;flex-direction:column;gap:5px}
.field label{font-size:13px;font-weight:600;color:var(--ink-2)}
.field input,.field select,.field textarea{width:100%;border:1px solid var(--line);background:var(--surface);border-radius:var(--r-sm);padding:10px 12px;min-height:44px}
.field textarea{min-height:76px;resize:vertical}
.err{color:var(--danger);font-size:13px;margin:0}
.row2{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:8px}

/* cart list */
.lines{display:flex;flex-direction:column}
.line{display:grid;grid-template-columns:52px minmax(0,1fr) auto;gap:10px;align-items:center;padding:10px 0;border-bottom:1px solid var(--line)}
.line:last-child{border-bottom:0}
.line img{width:52px;height:39px;object-fit:contain;background:#fff;border-radius:6px;border:1px solid var(--line)}
.line .nm{font-size:14px;font-weight:600;line-height:1.3}
.line .stepper button{width:32px;height:32px;font-size:17px}
.line .stepper output{min-width:26px}

/* ---------- bottom bar ---------- */
.bar{position:fixed;left:0;right:0;bottom:0;z-index:25;background:var(--surface);border-top:1px solid var(--line);padding-top:10px;padding-bottom:calc(10px + env(safe-area-inset-bottom,0px));padding-left:max(16px,env(safe-area-inset-left,0px));padding-right:max(16px,env(safe-area-inset-right,0px))}
.bar-in{max-width:640px;margin:0 auto;display:flex;gap:10px;align-items:center}
.btn{appearance:none;border:0;border-radius:var(--r);background:var(--accent);color:var(--accent-ink);font-weight:700;font-size:16px;padding:13px 16px;min-height:48px;flex:1;display:flex;align-items:center;justify-content:center;gap:8px}
.btn[disabled]{opacity:.5;cursor:not-allowed}
.btn.ghost{background:var(--surface-2);color:var(--ink)}
.btn.tg{background:#2aabee;color:#fff}
.btn svg{width:18px;height:18px}
.count{font-variant-numeric:tabular-nums;background:rgba(255,255,255,.22);border-radius:999px;padding:1px 8px;font-size:14px}

/* ---------- summary / done ---------- */
.summary{background:var(--surface-2);border-radius:var(--r-sm);padding:12px;font-size:13.5px;white-space:pre-wrap;line-height:1.55;overflow-wrap:anywhere}
.done{align-items:center;text-align:center;padding-top:40px}
.done .tick{width:64px;height:64px;border-radius:50%;background:var(--green);display:grid;place-items:center;color:#fff}
.done .tick svg{width:32px;height:32px}
.done h2{font-size:30px}
.ref{font-family:ui-monospace,Menlo,Consolas,monospace;font-size:15px;background:var(--surface);border:1px solid var(--line);border-radius:var(--r-sm);padding:6px 12px}
.tgmsg{width:100%;text-align:left;background:var(--surface);border:1px solid var(--line);border-radius:var(--r);padding:12px;font-size:14px;white-space:pre-wrap;font-family:var(--f-body)}

/* ---------- EV (navy) ---------- */
body.ev{--bg:#0b1430;--surface:#111c3e;--surface-2:#182650;--ink:#eef2fb;--ink-2:#c3cbe0;--muted:#8f9ac0;--line:#26366a;--accent:#17b6ee;--accent-ink:#04121f;--shadow:none;color-scheme:dark}
body.ev .top,body.ev::before{background:#0b1430}
.evhero{display:flex;align-items:center;gap:14px}
.evhero img{width:60px;height:auto;flex:none}
.evhero h2{font-size:26px}
.gem{height:3px;border-radius:2px;background:linear-gradient(90deg,#e3263f,#ff9f1c,#ffd23f,#2ec27e,#17b6ee,#5b5bf0,#a24df0)}
.charger{display:grid;grid-template-columns:auto minmax(0,1fr) minmax(0,1fr);gap:8px;align-items:end}
.charger .n{font-family:var(--f-display);font-weight:700;font-size:15px;color:var(--muted);padding-bottom:12px;min-width:22px}
.total{display:flex;justify-content:space-between;align-items:baseline;border-top:1px solid var(--line);padding-top:10px}
.total b{font-family:var(--f-display);font-size:26px;font-variant-numeric:tabular-nums}

@media (min-width:560px){.grid{grid-template-columns:repeat(3,minmax(0,1fr))}}
@media (prefers-reduced-motion:reduce){*{animation:none!important;transition:none!important}}
