:root {
  color-scheme: light;
  --ink: #17201d;
  --muted: #5f6f6a;
  --line: #d8e2df;
  --line-strong: #b7c8c2;
  --surface: #ffffff;
  --surface-soft: #f4f8f7;
  --surface-tint: #e8f2ef;
  --brand: #075e50;
  --brand-strong: #06483d;
  --brand-blue: #0b6f8f;
  --accent: #e86a1c;
  --accent-strong: #c84c0b;
  --warning-wash: rgba(255, 220, 92, 0.3);
  --shadow: 0 16px 42px rgba(22, 35, 31, 0.14);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  background: #edf3f1;
  font-family: "Microsoft JhengHei", "PingFang TC", "Noto Sans TC", Arial, sans-serif;
}

button,
input {
  min-width: 0;
  font: inherit;
}

button {
  cursor: pointer;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-height: 620px;
}

.app-header {
  display: grid;
  grid-template-columns: minmax(260px, 360px) minmax(300px, 1fr) max-content max-content max-content;
  align-items: center;
  gap: 18px;
  padding: 14px 22px;
  color: #fff;
  background: linear-gradient(90deg, var(--brand-strong), var(--brand), #0a7188);
  border-bottom: 4px solid #dba54a;
}

.brand {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 12px;
}

.brand-mark {
  display: grid;
  flex: 0 0 52px;
  width: 52px;
  height: 52px;
  place-items: center;
  color: var(--brand);
  background: #fff;
  border-radius: 8px;
  font-weight: 800;
}

.brand-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.brand-copy strong {
  overflow: hidden;
  font-size: 17px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.brand-copy span {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.84);
}

.search-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 92px;
  align-items: start;
  gap: 10px;
  min-width: 0;
}

.detector-token-input {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  width: 100%;
  min-height: 36px;
  padding: 4px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
}

.search-bar .detector-token-input {
  min-height: 46px;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.detector-token-input:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(232, 106, 28, 0.16);
}

.search-bar .detector-token-input:focus-within {
  border-color: #f2c167;
  box-shadow: 0 0 0 4px rgba(242, 193, 103, 0.28);
}

.detector-token-list {
  display: flex;
  flex: 0 1 auto;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.detector-token {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  height: 28px;
  padding: 0 6px 0 10px;
  color: var(--brand-strong);
  background: var(--surface-tint);
  border: 1px solid #b8d7cf;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
}

.detector-token-edit {
  display: block;
  min-width: 0;
  padding: 0;
  overflow: visible;
  color: inherit;
  background: transparent;
  border: 0;
  font: inherit;
  text-overflow: clip;
  white-space: nowrap;
}

.detector-token-edit:hover {
  color: var(--accent);
}

.detector-token-remove {
  display: grid;
  width: 18px;
  height: 18px;
  padding: 0;
  place-items: center;
  color: var(--brand);
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid transparent;
  border-radius: 50%;
  line-height: 1;
}

.detector-token-remove:hover {
  color: #fff;
  background: var(--accent);
}

.detector-token-input input {
  flex: 1 1 110px;
  min-width: 96px;
  height: 28px;
  padding: 0 8px;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-radius: 8px;
  font-size: 16px;
  outline: none;
}

.detector-token-input--global input {
  height: 36px;
  min-width: 150px;
}

.primary-button {
  height: 46px;
  color: #fff;
  background: var(--accent);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  font-weight: 800;
}

.primary-button:hover {
  background: var(--accent-strong);
}

.system-status,
.version-badge {
  justify-self: end;
  min-width: 156px;
  padding: 8px 12px;
  color: rgba(255, 255, 255, 0.92);
  background: rgba(255, 255, 255, 0.13);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  font-size: 13px;
  text-align: center;
}

.version-badge {
  min-width: 72px;
  font-weight: 900;
  letter-spacing: 0;
  white-space: nowrap;
}

.brand .version-badge {
  flex: 0 0 auto;
  justify-self: auto;
  min-width: auto;
  padding: 6px 10px;
}

.assistant-button,
.manual-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 8px 12px;
  color: #fff;
  background: rgba(255, 255, 255, 0.13);
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 900;
  text-decoration: none;
  white-space: nowrap;
}

.assistant-button {
  font-family: inherit;
}

.assistant-button:hover,
.manual-button:hover {
  background: rgba(255, 255, 255, 0.22);
}

