:root {
  --bg: #f5f2ec;
  --panel: rgba(255, 254, 251, 0.96);
  --panel-2: #fbf9f5;
  --panel-solid: #fffefb;
  --line: #ece7de;
  --line-2: #ddd6ca;
  --ink: #2e2c29;
  --ink-2: #5f5a52;
  --muted: #968f84;
  --dim: #bdb6aa;
  --accent: #6f86d6;
  --accent-2: #a78bcf;
  --accent-soft: #eef1fb;
  --ok: #4e9a7c;
  --warn: #c28a38;
  --err: #cc6a62;
  --run: #6f86d6;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(80, 64, 40, 0.04), 0 12px 32px rgba(80, 64, 40, 0.06);
  --shadow-soft: 0 1px 2px rgba(80, 64, 40, 0.05), 0 4px 14px rgba(80, 64, 40, 0.05);
  --shadow-pop: 0 2px 6px rgba(80, 64, 40, 0.06), 0 18px 48px rgba(80, 64, 40, 0.14);
  --mono: "SF Mono", ui-monospace, "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  color-scheme: light;
  font-family: var(--sans);
  font-size: 14px;
  color: var(--ink);
  background: var(--bg);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-height: 100vh; background: var(--bg); overflow-x: hidden; -webkit-font-smoothing: antialiased; }
body.no-scroll { overflow: hidden; }
[hidden] { display: none !important; }
a { color: var(--accent); text-decoration: none; }
button { font: inherit; color: inherit; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.hint { color: var(--muted); font-size: 12px; line-height: 1.55; }

::selection { background: rgba(111, 134, 214, 0.2); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(120, 108, 90, 0.18); border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }

/* ------------------------------------------------------------ status chips */
.sys-chip { display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--panel-solid); color: var(--ink-2); font-size: 12px; white-space: nowrap; }
.sys-chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--dim); }
.sys-chip.online .dot { background: var(--ok); animation: ping 2.6s infinite; }
.sys-chip.offline .dot { background: var(--err); }
.sys-chip.busy { color: var(--accent); }

