:root {
  --bg: #f3f5f1;
  --ink: #202522;
  --muted: #68716b;
  --panel: #ffffff;
  --line: #d7ddd7;
  --accent: #0f766e;
  --accent-2: #c2410c;
  --steel: #35566b;
  --cab: #edf2f7;
  --part: #f8fafc;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 300px 1fr;
  grid-template-rows: minmax(0, 1fr);
  grid-template-areas: 'sidebar workspace';
  color: var(--ink);
  background: var(--bg);
  font-family: Inter, Segoe UI, Arial, sans-serif;
}

.compact-chrome {
  display: none;
}

html.layout-compact-pending .compact-chrome {
  display: block;
}

html.layout-compact-pending body {
  grid-template-columns: 1fr;
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas:
    'chrome'
    'workspace';
  min-height: 100dvh;
  height: 100dvh;
  overflow: hidden;
}

html.layout-compact-pending .workspace {
  min-height: 0;
  overflow: hidden;
}

html.layout-compact-pending .canvas-wrap {
  min-height: 0;
}

html.layout-compact-pending.layout-compact-landscape-pending body {
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  grid-template-areas: 'chrome workspace';
}

html.layout-compact-pending.layout-compact-landscape-pending {
  --compact-nav-width: 160px;
}

html.layout-compact-pending.layout-compact-landscape-pending .compact-chrome {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-content: start;
  gap: 6px;
  align-self: stretch;
  width: var(--compact-nav-width);
  min-width: var(--compact-nav-width);
  max-width: var(--compact-nav-width);
  max-height: 100dvh;
  overflow: visible;
  padding: 8px;
  border-bottom: 0;
  border-right: 1px solid var(--line);
}

html.layout-compact-pending.layout-compact-landscape-pending .compact-chrome-row,
html.layout-compact-pending.layout-compact-landscape-pending .compact-chrome-row-primary,
html.layout-compact-pending.layout-compact-landscape-pending .compact-chrome-row-secondary,
html.layout-compact-pending.layout-compact-landscape-pending .compact-chrome-primary-actions {
  display: contents;
}

html.layout-compact-pending.layout-compact-landscape-pending .compact-chrome-locale,
html.layout-compact-pending.layout-compact-landscape-pending .compact-chrome-tabs,
html.layout-compact-pending.layout-compact-landscape-pending .compact-chrome-tools,
html.layout-compact-pending.layout-compact-landscape-pending .compact-toolbar-host {
  grid-column: 1 / -1;
}

html.layout-compact-pending.layout-compact-landscape-pending .compact-chrome .tabs {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  width: 100%;
  margin-bottom: 0;
}

html.layout-compact-pending.layout-compact-landscape-pending .sidebar {
  top: 0;
  left: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateX(-100%);
}

html.layout-compact-pending .sidebar {
  position: fixed;
  z-index: 110;
  top: var(--compact-chrome-offset, 88px);
  left: 0;
  bottom: 0;
  width: min(300px, 88vw);
  visibility: hidden;
  pointer-events: none;
  transform: translateX(-100%);
}

html.layout-compact-pending .toolbar-help {
  display: none;
}

html.layout-compact-pending #fitButton,
body.layout-compact #fitButton {
  display: none;
}

.compact-chrome-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.compact-chrome-row-primary {
  padding: 8px 10px 6px;
  border-bottom: 1px solid var(--line);
}

.compact-chrome-row-secondary {
  padding: 6px 10px 8px;
}

.compact-chrome-locale {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  flex: 0 0 auto;
}

.compact-chrome-primary-actions {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.compact-chrome-file {
  flex: 1 1 auto;
  min-width: 0;
}

.compact-chrome-save {
  flex: 0 0 auto;
}

.compact-chrome-save #saveDxfBtn {
  width: auto;
  white-space: nowrap;
}

.compact-chrome-save #saveDxfBtn.dirty {
  border-color: var(--accent-2);
  color: var(--accent-2);
}

.compact-chrome-tabs {
  flex: 1 1 auto;
  min-width: 0;
}

