/* Gemini 3D Component Marker: Gemini-like look (soft surfaces, gradient accent, pills),
   light and dark, phone first. */
:root {
  --bg: #f0f4f9; --surface: #ffffff; --surface-2: #e9eef6; --surface-3: #dde3ea;
  --ink: #1f1f1f; --muted: #5f6368; --line: #d3dbe5;
  --primary: #0b57d0; --primary-ink: #ffffff; --primary-soft: #d3e3fd; --primary-soft-ink: #041e49;
  --danger: #b3261e; --ok: #146c2e; --warn: #8a5300;
  --grad: linear-gradient(90deg, #4285f4 0%, #9b72cb 55%, #d96570 100%);
  --sel: #d96570;
  --radius: 24px; --radius-s: 14px;
  --shadow: 0 1px 2px rgba(60, 64, 67, .12), 0 2px 8px rgba(60, 64, 67, .08);
  --font: "Google Sans", "Google Sans Text", "Product Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131314; --surface: #1e1f20; --surface-2: #282a2c; --surface-3: #333537;
    --ink: #e3e3e3; --muted: #a8abb0; --line: #3c4043;
    --primary: #a8c7fa; --primary-ink: #062e6f; --primary-soft: #0842a0; --primary-soft-ink: #d3e3fd;
    --danger: #f2b8b5; --ok: #6dd58c; --warn: #ffb95c;
    --shadow: 0 1px 3px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 15px; line-height: 1.45;
  min-height: 100vh; min-height: 100dvh; }
a { color: var(--primary); }
.icon { width: 20px; height: 20px; flex: none; fill: currentColor; }

/* ---------------------------------------------------------------- app bar */
.appbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px;
  padding: 10px max(16px, env(safe-area-inset-left)); padding-top: max(10px, env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(12px); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); min-width: 0; }