/* ------------------------------------------------------------ layout */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; min-width: 0; }
/* a panel whose ⋯ menu is open is lifted above the panels that follow it */
.panel:has(.menu) { position: relative; z-index: 45; }
.section-title { display: flex; align-items: center; gap: 10px; margin: 0 0 14px; font-size: 13.5px; font-weight: 650; color: var(--ink); }
.section-title::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.section-title .aside { margin-left: auto; font-weight: 400; display: flex; align-items: center; gap: 8px; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn { from { opacity: 0; transform: translateY(-4px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes ping { 0% { box-shadow: 0 0 0 0 rgba(78, 154, 124, 0.45); } 70% { box-shadow: 0 0 0 7px rgba(78, 154, 124, 0); } 100% { box-shadow: 0 0 0 0 rgba(78, 154, 124, 0); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { from { background-position: -200% 0; } to { background-position: 200% 0; } }
@keyframes scan { 0% { transform: translateX(-100%); } 100% { transform: translateX(260%); } }
@keyframes flow { to { background-position: 40px 0; } }
@keyframes pulseRing { 0% { box-shadow: 0 0 0 0 rgba(111, 134, 214, 0.4); } 70% { box-shadow: 0 0 0 12px rgba(111, 134, 214, 0); } 100% { box-shadow: 0 0 0 0 rgba(111, 134, 214, 0); } }

/* ------------------------------------------------------------ buttons */
.btn-primary { position: relative; overflow: hidden; display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 36px; padding: 0 16px;
  border: 0; border-radius: 11px; cursor: pointer; font-weight: 600; font-size: 13.5px; color: #fff; letter-spacing: 0.04em;
  background: linear-gradient(120deg, #7f95e0 0%, #97a0e0 50%, #ad92d6 100%);
  box-shadow: 0 6px 18px rgba(111, 134, 214, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.35); transition: transform 0.15s, box-shadow 0.2s, opacity 0.2s; }
.btn-primary:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 10px 26px rgba(111, 134, 214, 0.36), inset 0 1px 0 rgba(255, 255, 255, 0.35); }
.btn-primary:disabled { cursor: not-allowed; opacity: 0.6; box-shadow: none; }
.icon-btn { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel-solid); color: var(--ink-2); cursor: pointer; transition: color 0.15s, border-color 0.15s, background 0.15s; flex: none; }
.icon-btn:hover, .icon-btn[aria-expanded="true"] { color: var(--accent); border-color: #d6ddf3; background: var(--accent-soft); }
.icon-btn.plain { border-color: transparent; background: transparent; }

/* ------------------------------------------------------------ menu (collapsed actions) */
.menu-wrap { position: relative; display: inline-flex; }
.menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 60; min-width: 220px; padding: 6px; border-radius: 13px; border: 1px solid var(--line);
  background: var(--panel-solid); box-shadow: var(--shadow-pop); animation: popIn 0.16s ease both; }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; border-radius: 9px; background: transparent; color: var(--ink);
  font-size: 13px; text-align: left; cursor: pointer; white-space: nowrap; text-decoration: none !important; }
.menu-item:hover { background: var(--accent-soft); color: var(--accent); }
.menu-item.danger { color: var(--err); }
.menu-item.danger:hover { background: #fbf0ee; }
.menu-item:disabled { opacity: 0.45; cursor: default; background: transparent; color: var(--ink); }
.menu-item .mi-icon { width: 16px; text-align: center; color: var(--muted); }
.menu-item .mi-note { margin-left: auto; font-size: 11px; color: var(--muted); }
.menu-sep { height: 1px; background: var(--line); margin: 5px 4px; }
.menu-label { font-size: 11px; color: var(--muted); padding: 6px 10px 3px; }

/* ------------------------------------------------------------ modal (new analysis) */
.modal { position: fixed; inset: 0; z-index: 90; display: grid; place-items: start center; padding: 72px 16px 24px; background: rgba(60, 52, 40, 0.18); backdrop-filter: blur(6px); animation: fadeIn 0.18s ease; overflow-y: auto; }
.modal-card { width: min(460px, 100%); background: var(--panel-solid); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow-pop); padding: 22px 24px 24px; animation: popIn 0.22s ease both; }
.modal-head { display: flex; align-items: center; margin-bottom: 16px; }
.modal-head h2 { margin: 0; font-size: 17px; font-weight: 650; }
.modal-head .icon-btn { margin-left: auto; }

.field-label { display: block; font-size: 12px; color: var(--ink-2); margin-bottom: 8px; font-weight: 600; }
.input { width: 100%; height: 36px; padding: 0 12px; border-radius: var(--radius-sm); border: 1px solid var(--line-2); background: var(--panel-solid); color: var(--ink); font: inherit; outline: none; transition: border-color 0.15s, box-shadow 0.15s; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(111, 134, 214, 0.14); }
.input::placeholder { color: var(--dim); }
select.input { appearance: none; padding-right: 30px; font-size: 12px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 15px) 15px, calc(100% - 10px) 15px; background-size: 5px 5px; background-repeat: no-repeat; }
.form-message { margin-top: 10px; font-size: 12.5px; color: var(--ink-2); word-break: break-all; }
.form-message:empty { display: none; }
.form-message.error { color: var(--err); }

.empty { color: var(--muted); font-size: 12.5px; text-align: center; padding: 20px 0; }

/* ------------------------------------------------------------ chips */
.chip { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px; border-radius: 999px; font-size: 11.5px; white-space: nowrap; border: 1px solid var(--line); background: var(--panel-2); color: var(--ink-2); }
.chip.ok { color: #3f8467; border-color: #d3e8dd; background: #eef6f1; }
.chip.warn { color: #a8762c; border-color: #f0e1c5; background: #fbf5ea; }
.chip.err { color: #b85c55; border-color: #f0d6d2; background: #fbf1ef; }
.chip.running, .chip.queued { color: var(--accent); border-color: #dbe1f5; background: var(--accent-soft); }
.chip.pending { color: var(--muted); }
.chip.scope { color: #8a6fbb; border-color: #e6dcf3; background: #f5f0fa; }
.chip.layer { height: 26px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; color: var(--ink); background: var(--panel-solid); }
.chip.layer.ok { color: #2f6f55; border-color: #d3e8dd; background: #f3f9f5; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }

/* ------------------------------------------------------------ KPI */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 1000px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.kpi { border-radius: 14px; border: 1px solid var(--line); background: var(--panel-solid); padding: 16px 18px; min-width: 0; box-shadow: var(--shadow-soft); }
.kpi-label { font-size: 12px; color: var(--muted); }
.kpi-value { font-family: var(--mono); font-size: 26px; font-weight: 600; margin-top: 6px; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink); }
.kpi-value small { font-size: 13px; color: var(--muted); font-weight: 500; margin-left: 3px; }
.kpi-sub { font-size: 11.5px; color: var(--muted); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-sub:empty { display: none; }
.kpi.ok .kpi-value { color: var(--ok); }
.kpi.warn .kpi-value { color: var(--warn); }
.kpi.err .kpi-value { color: var(--err); }
.kpi.run .kpi-value { color: var(--run); }

/* ------------------------------------------------------------ job header */
.menu .kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 5px 14px; margin: 0; padding: 8px 10px 4px; font-size: 12px; max-width: 360px; }
.menu .kv dt { color: var(--muted); }
.menu .kv dd { margin: 0; color: var(--ink); word-break: break-all; font-family: var(--mono); font-size: 11.5px; }

.banner { display: flex; gap: 12px; align-items: flex-start; border-radius: 12px; padding: 10px 14px; font-size: 13px; line-height: 1.6; border: 1px solid; }
.banner .b-icon { flex: none; width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 11px; margin-top: 2px; color: #fff; }
.banner .b-body { min-width: 0; word-break: break-word; }
.banner strong { font-weight: 600; margin-right: 8px; }
.banner.info { border-color: #dbe1f5; background: #f2f5fd; color: #4d609f; }
.banner.info .b-icon { background: var(--accent); }
.banner.warn { border-color: #f0e1c5; background: #fcf7ee; color: #8a6427; }
.banner.warn .b-icon { background: var(--warn); }
.banner.error { border-color: #f0d6d2; background: #fcf2f0; color: #9a4b45; }
.banner.error .b-icon { background: var(--err); }

/* ------------------------------------------------------------ progress bar */
.bar { position: relative; height: 6px; border-radius: 99px; overflow: hidden; background: #e6e9f4; margin-top: 14px; }
.bar-fill { position: absolute; inset: 0 auto 0 0; border-radius: 99px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width 0.4s ease; }
.bar.indeterminate .bar-fill { width: 36% !important; animation: scan 1.5s ease-in-out infinite; }

/* ------------------------------------------------------------ viewer */
.viewer { border-radius: 12px; border: 1px solid var(--line); background: #fff; overflow: hidden; position: relative; cursor: zoom-in; }
.viewer img { display: block; width: 100%; height: auto; opacity: 0; transition: opacity 0.35s; }
.viewer img.loaded { opacity: 1; }
.viewer.loading { min-height: 240px; background: linear-gradient(90deg, #f1ede6 0%, #faf8f4 50%, #f1ede6 100%); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
.placeholder { border-radius: 12px; border: 1px dashed var(--line-2); color: var(--muted); display: grid; place-items: center; min-height: 160px; font-size: 13px; background: var(--panel-2); }

/* ------------------------------------------------------------ table */
.table-wrap { overflow-x: auto; border-radius: 14px; border: 1px solid var(--line); background: var(--panel-solid); }
.table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.table th { text-align: left; font-weight: 600; font-size: 11.5px; color: var(--muted); padding: 11px 14px; background: var(--panel-2); border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: top; color: var(--ink-2); }
.table tbody tr { transition: background 0.15s; }
.table tbody tr:hover { background: #faf8f4; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tr.clickable { cursor: pointer; }
pre.json { margin: 0; max-height: 420px; overflow: auto; padding: 12px 14px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--line); font-family: var(--mono); font-size: 11.5px; line-height: 1.6; color: #545a78; }

/* ------------------------------------------------------------ zoom */
.zoom-overlay { position: fixed; inset: 0; z-index: 100; background: rgba(243, 240, 234, 0.97); backdrop-filter: blur(8px); display: flex; flex-direction: column; animation: fadeIn 0.2s ease; }
.zoom-bar { display: flex; align-items: center; gap: 12px; padding: 10px 18px; border-bottom: 1px solid var(--line); background: rgba(255, 254, 251, 0.9); }
.zoom-caption { font-weight: 600; }
.zoom-level { color: var(--muted); font-size: 12px; }
.zoom-actions { margin-left: auto; display: flex; gap: 6px; }
.zoom-stage { position: relative; flex: 1; overflow: hidden; cursor: grab; }
.zoom-stage.dragging { cursor: grabbing; }
.zoom-stage img { position: absolute; left: 0; top: 0; transform-origin: 0 0; user-select: none; max-width: none; background: #fff; box-shadow: 0 20px 60px rgba(80, 64, 40, 0.18); border-radius: 4px; }
.zoom-stage img.smooth { transition: transform 0.18s ease; }

/* ------------------------------------------------------------ toasts */
.toasts { position: fixed; right: 22px; bottom: 22px; z-index: 120; display: grid; gap: 8px; }
.toast { min-width: 180px; max-width: 420px; padding: 11px 15px; border-radius: 12px; font-size: 13px; background: var(--panel-solid); border: 1px solid var(--line); box-shadow: var(--shadow-pop); animation: fadeUp 0.3s ease both; }
.toast.ok { border-left: 3px solid var(--ok); }
.toast.err { border-left: 3px solid var(--err); color: #9a4b45; }
.toast.leave { animation: fadeIn 0.25s reverse both; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

.btn { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border-radius: 9px; cursor: pointer; white-space: nowrap;
  border: 1px solid #d6ddf3; background: var(--accent-soft); color: var(--accent); font-size: 12.5px; font-weight: 600; transition: background 0.15s, border-color 0.15s; }
.btn:hover:not(:disabled) { background: #e3e8f8; border-color: var(--accent); }
.btn.danger { border-color: #f0d6d2; background: #fbf1ef; color: var(--err); }
.btn.danger:hover:not(:disabled) { background: #f7e3e0; border-color: var(--err); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* ------------------------------------------------------------ layer chips */
.chip.layer b { font-family: var(--mono); color: #b3001a; }

/* ------------------------------------------------------------ page shell, upload tray */
.page { position: relative; z-index: 1; max-width: 1720px; margin: 0 auto; padding: 22px 28px 96px; }
@media (max-width: 1100px) { .page { padding: 16px 16px 96px; } }
.tag { display: inline-flex; align-items: center; height: 17px; padding: 0 6px; border-radius: 6px; font-size: 10.5px; font-family: var(--sans); color: #8a6fbb; background: #f5f0fa; border: 1px solid #e6dcf3; }

.modal-card.wide { width: min(560px, 100%); }
.file-picks { list-style: none; margin: 10px 0 0; padding: 0; max-height: 200px; overflow-y: auto; display: grid; gap: 4px; }
.file-picks:empty { display: none; }
.file-picks li { display: grid; grid-template-columns: minmax(0, 1fr) auto 28px; align-items: center; gap: 8px; padding: 5px 6px 5px 10px; border-radius: 9px; background: var(--panel-2); border: 1px solid var(--line); font-size: 12.5px; }
.file-picks .icon-btn { width: 26px; height: 26px; font-size: 16px; }

.upload-tray { position: fixed; right: 22px; bottom: 22px; z-index: 80; width: min(380px, calc(100vw - 32px)); padding: 14px 16px; border-radius: 16px; border: 1px solid var(--line);
  background: var(--panel-solid); box-shadow: var(--shadow-pop); animation: fadeUp 0.3s ease both; }
.upload-tray .bar { margin-top: 10px; }
.toasts { bottom: 22px; }

/* ---------------------------------------------------------------- 套用 (workspace) */
.ot-page .page { max-width: none; padding-bottom: 22px; }
.ot-body { display: grid; grid-template-columns: 240px minmax(0, 1fr) 340px; gap: 18px; height: calc(100vh - 106px); min-height: 560px; }
.ot-tools, .ot-side { display: flex; flex-direction: column; gap: 14px; padding: 16px; min-height: 0; overflow-y: auto; }
.ot-side > * { flex-shrink: 0; }
.ot-tools .section-title, .ot-side .section-title { margin: 0; }
.ot-tool-list { display: grid; gap: 8px; }
.ot-tool { position: relative; display: grid; gap: 3px; width: 100%; padding: 10px 12px 10px 15px; text-align: left; cursor: pointer;
  border-radius: 12px; border: 1px solid var(--line); background: var(--panel-solid); transition: background 0.15s, border-color 0.15s, box-shadow 0.15s; }
.ot-tool::before { content: ""; position: absolute; left: 0; top: 9px; bottom: 9px; width: 3px; border-radius: 0 3px 3px 0; background: var(--c); opacity: 0.35; }
.ot-tool:hover { background: var(--panel-2); border-color: var(--line-2); }
.ot-tool.active { background: var(--accent-soft); border-color: #cdd6f2; box-shadow: 0 0 0 3px rgba(111, 134, 214, 0.1); }
.ot-tool.active::before { opacity: 1; }
.ot-tool-label { display: flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 650; }
.ot-tool-label i { width: 10px; height: 10px; border-radius: 3px; background: var(--c); }
.ot-tool-hint { font-size: 11.5px; color: var(--muted); line-height: 1.4; }
.ot-tool-actions { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.ot-tool-actions .btn { justify-content: center; }
.ot-scale { display: grid; gap: 8px; padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel-2); }
.ot-scale-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12px; font-weight: 650; color: var(--ink-2); }
.ot-scale-reset { height: 24px; padding: 0 8px; border-radius: 7px; border: 1px solid var(--line); background: var(--panel-solid); color: var(--ink-2); font-size: 11.5px; cursor: pointer; }
.ot-scale-reset:hover:not(:disabled) { color: var(--accent); border-color: #d6ddf3; background: var(--accent-soft); }
.ot-scale-reset:disabled { opacity: 0.45; cursor: default; }
.ot-stepper { display: grid; grid-template-columns: 30px minmax(0, 1fr) 30px; align-items: center; gap: 8px; }
.ot-stepper > button { height: 30px; border-radius: 9px; border: 1px solid var(--line); background: var(--panel-solid); color: var(--ink-2); font-size: 16px; line-height: 1; cursor: pointer; }
.ot-stepper > button:hover:not(:disabled) { color: var(--accent); border-color: #d6ddf3; background: var(--accent-soft); }
.ot-stepper > button:disabled { opacity: 0.4; cursor: default; }
.ot-scale-value { display: flex; align-items: center; justify-content: center; gap: 2px; height: 30px; border-radius: 9px; border: 1px solid var(--line); background: var(--panel-solid); }
.ot-scale-value:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(111, 134, 214, 0.14); }
.ot-scale-value input { width: 44px; border: 0; outline: 0; background: transparent; text-align: right; font-size: 15px; font-weight: 600; color: var(--ink); -moz-appearance: textfield; }
.ot-scale-value input::-webkit-inner-spin-button, .ot-scale-value input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.ot-scale-value input:disabled { color: var(--dim); }
.ot-scale-value span { font-size: 12px; color: var(--muted); }
.ot-scale input[type="range"] { width: 100%; margin: 0; accent-color: var(--accent); }
.ot-scale input[type="range"]:disabled { opacity: 0.4; }
.ot-scale .hint { margin: 0; font-family: var(--mono); font-size: 11px; }
.ot-stats { display: grid; gap: 7px; margin: 0; padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel-2); }
.ot-stats > div { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.ot-stats dt { font-size: 12px; color: var(--muted); }
.ot-stats dd { margin: 0; font-size: 12.5px; color: var(--ink); text-align: right; }
.ot-legend { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 12px; color: var(--ink-2); }
.ot-legend span { display: inline-flex; align-items: center; gap: 6px; }
.ot-legend i { width: 14px; height: 10px; border-radius: 3px; }
.ot-legend .sw-area { background: rgba(111, 134, 214, 0.2); border: 1.5px solid #4d5670; }
.ot-legend .sw-core { height: 4px; background: #d9463b; }
.ot-legend .sw-hole { border: 1.5px dashed #cc6a62; background: rgba(204, 106, 98, 0.08); }
.ot-foot { margin: auto 0 0; }

.ot-canvas-panel { padding: 0; overflow: hidden; display: flex; min-height: 0; }
.ot-canvas-panel:fullscreen { border-radius: 0; border: 0; }
.ot-canvas { position: relative; flex: 1; min-width: 0; min-height: 0; overflow: hidden; background: #fffefb; touch-action: none; user-select: none; -webkit-user-select: none; }
.ot-canvas.drawing { cursor: crosshair; }
.ot-canvas.pannable { cursor: grab; }
.ot-canvas.panning { cursor: grabbing; }
.ot-svg { position: absolute; inset: 0; display: block; }
.ot-svg .ot-grid { stroke: rgba(120, 108, 90, 0.08); stroke-width: 1; fill: none; }
.ot-svg .ot-grid.major { stroke: rgba(120, 108, 90, 0.18); }
.ot-svg .ot-stroke { fill: none; stroke: rgba(111, 134, 214, 0.35); stroke-width: 1; stroke-dasharray: 4 4; }
.ot-svg .ot-stroke.hole { fill: rgba(204, 106, 98, 0.07); stroke: rgba(204, 106, 98, 0.7); }
.ot-svg .ot-area { fill: rgba(111, 134, 214, 0.14); stroke: none; }
.ot-svg .ot-edge { stroke: #4d5670; stroke-width: 2.4; stroke-linecap: square; }
.ot-svg .ot-core-halo { stroke: rgba(217, 70, 59, 0.2); stroke-width: 12; stroke-linecap: butt; }
.ot-svg .ot-core { stroke: #d9463b; stroke-width: 5; stroke-linecap: butt; }
.ot-svg .ot-core-preview { stroke: #d9463b; stroke-width: 5; stroke-dasharray: 7 5; opacity: 0.75; }
.ot-svg .ot-pick { fill: #fff; stroke: #d9463b; stroke-width: 2; }
.ot-svg .ot-pick.anchor { fill: #d9463b; stroke: #fff; }
.ot-svg .ot-dim { font-family: var(--mono); font-size: 11px; fill: var(--ink-2); dominant-baseline: central;
  paint-order: stroke; stroke: #fffefb; stroke-width: 4px; stroke-linejoin: round; pointer-events: none; }
.ot-svg .ot-band { fill: rgba(111, 134, 214, 0.1); stroke: #6f86d6; stroke-width: 1; stroke-dasharray: 5 4; }
.ot-svg .ot-band.hole { fill: rgba(204, 106, 98, 0.1); stroke: #cc6a62; }
.ot-svg .ot-band.core { fill: rgba(217, 70, 59, 0.08); stroke: #d9463b; }
.ot-svg .ot-band-size { font-family: var(--mono); font-size: 12px; font-weight: 600; fill: var(--ink); text-anchor: middle;
  paint-order: stroke; stroke: #fffefb; stroke-width: 4px; stroke-linejoin: round; }
.ot-viewport-ui { position: absolute; top: 12px; right: 12px; display: flex; align-items: center; gap: 2px; padding: 3px; border-radius: 11px;
  background: rgba(255, 254, 251, 0.94); border: 1px solid var(--line); box-shadow: var(--shadow-soft); }
.ot-viewport-ui button { display: grid; place-items: center; width: 30px; height: 30px; border: 0; border-radius: 8px; background: transparent; color: var(--ink-2); cursor: pointer; }
.ot-viewport-ui button:hover { background: var(--accent-soft); color: var(--accent); }
.ot-viewport-ui button.active { background: var(--accent-soft); color: var(--accent); }
.ot-viewport-ui svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.ot-ui-sep { width: 1px; height: 18px; margin: 0 3px; background: var(--line); }
.ot-dock { position: absolute; left: 0; right: 0; bottom: 0; z-index: 5; display: flex; flex-direction: column; align-items: flex-start; pointer-events: none; }
.ot-hint { margin: 0 12px 12px; max-width: calc(100% - 24px); padding: 6px 11px; border-radius: 9px; pointer-events: none;
  background: rgba(255, 254, 251, 0.94); border: 1px solid var(--line); font-size: 12px; color: var(--ink-2); }

.ot-blockers { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.ot-blockers li { position: relative; padding: 8px 10px 8px 26px; border-radius: 10px; border: 1px solid #f0e1c5; background: #fcf7ee; color: #8a6427; font-size: 12.5px; line-height: 1.45; }
.ot-blockers li::before { content: "!"; position: absolute; left: 8px; top: 9px; width: 13px; height: 13px; border-radius: 50%; background: var(--warn); color: #fff; font-size: 10px; font-weight: 700; display: grid; place-items: center; }
.ot-ready { padding: 8px 10px; border-radius: 10px; border: 1px solid #d3e8dd; background: #f3f9f5; color: #2f6f55; font-size: 12.5px; font-weight: 600; }
.ot-match { width: 100%; height: 42px; min-height: 42px; }
.ot-match-note { margin: -6px 0 0; }
.ot-results { display: grid; gap: 14px; }
.ot-result-group h3 { margin: 0 0 8px; font-size: 12px; font-weight: 650; color: var(--muted); letter-spacing: 0.02em; }
.ot-result-group .empty { padding: 18px 0; border-radius: 12px; border: 1px dashed var(--line-2); }

@media (max-width: 1200px) {
  .ot-body { grid-template-columns: 220px minmax(0, 1fr); height: auto; }
  .ot-canvas-panel { height: 70vh; min-height: 480px; }
  .ot-side { grid-column: 1 / -1; }
}
@media (max-width: 760px) {
  .ot-body { grid-template-columns: minmax(0, 1fr); }
  .ot-tools { order: 0; }
}

/* ---- 套用 · 配對結果 */
.ot-match-note.warn { color: #8a6427; }
.ot-result-group h3 .aside { margin-left: 6px; font-weight: 500; color: var(--dim); }
.ot-cards { display: grid; gap: 8px; }
.ot-card { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 10px; width: 100%; padding: 8px; text-align: left; cursor: pointer;
  border-radius: 12px; border: 1px solid var(--line); background: var(--panel-solid); transition: border-color 0.15s, box-shadow 0.15s; }
.ot-card:hover { border-color: #cdd6f2; box-shadow: 0 0 0 3px rgba(111, 134, 214, 0.1); }
.ot-card-thumb { display: grid; place-items: center; height: 84px; border-radius: 9px; background: #fffefb; border: 1px solid var(--line); overflow: hidden; }
.ot-card-thumb svg { width: 100%; height: 100%; }
.ot-card-meta { display: grid; gap: 3px; align-content: start; min-width: 0; }
.ot-card-metric { display: flex; align-items: center; gap: 6px; font-size: 13.5px; font-weight: 650; color: var(--ink); }
.ot-set-badge { display: inline-flex; align-items: center; height: 18px; padding: 0 7px; border-radius: 9px; font-size: 11px; font-weight: 700; color: #fff; background: var(--accent); }
.ot-card-rooms { font-size: 12.5px; font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ot-card-title { font-size: 12px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ot-card-detail { font-size: 11.5px; color: var(--muted); line-height: 1.4; }
.ot-card-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 2px; }
.ot-card-tags .tag.ok { color: #2f6f55; background: #f3f9f5; border-color: #d3e8dd; }
.ot-card-tags .tag.ot-tag-cut { color: #a8452f; background: #fbf0ec; border-color: #f1d9d0; }
.ot-card-tags .tag.ot-tag-add { color: #3f5f9a; background: #f1f5fc; border-color: #d8e2f4; }
.ot-results-hint { margin: -4px 0 6px; font-size: 11.5px; }
.ot-ov path, .ot-ov line { vector-effect: non-scaling-stroke; fill: none; stroke-linecap: butt; stroke-linejoin: miter; }
.ot-ov .ot-ov-query { fill: rgba(111, 134, 214, 0.16); stroke: #4d5670; stroke-width: 1.4px; }
.ot-ov .ot-ov-unit { stroke: #2f8f6b; stroke-width: 2px; stroke-dasharray: 5 3; }
.ot-ov .ot-ov-core { stroke: #d9463b; stroke-width: 4px; }
.ot-ov .ot-ov-door { stroke: #e08a1e; stroke-width: 5px; stroke-linecap: round; }
.ot-ov .ot-ov-bg { opacity: 0.62; pointer-events: none; }   /* the stored unit picture under the outline */
.ot-ov.large .ot-ov-query { stroke-width: 2px; }
.ot-ov.large .ot-ov-unit { stroke-width: 2.6px; stroke-dasharray: 8 5; }
.ot-ov.large .ot-ov-core { stroke-width: 6px; }
.ot-ov.large .ot-ov-door { stroke-width: 8px; }
.ot-ov-legend .sw-unit { height: 0; border-top: 2.5px dashed #2f8f6b; background: none; }
.ot-ov-legend .sw-door { height: 5px; background: #e08a1e; border-radius: 3px; }

.ot-modal { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 24px; background: rgba(40, 38, 34, 0.45); backdrop-filter: blur(2px); }
.ot-modal[hidden] { display: none; }
.ot-modal-box { display: grid; grid-template-rows: auto minmax(0, 1fr); width: min(1500px, 100%); height: min(900px, 100%); border-radius: 16px; background: var(--panel-solid); border: 1px solid var(--line); box-shadow: var(--shadow); overflow: hidden; }
.ot-modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.ot-modal-title { font-size: 14px; font-weight: 650; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ot-modal-members { display: grid; gap: 8px; align-content: start; padding: 16px; overflow-y: auto; min-height: 0; }
.ot-member { display: grid; gap: 6px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel-2); cursor: pointer; }
.ot-member:hover { border-color: var(--line-2); }
.ot-member.active { background: var(--accent-soft); border-color: #cdd6f2; }
.ot-member-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; font-size: 12.5px; color: var(--ink); }
.ot-member-head strong { font-weight: 650; }
.ot-member-rooms { font-size: 12.5px; font-weight: 600; color: var(--ink); }
.ot-member-rooms.unknown { font-weight: 400; color: var(--dim); }
.ot-member-sub { font-size: 11.5px; color: var(--muted); }
.ot-member-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }
.ot-member-actions .btn { height: 28px; padding: 0 10px; font-size: 11.5px; text-decoration: none; }
.ot-member-actions .ot-apply { padding: 7px 12px; font-size: 12px; }
.ot-fit-status { margin: 12px 0; padding: 12px; border: 1px solid #98b9ad; border-radius: 10px; background: #edf5f1; }
.ot-fit-status[hidden] { display: none; }
.ot-fit-status p { margin: 0 0 9px; font-size: 12px; line-height: 1.6; color: #284e40; }
/* the applied fit's actions: a two-column grid of equal buttons whose labels wrap instead of spilling out; the merged
   download and the mode switch take a whole row */
.ot-fit-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.ot-fit-actions > .ot-merged, .ot-fit-modes { grid-column: 1 / -1; }
.ot-fit-actions .btn, .ot-fit-actions .btn-primary { width: 100%; min-width: 0; height: auto; min-height: 32px; padding: 6px 8px;
  justify-content: center; text-align: center; white-space: normal; line-height: 1.3; font-size: 12px; letter-spacing: 0; text-decoration: none; }
.ot-fit-modes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.ot-fit-modes > button { flex-direction: column; gap: 2px; min-height: 44px; font-size: 12.5px; }
.ot-fit-modes > .btn-primary { border: 1px solid var(--accent); }
.ot-fit-modes small { font-size: 10.5px; font-weight: 500; opacity: 0.8; }
.ot-fitted-plan { pointer-events: none; }
.ot-fitted-space { fill: #dcece7; stroke: none; }
.ot-fitted-space.space-1 { fill: #eee6d5; }
.ot-fitted-space.space-2 { fill: #dfebe0; }
.ot-fitted-space.space-3 { fill: #e6e0ee; }
.ot-fitted-pocket { fill: #eed4a2; stroke: #b68c48; stroke-width: .7px; }
.ot-fitted-wall { fill: #46536b; stroke: none; }
.ot-fitted-wall-line { fill: none; stroke: #46536b; stroke-width: 1.4; vector-effect: non-scaling-stroke; }
.ot-fitted-furniture { fill: none; stroke: #9075b0; stroke-width: 1px; }
.ot-fitted-furniture.conflict { stroke: #d6453d; stroke-width: 1.6px; }
.ot-fitted-door { fill: none; stroke: #2f8f6b; stroke-width: 1.3px; }
.ot-fitted-door.loose { stroke: #7c8a83; stroke-opacity: 0.75; stroke-width: 1.1px; stroke-dasharray: 4 3; }
.ot-modal-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 300px; min-height: 0; }
.ot-pane { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; gap: 8px; padding: 14px 16px; min-height: 0; border-right: 1px solid var(--line); }
.ot-pane-head { font-size: 12.5px; font-weight: 650; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ot-pane-head .aside { margin-left: 6px; font-weight: 400; color: var(--dim); }
.ot-pane-box { position: relative; min-height: 0; border-radius: 12px; background: #fffefb; border: 1px solid var(--line); overflow: hidden; }
.ot-pane-box > svg, .ot-pane-box > canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.ot-pane-box > .empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 12.5px; }
.ot-pane-foot { margin: 0; }
.ot-db-chip { font-variant-numeric: tabular-nums; }
.ot-db-chip.ready .dot { background: var(--ok); }
.ot-db-chip.building .dot { background: var(--warn); }
@media (max-width: 1100px) { .ot-modal-body { grid-template-columns: 1fr 1fr; grid-template-rows: minmax(0, 1fr) auto; } .ot-modal-members { grid-column: 1 / -1; max-height: 220px; } }

/* One selected candidate owns the apply controls. */
.ot-modal-controls { display:flex; flex-direction:column; min-height:0; overflow:auto; }
.ot-modal-controls .ot-modal-members { flex:1 0 auto; max-height:240px; padding-bottom:10px; }
.ot-apply-settings { display:grid; gap:12px; padding:16px; border-top:1px solid var(--line); background:var(--panel); }
.ot-apply-heading { display:flex; justify-content:space-between; gap:8px; font-size:13px; font-weight:650; }
.ot-apply-heading span { font-size:11px; font-weight:400; color:var(--muted); }
.ot-apply-note { margin:0; font-size:11px; line-height:1.6; }
.ot-apply-actions { display:flex; gap:8px; }
.ot-apply-actions>.ot-apply { flex:1; min-width:0; padding:10px 8px; font-size:12px; }
.ot-apply-downloads summary { cursor:pointer; font-size:11px; color:var(--muted); padding:4px 0; }
@media (max-width:1100px) {
  .ot-modal-controls { grid-column:1/-1; display:grid; grid-template-columns:minmax(0,1fr) minmax(280px,1fr); max-height:45vh; }
  .ot-modal-controls .ot-modal-members { grid-column:auto; max-height:none; }
  .ot-apply-settings { border-top:0; border-left:1px solid var(--line); align-content:start; }
}
@media (max-width:650px) {
  .ot-modal-controls { grid-template-columns:1fr; max-height:52vh; }
  .ot-modal-controls .ot-modal-members { max-height:150px; }
  .ot-apply-settings { border-top:1px solid var(--line); border-left:0; }
}

/* unit cards: one SVG per unit, drawn from metadata.json */
.unit-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; margin-top: 12px; }
.unit-card { display: flex; flex-direction: column; gap: 10px; text-align: left; padding: 12px; border-radius: 14px; border: 1px solid var(--line);
  background: var(--panel-solid); box-shadow: var(--shadow-soft); cursor: pointer; transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s; min-width: 0; }
.unit-card:hover { border-color: var(--line-2); transform: translateY(-1px); box-shadow: var(--shadow); }
.unit-card.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft), var(--shadow); }

/* one unit opened */
.kv.wide { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 14px; margin: 0 0 12px; font-size: 12.5px; }
.kv.wide dt { color: var(--muted); }
.kv.wide dd { margin: 0; color: var(--ink); word-break: break-all; }

/* ===== 智慧搜尋 (text-search) ===== */
.ts-page .page { padding-bottom: 22px; max-width: 1240px; }
.ts-body { display: grid; justify-items: center; }
.ts-chat { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; width: 100%; max-width: 980px;
  height: calc(100vh - 106px); min-height: 520px; padding: 0; overflow: hidden; }
.ts-banners { display: grid; gap: 8px; padding: 14px 18px 0; }
.ts-banners:empty { display: none; }
/* explicit rows: with the banners hidden the log would otherwise slide into the auto row and the dock would stretch */
.ts-banners { grid-row: 1; }
.ts-log { grid-row: 2; }
.ts-dock { grid-row: 3; }
.ts-log { display: flex; flex-direction: column; gap: 14px; padding: 18px 18px 8px; overflow-y: auto; overscroll-behavior: contain; }

/* ---- messages */
.ts-msg { display: grid; gap: 5px; min-width: 0; }
.ts-msg.user { justify-items: end; }
.ts-msg.bot { justify-items: start; }
.ts-bubble { max-width: min(660px, 94%); padding: 10px 14px; border-radius: 15px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--ink); font-size: 13.5px; line-height: 1.65; white-space: pre-wrap; word-break: break-word; }
.ts-msg.bot .ts-bubble { border-bottom-left-radius: 5px; }
.ts-msg.user .ts-bubble { border-bottom-right-radius: 5px; border-color: #d6ddf3; background: var(--accent-soft); color: #44548c; }
.ts-bubble.err { border-color: #f0d6d2; background: #fcf2f0; color: #9a4b45; }
.ts-bubble strong { display: block; font-weight: 650; }
.ts-meta { padding: 0 5px; font-size: 11px; line-height: 1.5; color: var(--muted); font-variant-numeric: tabular-nums; }
.ts-unmapped { margin-top: 5px; font-size: 12px; color: var(--muted); }
.ts-typing { display: inline-flex; align-items: center; gap: 5px; padding: 14px; }
.ts-typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--dim); animation: tsDots 1.25s ease-in-out infinite; }
.ts-typing i:nth-child(2) { animation-delay: 0.16s; }
.ts-typing i:nth-child(3) { animation-delay: 0.32s; }
@keyframes tsDots { 0%, 75%, 100% { opacity: 0.3; transform: none; } 35% { opacity: 1; transform: translateY(-3px); } }

/* ---- empty state and example chips */
.ts-empty { display: grid; justify-items: center; gap: 10px; margin: auto; padding: 24px 12px; max-width: 620px; text-align: center; }
.ts-empty-icon { display: grid; place-items: center; width: 54px; height: 54px; border-radius: 16px; color: var(--accent); background: var(--accent-soft); }
.ts-empty h3 { margin: 4px 0 0; font-size: 18px; font-weight: 650; }
.ts-empty p { margin: 0; }
.ts-examples { display: flex; flex-wrap: wrap; gap: 6px; }
.ts-empty .ts-examples { justify-content: center; margin-top: 4px; }
.ts-examples.in-msg { max-width: min(660px, 94%); }
.ts-ex { padding: 7px 13px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--panel-solid); color: var(--ink-2);
  font-size: 12.5px; text-align: left; cursor: pointer; transition: color 0.15s, border-color 0.15s, background 0.15s; }
.ts-ex:hover { color: var(--accent); border-color: #d6ddf3; background: var(--accent-soft); }

/* ---- the interpretations to choose from */
.ts-options { display: grid; gap: 8px; width: min(660px, 100%); }
.ts-opt { display: grid; gap: 7px; width: 100%; padding: 12px 14px; text-align: left; cursor: pointer; border-radius: 14px;
  border: 1px solid var(--line); background: var(--panel-solid); box-shadow: var(--shadow-soft); transition: border-color 0.15s, box-shadow 0.15s, opacity 0.15s; }
.ts-opt:hover { border-color: #cdd6f2; box-shadow: 0 0 0 3px rgba(111, 134, 214, 0.1); }
.ts-opt-top { display: flex; align-items: baseline; gap: 9px; }
.ts-opt-no { flex: none; display: grid; place-items: center; width: 20px; height: 20px; border-radius: 7px;
  background: var(--accent-soft); color: var(--accent); font-size: 11.5px; font-weight: 700; }
.ts-opt-title { font-size: 13.5px; font-weight: 650; line-height: 1.55; color: var(--ink); }
.ts-opt-clauses { display: flex; flex-wrap: wrap; gap: 5px; }
.ts-opt-go { font-size: 11.5px; font-weight: 600; color: var(--accent); }
.ts-opt.chosen { border-color: var(--accent); background: var(--accent-soft); }
.ts-opt.chosen .ts-opt-go::before { content: "已選 · "; color: var(--ink-2); }
.ts-opt.faded { opacity: 0.55; }
.ts-opt.faded:hover { opacity: 1; }

/* ---- result cards */
.ts-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(212px, 1fr)); gap: 10px; width: 100%; }
.ts-card { display: grid; gap: 8px; align-content: start; padding: 9px; text-align: left; cursor: pointer; border-radius: 14px;
  border: 1px solid var(--line); background: var(--panel-solid); box-shadow: var(--shadow-soft); transition: border-color 0.15s, box-shadow 0.15s; }
.ts-card:hover { border-color: #cdd6f2; box-shadow: 0 0 0 3px rgba(111, 134, 214, 0.1); }
.ts-thumb { position: relative; height: 132px; border-radius: 10px; border: 1px solid var(--line); background: #fffefb; overflow: hidden; }
.ts-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.ts-thumb-svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.ts-thumb-empty { position: absolute; inset: 0; display: grid; place-items: center; font-size: 12px; color: var(--dim); }
.ts-outline { fill: none; stroke: var(--accent); stroke-width: 1.6px; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.ts-card-body { display: grid; gap: 3px; min-width: 0; }
.ts-card-head { display: flex; align-items: center; gap: 6px; min-width: 0; }
.ts-card-head strong { font-size: 14px; font-weight: 700; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ts-card-head .chip { margin-left: auto; flex: none; }
.ts-card-file { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ts-card-sum { font-size: 12.5px; font-weight: 600; color: var(--ink); }
.ts-twins { font-size: 11px; color: var(--muted); }

/* ---- clause verdicts (✓ 符合 / ✗ 不符合 / ◦ 只影響排序) */
.ts-cl-list { list-style: none; display: grid; gap: 3px; margin: 3px 0 0; padding: 0; }
.ts-cl { display: grid; grid-template-columns: 13px minmax(0, 1fr); gap: 6px; font-size: 12px; line-height: 1.45; color: var(--ink-2); }
.ts-cl-text { display: grid; gap: 2px; min-width: 0; }
.ts-cl-mark { font-weight: 700; text-align: center; }
.ts-cl.ok .ts-cl-mark { color: #3f8467; }
.ts-cl.no .ts-cl-mark { color: var(--err); }
.ts-cl.na .ts-cl-mark { color: var(--dim); }
.ts-cl.no .ts-cl-sentence { color: var(--muted); }
.ts-cl-list.wide { gap: 8px; }
.ts-cl-list.wide .ts-cl { font-size: 12.5px; }
.ts-cl-list.wide .tag { justify-self: start; }

/* ---- composer */
.ts-dock { display: grid; gap: 8px; padding: 12px 18px 14px; border-top: 1px solid var(--line); background: var(--panel-solid); }
.ts-composer { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: end; }
.ts-textarea { width: 100%; padding: 9px 12px; border-radius: 12px; border: 1px solid var(--line-2); background: var(--panel-solid);
  color: var(--ink); font: inherit; line-height: 1.55; resize: none; overflow-y: hidden; outline: none; transition: border-color 0.15s, box-shadow 0.15s; }
.ts-textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(111, 134, 214, 0.14); }
.ts-textarea:disabled { background: var(--panel-2); color: var(--muted); }
.ts-send { height: 40px; }
.ts-dock-foot { display: flex; align-items: center; gap: 10px; }
.ts-dock-foot .hint { margin-right: auto; font-variant-numeric: tabular-nums; }
.ts-db-chip { font-variant-numeric: tabular-nums; }
.ts-db-chip.ready .dot { background: var(--ok); }
.ts-db-chip.building .dot { background: var(--warn); }

/* ---- one unit, opened */
.ts-modal { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 22px;
  background: rgba(40, 38, 34, 0.45); backdrop-filter: blur(2px); animation: fadeIn 0.16s ease; }
.ts-modal[hidden] { display: none; }
.ts-modal-box { display: grid; grid-template-rows: auto minmax(0, 1fr); width: min(1280px, 100%); height: min(860px, 100%);
  border-radius: 18px; border: 1px solid var(--line); background: var(--panel-solid); box-shadow: var(--shadow-pop); overflow: hidden; }
.ts-modal-head { display: flex; align-items: center; gap: 12px; padding: 13px 16px; border-bottom: 1px solid var(--line); }
.ts-modal-title { font-size: 14px; font-weight: 650; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ts-modal-head .icon-btn { margin-left: auto; }
.ts-modal-body { display: grid; grid-template-columns: minmax(0, 1fr) 356px; min-height: 0; }
.ts-view { display: grid; grid-template-rows: minmax(0, 1fr) auto; gap: 8px; padding: 14px 14px 12px; min-height: 0; border-right: 1px solid var(--line); }
.ts-view-foot { margin: 0; }
.ts-stage { position: relative; min-height: 0; border-radius: 12px; border: 1px solid var(--line); background: #fffefb;
  overflow: hidden; cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; }
.ts-stage.dragging { cursor: grabbing; }
.ts-canvas { position: absolute; top: 0; left: 0; transform-origin: 0 0; }
.ts-canvas.no-pic { background: #fffefb; }
.ts-pic { display: block; width: 100%; height: 100%; }
.ts-pic-svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.ts-labels { position: absolute; inset: 0; pointer-events: none; }
.ts-room-label { position: absolute; transform: translate(-50%, -50%); display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 7px; border-radius: 7px; border: 1px solid rgba(120, 108, 90, 0.2); background: rgba(255, 254, 251, 0.82);
  font-size: 11.5px; line-height: 1.5; white-space: nowrap; color: var(--ink); }
.ts-room-label i { flex: none; width: 7px; height: 7px; border-radius: 2px; }
.ts-room-label b { font-weight: 650; }
.ts-room-label span { color: var(--ink-2); font-variant-numeric: tabular-nums; }
.ts-stage-ui { position: absolute; top: 10px; right: 10px; display: flex; gap: 6px; }
.ts-stage-ui .btn { background: rgba(255, 254, 251, 0.94); }
.ts-stage-empty { position: absolute; inset: 0; display: grid; place-items: center; font-size: 12.5px; color: var(--muted); }
.ts-detail { display: grid; gap: 10px; align-content: start; padding: 14px 16px 18px; min-height: 0; overflow-y: auto; }
.ts-detail-head { display: grid; gap: 2px; }
.ts-detail-head h3 { margin: 0; font-size: 17px; font-weight: 650; }
.ts-detail-sum { font-size: 13.5px; font-weight: 600; color: var(--ink); }
.ts-detail-badges { display: flex; flex-wrap: wrap; gap: 6px; }
.ts-detail .section-title { margin: 8px 0 0; }
.ts-detail .empty { padding: 14px 0; border-radius: 12px; border: 1px dashed var(--line-2); }
.ts-detail .table td { vertical-align: middle; }
.ts-room-cell { display: inline-flex; align-items: center; gap: 7px; color: var(--ink); }
.ts-room-cell i { flex: none; width: 9px; height: 9px; border-radius: 3px; }
.ts-dl { display: grid; gap: 8px; margin-top: 8px; }
.ts-dl .btn-primary { width: 100%; height: 42px; }
.ts-dl-btn.busy::before { content: ""; width: 13px; height: 13px; border: 2px solid rgba(255, 255, 255, 0.45);
  border-top-color: #fff; border-radius: 50%; animation: spin 0.8s linear infinite; }
.ts-dl-err { font-size: 12px; line-height: 1.5; color: var(--err); }

@media (max-width: 1100px) { .ts-chat { height: calc(100vh - 94px); } }
@media (max-width: 820px) {
  .ts-modal { padding: 0; }
  .ts-modal-box { height: 100%; border-radius: 0; border: 0; }
  .ts-modal-body { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(220px, 1fr) minmax(0, 48%); }
  .ts-view { border-right: 0; border-bottom: 1px solid var(--line); }
}
@media (max-width: 640px) {
  .ts-log { padding: 14px 12px 6px; }
  .ts-dock { padding: 10px 12px 12px; }
  .ts-cards { grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); }
  .ts-thumb { height: 108px; }
}

/* ---------------------------------------------------------------- 套用 · 上傳既有 DXF */
.ot-mode { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; padding: 3px; border-radius: 11px; border: 1px solid var(--line); background: var(--panel-2); }
.ot-mode-btn { min-width: 0; min-height: 30px; padding: 4px; border: 0; border-radius: 8px; background: transparent; color: var(--ink-2); font-size: 12.5px; font-weight: 600; line-height: 1.25; cursor: pointer; }
.ot-mode-btn:hover { color: var(--accent); }
.ot-mode-btn.active { background: var(--panel-solid); color: var(--ink); box-shadow: 0 1px 3px rgba(40, 38, 34, 0.12); }
.ot-dxf { display: grid; gap: 7px; padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel-2); }
.ot-dxf[hidden], .ot-areas[hidden], .ot-scale[hidden], .ot-tool[hidden], .ot-legend span[hidden] { display: none; }
.ot-dxf-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ot-dxf-pick { justify-content: center; flex: 1; }
.ot-dxf-units { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; color: var(--muted); }
.ot-dxf-units select { height: 30px; padding: 0 4px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel-solid); color: var(--ink); font-size: 12px; }
.ot-dxf-name { font-size: 11.5px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ot-dxf-note { margin: 0; font-size: 11.5px; line-height: 1.5; }
.ot-areas { display: grid; gap: 8px; }
.ot-areas-head { font-size: 12px; font-weight: 650; color: var(--ink-2); }
.ot-areas-head .aside { margin-left: 4px; font-weight: 500; color: var(--dim); }
.ot-area-list { display: grid; gap: 6px; }
.ot-area-list .empty { padding: 12px 8px; border-radius: 10px; border: 1px dashed var(--line-2); font-size: 12px; color: var(--muted); text-align: center; }
.ot-area-row { display: grid; gap: 4px; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel-solid); cursor: pointer; }
.ot-area-row:hover { border-color: #cdd6f2; }
.ot-area-row.active { border-color: #9fb0e6; background: var(--accent-soft); box-shadow: 0 0 0 3px rgba(111, 134, 214, 0.1); }
.ot-area-row-head { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.ot-area-row-head .mono { margin-left: auto; font-size: 11.5px; color: var(--ink-2); }
.ot-area-del { width: 20px; height: 20px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font-size: 15px; line-height: 1; cursor: pointer; }
.ot-area-del:hover { background: #fbeceb; color: #b3372e; }
.ot-card-tags .tag.warn { color: #8a6427; background: #fcf7ee; border-color: #f0e1c5; }
.ot-legend .sw-wall { height: 3px; background: #2b2f38; }
.ot-merged { height: 30px; font-size: 12px; text-decoration: none; }

.ot-svg.ot-bg { pointer-events: none; }
.ot-bg[hidden] { display: none; }
.ot-bg path { vector-effect: non-scaling-stroke; }
.ot-bg .ot-bg-line { fill: none; stroke: rgba(120, 108, 90, 0.42); stroke-width: 0.7; }
.ot-bg .ot-bg-wall { fill: none; stroke: #2b2f38; stroke-width: 1.3; }
.ot-bg .ot-fitted-space { opacity: 0.85; }
.ot-svg .ot-area.other { fill: rgba(47, 143, 107, 0.08); stroke: rgba(47, 143, 107, 0.55); stroke-width: 1.2; stroke-dasharray: 5 4; }
.ot-svg .ot-area.applied { fill: none; }
.ot-svg .ot-area.other.applied { fill: none; stroke: rgba(47, 143, 107, 0.35); }
.ot-svg .ot-area-label { font-size: 12px; font-weight: 700; fill: #2f6f55; text-anchor: middle; dominant-baseline: central; pointer-events: none;
  paint-order: stroke; stroke: rgba(255, 254, 251, 0.9); stroke-width: 3px; }
.ot-svg .ot-area-label.active { fill: #3b4f95; }

/* 套用 · 調整套用結果: what a press would take, the selection and its panel (no arrows: select first, then act) */
.ot-edit { display: grid; gap: 8px; padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel-2); }
.ot-edit[hidden] { display: none; }
.ot-edit-head { font-size: 12px; font-weight: 650; color: var(--ink-2); }
.ot-edit-head .aside { margin-left: 4px; font-weight: 500; color: var(--dim); }
.ot-edit-note { margin: 0; font-size: 11.5px; line-height: 1.5; }
.ot-edit-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ot-edit-actions .btn { justify-content: center; height: 30px; font-size: 12px; }
.ot-tool:disabled { opacity: 0.45; cursor: not-allowed; }
.ot-canvas.editing { cursor: default; }
.ot-canvas.editing.over-furn { cursor: move; }
.ot-canvas.editing.over-x { cursor: ew-resize; }
.ot-canvas.editing.over-y { cursor: ns-resize; }
.ot-canvas.editing.dragging-furn { cursor: grabbing; }
.ot-svg .ot-wall-hover { fill: rgba(144, 117, 176, 0.18); stroke: rgba(144, 117, 176, 0.55); stroke-width: 1; }
.ot-svg .ot-hover-box { fill: none; stroke: #6f86d6; stroke-opacity: 0.6; stroke-width: 1.2; }
.ot-svg .ot-hover-box.door { stroke: #2f8f6b; }
.ot-svg .ot-hover-box.symbol, .ot-svg .ot-sel-box.symbol { stroke: #7c8a83; }
.ot-svg .ot-handle { fill: #fffefb; stroke: #6f86d6; stroke-width: 1.5; }
.ot-svg .ot-handle.lit { fill: #6f86d6; }
.ot-svg .ot-handle.link { fill: #fffefb; stroke: #9075b0; stroke-width: 1.6; }
.ot-svg .ot-handle.link.lit { fill: #9075b0; }
.ot-svg .ot-wall-link { fill: rgba(144, 117, 176, 0.24); stroke: #9075b0; stroke-width: 1.2; stroke-dasharray: 5 3; }
.ot-svg .ot-wall-link.limit { fill: rgba(217, 152, 40, 0.32); stroke: #c98a1b; }
.ot-svg .ot-sel-box { fill: none; stroke: #6f86d6; stroke-width: 1.3; stroke-dasharray: 6 4; }
.ot-svg .ot-limit-mark { fill: rgba(214, 69, 61, 0.14); stroke: #d6453d; stroke-width: 2; }
.ot-svg .ot-red-label { font-size: 12px; font-weight: 700; fill: #d6453d; text-anchor: middle; pointer-events: none;
  paint-order: stroke; stroke: #fffefb; stroke-width: 3px; stroke-linejoin: round; }
.ot-fg.conflict .ot-fitted-furniture { stroke: #d6453d; stroke-width: 1.6px; }
.ot-sel-panel { align-self: stretch; box-sizing: border-box; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px;
  min-height: 44px; padding: 5px 8px; pointer-events: auto; border-top: 1px solid var(--line-2); background: var(--panel-solid);
  box-shadow: 0 -6px 18px rgba(40, 38, 34, 0.06); }
.ot-sel-panel[hidden] { display: none; }
.ot-fp-name { padding: 0 6px 0 8px; font-size: 11.5px; font-weight: 650; color: var(--ink-2); white-space: nowrap; }
.ot-sel-panel button { display: inline-flex; align-items: center; gap: 4px; height: 28px; padding: 0 8px; border: 0; border-radius: 8px;
  background: transparent; color: var(--ink-2); font-size: 12px; cursor: pointer; }
.ot-sel-panel button:hover { background: var(--accent-soft); color: var(--accent); }
.ot-sel-panel svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.ot-sel-panel .ot-fp-close { width: 28px; margin-left: auto; justify-content: center; font-size: 16px; }
.ot-sp-actions { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 2px; padding-left: 8px; border-left: 1px solid var(--line); }
.ot-sel-panel button.danger { color: #b3372e; }
.ot-sel-panel button.danger:hover { background: #fbeceb; color: #b3372e; }
.ot-sel-panel button:disabled, .ot-ctx-menu button:disabled { opacity: 0.45; cursor: not-allowed; }
.ot-sel-panel button:disabled:hover, .ot-ctx-menu button:disabled:hover { background: transparent; color: var(--ink-2); }
.ot-fp-icon { display: inline-flex; }
.ot-sp-field { display: inline-flex; align-items: center; gap: 6px; padding: 0 8px; border-left: 1px solid var(--line); white-space: nowrap; }
.ot-sp-line { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-2); }
.ot-sp-label { min-width: 2.2em; font-weight: 600; white-space: nowrap; }
.ot-sp-line input { width: 64px; height: 26px; padding: 0 7px; border-radius: 7px; border: 1px solid var(--line-2); background: var(--panel-solid);
  color: var(--ink); font-size: 13px; font-weight: 600; text-align: right; }
.ot-sp-line input:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(111, 134, 214, 0.14); }
.ot-sp-unit { color: var(--muted); }
.ot-sp-dir { display: inline-flex; gap: 2px; padding: 2px; border-radius: 8px; border: 1px solid var(--line); }
.ot-sel-panel .ot-sp-dir button { height: 22px; min-width: 24px; justify-content: center; padding: 0 6px; border-radius: 6px; }
.ot-sel-panel .ot-sp-dir button.active { background: var(--accent-soft); color: var(--accent); box-shadow: inset 0 0 0 1px #cdd6f2; }
.ot-sp-limit { margin-left: auto; padding-left: 4px; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; cursor: help; }
.ot-edit-modes kbd { margin-left: 3px; padding: 0 2px; border-radius: 4px; border: 1px solid var(--line-2); font: 600 9.5px/1.4 var(--mono); color: var(--dim); }
.ot-edit-modes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; padding: 3px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel-solid); }
.ot-edit-modes button { height: 28px; min-width: 0; padding: 0 2px; border: 0; border-radius: 7px; background: transparent; color: var(--ink-2); font-size: 11.5px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.ot-edit-modes button:hover:not(:disabled) { color: var(--accent); }
.ot-edit-modes button.active { background: var(--accent-soft); color: var(--accent); box-shadow: inset 0 0 0 1px #cdd6f2; }
.ot-edit-modes button:disabled { opacity: 0.45; cursor: not-allowed; }
.ot-edit-param { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-2); }
.ot-edit-param[hidden] { display: none; }
.ot-edit-param input { width: 64px; height: 28px; padding: 0 8px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--panel-solid); color: var(--ink); font-size: 13px; text-align: right; }
.ot-edit-param input:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(111, 134, 214, 0.14); }
.ot-edit-param span { color: var(--muted); }
.ot-canvas.editing.edit-draw { cursor: crosshair; }
.ot-canvas.editing.over-door { cursor: grab; }
.ot-svg .ot-sel-box.door { stroke: #2f8f6b; }
.ot-svg .ot-wall-sel { fill: rgba(111, 134, 214, 0.28); stroke: #6f86d6; stroke-width: 1.4; }
.ot-svg .ot-wall-sel.limit { fill: rgba(217, 152, 40, 0.32); stroke: #c98a1b; }
.ot-svg .ot-sel-box.limit { stroke: #c98a1b; }
.ot-svg .ot-draft-label { font-family: var(--mono); font-size: 12px; font-weight: 600; fill: var(--ink); text-anchor: middle; pointer-events: none;
  paint-order: stroke; stroke: #fffefb; stroke-width: 3px; stroke-linejoin: round; }
.ot-svg .ot-draft-label.bad { font-family: var(--sans); fill: #d6453d; }
.ot-svg .ot-draft-label.warn { fill: #a8661a; }
.ot-svg .ot-draft-bad { stroke: #d6453d; stroke-width: 2; stroke-dasharray: 6 4; }
.ot-ctx-menu { position: absolute; z-index: 6; display: grid; min-width: 168px; padding: 4px; border-radius: 10px; border: 1px solid var(--line-2);
  background: var(--panel-solid); box-shadow: var(--shadow-pop); }
.ot-ctx-menu[hidden] { display: none; }
.ot-ctx-menu button { height: 30px; padding: 0 10px; border: 0; border-radius: 7px; background: transparent; color: var(--ink); font-size: 12.5px; text-align: left; cursor: pointer; }
.ot-ctx-menu button:hover { background: var(--accent-soft); color: var(--accent); }
.ot-ctx-menu button.danger { color: #b3372e; }
.ot-ctx-menu button.danger:hover { background: #fbeceb; }
.ot-svg .ot-band.edit { fill: rgba(111, 134, 214, 0.06); stroke: #6f86d6; stroke-width: 1; stroke-dasharray: 5 4; }
.ot-svg .ot-line-sel { fill: none; stroke: #6f86d6; stroke-width: 3; stroke-opacity: 0.8; stroke-linecap: round; stroke-linejoin: round; }
