/* One bundled Latin font so every computer renders the same widths; Chinese text falls back to the system font. */
@font-face { font-family: "Lato UI"; src: url("/fonts/lato-regular.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Lato UI"; src: url("/fonts/lato-medium.woff2") format("woff2"); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: "Lato UI"; src: url("/fonts/lato-semibold.woff2") format("woff2"); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: "Lato UI"; src: url("/fonts/lato-bold.woff2") format("woff2"); font-weight: 700; font-style: normal; font-display: swap; }
:root {
  color-scheme: light;
  --bg: #f3f5f1;
  --panel: #ffffff;
  --panel-2: #f8faf6;
  --text: #28332b;
  --muted: #6c7867;
  --line: #e4e9e1;
  --accent: #356b4d;
  --accent-2: #27563c;
  --accent-soft: #f0f5ee;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 13px/1.5 "Lato UI", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
button, input, summary, .task { -webkit-tap-highlight-color: transparent; }
button:focus-visible, summary:focus-visible, .task:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 3px; }
.app { display: grid; grid-template-columns: 376px minmax(0, 1fr); height: 100dvh; min-height: 0; }
#inferenceAside { min-width: 0; min-height: 0; display: flex; flex-direction: column; background: var(--panel); border-right: 1px solid var(--line); }
.steps { flex: 1; min-height: 0; padding: 8px 24px 28px; overflow-y: auto; scrollbar-width: thin; scrollbar-color: #d4dcd0 transparent; }
.step { padding: 24px 0; border-bottom: 1px solid var(--line); }
.step:last-of-type { border-bottom: 0; padding-bottom: 0; }
.step-title { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; font-size: 13px; font-weight: 600; }
.num { width: 18px; flex: none; color: #929b90; font-size: 11px; font-weight: 500; font-variant-numeric: tabular-nums; }
.step.done .num { color: var(--accent); }
.section-meta { margin-left: auto; color: var(--muted); font-size: 11px; font-weight: 400; }
.field { margin-bottom: 0; }
.field > label { display: block; margin-bottom: 8px; color: var(--muted); font-size: 12px; }
.seg { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 3px; padding: 3px; border: 1px solid var(--line); border-radius: 6px; background: #f5f7f2; }
.seg button { min-height: 31px; padding: 4px 8px; border: 1px solid transparent; border-radius: 4px; background: transparent; color: var(--muted); font-size: 12px; }
.seg button:hover { color: var(--text); }
.seg button.on { border-color: #d8e2d3; background: #fff; color: var(--accent); font-weight: 600; }
.hint { margin-top: 8px; color: var(--muted); font-size: 11.5px; line-height: 1.65; }
.upload-notes { margin-top: 12px; color: var(--muted); font-size: 11.5px; }
.upload-notes summary { width: fit-content; cursor: pointer; list-style: none; display: flex; align-items: center; gap: 6px; }
.upload-notes summary::-webkit-details-marker { display: none; }
.upload-notes summary::before { content: "+"; color: #9ba497; font-size: 14px; line-height: 1; }
.upload-notes[open] summary::before { content: "−"; }
.upload-notes .hint { padding: 0 0 0 14px; }
#limits { margin-top: 12px; font-size: 11px; line-height: 1.5; }
.dimension-guide { display: grid; grid-template-columns: 128px minmax(0, 1fr); align-items: center; gap: 16px; margin: 16px 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 6px; background: #fafbf8; }
.dimension-guide svg { display: block; width: 128px; height: 108px; overflow: visible; }
.dimension-copy { min-width: 0; }
.dimension-heading { margin-bottom: 6px; font-size: 11px; color: var(--muted); }
.axis-key { display: grid; grid-template-columns: 14px 1fr; gap: 4px 7px; font-size: 12px; }
.axis-key b { font-weight: 600; color: var(--accent); }
.dimension-guide #limits { margin-top: 8px; font-size: 10.5px; line-height: 1.4; }
@media (max-width: 1100px) { .dimension-guide { grid-template-columns: 108px minmax(0, 1fr); gap: 10px; padding: 10px; } .dimension-guide svg { width: 108px; } }
.slots { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; }
.slots:empty { display: none; }
.slot { display: grid; grid-template-columns: 60px minmax(0, 1fr); align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.slot .pic { display: grid; place-items: center; width: 60px; height: 60px; overflow: hidden; padding: 0; border: 1px dashed #cdd8c7; border-radius: 4px; background: #f8faf5; color: var(--muted); text-align: center; font-size: 10px; line-height: 1.4; }
.slot .pic img { width: 100%; height: 100%; object-fit: contain; }
.slot .pic.drag { border-color: var(--accent); background: var(--accent-soft); }
.slot .pic:disabled { border-style: solid; }
.slot-fields { min-width: 0; }
.slot input[type=text], .slot input[type=number] { width: 100%; min-width: 0; height: 34px; padding: 7px 9px; border: 1px solid #dce4d7; border-radius: 4px; outline: 0; background: #fff; color: var(--text); font-size: 12px; }
.slot input::placeholder { color: #a0a99b; opacity: 1; }
.slot input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px #356b4d10; }
.slot input:disabled { background: #f7f9f4; color: var(--muted); }
.slot .xyz { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.slot .xyz label { display: flex; flex-direction: column; align-items: stretch; gap: 5px; color: var(--muted); font-size: 11px; }
.slot .xyz label span { white-space: nowrap; }
.slot .xyz label b { color: var(--text); font-weight: 500; margin-right: 3px; }
.slot .xyz input { font-variant-numeric: tabular-nums; }
.slot .state { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 6px; color: var(--muted); font-size: 11px; overflow-wrap: anywhere; }
.slot .state.ok { color: var(--accent); }
.slot .state.bad { color: #a34135; }
.slot .state button, #cancelQueue { padding: 4px 7px; border: 1px solid var(--line); border-radius: 4px; background: #fff; color: var(--muted); font-size: 10.5px; }
.slot .state button:hover, #cancelQueue:hover { border-color: #b8c8b2; color: var(--text); }
.btn { display: block; width: 100%; min-height: 39px; padding: 9px 12px; border: 1px solid #cad7c3; border-radius: 5px; background: #fff; color: var(--accent); font-size: 12px; font-weight: 600; line-height: 1.5; transition: background .15s, border-color .15s; }
.btn:hover:not(:disabled) { border-color: var(--accent); background: #f5f8f1; }
.btn:disabled { opacity: .42; }
#upload { margin-top: 12px; }
#run { margin-top: 16px !important; border-color: var(--accent); background: var(--accent); color: #fff; }
#run:hover:not(:disabled) { border-color: var(--accent-2); background: var(--accent-2); }
#gen { margin-top: 14px !important; }
.card { padding: 12px; border: 1px solid var(--line); border-radius: 6px; background: #fafbf8; }
.drawn { margin-bottom: 10px; color: var(--muted); font-size: 11px; }
.drawn b { color: var(--text); font-weight: 500; font-variant-numeric: tabular-nums; }
.objects { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px; margin: 0; padding: 0; list-style: none; }
.objects li { display: flex; min-width: 0; align-items: center; gap: 6px; overflow: hidden; padding: 5px 6px; border: 1px solid #edf0e9; border-radius: 3px; background: #fff; font-size: 11.5px; }
.objects .name { flex: 1 1 0; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.objects .object-label { display: flex; flex: 1 1 0; flex-direction: column; gap: 2px; min-width: 0; }
.objects .object-label .name { flex: none; }
.objects .object-id { color: var(--muted); font: 10px/1.4 ui-monospace, monospace; overflow-wrap: anywhere; user-select: text; }
.dot { flex: none; width: 6px; height: 6px; border-radius: 50%; background: #9da99c; }
.dot.custom { background: var(--accent); }
.legend { display: flex; gap: 12px; margin-top: 10px; color: #6f7b69; font-size: 10px; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.tasks { display: flex; flex-direction: column; gap: 5px; max-height: 286px; overflow-y: auto; scrollbar-width: thin; scrollbar-color: #d4dcd0 transparent; padding: 1px; }
.task-group { display: flex; align-items: baseline; justify-content: space-between; padding: 9px 1px 3px; color: var(--muted); font-size: 11px; font-weight: 500; }
.task-group:first-child { padding-top: 0; }
.task-group span { font-size: 10px; font-weight: 400; font-variant-numeric: tabular-nums; }
.task { display: flex; align-items: flex-start; gap: 8px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 4px; background: #fff; color: #4b574a; cursor: pointer; font-size: 12px; line-height: 1.5; }
.task:hover { border-color: #bfd0b6; }
.task.on { border-color: #b7ccb0; background: #f1f6ed; color: #29492e; }
.task > span { min-width: 0; overflow-wrap: anywhere; }
.task input { flex: none; width: 13px; height: 13px; margin: 3px 0 0; accent-color: var(--accent); }
.badge { display: inline; margin-left: 6px; color: var(--accent); font-size: 10px; font-weight: 500; }
.track { position: relative; height: 4px; margin: 4px 0 12px; }
.track .rail { position: absolute; inset: 0; overflow: hidden; border-radius: 2px; background: #e4eadd; }
.track .rail > div { width: 0; height: 100%; border-radius: 2px; background: var(--accent); transition: width .6s; }
.track .bot, .track .goal { display: none; }
.stage { color: #59644f; font-size: 12px; }
#cancelQueue { margin-top: 10px; }
.finished { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); color: var(--accent); font-size: 12px; }
.error { margin-top: 14px; color: #a34135; font-size: 12px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.error:empty { display: none; }
#capacityHint { margin: 12px 0 0; padding: 9px 10px; border: 1px solid #e5e5d3; border-radius: 4px; background: #fafaf2; color: #7a785a; font-size: 11px; line-height: 1.5; }
#inferenceMain { position: relative; min-width: 0; min-height: 0; overflow: hidden; background: #f2f4ef; }
#view { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.empty-view { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; color: #98a18f; pointer-events: none; }
.empty-view svg { width: 160px; height: 124px; color: #c8d0c0; }
.empty-view p { margin: 0; font-size: 12px; color: #78856e; }
#view:not([hidden]) ~ .empty-view { display: none; }
@media (max-width: 1100px) { .steps { padding-left: 20px; padding-right: 20px; } }
@media (max-width: 760px) {
  .app { height: auto; min-height: 100dvh; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(380px, 62dvh); }
  #inferenceAside { border-right: 0; border-bottom: 1px solid var(--line); }
  .steps { overflow: visible; padding: 0 24px 24px; }
  .step { padding: 22px 0; }
  .tasks { max-height: 236px; }
  /* Phones: no blank band above the 3D view, roomier taps, and 16px inputs so iOS does not zoom while typing. */
  .app { align-content: start; }
  .steps { padding: 0 max(16px, env(safe-area-inset-right, 0px)) 24px max(16px, env(safe-area-inset-left, 0px)); }
  .seg button { min-height: 40px; font-size: 13px; }
  .btn { min-height: 44px; font-size: 13px; }
  .slot input[type=text], .slot input[type=number] { height: 40px; font-size: 16px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }

/* Per-object actions and processing stages. No estimated percentage is fabricated. */
.slot { grid-template-columns: 48px minmax(0, 1fr) 26px; gap: 10px; }
.slot .pic { width: 48px; height: 48px; }
.remove-object { width: 26px; height: 28px; padding: 0; border: 0; border-radius: 4px; background: transparent; color: var(--muted); font: 22px/1 system-ui, sans-serif; cursor: pointer; }
.remove-object:hover { background: #f5f3f2; color: #8b3434; }
.remove-object:disabled { opacity: .35; cursor: default; }
.asset-progress { grid-column: 1 / -1; min-width: 0; }
.asset-steps { display: flex; justify-content: space-between; gap: 5px; margin: 0 0 8px; padding: 0; list-style: none; color: #879188; font-size: 10px; line-height: 1.4; }
.asset-steps li { white-space: nowrap; }
.asset-steps .complete { color: #657b6b; }
.asset-steps .current { color: #246843; font-weight: 600; }
.asset-bar { height: 3px; overflow: hidden; background: #e9eeea; border-radius: 2px; }
.asset-bar span { display: block; height: 100%; width: 35%; border-radius: inherit; background: #43835a; animation: asset-processing 1.4s ease-in-out infinite alternate; }
.asset-elapsed { display: block; margin-top: 6px; text-align: right; color: var(--muted); font-size: 10px; font-variant-numeric: tabular-nums; }
#assetNotice { margin-top: 8px; font-size: 11px; line-height: 1.5; }
@keyframes asset-processing { from { transform: translateX(0); } to { transform: translateX(185%); } }
@media (prefers-reduced-motion: reduce) { .asset-bar span { animation: none; width: 100%; opacity: .55; } }

/* Three explicit choices, using the existing sidebar palette. */
.task-choices{display:grid;gap:8px;margin-top:12px}
.task-choices label{font-size:12px;font-weight:600;margin-top:5px}
.task-choices select{width:100%;min-width:0;padding:10px 11px;border:1px solid var(--line,#d9dfd5);border-radius:8px;background:var(--card,#fff);color:var(--text,#25352b);font:inherit;font-size:13px}
.task-choices select:disabled{opacity:.55;cursor:not-allowed}
.task-choices select:focus-visible{outline:2px solid var(--accent,#356b4d);outline-offset:2px}
.task-choices #taskSummary{margin:4px 0 0;line-height:1.55;min-height:2.8em}
/* Task choices as buttons: three equal columns, width never depends on the name. Uploaded objects: light green, bold green border. */
.task-choices .choice-label{font-size:12px;font-weight:600;margin-top:5px}
.choice-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:6px}
.choice-grid.off{opacity:.5}
.choice{position:relative;display:grid;grid-template-columns:minmax(0,1fr);row-gap:1px;align-content:center;min-width:0;min-height:48px;padding:7px 9px;border:1px solid var(--line);border-radius:9px;background:var(--panel);color:var(--text);font:inherit;text-align:left;cursor:pointer}
.choice:hover:not(:disabled){border-color:#b5c7b8}
.choice:disabled{cursor:not-allowed}
.choice:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
.choice .nm{font-size:13px;font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.choice .cid{font-size:11px;color:#8e9a8a;font-variant-numeric:tabular-nums;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.choice.on{background:var(--accent);border-color:var(--accent);color:#fff}
.choice.on .cid{color:rgba(255,255,255,.8)}
.choice-grid.relations .choice{display:flex;justify-content:center;min-height:38px}
.choice.na{opacity:.35}
.choice-empty{grid-column:1/-1;margin:0;color:var(--muted);font-size:12px}
/* Tabletop scene list keeps its look; only its full-name card matches the task buttons (two columns here). */
.objects li{position:relative;overflow:visible}
.objects li .tip{position:absolute;z-index:20;left:0;bottom:calc(100% + 8px);display:block;width:max-content;max-width:240px;padding:7px 11px;border:1px solid #cfdccf;border-radius:8px;background:#fff;color:var(--text);font-size:13px;font-weight:600;line-height:1.35;white-space:normal;overflow-wrap:anywhere;text-align:left;box-shadow:0 6px 18px rgba(40,60,45,.14);opacity:0;visibility:hidden;pointer-events:none;transform:translateY(4px);transition:opacity .12s ease,transform .12s ease,visibility .12s}
.objects li .tip::before,.objects li .tip::after{content:"";position:absolute;top:100%;left:22px;border:6px solid transparent}
.objects li .tip::before{margin-left:-6px;border-top-color:#cfdccf}
.objects li .tip::after{margin-left:-5px;margin-top:-1px;border-width:5px;border-top-color:#fff}
.objects li:nth-child(2n) .tip{left:auto;right:0}
.objects li:nth-child(2n) .tip::before,.objects li:nth-child(2n) .tip::after{left:auto;right:16px;margin-left:0}
.objects li:nth-child(2n) .tip::after{right:17px}
.objects li.tip-on .tip{opacity:1;visibility:visible;transform:translateY(0)}
/* Hover card with the full name: shown whenever the mouse is anywhere on an object button; kept inside the sidebar on the outer columns. */
.choice .tip{position:absolute;z-index:20;left:50%;bottom:calc(100% + 8px);transform:translate(-50%,4px);display:block;width:max-content;max-width:240px;padding:7px 11px;border:1px solid #cfdccf;border-radius:8px;background:#fff;color:var(--text);font-size:13px;font-weight:600;line-height:1.35;white-space:normal;overflow-wrap:anywhere;text-align:left;box-shadow:0 6px 18px rgba(40,60,45,.14);opacity:0;visibility:hidden;pointer-events:none;transition:opacity .12s ease,transform .12s ease,visibility .12s}
.choice .tip::before,.choice .tip::after{content:"";position:absolute;top:100%;left:50%;border:6px solid transparent}
.choice .tip::before{margin-left:-6px;border-top-color:#cfdccf}
.choice .tip::after{margin-left:-5px;margin-top:-1px;border-width:5px;border-top-color:#fff}
.choice.tip-on .tip,.choice:focus-visible .tip{opacity:1;visibility:visible;transform:translate(-50%,0)}
.choice-grid > .choice:nth-child(3n+1) .tip{left:0;transform:translate(0,4px)}
.choice-grid > .choice:nth-child(3n+1) .tip::before{left:22px}
.choice-grid > .choice:nth-child(3n+1) .tip::after{left:22px}
.choice-grid > .choice:nth-child(3n) .tip{left:auto;right:0;transform:translate(0,4px)}
.choice-grid > .choice:nth-child(3n) .tip::before,.choice-grid > .choice:nth-child(3n) .tip::after{left:auto;right:16px;margin-left:0}
.choice-grid > .choice:nth-child(3n) .tip::after{right:17px}
.choice-grid > .choice.tip-on:nth-child(3n+1) .tip,.choice-grid > .choice:nth-child(3n+1):focus-visible .tip,
.choice-grid > .choice.tip-on:nth-child(3n) .tip,.choice-grid > .choice:nth-child(3n):focus-visible .tip{transform:translate(0,0)}
@media (prefers-reduced-motion: reduce){.choice .tip,.objects li .tip{transition:none}}
/* Phones: two object buttons per row so names fit; kept last so it overrides the base button rules. */
@media (max-width: 480px) {
  .choice-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .choice-grid.relations { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .choice { min-height: 52px; }
  .choice .nm { font-size: 14px; }
  .choice-grid > .choice:nth-child(n) .tip { left: 0; right: auto; transform: none; }
  .choice-grid > .choice.tip-on:nth-child(n) .tip { transform: none; }
  .choice-grid > .choice:nth-child(n) .tip::before, .choice-grid > .choice:nth-child(n) .tip::after { left: 22px; right: auto; }
  .choice-grid > .choice:nth-child(2n) .tip { left: auto; right: 0; }
  .choice-grid > .choice:nth-child(2n) .tip::before, .choice-grid > .choice:nth-child(2n) .tip::after { left: auto; right: 16px; margin-left: 0; }
  .choice-grid > .choice:nth-child(2n) .tip::after { right: 17px; }
}
/* Phones while inference runs: progress becomes a slim translucent bar floating at the bottom of the 3D view. */
@media (max-width: 760px) {
  body.inferring #step4 { position: fixed; z-index: 30; left: max(12px, env(safe-area-inset-left, 0px)); right: max(12px, env(safe-area-inset-right, 0px)); bottom: calc(12px + env(safe-area-inset-bottom, 0px)); padding: 0; border: 0; }
  body.inferring #step4 .step-title, body.inferring #step4 #queueDetails, body.inferring #step4 #taskConnection, body.inferring #step4 #result { display: none; }
  body.inferring #step4 .card { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 6px 10px; padding: 8px 12px; border: 1px solid rgba(255, 255, 255, .6); border-radius: 10px; background: rgba(255, 255, 255, .72); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); box-shadow: 0 4px 16px rgba(30, 45, 35, .16); }
  body.inferring #step4 .stage { grid-row: 1; grid-column: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
  body.inferring #step4 #cancelQueue { grid-row: 1; grid-column: 2; margin: 0; }
  body.inferring #step4 .track { grid-row: 2; grid-column: 1 / -1; margin: 0; height: 3px; }
  body.inferring #step4 .track .rail { background: rgba(53, 107, 77, .18); }
}
