/* The drawing viewer page (/dxf-viewer/), after style.css. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

main:has(.viewer) { max-width: 1400px; }

.viewer {
  margin: 20px 0 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  overflow: hidden;
}

.viewer-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}
.viewer-bar .spacer { flex: 1 1 auto; }
.open-button {
  display: inline-block;
  font-weight: 600;
  padding: 9px 16px;
  border-radius: 7px;
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
}
input:focus-visible + .open-button, .open-button:focus-within { outline: 3px solid #f0b429; outline-offset: 2px; }
.viewer-bar button.secondary { padding: 8px 14px; }
.file-name { font-weight: 600; overflow-wrap: anywhere; }
.view-tools { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.tool-button {
  min-width: 38px;
  padding: 6px 10px;
  background: #fff;
  color: var(--ink);
  border: 1px solid #9aa6ae;
  font-weight: 600;
}
.toggle { display: flex; gap: 5px; align-items: center; font-size: 0.92rem; margin-left: 6px; }

.viewer-body {
  display: grid;
  grid-template-columns: 1fr 280px;
  min-height: 0;
}
.viewer-body:has(.side[hidden]) { grid-template-columns: 1fr; }

.stage {
  position: relative;
  height: min(72vh, 760px);
  min-height: 360px;
  background: #fff;
}
.stage.dark { background: #1e2227; }
.stage.dragging { outline: 3px dashed var(--accent); outline-offset: -8px; }
.stage canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: grab;
}
.stage canvas:active { cursor: grabbing; }
.stage canvas:focus-visible { outline: 3px solid #f0b429; outline-offset: -3px; }

.drop-hint {
  position: absolute;
  inset: 24px;
  display: grid;
  place-content: center;
  text-align: center;
  border: 2px dashed #9aa6ae;
  border-radius: 10px;
  color: var(--muted);
  pointer-events: none;
}
.drop-hint p { margin: 4px 0; }

.status {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 10px;
  margin: 0;
  pointer-events: none;
  font-weight: 600;
}
.status:empty { display: none; }
.stop-reading {
  position: absolute;
  right: 12px;
  bottom: 6px;
}
.status.error { color: var(--error); }
.stage.dark .status:not(.error) { color: #fff; }
.coords {
  position: absolute;
  right: 10px;
  top: 8px;
  margin: 0;
  padding: 1px 6px;
  font: 12px/1.6 ui-monospace, Consolas, monospace;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.85);
  border-radius: 4px;
  pointer-events: none;
}
.coords:empty { display: none; }

.side {
  border-left: 1px solid var(--line);
  padding: 10px 14px 14px;
  overflow: auto;
  height: min(72vh, 760px);
  min-height: 360px;
  background: #fff;
}
.side-title { font-size: 1rem; margin: 8px 0 6px; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; margin: 0 0 10px; font-size: 0.9rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.notice { font-size: 0.86rem; background: #fff7e0; border: 1px solid #f0d58a; border-radius: 6px; padding: 6px 8px; margin: 0 0 10px; }
.layers-head { display: flex; align-items: baseline; gap: 10px; }
.layers-head .side-title { margin-right: auto; }
.link-button { background: none; color: var(--accent); padding: 0; font-weight: 600; font-size: 0.86rem; }
.layers { list-style: none; margin: 0; padding: 0; font-size: 0.9rem; }
.layers li { margin: 0; }
.layers label { display: flex; gap: 7px; align-items: center; padding: 3px 0; cursor: pointer; }
.swatch { flex: 0 0 auto; width: 12px; height: 12px; border-radius: 2px; border: 1px solid rgba(0, 0, 0, 0.35); color: #000; }
.layer-name { overflow-wrap: anywhere; }

@media (max-width: 860px) {
  .viewer-body { grid-template-columns: 1fr; }
  .side { border-left: 0; border-top: 1px solid var(--line); height: auto; min-height: 0; max-height: 50vh; }
  .stage { height: 62vh; min-height: 300px; }
}

.spaces {
  display: flex;
  gap: 2px;
  padding: 6px 10px 0;
  border-top: 1px solid var(--line);
  overflow-x: auto;
}
.space-tab {
  padding: 5px 12px;
  border-radius: 6px 6px 0 0;
  background: #e3e8eb;
  color: var(--ink);
  font-weight: 500;
  font-size: 0.9rem;
  white-space: nowrap;
}
.space-tab[aria-selected="true"] { background: #fff; color: var(--accent); font-weight: 700; box-shadow: inset 0 -3px 0 var(--accent); }

.export { display: grid; gap: 8px; margin: 4px 0 14px; padding: 10px; background: var(--panel); border-radius: 8px; }
.export .side-title { margin: 0; }
.export .field > label { font-size: 0.86rem; }
.export select { padding: 5px 7px; font-size: 0.9rem; }
.export #model-options { display: grid; gap: 8px; }
.export #model-options[hidden] { display: none; }
.export button { justify-self: start; padding: 8px 14px; }
.export .hint.warning { color: var(--error); font-weight: 600; }
.export .error { font-size: 0.86rem; }
