:root {
  --bg: #F6F7F9;
  --panel: #FFFFFF;
  --text: #14161C;
  --muted: #6B7180;
  --line: #E6E8EE;
  --soft: #F1F2F6;
  --accent: #5B5BF0;
  --accent-soft: #EEEEFE;
  --on-accent: #FFFFFF;
  --stage: #ECEEF2;
  --radius: 14px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, Roboto, Helvetica, Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0E0F13;
    --panel: #16181E;
    --text: #EEF0F4;
    --muted: #9298A6;
    --line: #262932;
    --soft: #1D2028;
    --accent: #7C7CFF;
    --accent-soft: #23244A;
    --stage: #121419;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.55 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; color: inherit; }

/* ---------- header ---------- */
.top { height: 56px; display: flex; align-items: center; gap: 24px; padding: 0 20px; border-bottom: 1px solid var(--line); background: var(--panel); position: relative; z-index: 5; }
.logo { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 16.5px; color: var(--text); letter-spacing: -0.2px; }
.logo:hover { text-decoration: none; }
.logo i { width: 28px; height: 28px; border-radius: 8px; background: var(--accent); display: grid; place-items: center; }
.top nav { display: flex; gap: 20px; margin-left: auto; align-items: center; font-size: 14.5px; }
.top nav a { color: var(--muted); font-weight: 500; }
.top nav a:hover { color: var(--text); text-decoration: none; }
.lang { position: relative; }
.lang summary { list-style: none; cursor: pointer; color: var(--muted); font-weight: 500; font-size: 14px; padding: 6px 10px; border-radius: 8px; display: flex; align-items: center; gap: 6px; }
.lang summary .chev { opacity: .7; transition: transform .15s; }
.lang[open] summary .chev { transform: rotate(180deg); }
.gallery-head { padding-bottom: 0; }
.gallery-head h1 { font-size: 34px; letter-spacing: -0.8px; margin: 0 0 8px; }
.lang summary::-webkit-details-marker { display: none; }
.lang[open] summary, .lang summary:hover { background: var(--soft); color: var(--text); }
.lang ul { position: absolute; right: 0; top: 38px; margin: 0; padding: 6px; list-style: none; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 32px rgba(0,0,0,.12); min-width: 150px; }
.lang li a { display: block; padding: 7px 12px; border-radius: 8px; color: var(--text); }
.lang li a:hover { background: var(--soft); text-decoration: none; }

/* ---------- app ---------- */
.app { display: grid; grid-template-columns: 1fr 360px; height: calc(100vh - 56px); min-height: 560px; max-height: 1100px; }
.stage-col { display: flex; flex-direction: column; min-width: 0; }
.intro { padding: 18px 28px 0; }
.intro h1 { margin: 0; font-size: 22px; line-height: 1.25; letter-spacing: -0.4px; }
.intro p { margin: 4px 0 0; color: var(--muted); font-size: 14.5px; }
.stage { position: relative; flex: 1; margin: 16px 28px 24px; border-radius: 22px; background: var(--stage); display: flex; min-height: 0; overflow: hidden; }
.canvas-wrap { position: absolute; inset: 28px; display: flex; align-items: center; justify-content: center; }
.canvas-wrap > canvas { min-width: 0; min-height: 0; }
#preview { max-width: 100%; max-height: 100%; width: auto; height: auto; border-radius: 10px; display: block; transition: opacity .2s; }
.stage.checker #preview { background: repeating-conic-gradient(rgba(128,128,128,.14) 0 25%, transparent 0 50%) 0 0 / 16px 16px; }
.stage.busy #preview { opacity: .92; }
.stage .shuffle { position: absolute; top: 14px; right: 14px; display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 8px 14px; cursor: pointer; font-size: 14px; font-weight: 600; box-shadow: 0 2px 8px rgba(0,0,0,.06); }
.stage .shuffle:hover { border-color: var(--accent); color: var(--accent); }
.drop-hint { position: absolute; inset: 10px; border: 2px dashed var(--accent); border-radius: 18px; display: none; place-items: center; font-weight: 600; color: var(--accent); background: color-mix(in srgb, var(--stage) 85%, transparent); }
.stage.dragging .drop-hint { display: grid; }
.nowebgl { margin: auto; max-width: 360px; text-align: center; color: var(--muted); }

.panel-col { border-left: 1px solid var(--line); background: var(--panel); display: flex; flex-direction: column; min-height: 0; }
#panel { overflow-y: auto; padding: 6px 18px 18px; flex: 1; scrollbar-width: thin; }
.sec { padding: 14px 0; border-bottom: 1px solid var(--line); }
.sec:last-child { border-bottom: 0; }
.sec h2 { margin: 0 0 10px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .7px; color: var(--muted); }
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.dev-tiles, .angle-tiles { grid-template-columns: repeat(5, 1fr); }
.tile { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 62px; padding: 8px 2px 6px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); cursor: pointer; color: var(--muted); transition: border-color .12s, color .12s, background .12s; }
.tile span { font-size: 11.5px; line-height: 1.15; font-weight: 600; text-align: center; color: var(--text); overflow: hidden; text-overflow: ellipsis; max-width: 100%; white-space: nowrap; }
.tile:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); color: var(--accent); }
.tile.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.tile.upload { border-style: dashed; }
.brand { margin-top: 10px; width: 100%; height: 38px; border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; background: var(--panel); color: var(--text); font: inherit; font-size: 14px; }
.brand:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.sw { width: 28px; height: 28px; border-radius: 50%; border: 0; background: var(--sw); cursor: pointer; box-shadow: inset 0 0 0 1px rgba(128,128,128,.3); position: relative; padding: 0; }
.bgs .sw { border-radius: 8px; width: 34px; height: 34px; }
.sw.on { box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--accent); }
.dots { margin-top: 10px; }
.dots .sw { width: 24px; height: 24px; }
.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 3px; margin-top: 10px; background: var(--soft); border-radius: 11px; }
.chip { border: 0; background: transparent; border-radius: 8px; padding: 6px 12px; font-size: 13.5px; font-weight: 600; color: var(--muted); cursor: pointer; }
.chip:hover { color: var(--text); }
.chip.on { background: var(--panel); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.1); }
.sub[hidden] { display: none; }
.more { margin-top: 10px; }
.more summary { cursor: pointer; color: var(--accent); font-weight: 600; font-size: 13.5px; list-style: none; }
.more summary::-webkit-details-marker { display: none; }
.more summary::after { content: ' ▾'; }
.more[open] summary::after { content: ' ▴'; }
.check { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 14px; cursor: pointer; user-select: none; }
.check input { width: 17px; height: 17px; accent-color: var(--accent); margin: 0; }

