:root {
  --bg: #f4f5f7; --card: #fff; --ink: #1e2430; --muted: #667085; --line: #e1e4ea; --accent: #1f6feb;
  --ok: #1a7f37; --ng: #c62828; --warn: #b26a00; --hl: #ff7a00;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", "Segoe UI", sans-serif; color: var(--ink);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); font-size: 14px; line-height: 1.5; }
code { font-family: "SF Mono", Menlo, Consolas, monospace; font-size: 0.92em; background: #eef1f5; padding: 0 0.3em; border-radius: 3px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.card h2 { margin: 0 0 8px; font-size: 15px; display: flex; align-items: center; gap: 6px; }
.collapseToggle { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 12px; padding: 2px 4px; line-height: 1; }
.collapseToggle:hover { color: var(--accent); }
.card.collapsible.collapsed .cardBody { display: none; }
.card.collapsible.collapsed h2 { margin-bottom: 0; }
.card.collapsible.collapsed .collapseToggle { transform: rotate(-90deg); }
.card h2 small { font-weight: normal; color: var(--muted); font-size: 12px; margin-left: 8px; }
.loader { margin: 6px 24px 0; }
.loaderRow { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.loaderRow label { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
.fileLabel input { width: auto; }
.hint { color: var(--muted); font-size: 12px; margin: 6px 0 0; }
.layout { display: grid; grid-template-columns: 300px minmax(360px, 1fr) 500px; gap: 14px; padding: 12px 24px 32px; align-items: start; }
.column { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
input, select, textarea { font: inherit; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: #fff; width: 100%; }
input[type="file"] { padding: 4px 0; border: 0; }
input[type="checkbox"] { width: auto; }
button { font: inherit; padding: 7px 14px; border-radius: 6px; border: 1px solid var(--accent); background: var(--accent); color: #fff; cursor: pointer; }
button:disabled { opacity: 0.5; cursor: default; }
button.secondary { background: #fff; color: var(--accent); }
.actions { display: flex; align-items: center; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
.status { color: var(--muted); font-size: 12px; }
.status.error { color: var(--ng); }
.list { max-height: 260px; overflow: auto; border: 1px solid var(--line); border-radius: 6px; margin-top: 6px; }
.item { padding: 6px 8px; border-bottom: 1px solid var(--line); cursor: pointer; font-size: 13px; }
.item:last-child { border-bottom: 0; }
.item:hover { background: #f0f5ff; }
.item.selected { background: #e3edff; }
.item.hl { box-shadow: inset 3px 0 0 var(--hl); }
.item .sub { color: var(--muted); font-size: 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; margin-top: 8px; }
.grid2 label { display: flex; flex-direction: column; gap: 2px; }
.grid2 label.wide { grid-column: 1 / -1; }
.grid2 label span { color: var(--muted); font-size: 12px; }
.addRecord { margin-top: 8px; }
.addRecord summary { cursor: pointer; color: var(--accent); font-size: 13px; }
.viewerCard { display: flex; flex-direction: column; height: calc(100vh - 190px); min-height: 520px; }
.viewerHead { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.toggle { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 4px; }
.viewerTools { display: flex; align-items: center; gap: 14px; white-space: nowrap; flex-shrink: 0; }
.cameraTools { margin-top: 6px; gap: 8px; }
#placeCamera.active { background: #9c36b5; color: #fff; border-color: #9c36b5; }
#gizmoModeGroup { display: inline-flex; gap: 4px; }
#gizmoModeGroup button.active { background: var(--accent); color: #fff; }
.viewerHead h2 small { display: block; margin-left: 0; }
.viewerTools input[type="range"] { width: 110px; padding: 0; }
button.small { padding: 3px 10px; font-size: 12px; }
.viewer { width: 100%; flex: 1 1 auto; min-height: 240px; border: 1px solid var(--line); border-radius: 6px; background: #fbfbfc; position: relative; overflow: hidden; }
.viewer canvas { display: block; }
.caption { min-height: 20px; color: var(--hl); font-size: 13px; margin-top: 6px; }
.selection { font-size: 13px; margin-top: 4px; overflow-y: auto; flex-shrink: 1; }
.selection dl { display: grid; grid-template-columns: 110px 1fr; gap: 2px 10px; margin: 6px 0 0; }
.selection dt { color: var(--muted); } .selection dd { margin: 0; overflow-wrap: anywhere; }
.chatColumn { position: sticky; top: 12px; }
.chat { display: flex; flex-direction: column; height: calc(100vh - 190px); min-height: 520px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.chip { font-size: 12px; padding: 3px 8px; background: #fff; color: var(--accent); border-color: var(--line); }
.messages { flex: 1; overflow: auto; border: 1px solid var(--line); border-radius: 6px; padding: 8px; display: flex; flex-direction: column; gap: 8px; background: #fafbfc; }
.msg { max-width: 95%; padding: 8px 10px; border-radius: 8px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13px; }
.msg.user { align-self: flex-end; background: #e3edff; }
.msg.assistant { align-self: stretch; background: #fff; border: 1px solid var(--line); white-space: normal; line-height: 1.6; }
.msg.assistant p { margin: 0 0 6px; }
.msg.assistant p:last-child, .msg.assistant ul:last-child, .msg.assistant ol:last-child { margin-bottom: 0; }
.msg.assistant h3, .msg.assistant h4, .msg.assistant h5 { margin: 8px 0 4px; font-size: 13px; }
.msg.assistant h3:first-child, .msg.assistant h4:first-child { margin-top: 0; }
.msg.assistant ul, .msg.assistant ol { margin: 4px 0 8px; padding-left: 20px; }
.msg.assistant li { margin: 2px 0; }
.msg.assistant .tableWrap { overflow-x: auto; margin: 6px 0 8px; }
.msg.assistant table { border-collapse: collapse; width: auto; min-width: 100%; font-size: 12px; font-variant-numeric: tabular-nums; }
.msg.assistant th, .msg.assistant td { border: 1px solid var(--line); padding: 3px 6px; text-align: left; vertical-align: top; white-space: nowrap; overflow-wrap: normal; word-break: normal; }
.msg.assistant th:last-child, .msg.assistant td:last-child { white-space: normal; overflow-wrap: anywhere; word-break: normal; min-width: 140px; }
.msg.assistant th { background: #f4f6f9; font-weight: 600; }
.msg.assistant pre { margin: 4px 0 8px; padding: 6px 8px; background: #eef1f5; border-radius: 4px; overflow: auto; font-size: 12px; }
.msg.assistant hr { border: 0; border-top: 1px solid var(--line); margin: 8px 0; }
.msg.assistant a.ref { color: var(--hl); font-weight: 600; text-decoration: none; border-bottom: 1px dotted var(--hl); }
.msg.assistant a.ref:hover { background: #fff3e6; }
.msg.error { align-self: stretch; background: #fdecea; color: var(--ng); }
.trace { align-self: flex-start; font-size: 12px; color: var(--muted); }
.trace details { margin: 2px 0; }
.trace summary { cursor: pointer; }
.trace pre { margin: 2px 0 4px; padding: 6px; background: #eef1f5; border-radius: 4px; max-height: 180px; overflow: auto; font-size: 11px; }
.usage { font-size: 11px; color: var(--muted); }
.msg.thinking { color: var(--muted); align-self: flex-start; }
.dots i { display: inline-block; width: 5px; height: 5px; margin-left: 3px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.dots i:nth-child(2) { animation-delay: 0.2s; } .dots i:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.2; } 40% { opacity: 1; } }
.chatForm { margin-top: 8px; }
@media (max-width: 1200px) { .layout { grid-template-columns: 1fr 1fr; } .chatColumn, .viewerCard { grid-column: 1 / -1; } .chat, .viewerCard { height: 560px; position: static; } }
@media (max-width: 800px) { .layout { grid-template-columns: 1fr; } }

/* ---- customer-facing tidy-up ---- */
.modelBar { margin: 16px 24px 0; padding: 10px 16px; }
.modelHead { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.modelTitle { font-weight: 600; font-size: 15px; }
.modelChip { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 999px; background: #eef1f5; color: var(--ink); margin-right: 6px; }
.loaderDetails { margin-left: auto; font-size: 12px; }
.loaderDetails summary { cursor: pointer; color: var(--accent); }
.loaderDetails .loaderRow { margin-top: 8px; }
.techDetails { margin-top: 6px; font-size: 12px; }
.techDetails summary { cursor: pointer; color: var(--muted); }
.muted { color: var(--muted); font-weight: normal; font-size: 12px; }
.list.tall { max-height: 380px; }
.item.rec { padding: 7px 8px; }
.recHead { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.recBody { font-size: 13px; margin-top: 2px; }
.kind { display: inline-block; color: #fff; font-size: 11px; padding: 0 6px; border-radius: 4px; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; color: var(--muted); margin: 2px 0 6px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 4px; vertical-align: -2px; }
.legend i.dot { border-radius: 50%; width: 10px; height: 10px; }
.viewerFoot { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 6px; flex-wrap: wrap; }
.viewerLegend { margin: 0; }
.selHead { margin-top: 6px; }
.selection dl { grid-template-columns: 96px 1fr; }
.selection a.ref { color: var(--hl); text-decoration: none; border-bottom: 1px dotted var(--hl); }
.trace > details > summary { color: var(--muted); }
.trace details.call { margin: 2px 0 2px 14px; }
.trace details.call summary { font-family: "SF Mono", Menlo, Consolas, monospace; font-size: 11px; }
