
:root {
  --bg: #ECEFEA; --surface: #FFFFFF; --surface-2: #F5F7F3; --ink: #141B18; --muted: #56615B; --line: #D3D9D1; --line-strong: #B9C1B7;
  --accent: #2741D3; --accent-ink: #FFFFFF; --accent-soft: #E2E6FB; --dot: #C7CEC4; --danger: #B3261E; --ok: #1B7A4B; --warn-bg: #FFF4D6; --warn-ink: #6B4B00;
  --f-display: "Archivo", "Helvetica Neue", Arial, sans-serif; --f-body: "Archivo", "Helvetica Neue", Arial, sans-serif; --f-mono: "Fragment Mono", ui-monospace, Menlo, Consolas, monospace;
  --shadow: 0 1px 2px rgba(20,27,24,.12), 0 8px 24px -12px rgba(20,27,24,.35);
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #0E1210; --surface: #161B18; --surface-2: #1C221F; --ink: #E4EAE6; --muted: #98A49D; --line: #2A322E; --line-strong: #3A443F;
  --accent: #8E9DFF; --accent-ink: #0E1210; --accent-soft: #232A4E; --dot: #29312D; --danger: #FF8A80; --ok: #6FD39E; --warn-bg: #3A3016; --warn-ink: #F5D98A; color-scheme: dark;
  --shadow: 0 1px 2px rgba(0,0,0,.5), 0 10px 30px -12px rgba(0,0,0,.8); } }
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { background: var(--bg); color: var(--ink); font-family: var(--f-body); font-size: 14px; line-height: 1.5; margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; text-wrap: balance; }
svg.i { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.top { position: sticky; top: 0; z-index: 30; background: var(--bg); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 14px; padding: 10px 20px; height: 57px; }
.mark { display: inline-flex; align-items: center; gap: 10px; font-family: var(--f-display); font-stretch: 125%; font-weight: 800; font-size: 19px; letter-spacing: -0.01em; white-space: nowrap; color: var(--ink); text-decoration: none; }
.mark svg { width: 26px; height: 26px; flex: none; }
.tool-name { color: var(--muted); font-weight: 600; font-size: 14px; border-left: 1px solid var(--line-strong); padding-left: 14px; white-space: nowrap; }
.top .links { margin-left: auto; display: flex; gap: 16px; font-size: 13.5px; }
.top .links a { color: var(--muted); white-space: nowrap; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid var(--line-strong); background: var(--surface); border-radius: 8px; padding: 7px 12px; font-weight: 600; font-size: 13px; cursor: pointer; white-space: nowrap; min-height: 34px; text-decoration: none; color: var(--ink); }
.btn:hover:not(:disabled) { border-color: var(--ink); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover:not(:disabled) { filter: brightness(1.08); border-color: var(--accent); }
.btn.quiet { border-color: transparent; background: transparent; color: var(--muted); }
.btn.quiet:hover:not(:disabled) { color: var(--ink); background: var(--surface-2); }
.btn.icon { padding: 6px; min-width: 34px; }
.btn.sm { min-height: 28px; padding: 4px 9px; font-size: 12.5px; }
.fld { display: grid; gap: 5px; min-width: 0; }
.fld > label, .fld-label { font-size: 12.5px; font-weight: 600; }
.fld input[type=text], .fld input[type=number], .fld select, .fld textarea, .inp { width: 100%; border: 1px solid var(--line-strong); border-radius: 7px; padding: 6px 8px; background: var(--surface); min-width: 0; }
.fgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 12px; }
.chk { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; cursor: pointer; }
.chk input { width: 16px; height: 16px; accent-color: var(--accent); flex: none; }
.note { color: var(--muted); font-size: 12.5px; margin: 0; }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 8px; overflow: hidden; flex-wrap: wrap; max-width: 100%; }
.seg label { padding: 5px 10px; font-size: 12.5px; font-weight: 600; cursor: pointer; border-left: 1px solid var(--line); white-space: nowrap; }
.seg label:first-child { border-left: 0; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label:has(input:checked) { background: var(--ink); color: var(--bg); }
.seg label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: -2px; }
.seg.full { display: flex; } .seg.full label { flex: 1; text-align: center; }
.range { display: flex; align-items: center; gap: 10px; }
.range input { flex: 1; accent-color: var(--accent); min-width: 0; }
.range output { font-family: var(--f-mono); font-size: 12px; color: var(--muted); min-width: 3em; text-align: right; }
.colour { display: flex; gap: 6px; align-items: center; }
.colour input[type=color] { width: 34px; height: 30px; border: 1px solid var(--line-strong); border-radius: 7px; padding: 2px; background: var(--surface); cursor: pointer; }

/* Start screen */
.start { max-width: 1080px; margin: 0 auto; padding: 44px 24px 64px; }
.start h1 { font-family: var(--f-display); font-stretch: 112%; font-weight: 800; font-size: clamp(32px, 5vw, 50px); line-height: 1.04; letter-spacing: -0.025em; max-width: 17ch; }
.start .lede { color: var(--muted); font-size: 18px; max-width: 40em; margin: 14px 0 26px; }
.entry { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 14px; }
.drop { display: grid; place-items: center; text-align: center; gap: 10px; border: 2px dashed var(--line-strong); border-radius: 16px; padding: 34px 20px; background: var(--surface);
  background-image: radial-gradient(var(--dot) 1px, transparent 1.2px); background-size: 18px 18px; cursor: pointer; transition: border-color .15s, background-color .15s; }