.actions { position: relative; display: flex; gap: 8px; padding: 14px 18px; border-top: 1px solid var(--line); background: var(--panel); }
.btn-primary { flex: 1; height: 50px; border: 0; border-radius: 14px; background: var(--accent); color: var(--on-accent); font-weight: 700; font-size: 16px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 35%, transparent); }
.btn-primary:hover { filter: brightness(1.06); }
.btn-primary:disabled { opacity: .7; cursor: progress; }
.btn-icon { width: 50px; height: 50px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); cursor: pointer; display: grid; place-items: center; color: var(--text); }
.btn-icon:hover { border-color: var(--accent); color: var(--accent); }
#export { position: absolute; right: 18px; bottom: 74px; width: 300px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 18px 48px rgba(0,0,0,.16); padding: 14px; display: none; z-index: 10; }
#export.open { display: block; }
#export h3 { margin: 4px 2px 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .7px; color: var(--muted); }
#export .list { display: flex; flex-direction: column; gap: 2px; margin-bottom: 8px; }
#export .list .chip { text-align: left; padding: 7px 10px; }
#export .list .chip.on { background: var(--accent-soft); color: var(--accent); box-shadow: none; }
#export .seg { margin: 0 0 12px; }
#copy { width: 100%; height: 40px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); font-weight: 600; cursor: pointer; }
#copy:hover { border-color: var(--accent); color: var(--accent); }
.privacy { margin: 8px 2px 0; font-size: 12px; color: var(--muted); line-height: 1.4; }

