:root {
  --bg: #f3f4f6; --card: #fff; --text: #1f2937; --muted: #6b7280; --border: #d1d5db;
  --primary: #1d4ed8; --green: #15803d; --green-bg: #dcfce7; --red: #b91c1c; --red-bg: #fee2e2;
  --orange: #c2410c; --orange-bg: #ffedd5; --blue-bg: #dbeafe; --mono: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
[hidden] { display: none !important; }
h1 { font-size: 17px; margin: 0; }
h2 { font-size: 15px; margin: 0 0 10px; }
h3 { font-size: 14px; margin: 14px 0 6px; }
code, pre, textarea { font-family: var(--mono); font-size: 12.5px; }
input, select, textarea { font: inherit; border: 1px solid var(--border); border-radius: 6px; padding: 5px 7px; background: #fff; color: inherit; width: 100%; }
textarea { font-family: var(--mono); font-size: 12.5px; }
input:focus, select:focus, textarea:focus { outline: 2px solid #93c5fd; border-color: var(--primary); }
button { font: inherit; border: 1px solid var(--border); background: #fff; border-radius: 6px; padding: 5px 11px; cursor: pointer; color: inherit; }
button:hover { background: #f9fafb; }
button.primary { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
button.primary:hover { background: #1e40af; }
button:disabled { opacity: .55; cursor: progress; }
button.link { border: 0; background: none; color: var(--primary); padding: 0; text-decoration: underline; }
label { display: flex; flex-direction: column; gap: 3px; font-size: 12.5px; color: var(--muted); }
label.inline { flex-direction: row; align-items: center; gap: 6px; }
label.inline input { width: 80px; }
label.check { flex-direction: row; align-items: center; gap: 6px; margin-top: 12px; color: var(--text); }
label.check input, .radios input, .target-switch input { width: auto; }
.radios { display: flex; gap: 16px; }
.radios label { flex-direction: row; align-items: center; gap: 5px; color: var(--text); font-size: 14px; }

.login { min-height: 100vh; display: grid; place-items: center; }
.login-card { width: 340px; display: flex; flex-direction: column; gap: 14px; }

.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: #111827; color: #fff; flex-wrap: wrap; }
.topbar a { color: #bfdbfe; }
.topbar button { background: #1f2937; color: #fff; border-color: #374151; }
.target-switch { display: flex; gap: 10px; align-items: center; background: #1f2937; padding: 4px 10px; border-radius: 6px; }
.target-switch label { flex-direction: row; gap: 4px; color: #fff; font-size: 14px; align-items: center; }
.spacer { flex: 1; }

.layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; padding: 14px; max-width: 1700px; margin: 0 auto; }
@media (min-width: 1150px) { .layout { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); } }
.col { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; min-width: 0; }
.card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 12px; align-items: end; }
.wide { grid-column: 1 / -1; }
.span2 { grid-column: span 2; }
.span3 { grid-column: span 3; }
.row { display: flex; gap: 10px; align-items: end; }
.grow { flex: 1; }
.actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; align-items: center; }
.chips { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; align-items: center; }
.chips button { border-radius: 999px; padding: 2px 10px; font-size: 12.5px; font-family: var(--mono); }
.sub { margin-top: 8px; padding: 10px; background: #f9fafb; border-radius: 8px; }
.hint { color: var(--muted); font-size: 12.5px; margin: 8px 0 0; }
.muted { color: var(--muted); font-size: 12.5px; }
.error { color: var(--red); margin: 6px 0 0; }
.weight-preview { font-size: 12.5px; color: var(--muted); padding-bottom: 6px; }
.weight-preview code { color: var(--text); font-weight: 600; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: #e5e7eb; color: #374151; }
.badge.green { background: var(--green-bg); color: var(--green); }
.badge.red { background: var(--red-bg); color: var(--red); }
.badge.orange { background: #f97316; color: #fff; }
.badge.amber { background: var(--orange-bg); color: var(--orange); }
.badge.blue { background: var(--blue-bg); color: var(--primary); }

.tabs { display: flex; gap: 4px; margin-left: 12px; }
.tabs button[aria-selected="true"] { background: var(--primary); border-color: var(--primary); color: #fff; }
.req-line { background: #111827; color: #e5e7eb; padding: 6px 10px; border-radius: 6px; overflow-x: auto; white-space: nowrap; }
.req-line code { color: inherit; }
table { border-collapse: collapse; width: 100%; }
table.kv td, table.kv th { border-bottom: 1px solid #eef0f3; padding: 3px 6px; vertical-align: top; text-align: left; font-size: 12.5px; }
table.kv th { width: 180px; color: var(--muted); font-weight: 500; font-family: var(--mono); }
table.kv td { font-family: var(--mono); word-break: break-all; }
table.kv td button { font-family: system-ui, sans-serif; padding: 0 6px; margin-left: 6px; font-size: 12px; }

.editor-head { display: flex; gap: 6px; align-items: center; margin-top: 12px; flex-wrap: wrap; }
.editor-head button { padding: 3px 9px; font-size: 12.5px; }
#editor { margin-top: 6px; min-height: 170px; resize: vertical; white-space: pre-wrap; word-break: break-all; tab-size: 2; }
#editor.invalid { border-color: var(--red); outline-color: #fca5a5; }
.notice { margin-top: 6px; padding: 6px 10px; border-radius: 6px; background: var(--orange-bg); color: var(--orange); font-size: 12.5px; }
.parse-status { margin-top: 6px; font-size: 13px; font-weight: 600; }
.parse-status.ok { color: var(--green); }
.parse-status.bad { color: var(--red); }
.parse-status button { margin-left: 8px; font-weight: 400; }
table.params { margin-top: 6px; }
table.params th, table.params td { border-bottom: 1px solid #eef0f3; padding: 3px 6px; text-align: left; font-size: 12.5px; }
table.params th { color: var(--muted); font-weight: 500; }
table.params td.v { font-family: var(--mono); word-break: break-all; }
table.params tr.bad td { background: var(--red-bg); }
.kind { font-family: var(--mono); font-size: 11.5px; padding: 1px 6px; border-radius: 4px; background: #eef2ff; color: #3730a3; }
ul.issues, ul.warnings { margin: 6px 0 0; padding-left: 18px; font-size: 12.5px; }
ul.issues li.issue, ul.warnings li { color: var(--red); }
ul.issues li.warn { color: var(--orange); }
ul.issues li.info { color: var(--muted); }

.facts { display: grid; grid-template-columns: max-content 1fr; gap: 2px 12px; margin: 0; font-size: 12.5px; }
.facts.wide { grid-template-columns: max-content 1fr max-content 1fr; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-family: var(--mono); word-break: break-all; }
.photo-info { display: flex; gap: 14px; margin-top: 10px; align-items: flex-start; }
.photo-info img { max-width: 320px; max-height: 240px; border: 1px solid var(--border); border-radius: 6px; cursor: zoom-in; }
.in-band { color: var(--green); font-weight: 600; }
.off-band { color: var(--orange); font-weight: 600; }

pre.body { background: #f9fafb; border: 1px solid #eef0f3; border-radius: 6px; padding: 8px 10px; max-height: 420px; overflow: auto; white-space: pre-wrap; word-break: break-all; margin: 6px 0 0; }
details { margin-top: 10px; }
summary { cursor: pointer; font-weight: 600; font-size: 13px; }
.eval { margin-top: 10px; padding: 8px 12px; border-radius: 8px; font-size: 13px; }
.eval.green { background: var(--green-bg); }
.eval.red { background: var(--red-bg); }
.eval.amber { background: var(--orange-bg); }
.eval pre { margin: 6px 0 0; white-space: pre-wrap; font-size: 12.5px; }
.eval table { margin-top: 6px; }

table.history th, table.history td { border-bottom: 1px solid #eef0f3; padding: 4px 6px; text-align: left; font-size: 12.5px; white-space: nowrap; }
table.history th { color: var(--muted); font-weight: 500; }
table.history tbody tr { cursor: pointer; }
table.history tbody tr:hover { background: #f9fafb; }
#mock-log table td { white-space: normal; }

.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.85); display: grid; place-items: center; z-index: 20; cursor: zoom-out; overflow: auto; }
.overlay img { max-width: 98vw; max-height: 98vh; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #111827; color: #fff; padding: 8px 16px; border-radius: 8px; z-index: 30; }
.help ul { margin: 0; padding-left: 18px; font-size: 13px; }
.help li { margin-bottom: 4px; }
