:root {
  color-scheme: light;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  color: #17212b;
  background: #eef2f5;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 760px;
  min-height: 100vh;
}

button, input, select { font: inherit; }

button, .file-button {
  min-height: 38px;
  border: 1px solid #cbd5df;
  border-radius: 7px;
  padding: 8px 12px;
  color: #263545;
  background: #fff;
  cursor: pointer;
}

button:hover:not(:disabled), .file-button:hover { border-color: #7d93a7; background: #f7fafc; }
button:disabled { opacity: .45; cursor: not-allowed; }
.button-primary { color: #fff; border-color: #146c94; background: #146c94; font-weight: 650; }
.button-primary:hover:not(:disabled), .file-button.button-primary:hover { color: #fff; border-color: #0e5678; background: #0e5678; }

.topbar {
  height: 76px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 24px;
  color: #f3f7fa;
  background: #17212b;
  box-shadow: 0 2px 6px rgba(20,33,45,.16);
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  color: white;
  background: #146c94;
  font-size: 20px;
  font-weight: 800;
}

.topbar h1 { margin: 0; font-size: 18px; letter-spacing: .01em; }
.topbar h1 span { margin-left: 6px; color: #9fb3c1; font-size: 12px; font-weight: 500; text-transform: uppercase; }
.topbar p { margin: 4px 0 0; color: #b7c5cf; font-size: 12px; }
.privacy-note { margin-left: auto; color: #c4d0d8; font-size: 12px; }

.app-layout {
  min-height: calc(100vh - 76px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 370px;
}

.work-area { min-width: 0; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.toolbar, .canvas-options, .status-bar { display: flex; align-items: center; gap: 8px; }
.toolbar { min-height: 52px; flex-wrap: wrap; }
.file-button { display: inline-flex; align-items: center; justify-content: center; }
.file-button input { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
.example-select { max-width: 260px; min-height: 38px; border: 1px solid #cbd5df; border-radius: 7px; padding: 6px 8px; color: #263545; background: #fff; }
.toolbar-divider { width: 1px; height: 26px; margin: 0 3px; background: #cbd5df; }
.canvas-options { min-height: 34px; color: #526170; font-size: 12px; }
.review-panel { padding: 10px 12px; border: 1px solid #90bbd0; border-radius: 8px; background: #f1f8fb; }
.review-panel[hidden] { display: none; }
.review-panel strong { color: #263545; font-size: 13px; }
.review-fields, .review-actions { display: flex; flex-wrap: wrap; align-items: end; gap: 8px; margin-top: 8px; }
.review-fields label { display: flex; flex-direction: column; gap: 4px; color: #526170; font-size: 12px; }
.review-fields input, .review-fields select { width: 180px; min-height: 34px; border: 1px solid #cbd5df; border-radius: 6px; padding: 5px 8px; background: #fff; }
.review-actions button { min-height: 34px; padding: 5px 9px; font-size: 12px; }
.review-original { margin-top: 8px; color: #526170; font-size: 12px; }
.check-option, .zoom-option { display: inline-flex; align-items: center; gap: 7px; }
.check-option input, .zoom-option input { accent-color: #146c94; }
.zoom-option { margin-left: 10px; }
.zoom-option input { width: 90px; }
.image-info { margin-left: auto; overflow: hidden; color: #6a7885; text-overflow: ellipsis; white-space: nowrap; }

.canvas-wrap {
  position: relative;
  flex: 1;
  min-height: 440px;
  max-height: calc(100vh - 210px);
  overflow: auto;
  border: 1px solid #d5dde4;
  border-radius: 9px;
  background-color: #fff;
  background-image: linear-gradient(45deg,#f8fafb 25%,transparent 25%),linear-gradient(-45deg,#f8fafb 25%,transparent 25%),linear-gradient(45deg,transparent 75%,#f8fafb 75%),linear-gradient(-45deg,transparent 75%,#f8fafb 75%);
  background-position: 0 0,0 8px,8px -8px,-8px 0;
  background-size: 16px 16px;
}

#plan-canvas { display: block; max-width: none; cursor: crosshair; }
#plan-canvas[hidden] { display: none; }
#plan-canvas.tracing { cursor: crosshair; }
.empty-state { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; color: #617180; text-align: center; }
.empty-state[hidden] { display: none; }
.empty-state strong { margin-top: 12px; color: #263545; font-size: 15px; }
.empty-state p { max-width: 380px; margin: 8px 0 0; font-size: 13px; line-height: 1.5; }
.empty-icon { width: 44px; height: 44px; display: grid; place-items: center; border: 1px dashed #9aabba; border-radius: 12px; color: #146c94; font-size: 25px; }
.status-bar { min-height: 24px; color: #566574; font-size: 12px; }
.status-dot { width: 8px; height: 8px; flex: none; border-radius: 50%; background: #38a169; }
.status-dot.error { background: #d92d20; }
#status-text.error { color: #b42318; }

.side-panel { display: flex; flex-direction: column; padding: 18px; border-left: 1px solid #d5dde4; background: #fff; }
.panel-section, .export-section { padding-bottom: 17px; border-bottom: 1px solid #e6ebef; }
.panel-section + .panel-section, .export-section { padding-top: 17px; }
.section-heading { display: flex; align-items: center; gap: 9px; margin-bottom: 12px; }
.step-number { width: 23px; height: 23px; display: grid; place-items: center; border-radius: 50%; color: #146c94; background: #e7f2f7; font-size: 12px; font-weight: 750; }
.section-heading h2 { margin: 0; font-size: 14px; }
.field-label { display: block; margin-bottom: 6px; color: #526170; font-size: 12px; }
.unit-select, .segment-row select, .segment-row input { min-width: 0; min-height: 36px; border: 1px solid #cbd5df; border-radius: 6px; padding: 6px 8px; color: #263545; background: #fff; }
.unit-select { width: 100%; }
.helper-text { margin: 8px 0 0; color: #687786; font-size: 12px; line-height: 1.45; }
.recognition-section .field-label { margin-top: 10px; }
.confidence-filter { width: 100%; accent-color: #146c94; }
code { padding: 1px 4px; border-radius: 4px; color: #334e68; background: #edf2f7; font-size: 11px; }
.trace-list { display: flex; flex-direction: column; gap: 9px; margin-top: 12px; }
.list-empty { margin: 10px 0; color: #778593; font-size: 12px; line-height: 1.45; }
.trace-card { padding: 9px; border: 1px solid #e1e7ec; border-radius: 7px; background: #fbfcfd; }
.trace-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 7px; color: #34495e; font-size: 12px; }
.icon-button { min-height: 26px; padding: 3px 7px; color: #6b7785; font-size: 11px; }
.segment-row { display: grid; grid-template-columns: 28px minmax(96px,1fr) minmax(100px,1.1fr); align-items: center; gap: 5px; margin-top: 5px; }
.segment-label { color: #708090; font-size: 11px; text-align: center; }
.segment-row select, .segment-row input { width: 100%; min-height: 32px; padding: 5px 6px; font-size: 11px; }
.progress-block { margin-top: 12px; }
.progress-block[hidden] { display: none; }
.progress-block progress { width: 100%; height: 8px; }
.progress-block .summary-text { display: block; margin-top: 4px; }
.summary-text { margin: 12px 0 0; color: #526170; font-size: 11px; line-height: 1.5; }
.recognition-section > button { width: 100%; margin-top: 8px; }
.recognition-section details { margin-top: 8px; color: #526170; font-size: 12px; }
.recognition-section summary { cursor: pointer; }
.recognition-section details > button { width: 100%; margin-top: 8px; }
.recognition-heading { margin: 13px 0 6px; color: #526170; font-size: 11px; }
.recognition-list { display: flex; flex-direction: column; gap: 5px; }
.recognition-item { display: grid; grid-template-columns: minmax(55px,.8fr) minmax(105px,1.3fr) auto; align-items: center; gap: 5px; }
.recognition-item > span { overflow: hidden; color: #526170; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.recognition-item select { min-width: 0; min-height: 32px; border: 1px solid #cbd5df; border-radius: 6px; padding: 4px; font-size: 10px; }
.recognition-item button { min-height: 32px; padding: 5px 7px; font-size: 10px; }
.recognition-line { display: grid; grid-template-columns: 16px minmax(0,1fr) 112px; align-items: center; gap: 6px; color: #526170; font-size: 11px; }
.recognition-line[hidden] { display: none; }
.recognition-line input { accent-color: #146c94; }
.recognition-line span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recognition-line select { min-width: 0; min-height: 30px; border: 1px solid #cbd5df; border-radius: 6px; padding: 3px 4px; font-size: 10px; }
.recognition-assignment { grid-column: 2 / -1; display: flex; align-items: center; gap: 5px; font-size: 11px; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 10px; color: #687786; font-size: 11px; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 9px; height: 9px; display: inline-block; border-radius: 2px; }
.legend-wall { background: #ee6c4d; }
.legend-window { background: #168aad; }
.legend-door { background: #f4a261; }
.export-section { border-bottom: 0; }
.export-button { width: 100%; margin-top: 13px; }
.error-message { margin: 10px 0 0; color: #b42318; font-size: 12px; line-height: 1.4; }
.principle-note { margin-top: auto; padding: 12px; border: 1px solid #cfe2eb; border-radius: 7px; color: #33586b; background: #f1f8fb; }
.principle-note strong { font-size: 12px; }
.principle-note p { margin: 5px 0 0; font-size: 11px; line-height: 1.45; }

@media (max-width: 980px) {
  .app-layout { grid-template-columns: minmax(0,1fr) 330px; }
  .side-panel { padding-right: 12px; padding-left: 12px; }
}

@media (max-width: 760px) {
  body { min-width: 360px; }
  .topbar { padding: 0 14px; }
  .privacy-note { display: none; }
  .app-layout { display: flex; flex-direction: column; }
  .work-area { min-height: 65vh; padding: 10px; }
  .canvas-wrap { min-height: 360px; }
  .side-panel { border-top: 1px solid #d5dde4; border-left: 0; }
}