.compact-chrome-tools {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

.compact-toolbar-host {
  display: none;
}

.compact-chrome .file-picker {
  margin-bottom: 0;
}

.compact-chrome .tabs {
  margin-bottom: 0;
}

.compact-chrome .panel-action,
.compact-chrome .compact-layers-btn {
  min-height: 34px;
}

.compact-layers-btn {
  padding: 0 10px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.compact-layers-btn:hover,
.compact-layers-btn[aria-expanded='true'] {
  border-color: var(--accent);
  color: var(--accent);
}

.layers-backdrop {
  display: none;
}

.sidebar {
  grid-area: sidebar;
}

.workspace {
  grid-area: workspace;
}

button,
input {
  font: inherit;
}

.sidebar {
  min-height: 100vh;
  padding: 18px;
  background: #ffffff;
  border-right: 1px solid var(--line);
  overflow: auto;
  overscroll-behavior: contain;
}

.brand {
  margin-bottom: 18px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.compact-fullscreen-btn {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}

.compact-fullscreen-btn:hover,
.compact-fullscreen-btn[aria-pressed='true'] {
  border-color: var(--accent);
  color: var(--accent);
}

.settings-gear {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
  text-decoration: none;
}

.settings-gear:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.file-action-btn {
  width: 100%;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  cursor: pointer;
}

#openDrawingBtn.file-action-btn {
  width: auto;
  min-height: 0;
  padding: 0.25rem 0.35rem;
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
  font-size: 12px;
  font-weight: 500;
  text-transform: none;
}

.file-action-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.local-folder-link {
  width: fit-content;
  max-width: 100%;
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: none;
  text-decoration: underline;
  text-underline-offset: 2px;
  text-align: left;
  cursor: pointer;
}

.local-folder-link:hover {
  color: var(--accent);
}

.open-drawing-modal {
  width: min(440px, calc(100vw - 32px));
  max-height: min(80vh, 560px);
  margin: auto;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 18px 48px rgba(32, 37, 34, .22);
}

.open-drawing-modal::backdrop {
  background: rgba(32, 37, 34, .45);
}

.open-drawing-modal-inner {
  position: relative;
  padding: 18px 20px 16px;
}

.open-drawing-modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfb;
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.open-drawing-modal-title {
  margin: 0 36px 8px 0;
  font-size: 18px;
}

.open-drawing-modal-folder {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 12px;
}

.open-drawing-search {
  width: 100%;
  min-height: 34px;
  margin: 0 0 10px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: 13px;
}

.open-drawing-list {
  display: grid;
  gap: 6px;
  max-height: min(50vh, 360px);
  overflow-y: auto;
  margin-bottom: 12px;
}

.open-drawing-item {
  display: block;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  font: inherit;
}

.open-drawing-item:hover {
  border-color: var(--accent);
  background: #ecfdf5;
}

.open-drawing-item-name {
  display: block;
  font-weight: 700;
  font-size: 14px;
}

.open-drawing-item-meta {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.open-drawing-empty {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 13px;
}

.open-drawing-modal-actions {
  display: flex;
  justify-content: flex-end;
}

.brand-text {
  min-width: 0;
  flex: 1 1 auto;
}

.lang-switcher,
.cv-lang-switcher {
  flex: 0 0 auto;
}

.lang-switcher-select {
  font: inherit;
  font-size: 12px;
  padding: 0.25rem 0.35rem;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  max-width: 9rem;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.brand h1 {
  margin: 0;
  font-size: 20px;
  letter-spacing: 0;
}

.brand p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.file-picker {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.file-picker input {
  width: 100%;
  color: var(--ink);
  text-transform: none;
  font-weight: 500;
}

.storage-source-select {
  width: 100%;
  color: var(--ink);
  text-transform: none;
  font-weight: 500;
  font-size: 13px;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  padding: 4px;
  margin-bottom: 16px;
  background: #eef1ee;
  border: 1px solid var(--line);
}

.tab,
.tools button {
  min-height: 34px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}

.tab.active,
.tools button.active {
  background: var(--panel);
  border-color: var(--line);
  color: var(--accent);
  font-weight: 700;
}

.panel {
  margin-top: 16px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.panel-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.panel-title {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.panel-action {
  flex-shrink: 0;
  min-height: 26px;
  padding: 0 8px;
  border: 1px solid var(--line);
  background: #fbfcfb;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.panel-action:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.panel-action.active {
  border-color: var(--accent);
  color: var(--accent);
  background: #ecfeff;
}

.list {
  display: grid;
  gap: 6px;
}

.list button {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  background: #fbfcfb;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.layer-list {
  max-height: min(72vh, calc(100vh - 220px));
  overflow-y: auto;
  overscroll-behavior: contain;
}

.layer-row {
  display: block;
}

.layer-row-suppressed .layer-item {
  border-style: dashed;
  background: #f8faf8;
}

.layer-list .layer-item {
  position: relative;
  display: grid;
  grid-template-columns: 14px 1fr;
  align-items: center;
  gap: 9px;
  width: 100%;
  min-height: 38px;
  padding: 8px 10px 8px 10px;
  border: 1px solid var(--line);
  background: #fbfcfb;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.layer-hide {
  position: absolute;
  top: 6px;
  right: 8px;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 0;
  padding: 2px 4px;
  border-radius: 4px;
  background: rgba(255, 255, 255, .92);
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}

.layer-hide:hover {
  color: var(--accent);
}

.layer-hide-input {
  width: 12px;
  height: 12px;
  margin: 0;
  cursor: pointer;
}

.layer-hide-label {
  user-select: none;
}

.layer-copy {
  min-width: 0;
  padding-right: 52px;
}

.list button.active,
.layer-list .layer-item.active {
  border-color: var(--accent);
  box-shadow: inset 3px 0 0 var(--accent);
}

.list button:not(.active),
.layer-list .layer-item:not(.active) {
  opacity: .45;
}

.list button.selected,
.layer-list .layer-item.selected {
  background: #ecfeff;
}

.swatch {
  width: 12px;
  height: 24px;
  border: 1px solid rgba(0, 0, 0, .18);
}

.item-title {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
  font-size: 13px;
}

.item-subtitle {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.workspace {
  min-width: 0;
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 16px;
  background: #fbfcfb;
  border-bottom: 1px solid var(--line);
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1 1 auto;
}

.elevation-nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.toolbar-actions button {
  min-width: 54px;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
}

.toolbar-actions button.active {
  background: var(--panel);
  border-color: var(--line);
  color: var(--accent);
  font-weight: 700;
}

.toolbar-annotations {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: 4px;
  padding-left: 12px;
  border-left: 1px solid var(--line);
}

.toolbar-annotations button {
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
}

.toolbar-annotations button.active {
  color: var(--accent);
  font-weight: 700;
}

.toolbar-annotations button.dirty {
  border-color: var(--accent-2);
  color: var(--accent-2);
}

.toolbar-annotations .annotation-toggle {
  min-height: 34px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--panel);
}

.toolbar-help {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 6px 12px;
  flex: 0 0 auto;
  margin-left: auto;
}

.help-link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  text-align: left;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.help-link:hover {
  color: #0d5c56;
}

.help-modal {
  width: min(520px, calc(100vw - 32px));
  max-height: min(85vh, 640px);
  margin: auto;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 18px 48px rgba(32, 37, 34, .22);
}

.help-modal::backdrop {
  background: rgba(32, 37, 34, .45);
}

.help-modal-inner {
  position: relative;
  padding: 22px 22px 20px;
}

.help-modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfb;
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.help-modal-close:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.help-modal-title {
  margin: 0 36px 12px 0;
  font-size: 18px;
  line-height: 1.3;
}

.help-modal-body {
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink);
}

.help-modal-body p {
  margin: 0 0 12px;
}

.help-modal-body p:last-child {
  margin-bottom: 0;
}

.help-modal-body strong {
  color: var(--accent);
}

.annotation-modal {
  width: min(420px, calc(100vw - 32px));
  max-height: min(85vh, 520px);
  margin: auto;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 18px 48px rgba(32, 37, 34, .22);
}

.annotation-modal::backdrop {
  background: rgba(32, 37, 34, .45);
}

.annotation-modal-inner {
  position: relative;
  padding: 20px 22px 18px;
}

.annotation-modal-close {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 32px;
  height: 32px;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.annotation-modal-close:hover {
  color: var(--ink);
}

.annotation-modal-title {
  margin: 0 28px 8px 0;
  font-size: 18px;
}

.annotation-modal-subtitle {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 14px;
}

.annotation-field {
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
  font-size: 13px;
  color: var(--muted);
}

.annotation-field textarea {
  width: 100%;
  min-height: 72px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  resize: vertical;
  color: var(--ink);
}

.annotation-modal-hint {
  margin: 0 0 12px;
  font-size: 12px;
  color: var(--muted);
}

.annotation-modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.annotation-modal-actions button {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  cursor: pointer;
}

.annotation-modal-actions .btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

.annotation-modal-actions .btn-danger {
  color: #b91c1c;
  border-color: #fecaca;
  background: #fff5f5;
}

#drawing.annotation-move-mode {
  cursor: crosshair;
}

.save-confirm-modal {
  width: min(380px, calc(100vw - 32px));
  margin: auto;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 18px 48px rgba(32, 37, 34, .22);
}

.save-confirm-modal::backdrop {
  background: rgba(32, 37, 34, .45);
}

.save-confirm-modal-inner {
  padding: 22px;
}

.save-confirm-modal-title {
  margin: 0 0 18px;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.4;
}

.save-confirm-modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.save-confirm-modal-actions button {
  min-height: 36px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  cursor: pointer;
}

.save-confirm-modal-actions .btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

.icon-btn {
  min-width: 36px;
  min-height: 34px;
  padding: 0 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
}

.icon-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.tools {
  display: flex;
  gap: 6px;
}

.tools button {
  min-width: 54px;
  padding: 0 10px;
  border-color: var(--line);
  background: var(--panel);
}

.canvas-wrap {
  position: relative;
  min-height: 0;
  overflow: hidden;
  touch-action: none;
  background: var(--bg);
}

.canvas-wrap.is-loading #drawing {
  visibility: hidden;
}

.loading-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: rgba(243, 245, 241, 0.82);
  backdrop-filter: blur(2px);
}

.loading-overlay[hidden] {
  display: none !important;
}

.loading-spinner {
  width: 44px;
  height: 44px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: cv-loading-spin 0.75s linear infinite;
}

.loading-label {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}

@keyframes cv-loading-spin {
  to {
    transform: rotate(360deg);
  }
}

#drawing {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
  user-select: none;
}

.gl-canvas {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  display: none;
  pointer-events: none;
}

#drawing.dragging {
  cursor: grabbing;
  will-change: transform;
}

#drawing.dragging.orbit-pan {
  cursor: move;
}

#drawing.measure-mode {
  cursor: crosshair;
}

