:root {
  --ink: #102a36;
  --ink-soft: #294550;
  --muted: #60747b;
  --surface: #ffffff;
  --surface-soft: #f3f7f6;
  --canvas: #eaf0ef;
  --line: #ccd8d7;
  --line-strong: #98aeac;
  --teal: #176b72;
  --teal-dark: #0d535a;
  --teal-pale: #e1f1f0;
  --green: #17613d;
  --green-pale: #e5f3e9;
  --amber: #815515;
  --amber-pale: #fff1d9;
  --red: #92382f;
  --red-pale: #fae8e5;
  --blue: #155b86;
  --focus: #0877b5;
  --radius: 13px;
  --shadow: 0 10px 28px rgb(16 42 54 / 8%);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  color: var(--ink);
  background: var(--canvas);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-width: 320px; scroll-behavior: smooth; overflow-x: hidden; }
body { min-width: 320px; margin: 0; overflow-x: hidden; background: var(--canvas); color: var(--ink); }
a { color: inherit; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 12px; font-size: clamp(1.9rem, 4.2vw, 3.4rem); letter-spacing: -0.045em; line-height: 1.02; }
h2 { margin-bottom: 8px; font-size: clamp(1.2rem, 2.2vw, 1.55rem); letter-spacing: -0.02em; }
h3 { margin-bottom: 8px; font-size: 1.1rem; }