.back-to-top {
  position: fixed;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 70;
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  color: #fff;
  background: var(--brand);
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 50%;
  box-shadow: 0 12px 28px rgba(22, 35, 31, 0.24);
  font-size: 24px;
  font-weight: 900;
  line-height: 1;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity 160ms ease, transform 160ms ease, background 160ms ease;
}

.back-to-top.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.back-to-top:hover,
.back-to-top:focus-visible {
  background: var(--brand-strong);
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 360px;
  flex: 1;
  min-height: 0;
}

.building-panel,
.results-panel,
.workspace {
  min-height: 0;
  background: var(--surface);
}

.building-panel,
.results-panel {
  display: flex;
  flex-direction: column;
}

.building-panel {
  border-right: 1px solid var(--line);
}

.results-panel {
  border-left: 1px solid var(--line);
}

.workspace,
.results-panel {
  scroll-margin-top: 12px;
}

.workspace.is-attention,
.results-panel.is-attention {
  animation: sectionAttention 1.15s ease-out;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 58px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.panel-heading h1 {
  margin: 0;
  font-size: 17px;
}

.panel-heading span {
  color: var(--muted);
  font-size: 13px;
}

.building-groups {
  overflow: auto;
  padding: 10px 12px 18px;
}

.building-group + .building-group {
  margin-top: 14px;
}

.building-group-title {
  margin: 8px 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.building-list {
  display: grid;
  gap: 8px;
}

.building-button,
.floor-button,
.result-item,
.tool-button {
  border: 1px solid var(--line);
  transition: border-color 0.16s ease, background-color 0.16s ease, color 0.16s ease, transform 0.16s ease;
}

.building-button {
  display: grid;
  grid-template-columns: minmax(0, 1fr) max-content;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 10px;
  color: var(--ink);
  background: var(--surface-soft);
  border-radius: 8px;
  text-align: left;
}

.building-button strong {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.building-button span {
  color: var(--muted);
  font-size: 12px;
}

.building-button:hover,
.floor-button:hover,
.tool-button:hover {
  border-color: var(--brand);
  color: var(--brand-strong);
  background: var(--surface-tint);
}

.building-button.is-active,
.floor-button.is-active {
  color: #fff;
  background: var(--brand);
  border-color: var(--brand);
}

.building-button.is-active span,
.floor-button.is-active span {
  color: rgba(255, 255, 255, 0.82);
}

.workspace {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: #dfe8e5;
}

.floor-panel {
  flex: 0 0 auto;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.floor-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 18px 6px;
}

.floor-heading > div {
  display: grid;
  gap: 2px;
}

.eyebrow {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

#selectedBuildingName {
  font-size: 18px;
}

#selectedFloorMeta {
  color: var(--muted);
  font-size: 13px;
}

.floor-grid {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 8px 18px 14px;
}

.floor-button {
  flex: 0 0 auto;
  min-width: 58px;
  height: 38px;
  padding: 0 12px;
  color: var(--ink);
  background: var(--surface-soft);
  border-radius: 8px;
  font-weight: 800;
}

.pdf-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 54px;
  padding: 8px 14px;
  background: #f8fbfa;
  border-bottom: 1px solid var(--line);
}

.current-file {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex: 1 1 220px;
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
}

.current-file-name {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.current-file-updated {
  flex: 0 0 auto;
  color: var(--brand);
  font-weight: 800;
  white-space: nowrap;
}

.pdf-search {
  display: grid;
  grid-template-columns: minmax(160px, 260px) max-content;
  align-items: center;
  gap: 8px;
  flex: 0 1 430px;
}

.detector-token-input--compact {
  align-self: start;
}

.pdf-search-message {
  grid-column: 1 / -1;
  min-height: 16px;
  color: var(--muted);
  font-size: 12px;
}

.pdf-search-message.is-error {
  color: var(--accent-strong);
  font-weight: 800;
}

.tool-buttons {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

.tool-button {
  min-width: 48px;
  height: 34px;
  padding: 0 10px;
  color: var(--ink);
  background: #fff;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
}

.tool-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.page-status,
.zoom-status {
  min-width: 52px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.zoom-status {
  min-width: 48px;
  color: var(--brand-strong);
  font-weight: 900;
}

.viewer-shell {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: auto;
  cursor: grab;
  user-select: none;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.22) 1px, transparent 1px),
    linear-gradient(0deg, rgba(255, 255, 255, 0.22) 1px, transparent 1px),
    #dfe8e5;
  background-size: 28px 28px;
  touch-action: pan-x pan-y;
}

.viewer-shell.is-panning {
  cursor: grabbing;
}

.viewer-shell.is-zoomed {
  touch-action: none;
}

.pdf-search-overlay {
  position: absolute;
  left: 50%;
  z-index: 20;
  display: grid;
  width: min(420px, calc(100% - 36px));
  gap: 10px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.96);
  border: 3px solid var(--accent);
  border-radius: 8px;
  box-shadow: 0 16px 34px rgba(58, 30, 13, 0.24);
  transform: translateX(-50%);
}

.pdf-search-overlay.is-hidden {
  display: none;
}

.pdf-search-overlay strong {
  color: var(--accent-strong);
  font-size: 24px;
}

.pdf-search-overlay form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 86px;
  gap: 8px;
}

