/* pdf-markup primitives. Role tokens only (tokens.css); no raw colours except fixed functional ones there. */
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font: var(--fs-base)/var(--lh-base) var(--font); color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
.ico { width: var(--size-icon); height: var(--size-icon); fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.mono { font-family: var(--font-mono); font-size: var(--fs-xs); }
.muted { color: var(--text-muted); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* Top bar */
.topbar { height: var(--size-topbar); display: flex; align-items: center; gap: var(--sp-6); padding: 0 var(--sp-6); background: var(--surface); border-bottom: 1px solid var(--border); position: relative; }
:root[data-skin="wsdg"] .topbar::after { content: ""; position: absolute; left: 0; right: 0; bottom: -4px; height: 3px; opacity: .55; background: repeating-linear-gradient(90deg, var(--accent) 0 3px, transparent 3px 6px); pointer-events: none; }
.brand { display: flex; align-items: center; gap: var(--sp-5); white-space: nowrap; }
.brand img { height: 20px; display: block; }
.brand .logo-dark, :root[data-theme="dark"] .brand .logo-light { display: none; }
:root[data-theme="dark"] .brand .logo-dark { display: block; }
.brand .name { font-size: 15px; font-weight: 600; padding-left: var(--sp-5); border-left: 1px solid var(--border-strong); }
.brand .mark { width: 22px; height: 18px; }
.brand .mark .m { stroke: var(--text); } .brand .mark .w { stroke: var(--accent); }
.skin-wsdg-only, .skin-mwa-only { display: none; }
:root[data-skin="wsdg"] .skin-wsdg-only, :root[data-skin="mwa"] .skin-mwa-only { display: flex; }
.spacer { flex: 1; }

/* Doc tabs */
.tabs { display: flex; gap: var(--sp-1); align-self: stretch; align-items: flex-end; min-width: 0; }
.doctab { display: flex; align-items: center; gap: var(--sp-3); height: 34px; padding: 0 var(--sp-4); border: 1px solid transparent; border-bottom: 0; border-radius: var(--r-md) var(--r-md) 0 0; font-size: var(--fs-sm); color: var(--text-muted); cursor: pointer; white-space: nowrap; }
.doctab:hover { background: var(--surface-2); }
.doctab[aria-selected="true"] { background: var(--bg); border-color: var(--border); color: var(--text); font-weight: 600; margin-bottom: -1px; }
.doctab .dirty { width: 7px; height: 7px; border-radius: 50%; background: var(--accent-text); }
.doctab .close { opacity: .6; border: 0; background: none; padding: 0; display: flex; cursor: pointer; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2); height: 32px; padding: 0 var(--sp-6); border-radius: var(--r-md); border: 1px solid var(--border-strong); background: var(--surface); font-size: var(--fs-sm); cursor: pointer; white-space: nowrap; transition: border-color var(--motion-fast), background var(--motion-fast); }
.btn:hover { border-color: var(--text-muted); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
.btn.primary:hover { filter: brightness(.95); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { color: var(--danger); }
.btn.sm { height: 26px; padding: 0 var(--sp-4); }
.btn.icon { width: 32px; padding: 0; }
.btn.sm.icon { width: 26px; }
.btn .spin { width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(1turn); } }

/* Toolbar + tool buttons */
.toolbar { height: var(--size-toolbar); display: flex; align-items: center; gap: var(--sp-1); padding: 0 var(--sp-4); background: var(--surface); border-bottom: 1px solid var(--border); overflow: hidden; }
.toolbar .sep { width: 1px; height: 22px; background: var(--border); margin: 0 var(--sp-3); }
.tool { position: relative; width: var(--size-tool-btn); height: var(--size-tool-btn); display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: var(--r-md); background: transparent; color: var(--text); cursor: pointer; }
.tool:hover { background: var(--surface-2); }
.tool[aria-checked="true"] { background: var(--accent-wash); color: var(--accent-text); }
.tool[aria-checked="true"]::after { content: ""; position: absolute; left: 7px; right: 7px; bottom: 2px; height: 2px; border-radius: 2px; background: var(--accent); }
.tool[aria-disabled="true"] { opacity: .4; cursor: not-allowed; }
.tool .pin { position: absolute; top: 4px; right: 4px; width: 5px; height: 5px; border-radius: 50%; background: var(--accent-text); }

/* Properties strip */
.props { height: 36px; display: flex; align-items: center; gap: var(--sp-5); padding: 0 var(--sp-6); background: var(--bg); border-bottom: 1px solid var(--border); font-size: var(--fs-sm); }
.props label { display: flex; align-items: center; gap: var(--sp-3); color: var(--text-muted); }
.swatch { width: 18px; height: 18px; border-radius: var(--r-sm); border: 1px solid var(--border-strong); display: inline-block; }
.swatch.none { background: linear-gradient(135deg, transparent 45%, var(--danger) 45% 55%, transparent 55%); }

/* Inputs */
.field { display: grid; gap: var(--sp-2); font-size: var(--fs-sm); }
.field > span { color: var(--text-muted); font-size: var(--fs-xs); }
.input, .select { height: 28px; padding: 0 var(--sp-4); border: 1px solid var(--border-input); border-radius: var(--r-sm); background: var(--surface); font-size: var(--fs-sm); min-width: 0; }
.input:focus, .select:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 2px color-mix(in srgb, var(--focus) 30%, transparent); }
.input[aria-invalid="true"] { border-color: var(--danger); }
.field .hint { font-size: var(--fs-xs); color: var(--text-muted); font-family: var(--font-mono); }
.field .err { font-size: var(--fs-xs); color: var(--danger); }

/* Colour picker */
.colors { display: grid; grid-template-columns: repeat(6, 22px); gap: var(--sp-2); }
.colors button { width: 22px; height: 22px; border-radius: var(--r-sm); border: 1px solid rgba(0,0,0,.2); cursor: pointer; padding: 0; }
.colors button[aria-checked="true"] { box-shadow: 0 0 0 1px var(--surface), 0 0 0 3px var(--text); }

/* Icon toggles */
.itog { width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center; border: 0; background: none; border-radius: var(--r-sm); color: var(--text); cursor: pointer; }
.itog[aria-pressed="false"] { color: var(--text-muted); opacity: .55; }
.itog:hover { background: var(--surface-2); }
.itog .ico { width: 16px; height: 16px; }

/* Docks + panels */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; }
.panel-head { display: flex; align-items: center; gap: var(--sp-3); height: 34px; padding: 0 var(--sp-5); border-bottom: 1px solid var(--border); font-weight: 600; font-size: var(--fs-sm); }
.panel-tabs { display: flex; gap: var(--sp-1); padding: var(--sp-2) var(--sp-3) 0; border-bottom: 1px solid var(--border); background: var(--bg); }
.panel-tabs [role="tab"] { border: 0; background: none; padding: var(--sp-3) var(--sp-4); font-size: var(--fs-sm); color: var(--text-muted); border-bottom: 2px solid transparent; cursor: pointer; display: flex; align-items: center; gap: var(--sp-2); }
.panel-tabs [role="tab"][aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }

/* Markups list */
.mlist { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.mlist th { position: sticky; top: 0; text-align: left; font-weight: 600; font-size: var(--fs-xs); color: var(--text-muted); background: var(--bg); border-bottom: 1px solid var(--border); padding: 0 var(--sp-4); height: 28px; white-space: nowrap; }
.mlist td { height: var(--size-list-row); padding: 0 var(--sp-4); border-bottom: 1px solid var(--border); white-space: nowrap; }
.mlist tbody tr:hover { background: var(--surface-2); }
.mlist tr[aria-selected="true"] { background: var(--accent-wash); }
.mlist tr.reply td:nth-child(2) { padding-left: 28px; color: var(--text-muted); }
.mlist tr.hidden-layer { color: var(--text-muted); font-style: italic; }
.mlist tfoot td { font-weight: 600; background: var(--bg); }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; vertical-align: middle; }
.chip { display: inline-flex; align-items: center; height: 20px; padding: 0 var(--sp-3); border-radius: var(--r-pill); font-size: var(--fs-xs); border: 1px solid var(--border-strong); color: var(--text); background: var(--surface); white-space: nowrap; }
.chip.ok { color: var(--success); border-color: currentColor; }
.chip.no { color: var(--danger); border-color: currentColor; }

/* Layers rows */
.lrow { display: flex; align-items: center; gap: var(--sp-2); height: 28px; padding: 0 var(--sp-4); font-size: var(--fs-sm); }
.lrow:hover { background: var(--surface-2); }
.lrow .lname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lrow.active .lname { font-weight: 600; }
.lrow.active .lname::before { content: "●"; color: var(--accent-text); margin-right: 6px; font-size: 9px; vertical-align: 2px; }
.lsec { font-size: var(--fs-xs); font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; padding: var(--sp-5) var(--sp-4) var(--sp-2); }

