:root {
  --bg: #f4f3f0; --panel: #ffffff; --line: #dcdad4; --fg: #1d1d1b; --mute: #6a6964;
  --accent: #00384f; --accent-fg: #ffffff; --stage: #2a2b2d;
  --ok: #1e6b3a; --warn: #8a5a00; --fail: #a3271f; --sel: #2f80ed;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--fg); font: 13.5px/1.45 -apple-system, "Helvetica Neue", Arial, sans-serif; display: flex; flex-direction: column; overflow: hidden; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
button { border: 1px solid var(--line); background: var(--panel); border-radius: 6px; padding: 6px 11px; cursor: pointer; }
button:hover:not(:disabled) { border-color: #b9b6ae; }
button:disabled { opacity: 0.45; cursor: default; }
button.primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
button.link { border: 0; background: none; padding: 0; color: var(--accent); text-decoration: underline; }
button.on { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
:focus-visible { outline: 2px solid var(--sel); outline-offset: 1px; }

.top { display: flex; align-items: center; gap: 10px; padding: 8px 14px; background: var(--panel); border-bottom: 1px solid var(--line); flex: none; }
.brand { font-weight: 650; color: var(--fg); text-decoration: none; }
.name { border: 1px solid transparent; border-radius: 6px; padding: 5px 8px; min-width: 240px; background: transparent; font-weight: 500; }
.name:hover, .name:focus { border-color: var(--line); background: var(--panel); }
.saved { color: var(--mute); font-size: 12.5px; }
.saved.err { color: var(--fail); }
.grow { flex: 1; }

main { flex: 1; min-height: 0; display: grid; grid-template-columns: 290px minmax(0, 1fr) 250px; }
.left, .right { background: var(--panel); overflow-y: auto; padding: 12px; }
.left { border-right: 1px solid var(--line); }
.right { border-left: 1px solid var(--line); }
.centre { display: flex; flex-direction: column; min-width: 0; min-height: 0; }

h2 { font-size: 11.5px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--mute); margin: 18px 0 8px; font-weight: 600; }
h2:first-child { margin-top: 2px; }
.row { display: flex; gap: 8px; align-items: center; margin: 6px 0; flex-wrap: wrap; }
.row > label { color: var(--mute); min-width: 74px; }
.row input[type="number"] { width: 78px; }
.field { display: block; margin: 8px 0; }
.field > span { display: block; color: var(--mute); margin-bottom: 3px; }
input[type="text"], input[type="number"], select, textarea { border: 1px solid var(--line); border-radius: 6px; padding: 5px 7px; background: var(--panel); }
textarea { width: 100%; min-height: 62px; resize: vertical; }
input[type="color"] { width: 38px; height: 28px; padding: 1px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); }
input[type="range"] { flex: 1; min-width: 100px; }
.hint { color: var(--mute); font-size: 12.5px; margin: 6px 0; }
.note { background: #fff7e0; border: 1px solid #ecd9a0; border-radius: 6px; padding: 7px 9px; margin: 8px 0; font-size: 12.5px; }
.seg { display: inline-flex; }
.seg button { border-radius: 0; margin-left: -1px; padding: 5px 10px; }
.seg button:first-child { border-radius: 6px 0 0 6px; margin-left: 0; }
.seg button:last-child { border-radius: 0 6px 6px 0; }

.layers { list-style: none; margin: 0; padding: 0; }
.layers li { display: flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 6px; margin: 4px 0; padding: 2px 4px 2px 0; }
.layers li.sel { border-color: var(--sel); box-shadow: 0 0 0 1px var(--sel); }
.layers li.off .pick { color: var(--mute); text-decoration: line-through; }
.layers .pick { flex: 1; text-align: left; border: 0; background: none; padding: 6px 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.layers .mini { border: 0; background: none; padding: 4px 6px; color: var(--mute); font-size: 12px; }
.layers .mini:hover { color: var(--fg); }

.stageBar { display: flex; align-items: center; gap: 10px; padding: 8px 14px; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; min-height: 45px; }
.stageBar strong { font-size: 14px; }
.chip { font-size: 11.5px; border-radius: 99px; padding: 2px 9px; border: 1px solid var(--line); color: var(--mute); white-space: nowrap; }
.chip.master { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.chip.edited { background: #e7f0fd; border-color: #b8d2f7; color: #1c4f96; }
.chip.ok { color: var(--ok); border-color: #b9dcc5; } .chip.warn { color: var(--warn); border-color: #e6cf94; } .chip.fail { color: var(--fail); border-color: #e3b1ac; }
.stage { flex: 1; min-height: 0; background: var(--stage); display: flex; align-items: center; justify-content: center; overflow: hidden; position: relative; touch-action: none; outline: none; }
.stageFrame { position: relative; box-shadow: 0 2px 18px rgba(0, 0, 0, 0.5); flex: none; }
.stageFrame .ad { transform-origin: 0 0; position: absolute !important; left: 0; top: 0; }
.overlay { position: absolute; inset: 0; pointer-events: none; }
.overlay .safe { position: absolute; border: 1px dashed rgba(255, 255, 255, 0.35); }
.overlay .subject { position: absolute; border: 2px dashed #ffd24a; background: rgba(255, 210, 74, 0.12); }
.overlay .selbox { position: absolute; border: 1.5px solid var(--sel); }
.overlay .handle { position: absolute; width: 10px; height: 10px; margin: -5px 0 0 -5px; background: #fff; border: 1.5px solid var(--sel); border-radius: 2px; }
.overlay .guide { position: absolute; background: #ff4fa3; }
.empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; color: #fff; padding: 12%; font-size: 15px; pointer-events: none; }
.issues { background: var(--panel); border-top: 1px solid var(--line); padding: 8px 14px; max-height: 108px; overflow-y: auto; flex: none; }
.issues ul { margin: 0; padding-left: 18px; }
.issues li.fail { color: var(--fail); } .issues li.warn { color: var(--warn); }
.issues .fine { color: var(--ok); }

.right h2 { display: flex; justify-content: space-between; }
.card { display: block; width: 100%; text-align: left; border: 1px solid var(--line); border-radius: 8px; padding: 8px; margin: 0 0 8px; background: var(--panel); }
.card.cur { border-color: var(--sel); box-shadow: 0 0 0 1px var(--sel); }
.thumb { position: relative; overflow: hidden; margin: 0 auto 6px; background: #ddd; pointer-events: none; }
.thumb .ad { transform-origin: 0 0; position: absolute !important; left: 0; top: 0; }
.card .meta { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.card .dims { font-weight: 600; }
.card .lbl { color: var(--mute); font-size: 12px; display: block; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.dot.ok { background: var(--ok); } .dot.warn { background: #d99a00; } .dot.fail { background: var(--fail); }

dialog { border: 1px solid var(--line); border-radius: 10px; padding: 0; width: min(760px, 92vw); max-height: 86vh; color: var(--fg); background: var(--panel); }
dialog::backdrop { background: rgba(0, 0, 0, 0.45); }
.dlgHead { padding: 14px 18px; border-bottom: 1px solid var(--line); font-weight: 600; font-size: 15px; }
.dlgBody { padding: 12px 18px; overflow-y: auto; max-height: 62vh; }
.dlgFoot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; align-items: center; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 2px 14px; margin-bottom: 6px; }
.checks label { display: flex; gap: 6px; align-items: baseline; padding: 2px 0; }
.checks small { color: var(--mute); }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 4px 10px 4px 0; border-bottom: 1px solid var(--line); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

.home { flex: 1; overflow-y: auto; padding: 36px 16px; }
.home .inner { max-width: 640px; margin: 0 auto; }
.home h1 { font-size: 22px; margin: 0 0 4px; }
.home .proj { display: flex; justify-content: space-between; gap: 12px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; margin: 8px 0; color: var(--fg); text-decoration: none; }
.home .proj:hover { border-color: #b9b6ae; }
.home form { display: flex; gap: 8px; margin: 18px 0 26px; }
.home form input { flex: 1; padding: 8px 10px; }
.toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); background: #1d1d1b; color: #fff; padding: 9px 14px; border-radius: 8px; max-width: 80vw; z-index: 10; }

.dlgBody h2 { display: flex; gap: 12px; align-items: baseline; }
.dlgBody h2 .link { text-transform: none; letter-spacing: 0; font-weight: 400; }

.layers.kit li { border-style: dashed; }
.layers.kit .pick { color: var(--sel); }
#layerFont { max-width: 150px; }
#client:not(:empty) { margin-right: 8px; padding-right: 9px; border-right: 1px solid var(--line); color: var(--accent); }
.spec { margin: -2px 0 6px; }
.spec a { color: var(--accent); }
.stale { color: var(--warn); font-weight: 600; }
table.rules th { text-align: left; font-weight: 500; color: var(--mute); padding: 3px 14px 3px 0; vertical-align: top; white-space: nowrap; }
table.rules td { padding: 3px 0; }
.rulesList { margin: 6px 0; padding-left: 18px; }
.rulesList li { margin: 2px 0; }