.brand img { width: 32px; height: 32px; border-radius: 9px; }
.brand span { font-size: 19px; font-weight: 500; letter-spacing: -.2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand b { font-weight: 600; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.appbar nav { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.navlink { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 99px; color: var(--ink);
  text-decoration: none; font-weight: 500; }
.navlink:hover, .navlink.active { background: var(--surface-2); }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 600;
  background: var(--grad); color: #fff; text-transform: uppercase; border: 0; padding: 0; cursor: pointer; }
.menu { position: relative; }
.menu-pop { position: absolute; right: 0; top: 44px; min-width: 180px; background: var(--surface); border-radius: var(--radius-s);
  box-shadow: 0 4px 24px rgba(0,0,0,.18); padding: 6px; display: none; }
.menu-pop.open { display: block; }
.menu-pop .who { padding: 8px 12px; color: var(--muted); font-size: 13px; }
.menu-pop button, .menu-pop a { display: flex; width: 100%; text-align: left; padding: 10px 12px; border-radius: 10px;
  background: none; border: 0; color: var(--ink); font: inherit; text-decoration: none; cursor: pointer; }
.menu-pop button:hover, .menu-pop a:hover { background: var(--surface-2); }
@media (max-width: 640px) { .navlink span { display: none; } .navlink { padding: 8px 10px; } .brand span { font-size: 17px; } }

main { padding: 8px 16px calc(96px + env(safe-area-inset-bottom)); max-width: 1500px; margin: 0 auto; }

/* ---------------------------------------------------------------- surfaces */
.card { background: var(--surface); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 16px; box-shadow: var(--shadow); }
.hero { text-align: left; padding: 22px 22px 18px; }
.hero h1 { font-size: clamp(24px, 4vw, 34px); font-weight: 500; margin: 0 0 6px; letter-spacing: -.5px; }
.hero h1 .g { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
h1 { font-size: 22px; font-weight: 500; margin: 0; } h2 { font-size: 18px; font-weight: 500; margin: 0 0 10px; }
h3 { font-size: 13px; font-weight: 600; margin: 14px 0 6px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spacer { flex: 1; }
.hint { color: var(--muted); font-size: 13.5px; }
.small { font-size: 13px; padding-left: 18px; margin: 0; } .small li { margin: 3px 0; }
.error { color: var(--danger); }

/* ---------------------------------------------------------------- controls */
button, .button { font: inherit; font-weight: 500; border: 0; border-radius: 99px; padding: 10px 20px; min-height: 40px;
  cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--primary); color: var(--primary-ink); transition: filter .15s, background .15s; -webkit-tap-highlight-color: transparent; }
button:hover, .button:hover { filter: brightness(1.06); }
button.tonal, .button.tonal { background: var(--primary-soft); color: var(--primary-soft-ink); }
button.ghost, .button.ghost { background: transparent; color: var(--primary); box-shadow: inset 0 0 0 1px var(--line); }
button.text, .button.text { background: transparent; color: var(--primary); padding: 8px 12px; }
button.danger { color: var(--danger); }
button.gradient { background: var(--grad); color: #fff; }
button:disabled { opacity: .45; cursor: default; filter: none; }
.iconbtn { width: 44px; height: 44px; padding: 0; border-radius: 50%; background: var(--surface-2); color: var(--ink); }
input, select, textarea { font: inherit; color: var(--ink); background: var(--surface-2); border: 1px solid transparent;
  border-radius: var(--radius-s); padding: 10px 14px; min-height: 42px; outline: none; transition: border-color .15s, background .15s; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); background: var(--surface); }
textarea { width: 100%; resize: vertical; border-radius: 20px; }
label { display: inline-flex; gap: 8px; align-items: center; font-size: 14px; }
.check { gap: 6px; }

/* ---------------------------------------------------------------- login */
.login { max-width: 400px; margin: 8vh auto; display: flex; flex-direction: column; gap: 14px; padding: 28px; }
.login img { width: 56px; height: 56px; border-radius: 16px; }
.login label { flex-direction: column; align-items: stretch; gap: 6px; }

/* ---------------------------------------------------------------- add + list */
.composer { display: flex; gap: 10px; align-items: flex-end; background: var(--surface-2); border-radius: 28px; padding: 8px 8px 8px 18px; }
.composer textarea { background: transparent; border: 0; padding: 10px 0; min-height: 44px; border-radius: 0; }
.composer textarea:focus { background: transparent; }
.composer button { flex: none; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0 0; }
.chip { padding: 6px 14px; border-radius: 99px; background: var(--surface-2); font-size: 13px; border: 0; color: var(--ink); min-height: 32px; }
.chip.on { background: var(--primary-soft); color: var(--primary-soft-ink); }
.search { flex: 1; min-width: 160px; border-radius: 99px; }
table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
th, td { text-align: left; padding: 10px 10px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 500; font-size: 13px; }
tr.clickable { cursor: pointer; } tr.clickable:hover td { background: var(--surface-2); }
@media (max-width: 700px) {
  table.cards thead { display: none; }
  table.cards, table.cards tbody, table.cards tr, table.cards td { display: block; width: 100%; }
  table.cards tr { background: var(--surface-2); border-radius: var(--radius-s); padding: 10px 14px; margin-bottom: 10px; }
  table.cards td { border: 0; padding: 2px 0; }
  table.cards td[data-l]::before { content: attr(data-l) ": "; color: var(--muted); font-size: 12.5px; }
  table.cards td.code { font-size: 16px; font-weight: 600; }
}
.badge { font-size: 12.5px; padding: 3px 10px; border-radius: 99px; background: var(--surface-3); font-weight: 500; white-space: nowrap; }
.badge.done { background: #c4eed0; color: #0d4d22; } .badge.review { background: #ffe1b3; color: #5c3700; }
.badge.failed { background: #f9dedc; color: #8c1d18; } .badge.running { background: var(--primary-soft); color: var(--primary-soft-ink); }
.badge.queued { background: var(--surface-3); }
.badge.approved { background: #0b8043; color: #fff; } .badge.rejected { background: #5f6368; color: #fff; } .badge.waiting { background: var(--surface-3); color: var(--muted); }
@media (prefers-color-scheme: dark) {
  .badge.done { background: #0f5223; color: #c4eed0; } .badge.review { background: #5c3700; color: #ffdcbe; }
  .badge.failed { background: #601410; color: #f9dedc; }
}

/* ---------------------------------------------------------------- part page */
.part-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 6px 0 14px; }
.part-head h1 { font-size: clamp(20px, 3.5vw, 26px); }
.part-head .model { color: var(--muted); font-size: 15px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-left: auto; }
@media (max-width: 700px) { .actions { margin-left: 0; width: 100%; overflow-x: auto; flex-wrap: nowrap; } .actions > * { flex: none; } }
.layout { display: grid; grid-template-columns: minmax(220px, 1fr) minmax(380px, 2.3fr) minmax(260px, 1fr);
  grid-template-areas: "photo main props"; gap: 16px; align-items: start; }
.layout .main { grid-area: main; } .layout .props { grid-area: props; } .layout .photo { grid-area: photo; }
.layout > .card { margin-bottom: 0; }
@media (max-width: 1100px) { .layout { grid-template-columns: 1fr 1fr; grid-template-areas: "main main" "props photo"; } }
@media (max-width: 700px) { .layout { grid-template-columns: 1fr; grid-template-areas: "main" "props" "photo"; }
  .card { padding: 14px; border-radius: 20px; } }
.photo img { width: 100%; border-radius: var(--radius-s); background: #000; display: block; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 99px; padding: 4px; gap: 2px; }
.seg button { background: transparent; color: var(--ink); padding: 8px 16px; min-height: 36px; }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.toolbar { display: flex; gap: 8px; align-items: center; margin: 12px 0; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.toolbar::-webkit-scrollbar { display: none; }
.toolbar > * { flex: none; }
.tool { background: var(--surface-2); color: var(--ink); padding: 8px 14px; }
.tool .icon { width: 18px; height: 18px; }
.stage { position: relative; border-radius: 20px; overflow: hidden; background: var(--surface-2); }
.canvas { aspect-ratio: 1; display: flex; align-items: center; justify-content: center; outline: none; touch-action: none;
  background-image: radial-gradient(color-mix(in srgb, var(--muted) 25%, transparent) 1px, transparent 1px); background-size: 14px 14px; }
.canvas svg { width: 100%; height: 100%; }
.viewer { aspect-ratio: 1; touch-action: none; display: none; }
.viewer canvas { width: 100% !important; height: 100% !important; display: block; }
.stage.three .canvas { display: none; } .stage.three .viewer { display: block; }
.stage-note { position: absolute; left: 12px; bottom: 12px; right: 12px; display: flex; gap: 8px; flex-wrap: wrap; pointer-events: none; }
.stage-note > * { pointer-events: auto; }
.pill { background: color-mix(in srgb, var(--surface) 85%, transparent); backdrop-filter: blur(8px); border-radius: 99px;
  padding: 6px 12px; font-size: 12.5px; box-shadow: var(--shadow); color: var(--ink); border: 0; min-height: 32px; }
.savebar { display: flex; gap: 10px; align-items: center; margin-top: 12px; }
@media (max-width: 700px) {
  .savebar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 15; margin: 0; padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(12px); box-shadow: 0 -2px 12px rgba(0,0,0,.12); }
}
.props label { display: flex; justify-content: space-between; margin: 8px 0; gap: 10px; }
.props input, .props select { width: 62%; }
.nudge { display: grid; grid-template-columns: repeat(3, 44px); gap: 6px; justify-content: center; margin: 10px 0; }
.nudge button { width: 44px; height: 44px; padding: 0; border-radius: 12px; background: var(--surface-2); color: var(--ink); }
.ov-box { fill: transparent; stroke: #4285f4; stroke-dasharray: 0.06 0.04; cursor: move; }
.ov-box.sel { stroke: var(--sel); stroke-dasharray: none; fill: rgba(217, 101, 112, .06); }
.ov-handle { fill: #fff; stroke: var(--sel); cursor: nwse-resize; }
.ov-handle.ne, .ov-handle.sw { cursor: nesw-resize; }

/* ---------------------------------------------------------------- install prompt */
.install { position: fixed; z-index: 30; left: 50%; transform: translateX(-50%); bottom: calc(16px + env(safe-area-inset-bottom));
  width: min(520px, calc(100% - 24px)); background: var(--surface); border-radius: 22px; padding: 14px 16px;
  box-shadow: 0 8px 32px rgba(0,0,0,.22); display: flex; gap: 12px; align-items: center; animation: up .25s ease-out; }
.install[hidden] { display: none; }
.install img { width: 44px; height: 44px; border-radius: 12px; }
.install b { display: block; } .install p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.install .btns { margin-left: auto; display: flex; gap: 4px; flex: none; }
@keyframes up { from { transform: translate(-50%, 20px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }
@media (max-width: 700px) { body.has-savebar .install { bottom: calc(80px + env(safe-area-inset-bottom)); } }
.toast { position: fixed; z-index: 40; left: 50%; top: 70px; transform: translateX(-50%); background: #303030; color: #f2f2f2;
  padding: 10px 18px; border-radius: 12px; font-size: 14px; box-shadow: var(--shadow); }
.stage:not(.three) .stage-note { display: none; }

/* ---------------------------------------------------------------- settings */
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.settings-grid .card { margin-bottom: 0; }
.settings-grid .wide { grid-column: 1 / -1; }
@media (max-width: 900px) { .settings-grid { grid-template-columns: 1fr; } }
.field { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; flex: 1; min-width: 140px; }
.field > label { font-weight: 500; }
.field input { width: 100%; }
.grow { flex: 1; min-width: 0; }
.field .row { flex-wrap: nowrap; }
.state { font-weight: 400; font-size: 12.5px; color: var(--muted); margin-left: 6px; }
.state.on { color: var(--ok); }
.colors-wrap { display: grid; grid-template-columns: minmax(240px, 1fr) minmax(260px, 1.4fr); gap: 18px; align-items: start; }
@media (max-width: 800px) { .colors-wrap { grid-template-columns: 1fr; } }
.colors { display: flex; flex-direction: column; gap: 12px; }
.color-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--surface-2);
  border-radius: var(--radius-s); padding: 8px 12px; }
.color-row label { flex: 1; font-weight: 500; }
.swatch { width: 28px; height: 28px; border-radius: 8px; flex: none; box-shadow: inset 0 0 0 1px var(--line);
  background: repeating-linear-gradient(45deg, var(--surface-3) 0 4px, transparent 4px 8px); }
.rgb { width: 150px; font-family: ui-monospace, Menlo, monospace; text-align: center; }
.rgb.bad { border-color: var(--danger); }
.preview3d .viewer { aspect-ratio: 4 / 3; }

.status-pick { border-radius: 99px; padding: 8px 12px; min-height: 40px; max-width: 46vw; }

/* ---------------------------------------------------------------- narrow screens: never wider than the phone */
.layout > *, .settings-grid > *, .colors-wrap > * { min-width: 0; }
.layout { grid-template-columns: minmax(0, 1fr) minmax(0, 2.3fr) minmax(0, 1fr); }
@media (max-width: 1100px) { .layout { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
@media (max-width: 700px) {
  body { font-size: 14px; }
  main { padding-left: 10px; padding-right: 10px; }
  .layout { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .card { padding: 12px; border-radius: 18px; }
  .seg button { padding: 7px 12px; }
  .main .row label.hint { font-size: 12.5px; }
  .main .row select { padding: 6px 8px; min-height: 36px; max-width: 42vw; }
  .tool { padding: 7px 12px; min-height: 36px; }
  .savebar button#save { padding: 10px 16px; }
  .props input, .props select { width: 58%; }
  .field .row { flex-wrap: wrap; }
  .install { flex-wrap: wrap; }
  .install .btns { margin-left: auto; }
  .rgb { width: 120px; }
}

.menu-btn { background: transparent; border: 0; font: inherit; cursor: pointer; min-height: 40px; }
.menu-btn .caret { width: 16px; height: 16px; opacity: .7; }
@media (max-width: 640px) { .menu-btn .caret { display: none; } }
@media (max-width: 700px) { .stage-note { top: 10px; bottom: auto; left: 10px; right: 10px; } .stage-note .pill { font-size: 12px; padding: 5px 10px; min-height: 30px; } }