.shell { width: min(100% - 32px, 1480px); margin-inline: auto; }
.topbar { position: sticky; z-index: 20; top: 0; border-bottom: 1px solid #b8c8c7; background: rgb(239 245 244 / 96%); backdrop-filter: blur(14px); }
.topbar-inner { display: flex; width: min(100% - 32px, 1480px); min-height: 70px; margin-inline: auto; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; padding-block: 10px; }
.brand > div:last-child { display: grid; }
.brand small { color: var(--muted); font-size: 11px; }
.brand-mark { display: grid; width: 38px; height: 38px; place-items: center; border-radius: 8px; background: var(--ink); color: white; font-family: "Cascadia Mono", Consolas, monospace; font-weight: 800; }
nav { display: flex; align-items: center; gap: 4px; overflow-x: auto; }
nav a { min-height: 44px; padding: 13px 12px; border-radius: 8px; color: var(--ink-soft); font-size: 13px; font-weight: 700; text-decoration: none; white-space: nowrap; }
nav a:hover, nav a.active { background: var(--surface); color: var(--teal-dark); }

.page-heading { display: flex; min-height: 180px; padding-block: clamp(30px, 6vw, 62px); align-items: end; justify-content: space-between; gap: 30px; flex-wrap: wrap; }
.page-heading > div:first-child { max-width: 860px; }
.eyebrow { margin-bottom: 12px; color: var(--teal-dark); font-family: "Cascadia Mono", Consolas, monospace; font-size: 12px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.lede { max-width: 760px; margin-bottom: 0; color: var(--muted); font-size: clamp(1rem, 1.6vw, 1.1rem); line-height: 1.6; }
.lede-small { color: var(--muted); font-size: 13px; }
.heading-actions { flex: 0 0 auto; }

.sync-bar { display: flex; min-height: 44px; margin-bottom: 14px; padding: 10px 14px; align-items: center; gap: 9px; border: 1px solid #8fb8b4; border-radius: 10px; background: #e6f4f2; color: var(--teal-dark); font-size: 12px; flex-wrap: wrap; }
.sync-light { width: 9px; height: 9px; border-radius: 999px; background: #1f8c62; box-shadow: 0 0 0 4px rgb(31 140 98 / 12%); }
.sync-time { margin-left: auto; color: var(--muted); font-family: "Cascadia Mono", Consolas, monospace; }
.feedback { min-height: 0; }
.feedback p { margin-bottom: 14px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); }
.feedback.success p { border-color: #a4c9b2; background: var(--green-pale); color: var(--green); }
.feedback.error p { border-color: #ddb1ad; background: var(--red-pale); color: var(--red); }

.metrics { display: grid; margin-bottom: 14px; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.metrics.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.metric { min-width: 0; padding: 18px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); }
.metric.warn { border-color: #d6b77d; background: var(--amber-pale); }
.metric-label, .metric-detail { margin-bottom: 0; color: var(--muted); font-size: 11px; }
.metric-label { font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
.metric-value { margin: 7px 0 2px; font-size: clamp(1.4rem, 2.4vw, 2rem); font-weight: 800; letter-spacing: -.04em; }

.panel { padding: clamp(16px, 2.2vw, 26px); margin-bottom: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); overflow: hidden; }
.panel p { color: var(--muted); font-size: 13px; }

.node-graph { position: relative; width: 100%; max-width: 800px; aspect-ratio: 800 / 460; margin-block: 12px 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-soft); }
.node-graph-lines { position: absolute; inset: 0; width: 100%; height: 100%; }
.node-edge { stroke: var(--line-strong); stroke-width: 2; }
.node-dot { position: absolute; display: grid; grid-template-columns: 1fr; width: 140px; min-width: 108px; max-width: 140px; padding: 7px 8px; transform: translate(-50%, -50%); align-items: center; justify-items: center; gap: 4px; border: 2px solid var(--ink); border-radius: 10px; background: var(--surface); color: var(--ink); cursor: pointer; font-size: 11px; line-height: 1.3; text-align: center; }
.node-dot-label, .node-dot-state { min-width: 0; max-width: 100%; }
.node-dot:hover, .node-dot[aria-pressed="true"] { border-color: var(--focus); box-shadow: 0 0 0 3px rgb(8 119 181 / 18%); }
.node-kind-tag { padding: 1px 5px; border-radius: 5px; background: var(--ink); color: white; font-family: "Cascadia Mono", Consolas, monospace; font-size: 9px; font-weight: 800; letter-spacing: .04em; white-space: nowrap; }
.node-dot-label { font-weight: 700; word-break: normal; overflow-wrap: normal; }
.node-dot-state { padding: 2px 6px; border-radius: 999px; font-size: 8.5px; font-weight: 800; white-space: normal; word-break: break-word; overflow-wrap: break-word; text-align: center; }

.keyboard-nav { display: flex; margin-bottom: 14px; gap: 8px; flex-wrap: wrap; }
.connection-list { margin: 0; padding-left: 18px; color: var(--ink-soft); font-size: 13px; }
.connection-list li { margin-bottom: 4px; }

.node-list { display: grid; margin: 0; padding: 0; gap: 8px; list-style: none; }
.node-list-row { min-width: 0; }
.node-list-item { display: grid; width: 100%; min-height: 52px; padding: 10px 12px; align-items: center; grid-template-columns: auto minmax(0, 1fr) auto auto auto; gap: 10px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); cursor: pointer; text-align: left; }
.node-list-item:hover, .node-list-item[aria-pressed="true"] { border-color: var(--focus); background: var(--teal-pale); }
.node-list-label { min-width: 0; overflow-wrap: anywhere; font-weight: 700; }
.node-list-kind, .node-list-time { color: var(--muted); font-size: 11px; white-space: nowrap; }

.detail-panel-wrap { display: grid; gap: 10px; }
.node-detail-panel { padding: 16px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-soft); }
.detail-heading { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.detail-facts { display: grid; margin: 10px 0; gap: 0; }
.detail-facts > div { display: grid; padding: 9px 0; border-top: 1px solid #e4eae9; grid-template-columns: minmax(0, 160px) minmax(0, 1fr); gap: 10px; }
.detail-facts dt { color: var(--muted); font-size: 11px; font-weight: 750; text-transform: uppercase; }
.detail-facts dd { margin: 0; overflow-wrap: anywhere; font-size: 13px; font-weight: 650; }
.no-inference-note { padding: 10px 12px; border-left: 3px solid var(--teal); background: var(--teal-pale); font-size: 12px; }
.history-mini { margin: 0 0 12px; padding-left: 18px; color: var(--ink-soft); font-size: 12px; }
.history-mini li { margin-bottom: 4px; }

.annotate-form { display: grid; gap: 13px; margin-top: 8px; }
.field { display: grid; gap: 6px; }
.field label { display: flex; gap: 6px; color: var(--ink-soft); font-size: 12px; font-weight: 750; }
.required-word { color: var(--red); font-size: 10px; font-weight: 800; text-transform: uppercase; }
.field-error { margin: 0; color: var(--red); font-size: 12px; }
.field-hint { margin: 0; color: var(--muted); font-size: 12px; }
.ui-input, .ui-select, .ui-textarea, .update-form input { width: 100%; min-width: 0; min-height: 48px; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); color: var(--ink); }
.ui-textarea { min-height: 88px; resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { border-color: var(--focus); outline: 3px solid rgb(8 119 181 / 18%); outline-offset: 1px; }

.canvas-panel { display: grid; gap: 8px; }
.canvas-hint { font-size: 12px; }
.mark-canvas { width: 100%; max-width: 300px; height: auto; border: 1px dashed var(--line-strong); border-radius: 8px; background: var(--surface); cursor: crosshair; }
.mark-canvas-bg { fill: var(--surface-soft); }
.mark-canvas-dot { fill: var(--red); stroke: white; stroke-width: 2; }
.canvas-controls { display: flex; gap: 8px; flex-wrap: wrap; }
.clear-confirm { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid #ddb1ad; border-radius: 8px; background: var(--red-pale); flex-wrap: wrap; font-size: 12px; }

.ui-button { display: inline-flex; min-height: 46px; padding: 11px 16px; align-items: center; justify-content: center; border: 1px solid var(--ink); border-radius: 8px; background: var(--ink); color: white; cursor: pointer; font-size: 13px; font-weight: 760; line-height: 1.2; text-align: center; text-decoration: none; }
.ui-button:hover { border-color: var(--teal-dark); background: var(--teal-dark); }
.ui-button-secondary, .ui-button-outline { border-color: var(--line-strong); background: var(--surface); color: var(--ink); }
.ui-button-secondary:hover, .ui-button-outline:hover { background: var(--teal-pale); color: var(--ink); }
.ui-button-danger { border-color: var(--red); background: var(--red); color: white; }
.ui-button-danger:hover { border-color: #7a2c24; background: #7a2c24; }
.ui-badge { display: inline-flex; min-height: 26px; padding: 4px 8px; align-items: center; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--surface-soft); color: var(--ink-soft); font-size: 10px; font-weight: 800; letter-spacing: .04em; white-space: nowrap; }
.ui-badge-success { border-color: #a7c8b2; background: var(--green-pale); color: var(--green); }
.ui-badge-warning { border-color: #e1bf84; background: var(--amber-pale); color: var(--amber); }
.ui-badge-danger { border-color: #ddb1ad; background: var(--red-pale); color: var(--red); }

.request-board { display: grid; padding-bottom: 30px; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.request-card, .open-request-card { min-width: 0; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.request-card.severity-critical, .open-request-card.severity-critical { border-left: 5px solid var(--red); }
.request-card.severity-high { border-left: 5px solid #c18222; }
.request-card.severity-normal { border-left: 5px solid var(--teal); }
.badge-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.request-symptom { margin: 10px 0 4px; color: var(--ink); font-size: 14px; font-weight: 650; }
.request-meta, .owner-line { color: var(--muted); font-size: 12px; }
.update-list { display: grid; margin: 10px 0; padding: 0; gap: 6px; list-style: none; }
.update-list li { display: grid; padding: 8px 10px; border-radius: 7px; background: var(--surface-soft); font-size: 12px; }
.update-list time { color: var(--muted); font-size: 10px; }
.request-controls { display: grid; margin-top: 12px; gap: 8px; }
.update-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 7px; }
.report-link { display: inline-block; margin-top: 10px; color: var(--teal-dark); font-size: 12px; font-weight: 750; text-decoration: underline; }
.empty, .empty-state { color: var(--muted); }
.empty-state { padding: 40px 20px; text-align: center; }

.report-facts { display: grid; margin: 10px 0; }
.report-facts > div { display: grid; padding: 9px 0; border-top: 1px solid #e4eae9; grid-template-columns: minmax(0, 160px) minmax(0, 1fr); gap: 10px; }
.report-facts dt { color: var(--muted); font-size: 11px; font-weight: 750; text-transform: uppercase; }
.report-facts dd { margin: 0; overflow-wrap: anywhere; font-size: 13px; }
.export-form { display: grid; gap: 8px; }
.export-status { flex-wrap: wrap; }

.fictional-notice { margin: 0; }
.site-footer { padding-block: 24px 36px; color: var(--muted); font-size: 11px; text-align: center; }

@media (max-width: 1100px) {
  .topbar-inner { align-items: start; flex-direction: column; padding-block: 10px; }
  nav { width: 100%; }
  .request-board { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  .shell, .topbar-inner { width: min(100% - 20px, 1480px); }
  .brand small { display: none; }
  .page-heading { min-height: auto; padding-block: 30px; align-items: stretch; flex-direction: column; }
  .heading-actions, .heading-actions .ui-button { width: 100%; }
  .metrics, .metrics.two, .request-board { grid-template-columns: 1fr; }
  .update-form { grid-template-columns: 1fr; }
  .node-list-item { grid-template-columns: auto minmax(0, 1fr); grid-template-rows: auto auto; }
}

@media (max-width: 420px) {
  .shell, .topbar-inner { width: min(100% - 12px, 1480px); }
  nav a { padding-inline: 10px; }
  .panel { border-radius: 9px; padding: 13px; }
  .sync-bar { align-items: start; flex-wrap: wrap; }
  .sync-time { width: 100%; margin-left: 18px; }
  .node-dot { min-width: 76px; max-width: 100px; font-size: 10px; }
  .detail-facts > div, .report-facts > div { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

/* -------------------------------------------- high-fidelity interaction layer */
/* Restrained motion: node repositioning eases; the global prefers-reduced-motion
   block above uses !important and therefore disables these transitions. */
.node-dot { transition: left .14s ease, top .14s ease, border-color .12s ease, box-shadow .12s ease; }
.node-graph-lines line { transition: x1 .14s ease, y1 .14s ease, x2 .14s ease, y2 .14s ease; }

/* Edit-layout mode */
.node-graph[data-editing="true"] { outline: 2px dashed var(--blue); outline-offset: 3px; background: #eef5f9; }
.node-dot[data-editable="true"] { cursor: grab; touch-action: none; }
.node-dot[data-editable="true"]:active { cursor: grabbing; }
.layout-controls { display: flex; margin-block: 6px 4px; gap: 8px; flex-wrap: wrap; align-items: center; }
.layout-hint { flex: 1 1 100%; margin: 0; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--teal-pale); color: var(--teal-dark); font-size: 12px; }

/* Keyboard/touch nudge controls */
.nudge-controls { display: grid; margin-block: 10px; padding: 12px; gap: 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-soft); }
.nudge-title { margin: 0; font-size: 12px; font-weight: 800; color: var(--ink-soft); }
.nudge-pad { display: grid; justify-items: center; gap: 6px; }
.nudge-row { display: flex; gap: 6px; }
.nudge-controls button { min-height: 44px; }
.coord-form { display: grid; gap: 8px; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: end; }
.coord-form button { grid-column: 1 / -1; }

/* Drawing canvas with floating toolbar and undo/redo */
.draw-wrap { position: relative; width: 100%; max-width: 300px; }
.draw-toolbar { display: flex; margin-bottom: 6px; gap: 6px; flex-wrap: wrap; align-items: center; }
.draw-toolbar button { min-height: 40px; }
.draw-line { fill: none; stroke: var(--red); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.mark-canvas { touch-action: none; }

/* Report-embedded annotation */
.report-annotation-wrap { margin-block: 12px; }
.report-annotation { cursor: default; }
.report-stroke { fill: none; stroke: var(--red); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
