/* dxf-dump viewer — frontend only, no external assets. */

:root {
  color-scheme: light dark;

  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #eef0f4;
  --border: #d5d9e0;
  --text: #1b1f27;
  --muted: #616a7a;
  --accent: #2f6feb;
  --accent-soft: #e5edfd;
  --danger: #b4291f;
  --canvas-bg: #ffffff;
  --canvas-ink: #1b1f27;
  --grid: #e9ecf1;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151b;
    --surface: #191d25;
    --surface-2: #212734;
    --border: #2e3644;
    --text: #e7eaf0;
    --muted: #98a2b3;
    --accent: #6c9bff;
    --accent-soft: #1e2a44;
    --danger: #ff8a80;
    --canvas-bg: #0f1218;
    --canvas-ink: #e7eaf0;
    --grid: #1c222c;
  }
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  overflow: hidden;
}

/* ---------- header ---------- */

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}

.brand { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.brand-mark { color: var(--accent); font-size: 18px; }
.brand-name { font-weight: 650; letter-spacing: -0.01em; }
.brand-tag { color: var(--muted); font-size: 12px; white-space: nowrap; }
@media (max-width: 640px) { .brand-tag { display: none; } }

.header-actions { display: flex; gap: 8px; flex: 0 0 auto; }

.button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 550;
  cursor: pointer;
  white-space: nowrap;
}
.button:hover { filter: brightness(1.07); }
.button.ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}
.button.ghost:hover { background: var(--surface-2); }

/* ---------- layout ---------- */

.layout {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  min-height: 0;
}
@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) 44vh; }
}

.viewport-pane {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--canvas-bg);
}

.viewport-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
  user-select: none;
}
.chip:hover { border-color: var(--accent); }
.chip.toggle { cursor: pointer; }
.chip input { margin: 0; accent-color: var(--accent); }

.toolbar-status {
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
  font-family: var(--mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#canvas {
  flex: 1 1 auto;
  display: block;
  width: 100%;
  min-height: 0;
  touch-action: none;
  cursor: grab;
}
#canvas.panning { cursor: grabbing; }

.empty-state {
  position: absolute;
  inset: 44px 0 0 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  text-align: center;
  pointer-events: none;
  padding: 24px;
}
.empty-state[hidden] { display: none; }
.empty-icon { font-size: 44px; opacity: 0.7; }
.empty-state p { margin: 2px 0; }

/* ---------- side pane ---------- */

.side-pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--surface);
  border-left: 1px solid var(--border);
}
@media (max-width: 900px) {
  .side-pane { border-left: none; border-top: 1px solid var(--border); }
}

.tabs {
  display: flex;
  gap: 2px;
  padding: 8px 8px 0;
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
  overflow-x: auto;
}

.tab {
  padding: 7px 12px;
  border: none;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

.panel {
  display: none;
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 14px 16px;
}
.panel.active { display: block; }

/* ---------- content ---------- */

h2, h3 { margin: 0 0 8px; line-height: 1.25; }
h2 { font-size: 17px; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin-top: 20px; }
h3:first-child { margin-top: 0; }

.muted { color: var(--muted); }

dl.facts {
  display: grid;
  grid-template-columns: minmax(90px, auto) minmax(0, 1fr);
  gap: 5px 14px;
  margin: 0 0 4px;
}
dl.facts dt { color: var(--muted); font-size: 12.5px; }
dl.facts dd { margin: 0; font-family: var(--mono); font-size: 12.5px; word-break: break-word; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
th, td {
  text-align: left;
  padding: 5px 8px 5px 0;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
th { color: var(--muted); font-weight: 550; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.04em; }
td.num, th.num { text-align: right; font-family: var(--mono); padding-right: 0; }

.swatch {
  display: inline-block;
  width: 11px;
  height: 11px;
  border-radius: 3px;
  border: 1px solid rgba(128, 128, 128, 0.5);
  vertical-align: -1px;
  margin-right: 6px;
}

.layer-row.off td { opacity: 0.45; }

.notice {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  background: var(--accent-soft);
  margin: 0 0 12px;
  font-size: 13px;
}
.notice.error { border-left-color: var(--danger); background: transparent; }
.notice strong { display: block; margin-bottom: 3px; }

ul.tight { margin: 0; padding-left: 18px; }
ul.tight li { margin-bottom: 3px; }

code { font-family: var(--mono); font-size: 0.92em; }

.scroll-x { overflow-x: auto; }

/* ---------- overlay / dialog ---------- */

.drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  backdrop-filter: blur(2px);
}
.drop-overlay[hidden] { display: none; }
.drop-overlay-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 32px 44px;
  border: 2px dashed var(--accent);
  border-radius: 14px;
  background: var(--surface);
}
.drop-icon { font-size: 40px; }

.about-dialog {
  max-width: 620px;
  width: calc(100% - 32px);
  padding: 22px 24px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
}
.about-dialog::backdrop { background: rgba(0, 0, 0, 0.45); }
.about-dialog p { margin: 0 0 10px; }
.about-dialog ul { margin: 0 0 10px; padding-left: 20px; }