/* ---------- content ---------- */
.content { max-width: 1040px; margin: 0 auto; padding: 56px 20px 40px; }
.content h2 { font-size: 28px; letter-spacing: -0.6px; margin: 48px 0 16px; line-height: 1.2; }
.content h2:first-child { margin-top: 0; }
.content h3 { font-size: 17px; margin: 0 0 6px; }
.content p { color: var(--muted); margin: 0 0 14px; max-width: 760px; }
.content .lead { font-size: 17px; color: var(--text); }
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; padding: 0; list-style: none; counter-reset: s; }
.steps li { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; counter-increment: s; }
.steps li::before { content: counter(s); display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 700; margin-bottom: 12px; }
.steps p { margin: 0; font-size: 14.5px; }
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid.four { grid-template-columns: repeat(4, 1fr); }
.content h2 a { color: inherit; }
.card { display: block; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; color: var(--text); transition: transform .15s, box-shadow .15s; }
.card:hover { transform: translateY(-2px); box-shadow: 0 12px 30px rgba(0,0,0,.08); text-decoration: none; }
.card img { width: 100%; height: auto; display: block; aspect-ratio: 4 / 3; object-fit: cover; background: var(--soft); }
.card span { display: block; padding: 10px 14px 12px; font-size: 14px; font-weight: 600; }
.faq details { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 20px; margin-bottom: 10px; }
.faq summary { cursor: pointer; font-weight: 600; font-size: 16px; }
.faq details p { margin: 10px 0 0; }
.links { display: flex; flex-wrap: wrap; gap: 8px; padding: 0; list-style: none; }
.links a { display: inline-block; padding: 8px 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); color: var(--text); font-size: 14px; font-weight: 500; }
.links a:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.uses { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px 24px; padding: 0; list-style: none; }
.uses li { padding-left: 26px; position: relative; color: var(--muted); }
.uses li::before { content: '✓'; position: absolute; left: 0; color: var(--accent); font-weight: 700; }
footer { border-top: 1px solid var(--line); padding: 28px 20px 40px; color: var(--muted); font-size: 13.5px; }
footer .in { max-width: 1040px; margin: 0 auto; display: flex; flex-wrap: wrap; gap: 8px 18px; }
footer a { color: var(--muted); }
footer .copy { width: 100%; margin-top: 10px; }

/* ---------- small screens ---------- */
@media (max-width: 900px) {
  .top { padding: 0 16px; gap: 12px; }
  .top nav { gap: 12px; }
  .top nav .hide-sm { display: none; }
  .lang summary span { display: none; }
  .app { display: block; height: auto; max-height: none; min-height: 0; }
  .intro { padding: 14px 16px 0; }
  .intro h1 { font-size: 19px; }
  .intro p { font-size: 13.5px; }
  .stage-col { position: sticky; top: var(--stick, -100px); z-index: 4; background: var(--bg); padding-bottom: 10px; box-shadow: 0 8px 16px -12px rgba(0,0,0,.25); }
  .stage { margin: 12px 16px 0; flex: none; height: 58vw; min-height: 220px; max-height: 460px; border-radius: 18px; }
  .canvas-wrap { inset: 14px; }
  .stage .shuffle { top: 10px; right: 10px; padding: 6px 12px; font-size: 13px; }
  .panel-col { border-left: 0; background: transparent; }
  #panel { overflow: visible; padding: 4px 16px 90px; }
  .tiles { grid-template-columns: repeat(4, 1fr); }
  .actions { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); box-shadow: 0 -6px 20px rgba(0,0,0,.06); }
  #export { right: 16px; bottom: 76px; width: calc(100vw - 32px); max-width: 340px; }
  .content { padding: 40px 16px 100px; }
  .content h2 { font-size: 23px; }
  .steps, .grid { grid-template-columns: 1fr; }
  .grid, .grid.four { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .uses { grid-template-columns: 1fr; }
  footer { padding-bottom: 100px; }
}
@media (max-width: 380px) {
  .dev-tiles, .angle-tiles { grid-template-columns: repeat(3, 1fr); }
}
.tile.upload.pulse { animation: pulse 1.6s ease-in-out 4; border-color: var(--accent); color: var(--accent); }
@keyframes pulse { 50% { box-shadow: 0 0 0 5px var(--accent-soft); } }
.check[hidden], .tile[hidden] { display: none; }
.crumbs { font-size: 13.5px; color: var(--muted); margin-bottom: 18px; }
.crumbs a { color: var(--muted); }
.shot { margin: 24px 0 8px; }
.shot img { width: 100%; height: auto; border-radius: var(--radius); background: var(--soft); border: 1px solid var(--line); display: block; }
.shot figcaption { font-size: 13px; color: var(--muted); margin-top: 8px; }
.specs { border-collapse: collapse; width: 100%; max-width: 760px; font-size: 14.5px; }
.specs th, .specs td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.specs th { width: 160px; color: var(--muted); font-weight: 600; }
a.tile, a.tile:hover { text-decoration: none; }
.gallery-head + .content { padding-top: 12px; }
.stage .shuffle .count { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--soft); border-radius: 999px; padding: 1px 7px; }
