:root {
  color-scheme: light;
  --ink: #181a19;
  --paper: #f2efe7;
  --acid: #d5f13c;
  --orange: #ff5c35;
  --blue: #3457d5;
  --muted: #6c706b;
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; color: var(--ink); background: var(--paper); }
button, input { font: inherit; }
button { color: inherit; }

.masthead { min-height: 210px; display: grid; grid-template-columns: minmax(250px, 42%) 1fr; border-bottom: 3px solid var(--ink); }
.brand-block { padding: 22px 4vw 18px; background: var(--ink); color: var(--paper); display: flex; gap: 2.5vw; align-items: flex-end; }
.eyebrow { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; }
h1 { margin: 0; font: 900 clamp(48px, 7vw, 96px)/.75 system-ui, sans-serif; letter-spacing: -.08em; }
.intro { padding: 34px 4vw; display: flex; flex-direction: column; justify-content: space-between; }
.intro p { max-width: 620px; margin: 0; font: 700 clamp(17px, 2.3vw, 28px)/1.35 system-ui, sans-serif; }
.save-state { font-size: 12px; color: var(--muted); }
.save-state span { display: inline-block; width: 8px; height: 8px; margin-right: 7px; border-radius: 50%; background: var(--acid); border: 1px solid var(--ink); }

