:root {
  --navy: #10284a;
  --navy-2: #1d3b66;
  --accent: #f26b21;
  --accent-2: #ff8a45;
  --bg: #f4f6f9;
  --panel: #ffffff;
  --line: #dde3ec;
  --text: #16202e;
  --muted: #6b7788;
  --ok: #1f8a4c;
  --warn: #b7791f;
  --err: #c53030;
  --radius: 10px;
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); height: 100vh; display: flex; flex-direction: column; }

.top { display: flex; align-items: center; justify-content: space-between; padding: 10px 18px; background: var(--navy); color: #fff; }
.brand { display: flex; gap: 12px; align-items: center; }
.brand b { font-size: 18px; letter-spacing: .2px; }
.brand small { display: block; color: #b8c6dc; font-size: 12px; }
.logo { width: 34px; height: 34px; border-radius: 8px; background: var(--accent); display: grid; place-items: center; font-weight: 800; font-size: 18px; }
.actions { display: flex; gap: 8px; }

button { font: inherit; font-size: 14px; border-radius: 8px; padding: 8px 14px; border: 1px solid transparent; cursor: pointer; }
button:disabled { opacity: .45; cursor: default; }
.primary { background: var(--accent); color: #fff; }
.primary:hover:not(:disabled) { background: var(--accent-2); }
.ghost { background: transparent; color: #fff; border-color: #4a6388; }
.ghost:hover:not(:disabled) { background: var(--navy-2); }
.secondary { background: #fff; color: var(--navy); border-color: var(--line); width: 100%; margin-top: 8px; }
.secondary:hover { border-color: var(--navy-2); }
.big { width: 100%; padding: 12px; font-size: 15px; font-weight: 600; margin-top: 10px; }

.grid { flex: 1; display: grid; grid-template-columns: 340px 1fr 330px; min-height: 0; }
.panel { background: var(--panel); padding: 16px; overflow: auto; }
.input { border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.report { border-left: 1px solid var(--line); }
label { font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin: 10px 0 6px; }
select, textarea { width: 100%; font: inherit; font-size: 14px; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: #fff; }
textarea { flex: 1; min-height: 240px; resize: none; line-height: 1.5; }
.highlight { flex: 1; min-height: 240px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 14px; line-height: 1.5; white-space: pre-wrap; }
.highlight mark { background: #ffe1cc; border-radius: 3px; padding: 0 2px; }
.hint { color: var(--muted); font-size: 12px; margin: 8px 0 0; }

.canvas-wrap { position: relative; min-width: 0; }
#canvas { position: absolute; inset: 0; background: #fff; }
.empty { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; padding: 40px; color: var(--muted); pointer-events: none; }
.empty h2 { color: var(--navy); margin: 0 0 10px; font-size: 22px; }
.empty p { max-width: 520px; margin: 0 auto; line-height: 1.5; }
.loading { position: absolute; inset: 0; background: rgba(255,255,255,.85); display: grid; place-content: center; justify-items: center; gap: 14px; color: var(--navy); font-weight: 600; }
.spinner { width: 42px; height: 42px; border: 4px solid #f9d3bd; border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin: 18px 0 8px; }
h3:first-child { margin-top: 0; }
.badge { padding: 10px 12px; border-radius: 8px; background: var(--bg); font-weight: 600; font-size: 14px; }
.badge.ok { background: #e6f5ec; color: var(--ok); }
.badge.bad { background: #fdecec; color: var(--err); }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.tile { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.tile b { display: block; font-size: 20px; color: var(--navy); }
.tile span { font-size: 12px; color: var(--muted); }
.tile.good b { color: var(--ok); }
.tile.bad b { color: var(--err); }
.issues { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.issues li { font-size: 13px; line-height: 1.4; padding: 8px 10px; border-radius: 8px; background: var(--bg); border-left: 3px solid var(--line); cursor: default; }
.issues li[data-el] { cursor: pointer; }
.issues li.error { border-left-color: var(--err); }
.issues li.warning { border-left-color: var(--warn); }
.issues li.info { border-left-color: #7f93b0; }
.issues .tag { font-size: 11px; font-weight: 700; margin-right: 6px; text-transform: uppercase; }
.issues .fixed { color: var(--ok); }
.muted { color: var(--muted); font-size: 13px; }
.trace { font-size: 13px; line-height: 1.5; }
.trace b { color: var(--navy); }
.trace q { display: block; margin-top: 6px; padding: 8px 10px; background: #fff4ec; border-radius: 8px; quotes: "«" "»"; }

.djs-element.issue-mark .djs-visual > :first-child { stroke: var(--accent) !important; stroke-width: 3px !important; }

.tabs { display: flex; gap: 4px; margin: 10px 0 6px; border-bottom: 1px solid var(--line); }
.tab { background: none; border: none; border-bottom: 2px solid transparent; border-radius: 0; padding: 6px 8px; color: var(--muted); font-size: 13px; }
.tab.active { color: var(--navy); border-bottom-color: var(--accent); font-weight: 600; }
.code-pane { flex: 1 0 320px; display: flex; flex-direction: column; }
.code-pane .hint { margin: 0 0 6px; }
#code { flex: 1; min-height: 0; font-family: "JetBrains Mono", "SF Mono", Menlo, monospace; font-size: 12px; line-height: 1.45; white-space: pre; resize: none; }

@media (max-width: 1100px) {
  body { height: auto; min-height: 100vh; }
  .top { flex-wrap: wrap; gap: 10px; }
  .grid { grid-template-columns: 1fr; }
  .input, .report { border: none; border-bottom: 1px solid var(--line); }
  .canvas-wrap { height: 70vh; }
  textarea#text, .highlight { min-height: 200px; }
}