.overlay-kicker {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.overlay-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  color: var(--muted);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 50%;
  font-size: 20px;
  line-height: 1;
}

.empty-state {
  width: min(720px, calc(100% - 32px));
  margin: 44px auto;
  padding: 30px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.empty-badge {
  display: inline-flex;
  align-items: center;
  height: 30px;
  padding: 0 12px;
  color: var(--brand-strong);
  background: var(--surface-tint);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
}

.empty-state h2 {
  margin: 18px 0 14px;
  font-size: 24px;
  line-height: 1.45;
}

.empty-state ul {
  display: grid;
  gap: 10px;
  margin: 0;
  padding-left: 22px;
  color: var(--muted);
  line-height: 1.7;
}

.pdf-page {
  position: relative;
  width: max-content;
  margin: 24px auto;
  background: #fff;
  box-shadow: var(--shadow);
  transform-origin: 0 0;
  user-select: none;
}

.viewer-shell.is-touch-zooming .pdf-page {
  transition: none;
  will-change: transform;
}

#pdfCanvas {
  display: block;
  background: #fff;
}

.marker-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.detector-marker {
  position: absolute;
  min-width: 34px;
  min-height: 24px;
  pointer-events: auto;
  cursor: zoom-in;
  border: 6px solid var(--accent);
  border-radius: 999px;
  background: var(--warning-wash);
  box-shadow:
    0 0 0 5px rgba(232, 106, 28, 0.18),
    0 0 20px rgba(232, 106, 28, 0.34);
  animation: markerPulse 0.95s ease-in-out 2;
}

.detector-marker::after {
  position: absolute;
  left: 50%;
  top: calc(100% + 8px);
  transform: translateX(-50%);
  content: attr(data-label);
  padding: 5px 10px;
  color: #fff;
  background: var(--accent-strong);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 900;
  white-space: nowrap;
  box-shadow: 0 8px 18px rgba(74, 30, 11, 0.28);
}

@keyframes markerPulse {
  0% {
    transform: scale(0.96);
  }
  50% {
    transform: scale(1.08);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes sectionAttention {
  0% {
    box-shadow: inset 0 0 0 0 rgba(232, 106, 28, 0);
  }
  28% {
    box-shadow: inset 0 0 0 4px rgba(232, 106, 28, 0.38);
  }
  100% {
    box-shadow: inset 0 0 0 0 rgba(232, 106, 28, 0);
  }
}

.result-summary {
  padding: 12px 16px;
  color: var(--muted);
  background: var(--surface-soft);
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  line-height: 1.55;
}

.results-list {
  display: grid;
  align-content: start;
  gap: 10px;
  overflow: auto;
  padding: 12px;
}

.result-item {
  display: grid;
  gap: 8px;
  width: 100%;
  padding: 12px;
  color: var(--ink);
  background: #fff;
  border-radius: 8px;
  text-align: left;
}

.result-item:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.result-item.is-active {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(232, 106, 28, 0.16);
}

.result-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.result-title strong {
  color: var(--brand-strong);
  font-size: 16px;
}

.result-title span {
  color: var(--accent-strong);
  font-weight: 900;
}

.result-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 3px 8px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
}

.result-group {
  display: grid;
  gap: 8px;
}

.result-group + .result-group {
  margin-top: 4px;
}

.result-group-title {
  position: sticky;
  top: -12px;
  z-index: 1;
  padding: 6px 2px;
  color: var(--brand-strong);
  background: var(--surface);
  font-size: 13px;
  font-weight: 900;
}

.result-group-empty {
  padding: 12px;
}

.message {
  padding: 18px;
  color: var(--muted);
  background: var(--surface-soft);
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  line-height: 1.7;
}

.assistant-dialog,
.manual-dialog {
  position: fixed;
  inset: 0;
  z-index: 82;
  display: grid;
  place-items: center;
  padding: 18px;
}

.assistant-dialog.is-hidden,
.manual-dialog.is-hidden {
  display: none;
}

.assistant-backdrop,
.manual-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 23, 20, 0.52);
}