.drop:hover, body.dragging .drop { border-color: var(--accent); background-color: var(--accent-soft); }
.drop strong { font-size: 19px; }
.drop .btn { pointer-events: none; }
.pastebox { display: flex; flex-direction: column; gap: 8px; border: 1px solid var(--line); border-radius: 16px; padding: 14px; background: var(--surface); }
.pastebox textarea { flex: 1; min-height: 150px; resize: vertical; border: 1px solid var(--line-strong); border-radius: 9px; padding: 9px 10px; font-family: var(--f-mono); font-size: 12.5px; background: var(--surface-2); }
.pastebox .row { display: flex; gap: 8px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.privacy-line { display: flex; gap: 8px; align-items: center; justify-content: center; color: var(--muted); font-size: 13.5px; margin-top: 14px; text-align: center; flex-wrap: wrap; }
.privacy-line svg { color: var(--ok); }
.tiles-h { font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin: 40px 0 14px; font-weight: 700; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); gap: 12px; }
.tile { display: grid; grid-template-rows: auto auto auto; gap: 6px; text-align: left; border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 12px; cursor: pointer; }
.tile:hover { border-color: var(--ink); }
.tile .pv { height: 92px; border-radius: 8px; background: var(--surface-2); overflow: hidden; display: grid; place-items: center; }
.tile .pv svg { width: 100%; height: 100%; }
.tile b { font-size: 14.5px; }
.tile span:last-child { color: var(--muted); font-size: 12.5px; line-height: 1.4; }