#drawing.measure-mode.dragging {
  cursor: crosshair;
}

#drawing.text-mode {
  cursor: text;
}

.annotations-panel {
  margin-top: 12px;
}

.annotation-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
}

.annotation-list {
  max-height: 220px;
}

.annotation-empty {
  margin: 0;
  padding: 8px 2px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.annotation-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 4px;
  align-items: stretch;
  margin-bottom: 4px;
}

.annotation-row.selected .annotation-row-main {
  border-color: var(--accent);
  background: #ecfdf5;
}

.annotation-row-main {
  display: grid;
  gap: 2px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fafbfa;
  text-align: left;
  cursor: pointer;
}

.annotation-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}

.annotation-subtitle {
  font-size: 11px;
  color: var(--muted);
}

.annotation-icon-btn {
  width: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  cursor: pointer;
}

.annotation-icon-btn:hover {
  color: var(--ink);
  border-color: #94a3b8;
}

.saved-annotations-overlay {
  pointer-events: none;
}

.saved-measure-line {
  stroke: #b45309;
  stroke-width: 0.9;
  vector-effect: non-scaling-stroke;
}

.saved-measure-line.selected-annotation {
  stroke: #0f766e;
  stroke-width: 1.1;
}

.saved-measure-label,
.saved-text-label {
  fill: #0f172a;
  font-size: 2.1px;
  font-weight: 700;
  paint-order: stroke;
  stroke: #ffffff;
  stroke-width: 0.32px;
  stroke-linejoin: round;
}