.assistant-panel {
  position: relative;
  z-index: 1;
  display: grid;
  width: min(760px, 100%);
  max-height: min(760px, calc(100dvh - 36px));
  grid-template-rows: auto minmax(220px, 1fr) auto auto;
  gap: 14px;
  padding: 18px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 22px 68px rgba(7, 28, 24, 0.3);
}

.assistant-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  padding-right: 34px;
}

.assistant-heading strong {
  color: var(--brand-strong);
  font-size: 22px;
}

.manual-panel {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: min(1040px, 100%);
  height: min(880px, calc(100dvh - 36px));
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 22px 68px rgba(7, 28, 24, 0.3);
}

.manual-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 52px 12px 18px;
  border-bottom: 1px solid var(--line);
}

.manual-heading strong {
  color: var(--brand-strong);
  font-size: 22px;
}

.manual-panel iframe {
  width: 100%;
  height: 100%;
  background: #edf3f1;
  border: 0;
}

.manual-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 10px 18px 14px;
  border-top: 1px solid var(--line);
}

.assistant-messages {
  display: grid;
  align-content: start;
  gap: 12px;
  overflow: auto;
  padding: 2px;
}

.assistant-message {
  display: grid;
  gap: 8px;
  max-width: 92%;
  padding: 12px 14px;
  border-radius: 8px;
  line-height: 1.6;
}

.assistant-message p {
  margin: 0;
}

.assistant-message--assistant {
  justify-self: start;
  color: var(--ink);
  background: var(--surface-soft);
  border: 1px solid var(--line);
}

.assistant-message--user {
  justify-self: end;
  color: #fff;
  background: var(--brand);
}

.assistant-example {
  color: var(--muted);
  font-size: 13px;
}

.assistant-usage {
  display: grid;
  gap: 6px;
}

.assistant-usage span {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.assistant-usage strong {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  padding: 2px 8px;
  color: var(--brand-strong);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 13px;
}

.assistant-result-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.assistant-result-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.assistant-result-title strong {
  color: var(--brand-strong);
  font-size: 17px;
}

.assistant-result-title span,
.assistant-result-detail {
  color: var(--muted);
  font-size: 13px;
}

.assistant-detector-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.assistant-detector {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 3px 8px;
  color: var(--accent-strong);
  background: #fff7ed;
  border: 1px solid #efc49b;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 900;
}

.assistant-recent {
  display: grid;
  gap: 8px;
  padding: 10px 12px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.assistant-recent-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.assistant-recent-heading button {
  min-height: 28px;
  padding: 0 9px;
  color: var(--brand-strong);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 800;
}

.assistant-recent-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.assistant-recent-item {
  max-width: 100%;
  min-height: 30px;
  padding: 4px 9px;
  overflow: hidden;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.assistant-recent-item:hover {
  color: var(--brand-strong);
  border-color: var(--brand);
  background: var(--surface-tint);
}

.assistant-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 86px;
  gap: 10px;
}

.assistant-form input {
  width: 100%;
  min-height: 46px;
  padding: 0 12px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  font-size: 16px;
  outline: none;
}

.assistant-form input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(232, 106, 28, 0.16);
}

.image-export-dialog {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 18px;
}

.image-export-dialog.is-hidden {
  display: none;
}

.image-export-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 23, 20, 0.56);
}

.image-export-panel {
  position: relative;
  z-index: 1;
  display: grid;
  width: min(920px, 100%);
  max-height: min(860px, calc(100dvh - 36px));
  gap: 12px;
  padding: 16px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(7, 28, 24, 0.28);
}

.image-export-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-right: 34px;
}

.image-export-heading strong {
  color: var(--brand-strong);
  font-size: 18px;
}

