:root {
  --bg: #1a1d21;
  --panel: #23272e;
  --panel-2: #2b3038;
  --border: #3a4049;
  --text: #e6e8eb;
  --muted: #9aa2ad;
  --accent: #4dd0e1;
  --danger: #ff5252;
  --ok: #66bb6a;
  --warn: #ffb74d;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; height: 100%;
  font: 14px/1.4 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg); color: var(--text);
  overflow: hidden;
}

/* Toolbar */
#toolbar {
  display: flex; align-items: center; gap: 16px;
  padding: 8px 12px; background: var(--panel); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; letter-spacing: 0.5px; color: var(--accent); }
#toolbar .group { display: flex; gap: 4px; }
button {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--border);
  padding: 6px 10px; border-radius: 6px; cursor: pointer; font-size: 13px;
}
button:hover:not(:disabled) { background: #333a44; }
button:disabled { opacity: 0.45; cursor: default; }
.mode.active { background: var(--accent); color: #08262b; border-color: var(--accent); font-weight: 600; }
#dirty-flag { color: var(--warn); font-size: 18px; margin-left: auto; }

/* Layout */
#layout { display: grid; grid-template-columns: 260px 1fr 300px; height: calc(100% - 49px); }
aside { background: var(--panel); overflow-y: auto; padding: 12px; }
#left { border-right: 1px solid var(--border); }
#right { border-left: 1px solid var(--border); }
aside section { margin-bottom: 20px; }
h3 { margin: 0 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); }
.hint { font-size: 11.5px; color: var(--muted); margin: 4px 0 8px; }
label { display: block; margin: 6px 0; font-size: 12.5px; }
label input[type=range] { width: 100%; }
.inline { display: inline-flex; align-items: center; gap: 4px; }
.inline input { width: 64px; }
.checkbox { display: flex; align-items: center; gap: 6px; }
.badge { background: var(--panel-2); border-radius: 10px; padding: 1px 7px; font-size: 11px; color: var(--muted); }
.status { font-size: 12px; padding: 4px 8px; border-radius: 4px; background: var(--panel-2); color: var(--muted); }
.status.ok { color: var(--ok); }

/* Landmark & structure lists */
#landmark-list, #structure-list, #analysis-toggle { list-style: none; margin: 0; padding: 0; }
#landmark-list li {
  display: flex; align-items: center; gap: 6px; padding: 4px 6px; border-radius: 4px;
  cursor: pointer; font-size: 12.5px;
}
#landmark-list li:hover { background: var(--panel-2); }
#landmark-list li.target { background: var(--accent); color: #08262b; }
#landmark-list li.placed .dot { background: var(--danger); }
#landmark-list li .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border); flex: none; }
#landmark-list li .lm-name { color: var(--muted); font-size: 11px; margin-left: auto; }
#landmark-list li.target .lm-name { color: #08262b; }
#structure-list li, #analysis-toggle li { padding: 4px 6px; font-size: 12.5px; }
#structure-list li { cursor: pointer; border-radius: 4px; display: flex; align-items: center; gap: 6px; }
#structure-list li:hover { background: var(--panel-2); }
#structure-list li.active { background: var(--panel-2); font-weight: 600; }
#structure-list .swatch { width: 12px; height: 12px; border-radius: 3px; flex: none; }
#structure-list .place-btn { margin-left: auto; padding: 2px 8px; font-size: 11px; }

/* Guide panel */
#guide-content { text-align: center; }
.guide-svg { background: var(--panel-2); border: 1px solid var(--border); border-radius: 6px; }
.guide-name { font-weight: 600; margin-top: 6px; font-size: 12.5px; }
.guide-desc { font-size: 11.5px; color: var(--muted); margin-top: 2px; text-align: left; }

/* Stage */
#stage { position: relative; overflow: hidden; background: #0d0f12; }
#viewport { position: absolute; inset: 0; }
#image-canvas, #overlay { position: absolute; inset: 0; width: 100%; height: 100%; }
#overlay { touch-action: none; }
#loupe {
  position: absolute; width: 180px; height: 180px; border-radius: 50%;
  border: 2px solid var(--accent); pointer-events: none; display: none;
  box-shadow: 0 4px 16px rgba(0,0,0,0.6); z-index: 5;
}
#empty-hint {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: var(--muted); pointer-events: none;
}
/* An id selector outranks the UA [hidden] rule, so restore hide behaviour explicitly. */
#empty-hint[hidden] { display: none; }

/* Measurements panel */
.m-analysis { margin-bottom: 16px; }
.m-analysis h4 { margin: 0 0 6px; font-size: 13px; color: var(--accent); }
.m-row {
  display: grid; grid-template-columns: 1fr auto; gap: 4px; align-items: baseline;
  padding: 5px 6px; border-radius: 4px; border-left: 3px solid transparent;
}
.m-row:hover { background: var(--panel-2); }
.m-row .m-name { font-size: 12.5px; }
.m-row .m-sub { font-size: 10.5px; color: var(--muted); }
.m-row .m-value { font-variant-numeric: tabular-nums; font-weight: 600; text-align: right; }
.m-row .m-dev { font-size: 10.5px; color: var(--muted); text-align: right; }
.m-row.pending .m-value { color: var(--muted); font-weight: 400; font-size: 11px; }
.dev-normal { border-left-color: var(--ok); }
.dev-mild   { border-left-color: var(--warn); }
.dev-marked { border-left-color: var(--danger); }
.disclaimer { font-size: 10.5px; color: var(--muted); margin-top: 16px; border-top: 1px solid var(--border); padding-top: 8px; }

/* Toast */
#toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: #333; color: #fff; padding: 10px 16px; border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5); opacity: 0; transition: opacity 0.2s;
  pointer-events: none; max-width: 60ch; z-index: 100;
}
#toast.show { opacity: 1; }
#toast.error { background: var(--danger); }

/* Report */
#report-view {
  position: fixed; inset: 0; background: #fff; color: #111; overflow-y: auto; z-index: 200;
}
.report-actions { position: sticky; top: 0; background: #eee; padding: 10px; display: flex; gap: 8px; }
#report-content { max-width: 800px; margin: 0 auto; padding: 24px; }
.rp-head h1 { font-size: 20px; margin: 0 0 4px; }
.rp-meta { display: flex; gap: 20px; color: #444; font-size: 13px; }
.rp-image { display: block; max-width: 100%; margin: 16px 0; border: 1px solid #ccc; }
.rp-analysis h2 { font-size: 15px; border-bottom: 2px solid #333; padding-bottom: 3px; }
.rp-table { width: 100%; border-collapse: collapse; margin-bottom: 16px; font-size: 13px; }
.rp-table th, .rp-table td { text-align: left; padding: 5px 8px; border-bottom: 1px solid #ddd; }
.rp-table .rp-val, .rp-table .rp-dev { text-align: right; font-variant-numeric: tabular-nums; }
.rp-table tr.dev-mild { background: #fff6e5; }
.rp-table tr.dev-marked { background: #ffe9e9; }
.rp-table tr.rp-pending td { color: #999; font-style: italic; }
.rp-note { font-size: 13px; margin: 12px 0; }
.rp-foot { font-size: 11px; color: #666; border-top: 1px solid #ccc; padding-top: 8px; margin-top: 20px; }

@media print {
  .no-print { display: none !important; }
  #report-view { position: static; }
  body { overflow: visible; }
}