.saved-text-label {
  fill: #1e3a5f;
}

.saved-measure-label.selected-annotation,
.saved-text-label.selected-annotation {
  fill: #0f766e;
}

.measure-overlay {
  pointer-events: none;
}

.measure-point-mark {
  pointer-events: none;
}

.measure-point-circle {
  fill: none;
  stroke: #dc2626;
  stroke-width: 0.55px;
  vector-effect: non-scaling-stroke;
}

.measure-point-cross {
  fill: none;
  stroke: #dc2626;
  stroke-width: 0.48px;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}

.measure-line {
  stroke: #c2410c;
  stroke-width: 0.85;
  vector-effect: non-scaling-stroke;
  stroke-dasharray: 5 3;
}

.measure-label {
  fill: #0f172a;
  font-size: 2.1px;
  font-weight: 700;
  paint-order: stroke;
  stroke: #ffffff;
  stroke-width: 0.32px;
  stroke-linejoin: round;
}

.measure-preview-line,
.measure-preview-dim-line {
  stroke: #c2410c;
  stroke-width: 0.85;
  stroke-dasharray: 5 3;
  opacity: 0.45;
  vector-effect: non-scaling-stroke;
}

.measure-preview-witness {
  stroke: #c2410c;
  stroke-width: 0.55;
  opacity: 0.35;
  vector-effect: non-scaling-stroke;
}

