:root{
  --paper:#F2F5F6; --panel:#FFFFFF; --ink:#16222A; --muted:#55646D; --line:#C9D3D8; --soft:#E6ECEF;
  --rack:#D5DDE1; --cab:#24323A; --mmf:#00909E; --smf:#B98A00; --ok:#2E7D4F; --bad:#B42318;
  --accent:var(--mmf);
  --sans:"Barlow","Sarabun",system-ui,-apple-system,"Segoe UI","PingFang SC","Noto Sans SC","Microsoft YaHei",Roboto,sans-serif;
  --cond:"Barlow Condensed","Sarabun","Arial Narrow",system-ui,"PingFang SC","Noto Sans SC","Microsoft YaHei",sans-serif;
  color-scheme:light;
}
@media (prefers-color-scheme: dark){
  :root:not([data-theme="light"]){
    --paper:#0F161A; --panel:#162027; --ink:#E3EBEE; --muted:#9AA9B1; --line:#2E3C44; --soft:#1A252B;
    --rack:#33434C; --cab:#56666F; --mmf:#36C6D3; --smf:#F0C330; --ok:#62C08B; --bad:#F2796B; color-scheme:dark;
  }
}
:root[data-theme="dark"]{
  --paper:#0F161A; --panel:#162027; --ink:#E3EBEE; --muted:#9AA9B1; --line:#2E3C44; --soft:#1A252B;
  --rack:#33434C; --cab:#56666F; --mmf:#36C6D3; --smf:#F0C330; --ok:#62C08B; --bad:#F2796B; color-scheme:dark;
}
:root[data-fiber="smf"]{ --accent:var(--smf); }
*,*::before,*::after{ box-sizing:border-box; }
body{
  margin:0; background:var(--paper); color:var(--ink);
  font:400 15px/1.5 var(--sans);
  font-variant-numeric:tabular-nums;
  padding-top:env(safe-area-inset-top,0px); padding-bottom:env(safe-area-inset-bottom,0px);
}
.event-strip{ display:block; padding:.55rem 16px; background:#FFC837; color:#1A1300; text-align:center; text-decoration:none; font-size:14px; line-height:1.4; }
.event-strip:hover{ background:#FFD665; }
.event-strip b{ font-weight:600; }
.wrap{ max-width:1280px; margin:0 auto; padding:16px 16px 48px; }
h1,h2,legend{ font-family:var(--cond); font-weight:600; }
h1{ font-size:clamp(24px,4vw,32px); line-height:1.1; margin:0 0 8px; }
h2{ font-size:20px; margin:0 0 10px; }
header p{ margin:0; color:var(--muted); max-width:64ch; }

.topbar{ display:flex; justify-content:space-between; align-items:center; gap:12px; margin-bottom:24px; }
.brand img{ height:32px; display:block; }
@media (prefers-color-scheme: dark){ :root:not([data-theme="light"]) .brand img{ filter:invert(1) hue-rotate(180deg); } }
.langs{ display:flex; gap:4px; }
.langs button{ background:transparent; color:var(--ink); border:1px solid var(--line); padding:4px 10px; font-size:13px; }
.langs button[aria-pressed="true"]{ background:var(--ink); color:var(--paper); border-color:var(--ink); }

.layout{ display:grid; grid-template-columns:minmax(280px,340px) 1fr; gap:24px; margin-top:24px; align-items:start; }
@media (max-width:900px){ .layout{ grid-template-columns:1fr; } }

.panel{ background:var(--panel); border:1px solid var(--line); border-radius:6px; padding:18px; }
form fieldset{ border:0; padding:0; margin:0 0 18px; min-width:0; }
legend{ font-size:18px; padding:0; margin-bottom:6px; }
.field{ display:grid; grid-template-columns:1fr 92px; gap:10px; align-items:center; margin:7px 0; }
.field.wide{ grid-template-columns:1fr; gap:4px; }
.field label{ font-size:14px; line-height:1.3; }
.field small{ display:block; color:var(--muted); font-size:12px; }
input,select{
  font:inherit; color:var(--ink); background:var(--paper);
  border:1px solid var(--line); border-radius:4px; padding:6px 8px; width:100%;
}
input[aria-invalid="true"]{ border-color:var(--bad); }
:focus-visible{ outline:2px solid var(--accent); outline-offset:2px; }
details{ border-top:1px solid var(--line); padding-top:12px; }
summary{ cursor:pointer; font-weight:500; }
.err{ color:var(--bad); font-size:13px; min-height:1em; margin:4px 0 0; }

.right{ display:grid; grid-template-columns:minmax(0,1fr); gap:20px; min-width:0; }

.stage{ position:relative; border:1px solid var(--line); border-radius:6px; overflow:hidden;
  background:radial-gradient(ellipse at 50% 35%, var(--panel), var(--soft)); }
#scene3d{ height:clamp(340px,58vh,600px); position:relative; }
#scene3d canvas{ display:block; width:100%; height:100%; touch-action:none; cursor:grab; }
#scene3d canvas.hover{ cursor:pointer; }
.stagetop{ position:absolute; top:12px; left:14px; right:14px; display:flex; justify-content:space-between; align-items:flex-start; gap:10px; pointer-events:none; }
.stagetop h2{ margin:0; white-space:nowrap; }
.viewbtns{ display:flex; gap:6px; flex-wrap:wrap; justify-content:flex-end; pointer-events:auto; }
.viewbtns button{ background:var(--panel); color:var(--ink); border:1px solid var(--line); font-size:13px; padding:5px 10px; }
.viewbtns button[aria-pressed="true"]{ background:var(--ink); color:var(--paper); border-color:var(--ink); }
.viewbtns .booth-btn{ background:var(--accent); color:#fff; border-color:var(--accent); }
.readout{ position:absolute; left:14px; right:14px; bottom:12px; pointer-events:none;
  display:flex; justify-content:space-between; align-items:flex-end; gap:12px; flex-wrap:wrap; }
.info{ margin:0; font-size:14px; background:var(--panel); border:1px solid var(--line); border-radius:4px; padding:8px 10px; max-width:520px; }
.scale{ background:var(--panel); border:1px solid var(--line); border-radius:4px; padding:6px 10px; font-size:12px; color:var(--muted); }
.scale .bar{ height:8px; width:150px; border-radius:2px; margin:3px 0; background:linear-gradient(90deg, var(--rack), var(--accent)); }
.scale .ends{ display:flex; justify-content:space-between; }
.nogl{ padding:60px 20px; text-align:center; color:var(--muted); }
.hint{ color:var(--muted); font-size:13px; margin:-12px 0 0; }

.stats{ display:grid; grid-template-columns:repeat(auto-fit,minmax(130px,1fr)); border:1px solid var(--line); border-radius:6px; background:var(--panel); margin:0; }
.stats div{ padding:12px 14px; border-right:1px solid var(--soft); }
.stats div:last-child{ border-right:0; }
.stats dt{ font-size:13px; color:var(--muted); }
.stats dd{ margin:2px 0 0; font-family:var(--cond); font-size:26px; font-weight:600; line-height:1.1; }
.stats dd.over{ color:var(--bad); }

.check{ padding:12px 14px; border-radius:6px; border-left:5px solid var(--ok); background:var(--panel); }
.check.bad{ border-left-color:var(--bad); }
.check p{ margin:0; }
.check ul{ margin:6px 0 0; padding-left:18px; }

.tablebox{ overflow-x:auto; }
table{ border-collapse:collapse; width:100%; min-width:560px; font-size:14px; }
th,td{ text-align:left; padding:8px 10px; border-bottom:1px solid var(--soft); vertical-align:top; }
th{ font-weight:600; color:var(--muted); border-bottom:1px solid var(--line); }
td.q,th.q{ text-align:right; white-space:nowrap; }
.bomhead{ display:flex; justify-content:space-between; align-items:center; gap:12px; flex-wrap:wrap; }
button{
  font:inherit; font-weight:500; color:var(--paper); background:var(--ink);
  border:0; border-radius:4px; padding:7px 14px; cursor:pointer;
}
.note{ color:var(--muted); font-size:13px; margin:10px 0 0; max-width:80ch; }

.cta{ display:flex; justify-content:space-between; align-items:center; gap:16px; flex-wrap:wrap;
  padding:18px; border-radius:6px; background:var(--ink); color:var(--paper); }
.cta p{ margin:0; max-width:60ch; }
.cta a{ background:var(--accent); color:#fff; text-decoration:none; font-weight:600; padding:9px 16px; border-radius:4px; white-space:nowrap; }

footer{ margin-top:32px; color:var(--muted); font-size:13px; }
footer a{ color:var(--ink); }
@media (max-width:560px){
  .info{ font-size:13px; }
  .scale{ display:none; }
}

/* Booth mode */
.booth-ui{ display:none; }
.stage.booth{ position:fixed; inset:0; z-index:100; border:0; border-radius:0; }
.stage:fullscreen{ border:0; border-radius:0; }
.stage.booth #scene3d{ height:100vh; height:100dvh; }
.stage.booth .stagetop, .stage.booth .readout{ display:none; }
.stage.booth .booth-ui{ display:block; position:absolute; inset:0; pointer-events:none; }
.stage.booth .booth-ui::before, .stage.booth .booth-ui::after{ content:''; position:absolute; left:0; right:0; pointer-events:none; }
.stage.booth .booth-ui::before{ top:0; height:34%; background:linear-gradient(var(--paper) 35%, transparent); }
.stage.booth .booth-ui::after{ bottom:0; height:38%; background:linear-gradient(transparent, var(--paper) 70%); }
.booth-head, .booth-foot, .booth-ctl{ z-index:1; }
.booth-head{ position:absolute; top:28px; left:32px; max-width:min(60vw,820px); }
.booth-brand img{ height:36px; display:block; margin-bottom:14px; }
.booth-title{ font-size:clamp(32px,4.4vw,64px); line-height:1.05; margin:0; transition:opacity .4s; }
.booth-sub{ font-size:clamp(16px,1.5vw,22px); color:var(--muted); margin:8px 0 0; transition:opacity .4s; }
.booth-head.fade .booth-title, .booth-head.fade .booth-sub{ opacity:0; }
.booth-ctl{ position:absolute; top:20px; right:20px; display:flex; gap:8px; align-items:center; pointer-events:auto; opacity:.35; transition:opacity .2s; }
.booth-ctl:hover, .booth-ctl:focus-within{ opacity:1; }
.booth-variants{ display:flex; gap:4px; }
.booth-variants button{ background:var(--panel); color:var(--ink); border:1px solid var(--line); font-size:13px; padding:5px 10px; }
.booth-variants button[aria-pressed="true"]{ background:var(--ink); color:var(--paper); border-color:var(--ink); }
.booth-foot{ position:absolute; left:32px; right:32px; bottom:28px; display:flex; justify-content:space-between; align-items:flex-end; gap:24px; }
.booth-left{ max-width:min(64vw,900px); }
.booth-scenario{ margin:0 0 10px; font-family:var(--cond); font-size:clamp(18px,1.8vw,26px); font-weight:600; color:var(--accent); min-height:1.2em; }
.booth-stats{ display:flex; flex-wrap:wrap; gap:10px; margin:0; }
.booth-stats div{ background:color-mix(in srgb, var(--panel) 88%, transparent); border:1px solid var(--line); border-radius:6px; padding:10px 16px; }
.booth-stats dt{ font-size:14px; color:var(--muted); }
.booth-stats dd{ margin:0; font-family:var(--cond); font-weight:600; font-size:clamp(26px,2.6vw,40px); line-height:1.1; }
.booth-stats dd.over{ color:var(--bad); }
.booth-check{ margin:10px 0 0; font-size:clamp(14px,1.2vw,18px); background:color-mix(in srgb, var(--panel) 88%, transparent);
  border-left:5px solid var(--ok); border-radius:4px; padding:8px 12px; }
.booth-check.bad{ border-left-color:var(--bad); }
.booth-qr{ background:#fff; color:#16222A; border-radius:10px; padding:14px; text-align:center; box-shadow:0 6px 24px rgba(0,0,0,.18); flex:none; }
#qr svg{ display:block; width:clamp(120px,13vw,200px); height:auto; margin:0 auto; }
.booth-qr p{ margin:8px 0 0; font-weight:600; font-size:15px; }
.booth-qr .booth-url{ margin-top:2px; font-weight:400; font-size:12px; color:#55646D; }
@media (max-width:700px){
  .booth-head{ left:16px; top:16px; max-width:calc(100vw - 32px); }
  .booth-sub{ display:none; }
  .booth-stats{ display:grid; grid-template-columns:1fr 1fr; gap:6px; }
  .booth-stats div{ padding:6px 10px; }
  .booth-stats dt{ font-size:12px; }
  .booth-stats dd{ font-size:22px; }
  .booth-check{ font-size:13px; }
  .booth-ctl{ top:auto; bottom:12px; right:12px; }
  .booth-foot{ left:16px; right:16px; bottom:56px; flex-direction:column; align-items:flex-start; }
  .booth-qr{ display:none; }
}
