:root {
  --bg: #f6f5f1; --panel: #fff; --line: #e2e0d8; --text: #2c2c2a; --muted: #77766f;
  --accent: #d85a30; --accent-d: #993c1d; --ok: #0f6e56; --warn: #854f0b; --err: #a32d2d;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 14px/1.6 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text); background: var(--bg); display: flex; flex-direction: column;
}
header { padding: 12px 20px; border-bottom: 1px solid var(--line); background: var(--panel); display: flex; align-items: baseline; gap: 16px; flex-wrap: wrap; }
header h1 { font-size: 18px; margin: 0; font-weight: 600; }
header .sub { color: var(--muted); font-size: 13px; }
main { flex: 1; display: flex; min-height: 0; }
aside { width: 340px; flex: none; overflow-y: auto; background: var(--panel); border-right: 1px solid var(--line); padding: 16px; display: flex; flex-direction: column; gap: 18px; }
aside h2 { font-size: 14px; margin: 0 0 8px; font-weight: 600; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 12px; margin: 8px 0 0; }

.drop { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; height: 96px; border: 1.5px dashed #b4b2a9; border-radius: 10px; cursor: pointer; background: #faf9f6; transition: .15s; }
.drop:hover, .drop.over { border-color: var(--accent); background: #faece7; }
.drop input { display: none; }
.drop span { color: var(--muted); font-size: 12px; }
#fileinfo { margin-top: 8px; font-size: 12px; word-break: break-all; }
.error { margin-top: 8px; padding: 8px 10px; background: #fcebeb; color: var(--err); border-radius: 6px; font-size: 13px; }

.markers { display: flex; flex-direction: column; gap: 6px; }
.markers button { text-align: left; display: flex; justify-content: space-between; align-items: center; }
.markers button.sel { border-color: var(--accent); background: #faece7; color: var(--accent-d); font-weight: 600; }
.markers .pos { color: var(--muted); font-size: 12px; font-weight: 400; }

button { font: inherit; padding: 7px 12px; border: 1px solid var(--line); background: #fff; border-radius: 6px; cursor: pointer; color: var(--text); }
button:hover:not(:disabled) { border-color: #b4b2a9; }
button:disabled { opacity: .45; cursor: default; }
button.primary { width: 100%; margin-top: 10px; background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; padding: 9px; }
button.primary:hover { background: var(--accent-d); }

#summary { font-size: 13px; }
#summary .big { font-size: 15px; font-weight: 600; color: var(--accent-d); }
#summary table { border-collapse: collapse; margin-top: 6px; width: 100%; }
#summary td { padding: 2px 0; }
#summary td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
details summary { cursor: pointer; color: var(--muted); font-size: 13px; margin-top: 10px; }
#detail { font-size: 12px; font-family: ui-monospace, Menlo, monospace; max-height: 220px; overflow: auto; margin-top: 6px; white-space: pre; }
.warn:not(:empty) { margin-top: 10px; padding: 8px 10px; background: #faeeda; color: var(--warn); border-radius: 6px; font-size: 13px; }

.field { margin-top: 10px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 3px; }
.field select, .field input { font: inherit; padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; width: 100%; background: #fff; }
.field .row { display: flex; align-items: center; gap: 8px; }
.field .row input { width: 100px; }

.viewer { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.toolbar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--line); background: var(--panel); flex-wrap: wrap; }
.legend { display: flex; gap: 12px; font-size: 12px; margin-left: 8px; }
.legend i { display: inline-block; width: 18px; height: 0; border-top: 2px solid; vertical-align: middle; margin-right: 4px; }
.coords { margin-left: auto; font-size: 12px; font-variant-numeric: tabular-nums; }
.stage { flex: 1; position: relative; min-height: 0; background: #fff; }
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; cursor: grab; }
.stage canvas.drag { cursor: grabbing; }
.empty { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; color: #9c9a92; text-align: center; pointer-events: none; }

@media (max-width: 760px) {
  main { flex-direction: column; }
  aside { width: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .viewer { min-height: 70vh; }
}
[hidden] { display: none !important; }