.measure-preview-label {
  opacity: 0.5;
}

.saved-measure-witness,
.saved-measure-dim-line {
  stroke: #b45309;
  stroke-width: 0.55;
  vector-effect: non-scaling-stroke;
}

.saved-measure-dim-line {
  stroke-width: 0.75;
}

.wall-line {
  stroke: var(--steel);
  stroke-width: 16;
  stroke-linecap: square;
}

.wall-thin {
  stroke: #718096;
  stroke-width: 3;
  stroke-dasharray: 14 8;
}

.cabinet-footprint,
.cabinet-elevation {
  fill: var(--cab);
  stroke: #334155;
  stroke-width: 2;
}

.cabinet-footprint.selected,
.cabinet-elevation.selected {
  fill: #ccfbf1;
  stroke: var(--accent);
  stroke-width: 4;
}

.part {
  fill: var(--part);
  stroke: #64748b;
  stroke-width: 1.5;
}

.face {
  fill: #fff7ed;
  stroke: var(--accent-2);
  stroke-width: 1.5;
}

.shape-line {
  fill: none;
  stroke: #7c2d12;
  stroke-width: 1.5;
}

.label {
  fill: #1f2937;
  font-size: 28px;
  paint-order: stroke;
  stroke: #ffffff;
  stroke-width: 5px;
  stroke-linejoin: round;
}

.dxf-line {
  fill: none;
  stroke-width: .55;
  vector-effect: non-scaling-stroke;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: .86;
}

.dxf-line.selected-layer {
  stroke-width: 1.1;
  opacity: 1;
}

.dxf-text-group {
  pointer-events: none;
}

.dxf-text {
  fill: #0f172a;
  font-size: 2.8px;
  font-weight: 700;
  paint-order: stroke;
  stroke: #ffffff;
  stroke-width: 0.45px;
  stroke-linejoin: round;
}

.joint-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  vertical-align: middle;
  background: #e0f2fe;
  color: #0369a1;
  border-radius: 4px;
}