/* Page canvas */
.canvas { background: var(--canvas); padding: var(--sp-8); overflow: hidden; position: relative; }
.page { background: var(--paper); box-shadow: var(--shadow-page); position: relative; margin: 0 auto; }
.page svg.overlay { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.sel-box { fill: none; stroke: var(--select); stroke-width: 1; stroke-dasharray: 4 3; vector-effect: non-scaling-stroke; }
.handle { fill: #fff; stroke: var(--select); stroke-width: 1; vector-effect: non-scaling-stroke; }
.snap { fill: none; stroke: var(--select); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.measure-tag { position: absolute; font-family: var(--font-mono); font-size: var(--fs-xs); background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); border-radius: var(--r-sm); padding: 2px 6px; box-shadow: var(--shadow-card); white-space: nowrap; }
.guide { position: absolute; left: 50%; top: var(--sp-6); transform: translateX(-50%); background: var(--text); color: var(--bg); font-size: var(--fs-sm); padding: var(--sp-3) var(--sp-6); border-radius: var(--r-pill); box-shadow: var(--shadow-pop); display: flex; gap: var(--sp-4); align-items: center; white-space: nowrap; }
.guide b { color: inherit; }

/* Status bar */
.statusbar { height: var(--size-status-bar); display: flex; align-items: center; gap: var(--sp-5); padding: 0 var(--sp-5); background: var(--surface); border-top: 1px solid var(--border); font-size: var(--fs-xs); color: var(--text-muted); }
.statusbar .warn { color: var(--warning); font-weight: 600; }

/* Toast, menu, dialog */
.toast { display: inline-flex; align-items: center; gap: var(--sp-4); padding: var(--sp-4) var(--sp-6); border-radius: var(--r-md); background: var(--text); color: var(--bg); font-size: var(--fs-sm); box-shadow: var(--shadow-pop); }
.toast.warning .ico { color: var(--markup-highlight); }
.menu { min-width: 200px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-md); box-shadow: var(--shadow-pop); padding: var(--sp-2); font-size: var(--fs-sm); }
.menu [role="menuitem"], .menu [role="menuitemcheckbox"] { display: flex; align-items: center; gap: var(--sp-4); height: 28px; padding: 0 var(--sp-4); border-radius: var(--r-sm); cursor: pointer; }
.menu [role^="menuitem"]:hover, .menu [role^="menuitem"].hot { background: var(--accent-wash); }
.menu [aria-disabled="true"] { opacity: .45; cursor: default; }
.menu .kbd { margin-left: auto; color: var(--text-muted); font-size: var(--fs-xs); }
.menu hr { border: 0; border-top: 1px solid var(--border); margin: var(--sp-2) 0; }
.dialog { width: 400px; max-width: 100%; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-lg); box-shadow: var(--shadow-pop); }
.dialog h3 { margin: 0; padding: var(--sp-6) var(--sp-6) 0; font-size: var(--fs-lg); }
.dialog .body { padding: var(--sp-6); display: grid; gap: var(--sp-5); }
.dialog .foot { display: flex; justify-content: flex-end; gap: var(--sp-4); padding: var(--sp-5) var(--sp-6); border-top: 1px solid var(--border); background: var(--bg); border-radius: 0 0 var(--r-lg) var(--r-lg); }
.empty { padding: var(--sp-8); text-align: center; color: var(--text-muted); font-size: var(--fs-sm); }