.project-strip { min-height: 58px; display: flex; align-items: stretch; border-bottom: 1px solid var(--ink); overflow-x: auto; }
.strip-title { padding: 20px 18px; font-size: 11px; font-weight: 800; letter-spacing: .12em; border-right: 1px solid var(--ink); white-space: nowrap; }
.project-tabs { display: flex; }
.project-tab { border: 0; border-right: 1px solid var(--ink); padding: 0 20px; background: transparent; white-space: nowrap; cursor: pointer; }
.project-tab.active { background: var(--acid); font-weight: 800; }
.project-tab small { opacity: .6; margin-left: 8px; }
.icon-button { border: 0; border-right: 1px solid var(--ink); background: transparent; padding: 0 20px; cursor: pointer; white-space: nowrap; }
.icon-button:hover, .text-button:hover { background: #fff; }

.tool-row { display: flex; gap: 20px; justify-content: space-between; padding: 18px 4vw; border-bottom: 1px solid var(--ink); }
.node-form { display: flex; gap: 12px; align-items: end; flex-wrap: wrap; }
.node-form > label { display: grid; gap: 6px; font-size: 11px; font-weight: 800; }
input[type="text"], input:not([type]) { border: 1px solid var(--ink); border-radius: 0; background: #fff; min-height: 42px; padding: 9px 11px; outline: none; }
input:focus { box-shadow: 4px 4px 0 var(--blue); }
#charInput { width: 110px; font-size: 18px; }
#labelInput { width: 190px; }
.segmented { display: flex; border: 1px solid var(--ink); height: 42px; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label { padding: 12px 13px; cursor: pointer; }
.segmented input:checked + label { background: var(--ink); color: white; }
.primary, .review-button, .export-button { min-height: 42px; border: 1px solid var(--ink); padding: 10px 16px; background: var(--acid); font-weight: 800; box-shadow: 4px 4px 0 var(--ink); cursor: pointer; }
.primary:active, .review-button:active, .export-button:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--ink); }
.tool-actions { display: flex; gap: 14px; align-items: center; }
.text-button { border: 0; background: transparent; padding: 10px; text-decoration: underline; cursor: pointer; }
.danger { color: #a22c22; }
.review-button { background: var(--ink); color: white; }
.review-button span { color: var(--acid); }

.workspace { padding: 24px 4vw 50px; }
.canvas-head { display: flex; justify-content: space-between; gap: 20px; margin-bottom: 10px; align-items: end; }
.canvas-head b { font: 800 22px system-ui, sans-serif; margin-right: 12px; }
.canvas-head span, .canvas-head p { color: var(--muted); font-size: 11px; }
.canvas-head p { margin: 0; text-align: right; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-left: 8px; border: 1px solid var(--ink); }
.dot.source { background: var(--orange); }
.dot.target { background: var(--blue); }
.canvas-wrap { position: relative; border: 2px solid var(--ink); background: #faf8f2; box-shadow: 10px 10px 0 var(--ink); overflow: hidden; }
#canvas { display: block; width: 100%; min-width: 720px; height: min(62vh, 650px); min-height: 440px; color: #dedbd3; touch-action: none; }
.grid { pointer-events: none; }
.glyph-node { cursor: grab; outline: none; }
.glyph-node:focus rect { stroke: var(--blue); stroke-width: 4px; }
.glyph-node rect { fill: #fff; stroke: var(--ink); stroke-width: 2px; }
.glyph-node.source rect { fill: #fff3ef; }
.glyph-node.target rect { fill: #eef1ff; }
.glyph-node.issue rect { stroke: #e52a20; stroke-width: 5px; }
.node-kind { font-size: 9px; font-weight: 800; letter-spacing: .12em; fill: var(--muted); }
.node-char { font: 700 34px system-ui, sans-serif; fill: var(--ink); }
.node-label { font-size: 9px; fill: var(--muted); }
.connector { fill: var(--acid); stroke: var(--ink); stroke-width: 2px; cursor: crosshair; }
.source .connector { fill: var(--orange); }
.target .connector { opacity: 0; pointer-events: none; }
.remove circle { fill: var(--ink); }
.remove text { fill: white; font: 14px system-ui; text-anchor: middle; }
.remove { opacity: 0; cursor: pointer; }
.glyph-node:hover .remove, .glyph-node:focus .remove { opacity: 1; }
.edge { fill: none; stroke: var(--blue); stroke-width: 3px; marker-end: url(#arrow); cursor: pointer; }
.edge:hover { stroke-width: 7px; }
.edge.issue { stroke: #e52a20; stroke-dasharray: 9 5; marker-end: url(#arrowBad); }
.draft-edge { fill: none; stroke: var(--orange); stroke-width: 3px; stroke-dasharray: 7 5; pointer-events: none; }
#arrow path { fill: var(--blue); } #arrowBad path { fill: #e52a20; }
.empty-canvas { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; pointer-events: none; gap: 8px; }
.empty-canvas b { font: 800 22px system-ui, sans-serif; }
.empty-canvas span { font-size: 12px; color: var(--muted); }
.canvas-toast { position: absolute; left: 18px; bottom: 18px; padding: 10px 14px; color: white; background: var(--ink); font-size: 12px; opacity: 0; transform: translateY(8px); transition: .2s; pointer-events: none; }
.canvas-toast.show { opacity: 1; transform: none; }

.review-panel { position: fixed; z-index: 20; right: 0; top: 0; bottom: 0; width: min(520px, 100%); padding: 28px; background: #f7f4ec; border-left: 3px solid var(--ink); transform: translateX(105%); transition: transform .24s ease; overflow-y: auto; }
.review-panel.open { transform: none; }
.scrim { position: fixed; inset: 0; z-index: 15; background: rgba(24,26,25,.54); }
.review-top { display: flex; justify-content: space-between; border-bottom: 2px solid var(--ink); padding-bottom: 18px; }
.review-top h2 { margin: 7px 0 0; font: 900 34px system-ui, sans-serif; letter-spacing: -.05em; }
.close-button { border: 0; background: transparent; font-size: 36px; cursor: pointer; }
.health { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; margin: 18px 0; background: var(--ink); border: 1px solid var(--ink); }
.health-item { padding: 12px 8px; background: white; text-align: center; font-size: 10px; }
.health-item b { display: block; font: 900 25px system-ui, sans-serif; }
.health-item.bad b { color: #d82a20; }
.review-help { color: var(--muted); font-size: 11px; margin-bottom: 12px; }
.review-list { border-top: 1px solid var(--ink); }
.review-row { display: grid; grid-template-columns: 28px 1fr auto; align-items: center; gap: 8px; padding: 13px 2px; border-bottom: 1px solid #a9aaa4; }
.review-row input { width: 17px; height: 17px; accent-color: var(--ink); }
.review-map { font: 700 18px system-ui, sans-serif; }
.review-map small { display: block; font: 10px ui-monospace, monospace; color: var(--muted); margin-top: 4px; }
.badge { padding: 4px 6px; border: 1px solid var(--ink); font-size: 9px; background: white; }
.badge.bad { color: white; border-color: #d82a20; background: #d82a20; }
.review-empty { padding: 32px 0; color: var(--muted); text-align: center; }
.export-box { position: sticky; bottom: -28px; margin: 22px -28px -28px; padding: 18px 28px 26px; background: var(--acid); border-top: 2px solid var(--ink); }
.check-all { font-size: 11px; display: block; margin-bottom: 12px; }
.export-button { width: 100%; background: var(--ink); color: white; box-shadow: none; }
.export-button:disabled { opacity: .35; cursor: not-allowed; }
.export-box p { margin: 9px 0 0; font-size: 10px; text-align: center; }

@media (max-width: 760px) {
  .masthead { grid-template-columns: 1fr; min-height: 0; }
  .brand-block { min-height: 145px; }
  .intro { gap: 22px; }
  .tool-row { display: block; }
  .node-form > label { flex: 1 1 130px; }
  #charInput, #labelInput { width: 100%; }
  .segmented { flex: 1; }
  .segmented label { flex: 1; text-align: center; }
  .primary { width: 100%; }
  .tool-actions { justify-content: space-between; margin-top: 17px; }
  .canvas-head { display: block; }
  .canvas-head p { margin-top: 9px; text-align: left; }
  .canvas-wrap { overflow-x: auto; box-shadow: 6px 6px 0 var(--ink); }
  #canvas { height: 480px; }
}

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