.axis-line {
  stroke: #111827;
  stroke-width: 1.4;
  vector-effect: non-scaling-stroke;
}

.axis-label {
  fill: #111827;
  font-size: 2.4px;
  paint-order: stroke;
  stroke: #ffffff;
  stroke-width: .35px;
  stroke-linejoin: round;
}

.empty-state {
  fill: #475569;
  font-size: 30px;
}

/* Phone / tablet compact layout (touch-first, max-width includes iPad portrait) */
@media (max-width: 1024px), ((hover: none) and (pointer: coarse) and (max-width: 1280px)) {
  body.layout-compact {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas:
      'chrome'
      'workspace';
    min-height: 100dvh;
    height: 100dvh;
    overflow: hidden;
  }

  body.layout-compact .workspace {
    min-height: 0;
    overflow: hidden;
  }

  body.layout-compact .canvas-wrap {
    min-height: 0;
  }

  body.layout-compact .compact-chrome {
    display: block;
    grid-area: chrome;
    background: #ffffff;
    border-bottom: 1px solid var(--line);
  }

  body.layout-compact .compact-chrome[hidden] {
    display: block;
  }

  body.layout-compact .compact-chrome .file-action-btn,
  body.layout-compact .compact-chrome-save #saveDxfBtn {
    text-transform: none;
  }

  body.layout-compact .settings-gear {
    display: none;
  }

  body.layout-compact .sidebar {
    position: fixed;
    z-index: 110;
    top: var(--compact-chrome-offset, 88px);
    left: 0;
    bottom: 0;
    width: min(300px, 88vw);
    max-width: 100%;
    min-height: 0;
    padding-top: 0;
    border-right: 1px solid var(--line);
    border-bottom: 0;
    box-shadow: 8px 0 28px rgba(32, 37, 34, .18);
    visibility: hidden;
    pointer-events: none;
    transform: translateX(-100%);
    transition: transform 0.2s ease, visibility 0.2s ease;
    overflow: auto;
    overscroll-behavior: contain;
  }

  body.layout-compact:not(.sidebar-layers-open) .sidebar {
    visibility: hidden;
    pointer-events: none;
    transform: translateX(-100%);
  }

  body.layout-compact.sidebar-layers-open .sidebar {
    visibility: visible;
    pointer-events: auto;
    transform: translateX(0);
  }

  body.layout-compact #sidebarFileHost,
  body.layout-compact #sidebarTabsHost {
    display: none;
  }

  body.layout-compact .layers-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 105;
    background: rgba(32, 37, 34, .35);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
  }

  body.layout-compact.sidebar-layers-open .layers-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  body.layout-compact .layers-backdrop[hidden] {
    display: block;
  }

  body.layout-compact .sidebar .brand {
    display: none;
  }

  body.layout-compact .layers-panel {
    margin-top: 8px;
  }

  body.layout-compact .layer-list {
    max-height: none;
  }

  body.layout-compact .toolbar-help {
    display: none;
  }

  body.layout-compact .toolbar {
    flex-wrap: wrap;
    padding: 8px 10px;
    gap: 8px;
  }

  body.layout-compact .toolbar-left {
    flex-wrap: wrap;
    width: 100%;
  }

  body.layout-compact .toolbar-annotations {
    margin-left: 0;
    padding-left: 0;
    border-left: 0;
    flex-wrap: wrap;
  }

  body.layout-compact .toolbar-actions button,
  body.layout-compact .toolbar-annotations button,
  body.layout-compact .icon-btn {
    min-height: 36px;
    font-size: 13px;
  }

  body.layout-compact .toolbar-annotations .annotation-toggle {
    display: none;
  }

  body.layout-compact.layout-compact-landscape {
    --compact-nav-width: 160px;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    grid-template-areas: 'chrome workspace';
    min-height: 100dvh;
    height: 100dvh;
    overflow: hidden;
  }

  body.layout-compact.layout-compact-landscape .compact-chrome {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-content: start;
    gap: 6px;
    align-self: stretch;
    width: var(--compact-nav-width);
    min-width: var(--compact-nav-width);
    max-width: var(--compact-nav-width);
    height: 100%;
    max-height: 100dvh;
    padding: 8px;
    overflow: visible;
    border-bottom: 0;
    border-right: 1px solid var(--line);
    z-index: 40;
  }

  body.layout-compact.layout-compact-landscape .compact-chrome-row,
  body.layout-compact.layout-compact-landscape .compact-chrome-row-primary,
  body.layout-compact.layout-compact-landscape .compact-chrome-row-secondary,
  body.layout-compact.layout-compact-landscape .compact-chrome-primary-actions {
    display: contents;
  }

  body.layout-compact.layout-compact-landscape .compact-chrome-locale,
  body.layout-compact.layout-compact-landscape .compact-chrome-tabs,
  body.layout-compact.layout-compact-landscape .compact-chrome-tools,
  body.layout-compact.layout-compact-landscape .compact-toolbar-host {
    grid-column: 1 / -1;
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  body.layout-compact.layout-compact-landscape .compact-chrome-file,
  body.layout-compact.layout-compact-landscape .compact-chrome-save {
    min-width: 0;
  }

  body.layout-compact.layout-compact-landscape .compact-chrome .tabs {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    width: 100%;
    margin-bottom: 0;
    gap: 4px;
    padding: 4px;
  }

  body.layout-compact.layout-compact-landscape .compact-chrome .file-action-btn,
  body.layout-compact.layout-compact-landscape .compact-chrome-save #saveDxfBtn,
  body.layout-compact.layout-compact-landscape .compact-chrome .tab,
  body.layout-compact.layout-compact-landscape .compact-layers-btn,
  body.layout-compact.layout-compact-landscape .compact-toolbar-host .toolbar-actions button,
  body.layout-compact.layout-compact-landscape .compact-toolbar-host .toolbar-annotations button {
    width: 100%;
    max-width: 100%;
    min-height: 32px;
    padding: 0 4px;
    font-size: 11px;
    font-weight: 700;
    text-transform: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  body.layout-compact.layout-compact-landscape .compact-toolbar-host {
    display: block;
    border-top: 1px solid var(--line);
    padding-top: 6px;
  }

  body.layout-compact.layout-compact-landscape .compact-toolbar-host .toolbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 6px;
    padding: 0;
    border: 0;
  }

  body.layout-compact.layout-compact-landscape .compact-toolbar-host .toolbar-left,
  body.layout-compact.layout-compact-landscape .compact-toolbar-host .toolbar-actions,
  body.layout-compact.layout-compact-landscape .compact-toolbar-host .toolbar-annotations {
    display: contents;
  }

  body.layout-compact.layout-compact-landscape .compact-toolbar-host #viewTitle {
    grid-column: 1 / -1;
    display: block;
    padding: 2px 0 0;
    font-size: 13px;
  }

  body.layout-compact.layout-compact-landscape .compact-toolbar-host .elevation-nav {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 6px;
    width: 100%;
  }

  body.layout-compact.layout-compact-landscape .workspace-toolbar-slot:empty {
    display: none;
  }

  body.layout-compact.layout-compact-landscape:not(.sidebar-layers-open) .sidebar {
    top: 0;
    left: 0;
    transform: translateX(-100%);
  }

  body.layout-compact.layout-compact-landscape.sidebar-layers-open .sidebar {
    top: 0;
    left: var(--compact-chrome-width, var(--compact-nav-width, 160px));
    transform: translateX(0);
  }

  body.layout-compact.layout-compact-landscape .workspace {
    grid-area: workspace;
    min-height: 0;
    min-width: 0;
  }
}

@media (display-mode: standalone), (display-mode: fullscreen) {
  body.layout-compact .compact-chrome {
    padding-top: max(8px, env(safe-area-inset-top, 0px));
    padding-left: max(8px, env(safe-area-inset-left, 0px));
    padding-right: max(8px, env(safe-area-inset-right, 0px));
    padding-bottom: max(8px, env(safe-area-inset-bottom, 0px));
  }
}