/* Workspace */
.work { display: flex; flex-direction: column; height: calc(100dvh - 57px); }
.bar { display: flex; align-items: center; gap: 8px; padding: 8px 16px; border-bottom: 1px solid var(--line); background: var(--surface); flex-wrap: wrap; }
.bar .sum { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 1; }
.bar .sum b { color: var(--ink); }
.bar .grp { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.ws { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 340px; }
.stage { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.viewport { flex: 1; min-height: 0; overflow: auto; background-color: var(--bg); background-image: radial-gradient(var(--dot) 1px, transparent 1.2px); background-size: 18px 18px; display: flex; align-items: flex-start; justify-content: center; padding: 22px; }
.canvas { width: 100%; max-width: 1100px; box-shadow: var(--shadow); border-radius: 4px; overflow: hidden; line-height: 0; background: #fff; }
.canvas svg { width: 100%; height: auto; display: block; }
.canvas [data-id] { cursor: default; }
.canvas path[data-id]:hover, .canvas circle[data-id]:hover { stroke: #141B18; stroke-width: 1.4; }
.maptip { position: fixed; z-index: 60; pointer-events: none; background: var(--ink); color: var(--bg); font-size: 12.5px; padding: 6px 9px; border-radius: 7px; box-shadow: 0 8px 22px -8px rgba(20,27,24,.45); max-width: 260px; line-height: 1.35; }
.maptip b { display: block; }
.infobar { display: flex; gap: 10px 20px; padding: 7px 14px; border-top: 1px solid var(--line); background: var(--surface); font-size: 12px; color: var(--muted); flex-wrap: wrap; align-items: center; min-height: 36px; }
.infobar b { color: var(--ink); font-weight: 600; }
.infobar .warn { color: var(--warn-ink); background: var(--warn-bg); border-radius: 6px; padding: 1px 8px; }
.infobar button.link { border: 0; background: none; padding: 0; color: var(--accent); font-weight: 600; cursor: pointer; font-size: 12px; text-decoration: underline; }

.settings { border-left: 1px solid var(--line); background: var(--surface); overflow-y: auto; padding: 0 0 40px; }
.sec { border-bottom: 1px solid var(--line); }
.sec summary { cursor: pointer; font-weight: 700; font-size: 14px; list-style: none; display: flex; gap: 9px; align-items: center; padding: 12px 16px; }
.sec summary::-webkit-details-marker { display: none; }
.sec summary::after { content: "+"; margin-left: auto; color: var(--muted); font-weight: 400; font-size: 20px; line-height: 1; }
.sec[open] summary::after { content: "–"; }
.sec summary svg { color: var(--accent); }
.sec .body { padding: 0 16px 16px; display: grid; gap: 12px; }
.sec .row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.warnbox { background: var(--warn-bg); color: var(--warn-ink); border-radius: 8px; padding: 10px 11px; font-size: 12.5px; display: grid; gap: 8px; }
.warnbox b { font-size: 13px; }
.warnbox .row { gap: 6px; }
.okbox { background: color-mix(in srgb, var(--ok) 12%, transparent); color: var(--ok); border-radius: 8px; padding: 8px 11px; font-size: 12.5px; }
.pals { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.pal { display: grid; gap: 4px; border: 1px solid var(--line); border-radius: 8px; padding: 6px; background: var(--surface); cursor: pointer; text-align: left; font-size: 11.5px; font-weight: 600; }
.pal i { display: block; height: 12px; border-radius: 3px; }
.pal[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.catlist { display: grid; gap: 4px; max-height: 260px; overflow: auto; }
.catrow { display: grid; grid-template-columns: 30px minmax(0, 1fr) 26px 26px; gap: 6px; align-items: center; font-size: 12.5px; }
.catrow input[type=color] { width: 30px; height: 24px; border: 1px solid var(--line-strong); border-radius: 5px; padding: 1px; background: var(--surface); }
.catrow span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.catrow button { min-height: 24px; min-width: 24px; padding: 2px; }
.code { width: 100%; min-height: 96px; font-family: var(--f-mono); font-size: 11.5px; border: 1px solid var(--line-strong); border-radius: 7px; padding: 7px 8px; background: var(--surface-2); resize: vertical; }

dialog { border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--ink); padding: 0; width: min(720px, calc(100vw - 24px)); max-height: calc(100dvh - 40px); box-shadow: 0 30px 80px -20px rgba(0,0,0,.5); }
dialog::backdrop { background: rgba(14, 18, 16, .45); }
dialog > div { padding: 20px 22px; display: flex; flex-direction: column; gap: 10px; max-height: calc(100dvh - 42px); }
dialog h2 { font-size: 19px; }
dialog .foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; flex-wrap: wrap; align-items: center; }
dialog .foot .sp { flex: 1; }
.mtable { overflow: auto; border: 1px solid var(--line); border-radius: 9px; min-height: 120px; }
.mtable table { border-collapse: collapse; width: 100%; font-size: 12.5px; }
.mtable th, .mtable td { padding: 5px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.mtable th { position: sticky; top: 0; background: var(--surface-2); font-weight: 700; z-index: 1; }
.mtable td.v { font-family: var(--f-mono); font-size: 12px; white-space: nowrap; }
.mtable select { width: 100%; max-width: 260px; border: 1px solid var(--line-strong); border-radius: 6px; padding: 3px 6px; background: var(--surface); font-size: 12.5px; }
.mtable tr.bad td:first-child { color: var(--danger); font-weight: 600; }
.mtable tr.agg td:first-child { color: var(--muted); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.pill { display: inline-block; font-size: 11px; font-weight: 700; padding: 0 7px; border-radius: 99px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.pill.ok { color: var(--ok); } .pill.bad { color: var(--danger); }
#data-text { width: 100%; min-height: 300px; flex: 1; font-family: var(--f-mono); font-size: 12px; border: 1px solid var(--line-strong); border-radius: 9px; padding: 8px 10px; background: var(--surface-2); resize: vertical; white-space: pre; }

.toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 90; background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 13.5px; box-shadow: 0 10px 30px -10px rgba(0,0,0,.5); max-width: calc(100vw - 32px); }
.busy { position: fixed; inset: 0; z-index: 85; display: grid; place-items: center; background: rgba(14, 18, 16, .35); }
.busy > div { background: var(--surface); border-radius: 12px; padding: 18px 22px; display: flex; gap: 12px; align-items: center; box-shadow: 0 20px 60px -20px rgba(0,0,0,.5); min-width: 240px; }
.spinner { width: 18px; height: 18px; border: 2.5px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.hint { position: absolute; z-index: 95; max-width: 260px; background: var(--ink); color: var(--bg); font-size: 12.5px; line-height: 1.4; font-weight: 500; padding: 7px 10px; border-radius: 7px; box-shadow: 0 8px 22px -8px rgba(20,27,24,.45); pointer-events: none; animation: hint-in .12s ease-out; }
.hint::after { content: ""; position: absolute; left: var(--ax, 50%); bottom: -5px; width: 10px; height: 10px; margin-left: -5px; background: inherit; transform: rotate(45deg); border-radius: 2px; }
.hint.below::after { bottom: auto; top: -5px; }
@keyframes hint-in { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .hint, .spinner { animation: none; } }

@media (max-width: 1100px) { .ws { grid-template-columns: minmax(0, 1fr) 300px; } }
@media (max-width: 900px) {
  .top { padding: 10px 14px; } .tool-name { display: none; }
  .entry { grid-template-columns: minmax(0, 1fr); }
  .work { height: auto; min-height: calc(100dvh - 57px); }
  .ws { grid-template-columns: minmax(0, 1fr); }
  .viewport { padding: 12px; }
  .settings { border-left: 0; border-top: 1px solid var(--line); }
  .bar { padding: 6px 10px; } .bar .sum { flex-basis: 100%; order: 3; }
  .start { padding: 26px 16px 50px; }
  .bar .grp .btn span { display: none; }
}
@media (max-width: 440px) { .top { gap: 10px; padding-left: 12px; padding-right: 12px; } .top .mark { font-size: 16px; gap: 8px; } .top .links .all { display: none; } .top .mark svg { width: 24px; height: 24px; } .top .links { gap: 10px; font-size: 13px; } }

a.mark { color: inherit; text-decoration: none; }
