:root {
  --bg: #f4f5f7; --panel: #fff; --ink: #1d2433; --muted: #5d6779; --line: #d9dde5;
  --accent: #2356c8; --accent-ink: #fff; --warn: #b3261e; --ok: #1b7a3e;
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); height: 100vh; display: flex; flex-direction: column; }
header.top { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 8px 12px; background: #172037; color: #fff; }
header.top h1 { font-size: 17px; margin: 0 10px 0 0; letter-spacing: .3px; }
header.top .sep { width: 1px; height: 22px; background: #44506e; margin: 0 4px; }
#toast { margin-left: auto; font-size: 13px; color: #b9d0ff; min-height: 1em; }
button, .btn, select, input { font: inherit; }
button, .btn { background: #fff; color: var(--ink); border: 1px solid var(--line); border-radius: 5px; padding: 4px 10px; cursor: pointer; display: inline-block; }
button:hover, .btn:hover { border-color: var(--accent); }
button:disabled { opacity: .45; cursor: default; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.active { outline: 2px solid #ff9f1a; }
select, input[type=number], input:not([type]), input[type=text] { border: 1px solid var(--line); border-radius: 4px; padding: 3px 5px; background: #fff; color: var(--ink); }
main { flex: 1; display: flex; min-height: 0; }
#stage-wrap { position: relative; flex: 1; min-width: 0; background: #2b3144; overflow: hidden; }
#stage { width: 100%; height: 100%; display: block; touch-action: none; cursor: crosshair; }
#tools { position: absolute; top: 8px; left: 8px; background: rgba(255,255,255,.92); border-radius: 6px; padding: 4px 8px; display: flex; gap: 10px; font-size: 13px; z-index: 2; }
#loupe { position: absolute; display: none; pointer-events: none; border: 2px solid #fff; border-radius: 50%; box-shadow: 0 2px 10px rgba(0,0,0,.5); z-index: 3; width: 150px; height: 150px; }
#drop { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; color: #cfd6e8; pointer-events: none; font-size: 18px; }
#drop span { font-size: 13px; opacity: .8; }
#stage-wrap.dragover { outline: 3px dashed #ff9f1a; outline-offset: -6px; }
#status { position: absolute; left: 0; right: 0; bottom: 0; padding: 3px 10px; font: 12px ui-monospace, monospace; color: #e7ecf8; background: rgba(15,20,35,.75); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#panel { width: 390px; overflow-y: auto; background: var(--panel); border-left: 1px solid var(--line); padding: 4px 12px 40px; }
details { border-bottom: 1px solid var(--line); padding: 6px 0 10px; }
summary { font-weight: 600; cursor: pointer; padding: 4px 0; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 6px 0; }
.opts { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0; }
.hint { color: var(--muted); font-size: 12.5px; margin: 4px 0; }
.result { font: 12.5px/1.45 ui-monospace, monospace; background: #f4f6fb; border-radius: 5px; padding: 6px 8px; margin-top: 6px; white-space: pre-wrap; min-height: 1.4em; }
.result.bad { color: var(--warn); }
.result.good { color: var(--ok); }
.narrow { width: 66px; } .mid { width: 90px; }
.swatch { display: inline-block; width: 22px; height: 22px; border-radius: 4px; border: 1px solid #888; background: repeating-conic-gradient(#ddd 0 25%, #fff 0 50%) 0 0 / 8px 8px; }
.cal-row, .ds-row { display: flex; align-items: center; gap: 6px; margin: 4px 0; font-size: 12.5px; }
.cal-row .tag { width: 24px; font-weight: 700; color: var(--accent); }
.cal-row .pos { color: var(--muted); font-family: ui-monospace, monospace; min-width: 96px; }
.cal-row input { width: 100px; }
.ds-row { padding: 3px 6px; border-radius: 5px; border: 1px solid transparent; }
.ds-row.active { background: #eaf0ff; border-color: #aac0f5; }
.ds-row input[type=text] { width: 120px; }
.ds-row input[type=color] { width: 28px; height: 24px; padding: 0; border: none; background: none; }
.ds-row .count { color: var(--muted); margin-left: auto; }
.ds-row .x { border: none; background: none; color: var(--warn); font-size: 16px; padding: 0 4px; }
#table-wrap { max-height: 260px; overflow: auto; border: 1px solid var(--line); border-radius: 5px; }
table { border-collapse: collapse; width: 100%; font: 12.5px ui-monospace, monospace; }
th, td { border-bottom: 1px solid #eceff4; padding: 1px 4px; text-align: right; }
th { position: sticky; top: 0; background: #f4f6fb; }
td input { width: 100%; border: none; text-align: right; font: inherit; background: transparent; padding: 2px; }
td input:focus { background: #fff8e1; outline: 1px solid #f0b429; }
td input[readonly] { color: var(--muted); }
#export-preview { width: 100%; font: 12px ui-monospace, monospace; margin-top: 6px; }
@media (max-width: 800px) { main { flex-direction: column; } #panel { width: 100%; height: 50%; } }
#drop[hidden] { display: none; }