.image-export-hint {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.image-export-panel img {
  display: block;
  width: 100%;
  max-height: min(620px, 62dvh);
  object-fit: contain;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  touch-action: pinch-zoom;
}

.image-export-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 240px minmax(0, 1fr) 320px;
  }

  .tool-buttons {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .pdf-search {
    flex: 1 1 320px;
  }
}

@media (max-width: 960px), (max-device-width: 960px), (hover: none) and (pointer: coarse) {
  html,
  body {
    height: auto;
    min-height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
  }

  .app {
    height: auto;
    min-height: 100dvh;
  }

  .app-header {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .system-status,
  .version-badge {
    justify-self: stretch;
  }

  .manual-button {
    justify-self: stretch;
  }

  .assistant-button {
    justify-self: stretch;
  }

  .assistant-panel {
    max-height: calc(100dvh - 24px);
    padding: 14px;
  }

  .manual-dialog {
    padding: 10px;
  }

  .manual-panel {
    height: calc(100dvh - 20px);
  }

  .manual-heading {
    padding: 14px 48px 12px 14px;
  }

  .manual-actions {
    padding: 10px 14px 12px;
  }

  .assistant-form {
    grid-template-columns: 1fr;
  }

  .back-to-top {
    right: max(14px, env(safe-area-inset-right));
    bottom: max(14px, env(safe-area-inset-bottom));
    width: 44px;
    height: 44px;
    font-size: 22px;
  }

  .detector-token {
    font-size: 14px;
  }

  .app-shell {
    display: flex;
    flex: initial;
    flex-direction: column;
    min-height: auto;
    overflow: visible;
  }

  .building-panel,
  .results-panel,
  .workspace {
    width: 100%;
    min-width: 0;
  }

  .building-panel,
  .results-panel {
    border: 0;
  }

  .building-panel {
    border-bottom: 1px solid var(--line);
  }

  .results-panel {
    border-top: 1px solid var(--line);
  }

  .building-groups {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 10px;
    overflow: visible;
    padding: 10px 14px 14px;
    width: 100%;
    min-width: 0;
  }

  .building-group,
  .building-list {
    display: contents;
  }

  .building-group + .building-group {
    margin-top: 0;
  }

  .building-group-title {
    grid-column: 1 / -1;
    margin: 10px 2px 0;
  }

  .building-button {
    min-width: 0;
  }

  .workspace {
    min-height: auto;
  }

  .viewer-shell {
    flex: none;
    height: min(68dvh, 640px);
    min-height: 460px;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x pan-y;
  }

  .results-list {
    max-height: none;
    overflow: visible;
  }
}

@media (max-width: 640px), (max-device-width: 640px) {
  .app-header {
    padding: 12px;
  }

  .brand-mark {
    flex-basis: 46px;
    width: 46px;
    height: 46px;
  }

  .brand-copy strong {
    font-size: 16px;
  }

  .brand-copy span {
    font-size: 13px;
  }

  .search-bar {
    grid-template-columns: minmax(0, 1fr) 76px;
    gap: 8px;
  }

  .primary-button {
    width: auto;
  }

  .floor-heading,
  .pdf-toolbar {
    align-items: stretch;
    flex-direction: column;
    justify-content: flex-start;
  }

  .tool-buttons {
    width: 100%;
    justify-content: flex-start;
    overflow-x: visible;
    flex-wrap: wrap;
  }

  .current-file {
    flex: none;
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  .tool-button {
    min-width: 72px;
    white-space: nowrap;
  }

  .pdf-search,
  .pdf-search-overlay form {
    grid-template-columns: 1fr;
  }

  .pdf-search {
    flex: none;
    width: 100%;
  }

  .search-bar button,
  .pdf-search button,
  .pdf-search-overlay button {
    font-size: 16px;
  }

  .viewer-shell {
    height: 66dvh;
    min-height: 420px;
  }

  .image-export-dialog {
    align-items: end;
    padding: 10px;
  }

  .image-export-panel {
    max-height: calc(100dvh - 20px);
  }

  .image-export-actions .primary-button,
  .image-export-actions .tool-button {
    flex: 1 1 120px;
  }

  .empty-state {
    margin: 20px auto;
    padding: 20px;
  }

  .empty-state h2 {
    font-size: 20px;
  }
}

@media (max-width: 380px), (max-device-width: 380px) {
  .building-groups {
    grid-template-columns: 1fr;
  }

  .search-bar {
    grid-template-columns: 1fr;
  }

  .primary-button {
    width: 100%;
  }
}
