:root {
  --ink: #172122;
  --muted: #647172;
  --paper: #f4f2ec;
  --card: #fffdf8;
  --line: #dedbd2;
  --green: #0d594b;
  --green-soft: #e2eee9;
  --orange: #c96536;
  --orange-soft: #f5e7dc;
  --red: #9d3d33;
  --shadow: 0 20px 60px rgba(20, 38, 35, .08);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--paper); }
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 0%, rgba(13, 89, 75, .09), transparent 26rem),
    var(--paper);
  font-family: Inter, "Noto Sans TC", "PingFang TC", system-ui, sans-serif;
}
a { color: inherit; }
.topbar {
  height: 76px;
  padding: 0 max(28px, calc((100vw - 1240px) / 2));
  border-bottom: 1px solid rgba(23, 33, 34, .1);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(244, 242, 236, .86);
  backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.brand-mark {
  width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center;
  background: var(--green); color: white; font-weight: 800; font-size: 13px; letter-spacing: .08em;
}
.brand strong, .brand small { display: block; }
.brand small { color: var(--muted); margin-top: 2px; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; }
nav { display: flex; gap: 24px; }
nav a { text-decoration: none; color: var(--muted); font-size: 14px; }
nav a:hover { color: var(--ink); }
.shell { width: min(1240px, calc(100% - 40px)); margin: 36px auto 80px; }
footer { padding: 28px 20px 48px; text-align: center; color: var(--muted); font-size: 12px; }
h1, h2, p { margin-top: 0; }
h1 { font-family: Georgia, "Noto Serif TC", serif; font-weight: 500; }
h2 { margin-bottom: 0; font-size: 20px; }
.eyebrow, .step { color: var(--orange); font-weight: 800; font-size: 11px; letter-spacing: .16em; }
.hero {
  display: grid; grid-template-columns: 1.5fr 1fr; gap: 60px; align-items: end;
  padding: 44px 0 50px;
}
.hero h1 { font-size: clamp(38px, 5vw, 68px); line-height: 1.05; margin: 14px 0 22px; max-width: 820px; }
.hero p { color: var(--muted); max-width: 760px; line-height: 1.8; }
.model-stack { display: grid; gap: 8px; justify-content: end; }
.model-stack span {
  font-family: ui-monospace, SFMono-Regular, monospace; font-size: 12px;
  padding: 10px 14px; border: 1px solid var(--line); border-radius: 999px; background: rgba(255,255,255,.45);
}
.panel {
  background: var(--card); border: 1px solid var(--line); border-radius: 24px;
  padding: 28px; box-shadow: var(--shadow); margin-bottom: 24px;
}
.upload-panel { padding: 32px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.section-heading > div { display: flex; align-items: baseline; gap: 12px; }
.hint { color: var(--muted); font-size: 12px; }
.dropzone {
  min-height: 168px; border: 1.5px dashed #aab6b2; border-radius: 18px;
  display: grid; place-items: center; align-content: center; gap: 8px; cursor: pointer;
  background: linear-gradient(135deg, rgba(226, 238, 233, .7), rgba(255, 253, 248, .9));
  transition: .2s ease;
}
.dropzone:hover { border-color: var(--green); transform: translateY(-1px); }
.dropzone input { position: absolute; opacity: 0; pointer-events: none; }
.dropzone small { color: var(--muted); }
.drop-icon { width: 42px; height: 42px; border-radius: 50%; background: var(--green); color: white; display: grid; place-items: center; font-size: 26px; }
.file-preview {
  min-height: 280px; display: grid; grid-template-columns: minmax(280px, 1.35fr) 1fr auto;
  gap: 18px; align-items: center; padding: 16px;
  border: 1px solid rgba(13, 89, 75, .3); border-radius: 18px;
  background: linear-gradient(135deg, rgba(226, 238, 233, .68), rgba(255, 253, 248, .96));
}
.file-preview-visual {
  min-width: 0; height: 248px; overflow: hidden; display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: 14px; background: #f7f7f4;
}
.file-preview-visual img,
.file-preview-visual embed {
  width: 100%; height: 100%; display: block; border: 0;
}
.file-preview-visual img { object-fit: contain; }
.file-preview-info { min-width: 0; display: flex; gap: 11px; align-items: flex-start; }
.file-preview-info > div { min-width: 0; }
.file-preview-info strong, .file-preview-info small { display: block; overflow-wrap: anywhere; }
.file-preview-info strong { font-size: 16px; line-height: 1.45; }
.file-preview-info small { margin-top: 5px; color: var(--green); font-size: 11px; font-weight: 800; }
.file-preview-info p { margin: 12px 0 0; color: var(--muted); font-size: 12px; line-height: 1.65; }
.remove-file {
  align-self: start; padding: 8px 10px; border: 1px solid var(--line);
  background: rgba(255,255,255,.72); color: var(--red); font-size: 11px;
}
.cad-file-badge {
  width: 132px; height: 132px; display: grid; place-items: center;
  border: 2px solid rgba(13, 89, 75, .36); border-radius: 24px;
  background: var(--green-soft); color: var(--green);
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 30px; font-weight: 900; letter-spacing: .06em;
  box-shadow: 0 18px 44px rgba(13, 89, 75, .12);
}
.window-drop-overlay {
  position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center;
  padding: 28px; background: rgba(7, 33, 29, .72); backdrop-filter: blur(10px);
  pointer-events: none;
}
.window-drop-overlay > div {
  width: min(620px, 100%); min-height: 330px; display: grid; place-items: center;
  align-content: center; gap: 12px; border: 2px dashed rgba(255,255,255,.82);
  border-radius: 30px; color: white; background: rgba(13, 89, 75, .66);
  box-shadow: 0 30px 100px rgba(0,0,0,.24);
}
.window-drop-overlay span {
  width: 68px; height: 68px; display: grid; place-items: center;
  border-radius: 50%; background: white; color: var(--green); font-size: 40px;
}
.window-drop-overlay strong { margin-top: 6px; font-size: 24px; }
.window-drop-overlay small { color: rgba(255,255,255,.76); letter-spacing: .05em; }
body.window-file-dragging { overflow: hidden; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin: 22px 0; }
fieldset { border: 1px solid var(--line); border-radius: 16px; padding: 16px; }
legend { padding: 0 8px; color: var(--muted); font-size: 12px; }
.upload-form { display: grid; gap: 18px; }
.intent-section {
  margin: 0; padding: 22px; border: 1px solid var(--line);
  border-radius: 18px; background: rgba(255, 255, 255, .46);
}
.field-head, .confirmation-head {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  margin-bottom: 16px;
}
.field-head > div, .confirmation-head > div {
  display: flex; align-items: center; gap: 10px;
}
.field-head > span { color: var(--muted); font-size: 12px; }
.field-step {
  width: 26px; height: 26px; display: inline-grid; place-items: center;
  border-radius: 50%; background: var(--green-soft); color: var(--green);
  font-size: 12px; font-weight: 850; flex: 0 0 auto;
}
.task-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.task-chip {
  padding: 8px 12px; border: 1px solid var(--line); border-radius: 999px;
  background: #fff; color: #526161; font-size: 12px; font-weight: 750;
  box-shadow: 0 1px 0 rgba(23, 33, 34, .03);
}
.task-chip:hover, .task-chip.active {
  border-color: rgba(13, 89, 75, .55); background: var(--green-soft); color: var(--green);
}
.textarea-label { display: block; font-size: 12px; font-weight: 800; margin-bottom: 7px; }
#task-request { min-height: 112px; resize: vertical; line-height: 1.7; }
.field-help { display: block; color: var(--muted); margin-top: 7px; }
.context-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 0;
}
.select-card, .rules-card {
  min-height: 116px; border: 1px solid var(--line); border-radius: 16px;
  padding: 16px; background: rgba(255, 255, 255, .46);
}
.select-card {
  display: grid; grid-template-columns: auto 1fr; gap: 10px 12px; align-items: start;
}
.select-card > span strong, .select-card > span small,
.rules-card summary span strong, .rules-card summary span small { display: block; }
.select-card small, .rules-card small { color: var(--muted); margin-top: 4px; line-height: 1.45; }
.select-card select { grid-column: 1 / -1; }
.rules-card summary {
  display: flex; gap: 10px; align-items: flex-start; cursor: pointer; list-style: none;
}
.rules-card summary::-webkit-details-marker { display: none; }
.rules-card[open] { grid-column: 1 / -1; }
.rules-card textarea { min-height: 110px; resize: vertical; margin-top: 14px; line-height: 1.7; }
.choice { display: flex; gap: 10px; padding: 10px; border-radius: 12px; cursor: pointer; }
.choice:hover { background: var(--green-soft); }
.choice input { accent-color: var(--green); margin-top: 4px; }
.choice strong, .choice small { display: block; }
.choice small { color: var(--muted); margin-top: 3px; }
.models-fieldset { margin: 0; padding: 18px; background: rgba(255, 255, 255, .42); }
.model-mode-picker { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mode-card {
  display: flex; gap: 10px; min-height: 76px; padding: 14px; border: 1px solid var(--line);
  border-radius: 14px; cursor: pointer;
}
.mode-card:has(input:checked) { border-color: rgba(13, 89, 75, .55); background: var(--green-soft); }
.mode-card input { accent-color: var(--green); }
.mode-card strong, .mode-card small { display: block; }
.mode-card small { color: var(--muted); margin-top: 4px; }
.manual-models { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 14px; }
.model-select-head {
  display: flex; justify-content: space-between; gap: 16px; align-items: center;
  padding: 2px 8px 14px; color: var(--muted); font-size: 12px;
}
.model-count {
  flex: 0 0 auto; border-radius: 999px; padding: 6px 10px;
  background: var(--green-soft); color: var(--green); font-weight: 800;
}
.model-count.invalid { background: #f5dedb; color: var(--red); }
.model-picker { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.model-choice { border: 1px solid var(--line); min-height: 92px; }
.model-choice:has(input:checked) {
  border-color: rgba(13, 89, 75, .55);
  background: var(--green-soft);
  box-shadow: inset 0 0 0 1px rgba(13, 89, 75, .08);
}
.model-choice code {
  display: block; margin-top: 7px; color: var(--green);
  font-size: 10px; overflow-wrap: anywhere;
}
.model-total {
  display: inline-block; padding: 4px 8px; border-radius: 999px;
  background: #eeeae0; color: #655f54; font-size: 11px; font-weight: 800;
}
button, .button {
  border: 0; border-radius: 12px; padding: 12px 18px; font-weight: 750; cursor: pointer;
  text-decoration: none; display: inline-flex; align-items: center; justify-content: center;
}
button:focus-visible, .button:focus-visible, input:focus-visible,
textarea:focus-visible, select:focus-visible, summary:focus-visible {
  outline: 3px solid rgba(13, 89, 75, .2); outline-offset: 2px;
}
.primary, button { background: var(--green); color: white; }
.secondary { background: var(--green-soft); color: var(--green); }
.upload-form > .primary { width: 100%; min-height: 48px; }
.task-confirmation {
  margin: 0; padding: 20px; border: 1px solid rgba(13, 89, 75, .42);
  border-radius: 18px; background: linear-gradient(135deg, var(--green-soft), #f8fbf9);
}
.task-confirmation p { margin: 0 0 16px; line-height: 1.7; font-weight: 700; }
.task-confirmation dl, .task-brief dl {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 0;
}
.task-confirmation dl div, .task-brief dl div {
  background: rgba(255, 255, 255, .64); border-radius: 12px; padding: 12px;
}
.task-confirmation dt, .task-brief dt {
  color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .06em;
}
.task-confirmation dd, .task-brief dd { margin: 5px 0 0; line-height: 1.55; font-size: 13px; }
.text-button { padding: 6px 8px; background: transparent; color: var(--green); font-size: 12px; }
.submit-row { display: flex; gap: 10px; padding-top: 2px; }
.submit-row button { width: 100%; min-height: 48px; }
.review-task { border: 1px solid rgba(13, 89, 75, .25); }
.task-snippet {
  display: -webkit-box; max-width: 260px; overflow: hidden; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; line-height: 1.45;
}
.table-wrap { width: 100%; overflow: auto; }
table { width: 100%; border-collapse: collapse; min-width: 820px; }
th { padding: 12px; text-align: left; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; border-bottom: 1px solid var(--line); }
td { padding: 15px 12px; border-bottom: 1px solid #ebe8df; vertical-align: top; font-size: 14px; }
tbody tr:hover { background: #fbf8f1; }
td small { display: block; color: var(--muted); margin-top: 4px; font-size: 10px; }
.case-link { font-weight: 750; text-decoration: none; }
.mono { font-family: ui-monospace, SFMono-Regular, monospace; font-size: 12px; }
.badge, .status, .agreement {
  display: inline-block; border-radius: 999px; padding: 5px 9px; font-size: 11px; font-weight: 800;
}
.badge { background: var(--green-soft); color: var(--green); }
.status.pending { background: #eeeae0; color: #655f54; }
.status.running { background: var(--orange-soft); color: var(--orange); }
.status.done, .agreement { background: var(--green-soft); color: var(--green); }
.status.error { background: #f5dedb; color: var(--red); }
.actions { display: flex; gap: 9px; align-items: center; flex-wrap: wrap; }
.actions a:not(.button) { color: var(--green); font-weight: 700; }
.empty { text-align: center; color: var(--muted); padding: 46px; }
.flash { padding: 12px 16px; margin-bottom: 18px; border-radius: 12px; }
.flash.success { background: var(--green-soft); color: var(--green); }
.flash.error { background: #f5dedb; color: var(--red); }
.page-head { display: flex; justify-content: space-between; gap: 30px; align-items: end; margin-bottom: 28px; }
.page-head h1, .chat-head h1 { font-size: clamp(32px, 4vw, 52px); margin: 12px 0 8px; }
.back { color: var(--muted); text-decoration: none; font-size: 13px; }
.summary-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 24px; }
.metric { padding: 20px; border-radius: 18px; background: var(--card); border: 1px solid var(--line); }
.metric span, .metric strong { display: block; }
.metric span { color: var(--muted); font-size: 12px; }
.metric strong { font-family: Georgia, serif; font-size: 38px; margin-top: 10px; }
.metric.high { border-top: 4px solid var(--green); }
.metric.medium { border-top: 4px solid var(--orange); }
.metric.low { border-top: 4px solid var(--red); }
.result-table .value { font-weight: 800; }
.confidence-medium { background: rgba(245, 231, 220, .5); }
.confidence-low { background: rgba(245, 222, 219, .52); }
.workers { max-width: 270px; font-size: 11px; color: var(--muted); }
.model-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; }
.model-cards > div { border: 1px solid var(--line); padding: 14px; border-radius: 14px; }
.model-cards strong, .model-cards small { display: block; }
.model-cards strong { font-size: 12px; }
.model-cards small { color: var(--muted); margin-top: 6px; }
.model-cards .ok, .model-cards .fail { float: right; font-size: 11px; }
.model-cards .ok { color: var(--green); }
.model-cards .fail { color: var(--red); }
.waiting, .error-panel { text-align: center; padding: 80px 30px; }
.selected-models { color: var(--green); font-size: 12px; overflow-wrap: anywhere; }
.task-brief { display: grid; grid-template-columns: 1.1fr 1fr; gap: 24px; align-items: start; }
.task-brief h2 { margin: 8px 0; }
.drawing-preview-panel { overflow: hidden; }
.drawing-preview-panel:fullscreen,
.drawing-preview-panel:-webkit-full-screen {
  width: 100vw; height: 100vh; margin: 0; padding: 20px;
  display: flex; flex-direction: column; border: 0; border-radius: 0;
  background: var(--card);
}
.drawing-preview-panel:fullscreen .drawing-preview-viewport,
.drawing-preview-panel:-webkit-full-screen .drawing-preview-viewport {
  height: auto; flex: 1 1 auto;
}
.drawing-preview-heading { align-items: center; }
.drawing-preview-toolbar {
  display: flex; align-items: center; justify-content: flex-end;
  gap: 7px; flex-wrap: wrap;
}
.drawing-preview-toolbar button,
.drawing-preview-toolbar .button {
  min-height: 38px; padding: 8px 12px; border: 1px solid var(--line);
  border-radius: 10px; background: var(--green-soft); color: var(--green);
  font-size: 12px;
}
.drawing-preview-toolbar button:disabled {
  cursor: not-allowed; opacity: .45;
}
#preview-zoom-label {
  min-width: 50px; color: var(--muted); font-size: 11px;
  font-variant-numeric: tabular-nums; text-align: center;
}
.drawing-preview-viewport {
  position: relative; height: clamp(360px, 56vw, 720px); overflow: hidden;
  border: 1px solid #cfd6d2; border-radius: 18px;
  background:
    linear-gradient(45deg, rgba(13, 89, 75, .025) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(13, 89, 75, .025) 25%, transparent 25%),
    #eef2ef;
  background-size: 24px 24px;
  background-position: 0 0, 0 12px;
  cursor: zoom-in; touch-action: none; user-select: none;
}
.drawing-preview-viewport.is-zoomed { cursor: grab; }
.drawing-preview-viewport.is-dragging { cursor: grabbing; }
.drawing-preview-viewport img {
  display: block; width: 100%; height: 100%; object-fit: contain;
  transform-origin: center center; will-change: transform;
  transition: transform .16s ease; pointer-events: none;
}
.drawing-preview-viewport.is-dragging img { transition: none; }
.drawing-preview-viewport:fullscreen,
.drawing-preview-viewport:-webkit-full-screen {
  width: 100vw; height: 100vh; border: 0; border-radius: 0;
  background-color: #eef2ef;
}
.drawing-preview-help {
  margin: 12px 2px 0; color: var(--muted);
  font-size: 11px; line-height: 1.6;
}
.cad-summary-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px;
}
.cad-summary-grid > div {
  padding: 16px; border: 1px solid var(--line); border-radius: 14px;
  background: rgba(255, 255, 255, .56);
}
.cad-summary-grid span, .cad-summary-grid strong { display: block; }
.cad-summary-grid span { color: var(--muted); font-size: 11px; }
.cad-summary-grid strong { margin-top: 6px; font-family: Georgia, serif; font-size: 28px; }
.cad-entity-list {
  display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px;
}
.cad-entity-list span {
  padding: 6px 9px; border-radius: 999px; background: var(--green-soft);
  color: var(--green); font-size: 11px;
}
.cad-audit { margin: 14px 0 0; color: var(--muted); font-size: 12px; }
.cad-audit-details {
  margin-top: 14px; border: 1px solid var(--line); border-radius: 12px;
  background: rgba(255, 255, 255, .46);
}
.cad-audit-details summary {
  padding: 9px 11px; color: var(--green); cursor: pointer;
  font-size: 11px; font-weight: 800; line-height: 1.45;
}
.cad-audit-details[open] { padding-bottom: 10px; }
.cad-audit-details[open] summary { border-bottom: 1px solid var(--line); }
.cad-audit-details .cad-audit { margin: 9px 11px 0; }
.task-brief p { margin: 0; color: var(--muted); line-height: 1.7; }
.task-brief dl { grid-template-columns: 1fr; }
.pulse { display: inline-block; width: 11px; height: 11px; border-radius: 50%; background: var(--orange); animation: breathe 1.4s infinite; }
@keyframes breathe { 50% { opacity: .25; transform: scale(.72); } }
.login-card { width: min(520px, 100%); margin: 10vh auto; padding: 42px; border-radius: 26px; background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow); }
.login-card h1 { font-size: 44px; margin: 14px 0; }
.login-card p { color: var(--muted); line-height: 1.7; }
.login-form { display: grid; gap: 10px; margin-top: 28px; }
.login-form label { font-size: 12px; font-weight: 700; }
input[type="password"], textarea, select {
  width: 100%; border: 1px solid #bfc6c2; border-radius: 12px; padding: 13px;
  background: white; color: var(--ink); font: inherit;
}
.chat-shell { min-height: calc(100vh - 210px); display: flex; flex-direction: column; }
.chat-head p { color: var(--muted); }
.messages { flex: 1; min-height: 360px; max-height: 56vh; overflow: auto; padding: 20px 0; }
.message { margin-bottom: 24px; max-width: 820px; }
.message.user { margin-left: auto; background: #e9e3d8; border-radius: 18px 18px 4px 18px; padding: 14px 16px; }
.message-meta { color: var(--orange); font-size: 10px; font-weight: 850; letter-spacing: .08em; margin-bottom: 7px; }
.message-body { white-space: pre-wrap; line-height: 1.75; }
.thinking { color: var(--muted); font-size: 13px; padding: 8px 0; }
.thinking .pulse { margin-right: 8px; }
.composer {
  position: relative; background: var(--card); border: 1px solid var(--line);
  border-radius: 18px; padding: 12px; box-shadow: var(--shadow);
  transition: border-color .18s ease, box-shadow .18s ease;
}
.composer.is-dragging {
  border-color: var(--green);
  box-shadow: 0 0 0 4px rgba(13, 89, 75, .12), var(--shadow);
}
.composer textarea { border: 0; resize: vertical; min-height: 64px; outline: none; }
.composer-foot { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.composer-tools { display: flex; gap: 8px; align-items: center; min-width: 0; }
.composer-foot select {
  width: auto; min-width: 164px; border: 0;
  background: transparent; color: var(--muted);
}
.attach-button {
  display: inline-flex; align-items: center; gap: 6px; flex: 0 0 auto;
  min-height: 38px; padding: 8px 11px; border: 1px solid var(--line);
  border-radius: 10px; color: var(--green); background: var(--green-soft);
  font-size: 12px; font-weight: 800; cursor: pointer;
}
.attach-button:hover { border-color: rgba(13, 89, 75, .4); }
.attach-button > span:first-child {
  width: 20px; height: 20px; display: inline-grid; place-items: center;
  border-radius: 50%; background: var(--green); color: white; line-height: 1;
}
.chat-submit { min-width: 70px; }
.attachment-help {
  display: block; margin: 8px 3px 0; color: var(--muted); font-size: 10px;
}
.composer-error {
  margin: 2px 4px 8px; color: var(--red); font-size: 12px; font-weight: 750;
}
.attachment-preview {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 8px; margin-bottom: 8px;
}
.attachment-card {
  min-width: 0; display: grid; grid-template-columns: 56px 1fr auto;
  gap: 10px; align-items: center; padding: 8px;
  border: 1px solid var(--line); border-radius: 12px; background: #fff;
}
.attachment-card img {
  width: 56px; height: 48px; border-radius: 8px;
  object-fit: cover; background: var(--green-soft);
}
.attachment-card span { min-width: 0; }
.attachment-card strong, .attachment-card small {
  display: block; max-width: 100%; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}
.attachment-card strong { font-size: 11px; }
.attachment-card small { margin-top: 3px; color: var(--muted); font-size: 9px; }
.remove-attachment {
  padding: 6px 8px; background: transparent; color: var(--red); font-size: 10px;
}
.drop-hint {
  position: absolute; inset: 8px; z-index: 3; display: none;
  align-items: center; justify-content: center; border: 2px dashed var(--green);
  border-radius: 14px; color: var(--green); background: rgba(226, 238, 233, .96);
  font-size: 15px; font-weight: 850; pointer-events: none;
}
.composer.is-dragging .drop-hint { display: flex; }
.message-attachments {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 260px));
  gap: 9px; margin-top: 10px;
}
.message-attachment {
  min-width: 0; overflow: hidden; border: 1px solid var(--line);
  border-radius: 13px; background: var(--card); text-decoration: none;
}
.message-attachment img {
  display: block; width: 100%; height: 150px;
  object-fit: cover; background: var(--green-soft);
}
.message-attachment span {
  display: block; overflow: hidden; padding: 8px 10px;
  color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap;
}

@media (max-width: 800px) {
  .shell { width: min(100% - 16px, 1240px); margin: 10px auto 40px; }
  .topbar { height: 54px; padding: 0 10px; }
  .brand { gap: 9px; }
  .brand-mark {
    width: 32px; height: 32px; border-radius: 10px;
    font-size: 10px;
  }
  .brand strong { font-size: 13px; line-height: 1.15; }
  .brand small { margin-top: 1px; font-size: 8px; }
  nav { gap: 10px; }
  nav a { font-size: 11px; }
  nav a:first-child { display: none; }
  .hero {
    grid-template-columns: 1fr; gap: 18px;
    padding: 24px 0 30px; align-items: start;
  }
  .eyebrow { font-size: 10px; letter-spacing: .13em; }
  .hero h1 {
    max-width: 680px; margin: 12px 0 16px;
    font-size: 36px; line-height: 1.12;
  }
  .hero p {
    margin-bottom: 0; max-width: 680px;
    font-size: 15px; line-height: 1.65;
  }
  .model-stack {
    width: 100%; display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px; justify-content: stretch;
  }
  .model-stack span {
    min-width: 0; min-height: 50px; padding: 11px 12px;
    border-radius: 14px; display: flex; align-items: center;
    background: rgba(255, 255, 255, .7);
    font-family: inherit; font-size: 12px; font-weight: 750;
    line-height: 1.35; box-shadow: 0 8px 24px rgba(20, 38, 35, .045);
  }
  .model-stack span::before {
    content: ""; width: 7px; height: 7px; margin-right: 9px;
    border-radius: 50%; flex: 0 0 auto; background: var(--green);
    box-shadow: 0 0 0 4px rgba(13, 89, 75, .1);
  }
  .form-grid, .summary-grid, .model-cards, .model-picker, .context-grid,
  .model-mode-picker, .task-confirmation dl, .task-brief { grid-template-columns: 1fr; }
  .cad-summary-grid { grid-template-columns: repeat(2, 1fr); }
  .drawing-preview-heading { gap: 12px; }
  .drawing-preview-toolbar { width: 100%; justify-content: flex-start; }
  .drawing-preview-toolbar button,
  .drawing-preview-toolbar .button { flex: 1 1 auto; min-width: 62px; }
  .drawing-preview-viewport { height: min(58vh, 500px); border-radius: 14px; }
  .model-select-head { align-items: flex-start; }
  .section-heading, .page-head, .field-head { align-items: flex-start; flex-direction: column; }
  .panel, .upload-panel { padding: 20px 16px; border-radius: 18px; }
  .intent-section { padding: 18px 14px; }
  .dropzone { min-height: 142px; }
  .file-preview {
    min-height: 0; grid-template-columns: 1fr; gap: 14px; padding: 12px;
  }
  .file-preview-visual { height: 230px; }
  .remove-file { width: 100%; }
  .window-drop-overlay > div { min-height: 280px; border-radius: 22px; }
  .window-drop-overlay strong { font-size: 20px; }
  .task-chips { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; }
  .task-chip { flex: 0 0 auto; }
  .hint { line-height: 1.5; }
  .messages { min-height: 300px; }
  .composer-foot { align-items: stretch; }
  .composer-tools { flex: 1 1 auto; }
  .composer-foot select { min-width: 0; width: 100%; }
  .attach-button > span:last-child { display: none; }
  .chat-submit { min-width: 64px; }
  .attachment-preview { grid-template-columns: 1fr; }
  .message-attachments { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .message-attachment img { height: 120px; }

  /* v1.5.3 — 案件頁採工程儀表板式高資訊密度，不影響首頁與聊天頁。 */
  .job-detail .page-head {
    display: grid; grid-template-columns: minmax(0, 1fr); gap: 7px;
    align-items: start; margin-bottom: 10px;
  }
  .job-detail .page-head > div:first-child { min-width: 0; }
  .job-detail .back { font-size: 10px; }
  .job-detail .page-head h1 {
    max-width: 100%; margin: 4px 0 2px; overflow: hidden;
    font-family: ui-monospace, SFMono-Regular, monospace;
    font-size: 22px; font-weight: 800; line-height: 1.15;
    text-overflow: ellipsis; white-space: nowrap;
  }
  .job-detail .page-head .mono { margin: 0; font-size: 9px; color: var(--muted); }
  .job-detail .actions {
    display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
    width: 100%; gap: 4px;
  }
  .job-detail .actions .button {
    min-width: 0; min-height: 32px; padding: 6px 3px;
    border-radius: 7px; font-size: 9.5px; line-height: 1.15;
    text-align: center;
  }
  .job-detail .panel {
    margin-bottom: 9px; padding: 11px; border-radius: 13px;
    box-shadow: 0 8px 24px rgba(20, 38, 35, .05);
  }
  .job-detail .step { font-size: 8px; letter-spacing: .12em; }
  .job-detail h2 { font-size: 16px; line-height: 1.2; }
  .job-detail .task-brief {
    display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(116px, .8fr);
    gap: 9px; align-items: stretch;
  }
  .job-detail .task-brief > div { min-width: 0; }
  .job-detail .task-brief h2 { margin: 4px 0; }
  .job-detail .task-brief p {
    font-size: 10.5px; line-height: 1.42; overflow-wrap: anywhere;
  }
  .job-detail .task-brief dl { display: grid; gap: 4px; }
  .job-detail .task-brief dl div { padding: 6px; border-radius: 7px; }
  .job-detail .task-brief dt { font-size: 7.5px; }
  .job-detail .task-brief dd { margin-top: 2px; font-size: 9.5px; line-height: 1.32; }
  .job-detail .section-heading {
    display: flex; flex-direction: row; align-items: center;
    justify-content: space-between; gap: 8px; margin-bottom: 8px;
  }
  .job-detail .section-heading > div {
    min-width: 0; display: flex; align-items: baseline; gap: 7px;
  }
  .job-detail .hint {
    max-width: 54%; overflow: hidden; font-size: 8.5px;
    line-height: 1.25; text-align: right; text-overflow: ellipsis; white-space: nowrap;
  }
  .job-detail .drawing-preview-heading { align-items: center; }
  .job-detail .drawing-preview-toolbar {
    min-width: 0; flex: 1 1 auto; display: flex; flex-wrap: nowrap;
    justify-content: flex-end; gap: 3px; overflow-x: auto;
    scrollbar-width: none;
  }
  .job-detail .drawing-preview-toolbar::-webkit-scrollbar { display: none; }
  .job-detail .drawing-preview-toolbar button,
  .job-detail .drawing-preview-toolbar .button {
    flex: 0 0 auto; min-width: 0; min-height: 27px;
    padding: 4px 7px; border-radius: 6px; font-size: 9px;
  }
  .job-detail #preview-zoom-label {
    flex: 0 0 32px; min-width: 32px; font-size: 8px;
  }
  .job-detail .drawing-preview-viewport {
    height: min(44vh, 390px); min-height: 238px; border-radius: 9px;
  }
  .job-detail .drawing-preview-help {
    margin: 5px 1px 0; font-size: 8.5px; line-height: 1.35;
  }
  .job-detail .cad-summary-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px;
  }
  .job-detail .cad-summary-grid > div {
    min-width: 0; padding: 6px 5px; border-radius: 7px;
  }
  .job-detail .cad-summary-grid span {
    overflow: hidden; font-size: 8px; text-overflow: ellipsis; white-space: nowrap;
  }
  .job-detail .cad-summary-grid strong { margin-top: 1px; font-size: 19px; }
  .job-detail .cad-audit-details { margin-top: 7px; border-radius: 7px; }
  .job-detail .cad-audit-details summary {
    padding: 5px 7px; font-size: 8.5px; line-height: 1.35;
  }
  .job-detail .cad-audit-details[open] { padding-bottom: 6px; }
  .job-detail .cad-audit-details .cad-audit {
    margin: 5px 7px 0; font-size: 8.5px; line-height: 1.4;
  }
  .job-detail .cad-entity-list { gap: 4px; margin-top: 6px; }
  .job-detail .cad-entity-list span {
    padding: 3px 6px; font-size: 8.5px;
  }
  .job-detail .summary-grid {
    display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px; margin-bottom: 9px;
  }
  .job-detail .metric {
    min-width: 0; padding: 7px 6px; border-radius: 9px;
  }
  .job-detail .metric span {
    overflow: hidden; font-size: 8px; line-height: 1.25;
    text-overflow: ellipsis; white-space: nowrap;
  }
  .job-detail .metric strong { margin-top: 1px; font-size: 23px; line-height: 1; }
  .job-detail .metric.high,
  .job-detail .metric.medium,
  .job-detail .metric.low { border-top-width: 2px; }
  .job-detail .result-table { overflow: visible; }
  .job-detail .result-table table,
  .job-detail .result-table tbody { display: block; width: 100%; min-width: 0; }
  .job-detail .result-table thead { display: none; }
  .job-detail .result-table tbody tr {
    display: grid;
    grid-template-columns: minmax(78px, .9fr) minmax(0, 1.7fr) auto;
    gap: 2px 7px; padding: 7px 2px; border-bottom: 1px solid #e8e4da;
  }
  .job-detail .result-table tbody tr:last-child { border-bottom: 0; }
  .job-detail .result-table td {
    min-width: 0; padding: 0; border: 0; font-size: 9.5px;
    line-height: 1.3; overflow-wrap: anywhere;
  }
  .job-detail .result-table td:nth-child(1) {
    grid-column: 1; grid-row: 1; color: var(--muted);
  }
  .job-detail .result-table td:nth-child(2) {
    grid-column: 2; grid-row: 1; font-size: 10.5px; font-weight: 800;
  }
  .job-detail .result-table td:nth-child(3) {
    grid-column: 3; grid-row: 1; color: var(--muted); text-align: right;
  }
  .job-detail .result-table td:nth-child(4) { grid-column: 1; grid-row: 2; }
  .job-detail .result-table td:nth-child(5) {
    grid-column: 3; grid-row: 2; color: var(--muted); text-align: right;
  }
  .job-detail .result-table td:nth-child(6) {
    grid-column: 2; grid-row: 2; overflow: hidden;
    color: var(--muted); font-size: 7.5px; text-overflow: ellipsis; white-space: nowrap;
  }
  .job-detail .agreement { padding: 2px 5px; font-size: 7.5px; }
  .job-detail .confidence-medium,
  .job-detail .confidence-low { background: transparent; }
  .job-detail .confidence-medium { border-left: 2px solid var(--orange); }
  .job-detail .confidence-low { border-left: 2px solid var(--red); }
  .job-detail .model-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px;
  }
  .job-detail .model-cards > div { padding: 7px; border-radius: 7px; }
  .job-detail .model-cards strong { font-size: 9px; }
  .job-detail .model-cards small { margin-top: 2px; font-size: 7.5px; }
  .job-detail .model-cards .ok,
  .job-detail .model-cards .fail { font-size: 8px; }
}

@media (max-width: 480px) {
  .hero h1 { font-size: 33px; }
  .hero p { font-size: 14px; }
  .model-stack span { min-height: 48px; padding: 10px; font-size: 11.5px; }
  .drawing-preview-toolbar {
    display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .drawing-preview-toolbar .button { grid-column: span 3; }
  #preview-zoom-label { min-width: 0; }
  .drawing-preview-viewport { height: 46vh; min-height: 300px; }
  .job-detail .drawing-preview-toolbar {
    display: flex; grid-template-columns: none;
  }
  .job-detail .drawing-preview-toolbar .button { grid-column: auto; }
  .job-detail .drawing-preview-viewport {
    height: min(42vh, 360px); min-height: 220px;
  }
}

@media (min-width: 801px) and (max-width: 1080px) {
  .shell { width: min(100% - 28px, 1240px); }
  .upload-panel { padding: 28px; }
  .hero { gap: 32px; }
  .hero h1 { font-size: 52px; }
  .model-stack { min-width: 220px; }
}
