/* ExtraNet editor: the tool's own interface, in the design language of the CMU Open Vehicles tool.
   Colours, radii and spacing are tokens; the in-game look of pages is in preview.css. */

/* The accent is a registered colour so the woke theme can fade and cycle it (as in Open Vehicles). */
@property --accent { syntax: '<color>'; inherits: true; initial-value: #b8e26a; }
@property --accent-soft { syntax: '<color>'; inherits: true; initial-value: rgba(184, 226, 106, 0.14); }

:root {
  /* surfaces, darkest to lightest */
  --bg: #0b0c0e;
  --surface: #111215;
  --surface-2: #15171a;
  --surface-3: #1c1f23;
  --surface-4: #24282d;
  /* hairlines */
  --hair: rgba(255, 255, 255, 0.055);
  --hair-2: rgba(255, 255, 255, 0.1);
  /* text */
  --text: #e8e9eb;
  --text-2: #a3a7ae;
  --text-3: #686d75;
  /* accent and states */
  --accent: #b8e26a;
  --accent-ink: #11140b;
  --accent-soft: color-mix(in srgb, var(--accent) 14%, transparent);
  --accent-line: color-mix(in srgb, var(--accent) 30%, transparent);
  --danger: #ff6b6b;
  --danger-soft: color-mix(in srgb, var(--danger) 14%, transparent);
  --warn: #ffc857;
  --warn-soft: color-mix(in srgb, var(--warn) 14%, transparent);
  --info: #7fc4ff;
  /* shape and rhythm */
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --gap: 10px;
  --pad: 12px;
  --rail-w: 56px;
  --panel-w: 290px;
  --inspector-w: 400px;
  --topbar-h: 44px;
  --status-h: 30px;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --mono: "Cascadia Mono", "Consolas", "Roboto Mono", monospace;

  /* Older names the builder and studio styles use. */
  --panel: var(--surface);
  --panel-2: var(--surface-2);
  --line: var(--hair);
  --line-2: var(--hair-2);
  --ink: var(--text);
  --ink-dim: var(--text-2);
  --ink-faint: var(--text-3);
  --green: var(--accent);
  --green-dim: var(--accent-line);
  --green-bg: var(--accent-soft);
  --amber: var(--warn);
  --amber-bg: var(--warn-soft);
  --red: var(--danger);
  --red-bg: var(--danger-soft);
  --blue: var(--info);
  --sans: var(--font);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 13px/1.4 var(--font);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; }
code, pre, .mono { font-family: var(--mono); }
code { color: var(--accent); font-size: 0.95em; }
a { color: var(--info); }
::selection { background: var(--accent-soft); }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--surface-4); border-radius: 8px; border: 2px solid var(--surface); }
::-webkit-scrollbar-track { background: transparent; }
.ico { display: inline-flex; width: 18px; height: 18px; flex: none; }
.ico svg { width: 100%; height: 100%; }

/* ------------------------------------------------------------- app frame */

.app {
  display: grid;
  grid-template-columns: var(--rail-w) var(--panel-w) minmax(0, 1fr) var(--inspector-w);
  grid-template-rows: var(--topbar-h) minmax(0, 1fr) var(--status-h);
  height: 100vh;
  opacity: 0;
  animation: appear 420ms var(--ease) 60ms forwards;
}
@keyframes appear { from { opacity: 0; transform: scale(0.995); } to { opacity: 1; transform: none; } }
.app.panel-closed { grid-template-columns: var(--rail-w) 0 minmax(0, 1fr) var(--inspector-w); }
.app.panel-closed .side-panel { visibility: hidden; padding: 0; }

/* title bar */
.titlebar {
  position: relative;
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 14px 0 18px;
  border-bottom: 1px solid var(--hair);
  min-width: 0;
}
.brand { display: flex; align-items: center; gap: 9px; min-width: 0; white-space: nowrap; }
/* The CMU emblem: green like the app until clicked, when it takes its own colours and the app its theme. */
.glyph-btn { padding: 0; border: 0; background: none; display: grid; place-items: center; border-radius: 50%; cursor: pointer; }
.glyph { width: 18px; height: 18px; display: block; filter: grayscale(1) sepia(1) hue-rotate(38deg) saturate(2.6) brightness(1.08);
  transition: filter 1100ms var(--ease), transform 600ms var(--spring); }
.glyph-btn:hover .glyph { transform: scale(1.12) rotate(-8deg); }
.glyph-btn:active .glyph { transform: scale(0.9); }
.woke .glyph { filter: none; }
.glyph-btn.pop .glyph { animation: glyph-pop 900ms var(--spring); }
@keyframes glyph-pop { 0% { transform: scale(1) rotate(0); } 35% { transform: scale(1.45) rotate(200deg); } 100% { transform: scale(1) rotate(360deg); } }
.name { font-weight: 600; letter-spacing: 0.01em; }
.sep { color: var(--text-3); }
.doc { color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 320px; }
.dirty { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); transform: scale(0); transition: transform 240ms var(--spring); flex: none; }
.dirty.on { transform: scale(1); }
.title-actions { display: flex; align-items: center; gap: 2px; margin-left: 8px; min-width: 0; }
.top-sep { width: 1px; height: 18px; background: var(--hair-2); margin: 0 6px; flex: none; }
.title-right { margin-left: auto; display: flex; align-items: center; gap: 2px; }
.ghost {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 11px; border: 0; border-radius: 7px; background: none;
  color: var(--text-2); cursor: pointer; white-space: nowrap;
  transition: background 140ms var(--ease), color 140ms var(--ease), transform 120ms var(--ease);
}
.ghost:hover { background: var(--surface-3); color: var(--text); }
.ghost:active { transform: scale(0.96); }
.ghost:disabled { opacity: 0.35; cursor: default; background: none; color: var(--text-2); transform: none; }
.ghost .ico { width: 16px; height: 16px; }
.save-state { color: var(--text-3); font: 11px var(--mono); white-space: nowrap; }

/* rail */
.rail {
  grid-row: 2;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 12px 0;
  border-right: 1px solid var(--hair);
}
.rail-btn {
  position: relative; width: 40px; height: 40px; border-radius: 11px; border: 0; background: none;
  display: grid; place-items: center; color: var(--text-2); cursor: pointer;
  transition: color 140ms var(--ease), background 140ms var(--ease), transform 140ms var(--ease);
}
.rail-btn:hover { color: var(--text); background: rgba(255, 255, 255, 0.035); }
.rail-btn:active { transform: scale(0.9); }
.rail-btn.on { color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 28%, transparent); }
.rail-btn .ico { width: 18px; height: 18px; }
.rail-badge {
  position: absolute; top: 2px; right: 1px; min-width: 15px; height: 15px; padding: 0 4px; border-radius: 8px;
  font: 600 9.5px/15px var(--mono); text-align: center; background: var(--surface-4); color: var(--text);
}
.rail-badge.bad { background: var(--danger); color: #1a0505; }
.rail-badge.warn { background: var(--warn); color: #201300; }
.rail-badge.ok { display: none; }
.rail-gap { width: 20px; height: 1px; background: var(--hair-2); margin: 8px 0; }
.rail-bottom { margin-top: auto; display: flex; flex-direction: column; gap: 4px; }

/* tooltips */
.tip {
  position: fixed; z-index: 80; padding: 5px 9px; border-radius: 7px; background: var(--surface-4);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4); font-size: 11.5px; color: var(--text);
  pointer-events: none; opacity: 0; transform: translateY(3px); transition: opacity 120ms var(--ease), transform 160ms var(--ease);
  max-width: 300px;
}
.tip.on { opacity: 1; transform: none; }
.tip kbd { margin-left: 6px; }

/* left panel */
.side-panel { grid-row: 2; min-width: 0; min-height: 0; display: flex; flex-direction: column; padding: var(--pad) 0 var(--pad) var(--pad); }
.panel-card { flex: 1; min-height: 0; }
.panel-head { display: flex; align-items: baseline; gap: 8px; padding: 10px 12px 2px; min-width: 0; }
.panel-title { font-weight: 600; flex: none; }
.panel-sub { color: var(--text-3); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.left-body { flex: 1; min-height: 0; overflow-y: auto; padding: 6px 12px 16px; }

/* centre */
.center { grid-row: 2; min-width: 0; min-height: 0; padding: var(--pad); display: flex; flex-direction: column; position: relative; }
.work-card { flex: 1; min-height: 0; overflow: hidden; }
.work-head { display: flex; align-items: center; gap: 8px; padding: 9px 12px 0; min-height: 34px; min-width: 0; }
.work-title { font-weight: 600; flex: none; }
.work-sub { color: var(--text-3); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.work-meta { margin-left: auto; display: flex; align-items: center; gap: 8px; color: var(--text-3); font: 11px var(--mono); white-space: nowrap; flex: none; }

/* inspector */
.inspector { grid-row: 2; min-width: 0; min-height: 0; padding: var(--pad) var(--pad) var(--pad) 0; display: flex; flex-direction: column; gap: var(--gap); }
.preview-card { flex: 0 0 auto; height: 46%; min-height: 220px; padding: 10px; gap: 8px; }
.preview-tools { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.preview-tools .input { width: 100%; font-size: 11.5px; padding: 3px 7px; height: 26px; }
.props-card { flex: 1; min-height: 0; overflow: hidden; }
.props-host { flex: 1; min-height: 0; overflow-y: auto; padding: 12px; }

/* status bar */
.statusbar {
  grid-column: 1 / -1;
  display: flex; align-items: center; gap: 10px; padding: 0 14px;
  border-top: 1px solid var(--hair); color: var(--text-3); font: 11.5px var(--mono); min-width: 0; white-space: nowrap; overflow: hidden;
}
.statusbar .grow { flex: 1; }
.sb-sep { width: 1px; height: 12px; background: var(--hair-2); flex: none; }
.sb-item { display: inline-flex; align-items: center; gap: 7px; overflow: hidden; text-overflow: ellipsis; }
.sb-link { background: none; border: 0; padding: 2px 6px; margin: 0 -6px; border-radius: 6px; color: inherit; font: inherit; cursor: pointer; display: inline-flex; gap: 8px; }
.sb-link:hover { background: var(--surface-3); color: var(--text); }
.sb-err { color: var(--danger); }
.sb-warn { color: var(--warn); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); flex: none; transition: background 200ms var(--ease); }
.dot.ready { background: var(--accent); }
.dot.busy { background: var(--accent); animation: breathe 900ms ease-in-out infinite; }
.dot.error { background: var(--danger); }
@keyframes breathe { 50% { opacity: 0.35; transform: scale(0.8); } }

/* ------------------------------------------------------------- cards and headings */

.card { background: var(--surface); border-radius: var(--radius); box-shadow: inset 0 0 0 1px var(--hair); display: flex; flex-direction: column; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--text-2); font-size: 12px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; }
.card-head .mini { text-transform: none; letter-spacing: 0; font-weight: 400; }
.section-title {
  display: flex; align-items: center; justify-content: space-between;
  color: var(--text-2); font: 600 11.5px var(--font); letter-spacing: 0.05em; text-transform: uppercase;
  margin: 14px 0 8px;
}
.section-title:first-child { margin-top: 4px; }
.form-section { background: var(--surface-2); border-radius: var(--radius-sm); box-shadow: inset 0 0 0 1px var(--hair); padding: 10px 11px; margin-bottom: 10px; }
.form-section .section-title { margin-top: 0; }
.note { color: var(--text-3); font-size: 12px; line-height: 1.45; margin: 4px 0 10px; }
.muted { color: var(--text-3); }
.mini { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; border-radius: 6px; border: 0; background: none; color: var(--text-3); font-size: 12px; cursor: pointer; transition: color 120ms var(--ease), background 120ms var(--ease); }
.mini:hover { color: var(--text); background: var(--surface-3); }
.mini.accent { color: var(--accent); }
.callout { border-radius: var(--radius-sm); background: var(--warn-soft); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--warn) 25%, transparent); color: #f0dcb8; padding: 9px 11px; font-size: 12px; margin-bottom: 10px; }
.callout strong { color: var(--warn); }
.empty-hint { border-radius: var(--radius-sm); border: 1px dashed var(--hair-2); color: var(--text-3); padding: 14px; text-align: center; font-size: 12px; margin: 6px 0; }
kbd { font: 10.5px var(--mono); color: var(--text-2); padding: 0 4px; border-radius: 4px; background: var(--surface-3); box-shadow: inset 0 0 0 1px var(--hair); }

/* ------------------------------------------------------------- buttons */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 30px; padding: 0 12px; border: 0; border-radius: var(--radius-sm);
  background: var(--surface-3); color: var(--text); font-size: 12.5px; cursor: pointer; white-space: nowrap;
  transition: background 140ms var(--ease), transform 120ms var(--ease), box-shadow 140ms var(--ease), color 140ms var(--ease);
}
.btn:hover { background: var(--surface-4); }
.btn:active { transform: scale(0.97); }
.btn:focus-visible, .ghost:focus-visible, .rail-btn:focus-visible { outline: 1px solid var(--accent); outline-offset: 1px; }
.btn:disabled { opacity: 0.4; cursor: default; transform: none; }
.btn-primary { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn-primary:hover { background: var(--accent); box-shadow: 0 6px 22px color-mix(in srgb, var(--accent) 22%, transparent); }
.btn-danger:hover { background: var(--danger-soft); color: var(--danger); }
.btn-warn { color: var(--warn); }
.btn-small { height: 26px; padding: 0 9px; font-size: 12px; border-radius: 7px; }
.btn-icon { width: 26px; height: 26px; padding: 0; border-radius: 7px; background: var(--surface-2); color: var(--text-2); }
.btn-icon:hover { color: var(--text); }
.button-row { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0; }

/* ------------------------------------------------------------- inputs */

.input {
  font: 12.5px var(--font); color: var(--text);
  background: var(--surface-2); border: 0; border-radius: 7px;
  box-shadow: inset 0 0 0 1px var(--hair-2);
  padding: 6px 9px; width: 100%; min-width: 0; outline: none;
  transition: box-shadow 140ms var(--ease);
}
.input:focus { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 50%, transparent); }
textarea.input { resize: vertical; line-height: 1.45; }
textarea.input.mono, .input.mono { font-family: var(--mono); font-size: 12px; }
select.input { width: auto; max-width: 100%; cursor: pointer; }
.input-small { width: 130px; }
.input-narrow { width: 76px; }
input[type="checkbox"] { accent-color: var(--accent); }

.field { display: flex; flex-direction: column; gap: 4px; margin: 0 0 10px; min-width: 0; }
.field-label { color: var(--text-2); font-size: 12px; }
.field-hint { color: var(--text-3); font-size: 11.5px; }
.hint-bad { color: var(--danger); }
.check { display: flex; gap: 8px; align-items: flex-start; margin: 4px 0; cursor: pointer; color: var(--text-2); font-size: 12.5px; }
.check:hover { color: var(--text); }
.check input { margin-top: 2px; }
.checks { margin-bottom: 6px; }

.colour-input { display: flex; gap: 6px; align-items: center; }
.colour-swatch { -webkit-appearance: none; appearance: none; width: 30px; height: 28px; padding: 0; border: 0; border-radius: 7px; background: none; cursor: pointer; flex: none; }
.colour-swatch::-webkit-color-swatch-wrapper { padding: 0; }
.colour-swatch::-webkit-color-swatch { border: 0; border-radius: 7px; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12); }
.colour-swatch::-moz-color-swatch { border: 0; border-radius: 7px; }
.colour-text { width: 100%; font-family: var(--mono); }

input[type="range"] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 4px; border-radius: 4px;
  background: var(--surface-4); outline: none; accent-color: var(--accent);
}
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%; background: var(--text); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5); transition: transform 180ms var(--spring); }
input[type="range"]:active::-webkit-slider-thumb { transform: scale(1.25); }
input[type="range"]::-moz-range-thumb { width: 14px; height: 14px; border: 0; border-radius: 50%; background: var(--text); }
input[type="range"]::-moz-range-progress { background: var(--accent); height: 4px; border-radius: 4px; }

.segmented { position: relative; display: flex; background: var(--surface-2); border-radius: 9px; padding: 3px; box-shadow: inset 0 0 0 1px var(--hair); gap: 2px; }
.segmented button { flex: 1; padding: 5px 10px; border: 0; border-radius: 7px; background: none; color: var(--text-2); font-size: 12px; white-space: nowrap; cursor: pointer; transition: color 160ms var(--ease), background 200ms var(--ease); }
.segmented button:hover { color: var(--text); }
.segmented button.on { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.segmented.small button { padding: 3px 8px; font-size: 11px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 8px; }
.row-edit { display: flex; gap: 6px; align-items: center; margin: 5px 0; flex-wrap: wrap; }
.row-edit > .input:first-child { flex: 1 1 140px; width: auto; }
.row-edit .field { margin: 0; }
.yaml-view { font: 11px/1.5 var(--mono); background: var(--bg); border-radius: var(--radius-sm); box-shadow: inset 0 0 0 1px var(--hair); padding: 10px; margin: 0; overflow-x: auto; color: var(--text-2); white-space: pre; }

/* ------------------------------------------------------------- lists */

.file-list, .issue-list, .page-list-rows { display: flex; flex-direction: column; gap: 2px; margin-bottom: 8px; }
.file-row, .page-row {
  position: relative; display: grid; gap: 8px; align-items: center;
  min-height: 32px; padding: 3px 6px; border-radius: 8px; cursor: pointer; color: var(--text-2);
  transition: background 140ms var(--ease), color 140ms var(--ease);
}
.page-row { grid-template-columns: auto minmax(0, 1fr) auto; }
.file-row { grid-template-columns: minmax(60px, 1fr) minmax(60px, 1fr) auto; }
.file-row:hover, .page-row:hover { background: var(--surface-2); color: var(--text); }
.file-row.active, .page-row.active { background: var(--accent-soft); color: var(--text); }
.file-row.active::before, .page-row.active::before { content: ""; position: absolute; left: -4px; top: 8px; bottom: 8px; width: 3px; border-radius: 3px; background: var(--accent); animation: grow 260ms var(--spring); }
@keyframes grow { from { transform: scaleY(0); } to { transform: none; } }
.page-row.dragging { opacity: 0.4; }
.page-row.drop-above { box-shadow: 0 -2px 0 var(--accent); }
.page-row.drop-below { box-shadow: 0 2px 0 var(--accent); }
.file-row.missing .file-name { color: var(--danger); }
.file-path { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-name { font: 11px var(--mono); color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-actions { display: flex; gap: 3px; }
.kdot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--text-3); }
.kdot.home { background: var(--accent); }
.kdot.tab { background: var(--info); }
.page-main { min-width: 0; display: flex; align-items: baseline; gap: 8px; }
.page-name { font-size: 12.5px; color: inherit; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page-path { font: 11px var(--mono); color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-btns { display: flex; gap: 1px; }
.row-btn { width: 24px; height: 24px; border: 0; border-radius: 6px; background: none; color: var(--text-3); display: grid; place-items: center; cursor: pointer; opacity: 0; transition: opacity 120ms var(--ease), color 120ms var(--ease), background 120ms var(--ease); }
.row-btn .ico { width: 14px; height: 14px; }
.page-row:hover .row-btn, .row-btn.keep { opacity: 1; }
.row-btn:hover { color: var(--text); background: var(--surface-3); }
.row-btn.danger:hover { color: var(--danger); }

.image-list { display: flex; flex-direction: column; gap: 6px; }
.image-row { display: grid; grid-template-columns: 56px 1fr; gap: 4px 10px; padding: 8px; border-radius: var(--radius-sm); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--hair); }
.image-thumb { width: 56px; height: 42px; object-fit: contain; image-rendering: pixelated; border-radius: 6px; background: repeating-conic-gradient(#1a1d21 0 25%, #131518 0 50%) 0 0 / 10px 10px; grid-row: span 2; }
.image-info { min-width: 0; font-size: 11.5px; }
.image-name { font: 12px var(--mono); overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.image-actions { display: flex; gap: 4px; flex-wrap: wrap; grid-column: 2; }
.attr-ok { color: var(--accent); }
.attr-missing { color: var(--warn); }

.badge { font: 600 10px var(--mono); padding: 0 5px; border-radius: 8px; background: var(--surface-4); color: var(--text); }
.badge-error { background: var(--danger); color: #1a0505; }
.badge-warn { background: var(--warn); color: #201300; }
.badge-ok { background: var(--accent-soft); color: var(--accent); }

.check-summary { padding: 10px 12px; border-radius: var(--radius-sm); margin-bottom: 10px; font-size: 12.5px; }
.check-summary.good { background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent-line); }
.check-summary.bad { background: var(--danger-soft); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--danger) 30%, transparent); }
.issue { position: relative; display: grid; grid-template-columns: 8px minmax(0, 1fr); gap: 2px 9px; padding: 7px 8px; border-radius: 8px; cursor: pointer; font-size: 12px; color: var(--text-2); transition: background 140ms var(--ease); }
.issue:hover { background: var(--surface-2); color: var(--text); }
.issue-level { width: 8px; height: 8px; border-radius: 50%; margin-top: 4px; font-size: 0; background: var(--text-3); grid-row: span 2; }
.issue-where { font: 11px var(--mono); color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.issue-text { grid-column: 2; }
.issue-error .issue-level { background: var(--danger); }
.issue-warning .issue-level { background: var(--warn); }
.issue-info .issue-level { background: var(--info); }

/* ------------------------------------------------------------- code editor (markup view) */

.editor-host { flex: 1 1 auto; min-height: 0; display: flex; margin: 8px; border-radius: var(--radius-sm); overflow: hidden; box-shadow: inset 0 0 0 1px var(--hair); }
.code-editor { flex: 1; display: flex; min-height: 0; background: var(--bg); font: 12.5px/19px var(--mono); }
.code-gutter { flex: 0 0 auto; min-width: 44px; padding: 8px 8px 40px 0; text-align: right; color: var(--text-3); background: var(--surface); border-right: 1px solid var(--hair); overflow: hidden; user-select: none; }
.gl { height: 19px; padding-left: 6px; }
.gl-error { color: #1a0505; background: var(--danger); }
.gl-warning { color: #201300; background: var(--warn); }
.gl-info { color: var(--info); }
.code-wrap { position: relative; flex: 1; min-width: 0; }
.code-highlight, .code-input { position: absolute; inset: 0; margin: 0; padding: 8px 10px 40px; font: inherit; white-space: pre; overflow: auto; tab-size: 2; border: 0; letter-spacing: 0; }
.code-highlight { color: #c8ccd2; pointer-events: none; overflow: hidden; }
.code-input { color: transparent; background: transparent; caret-color: var(--accent); resize: none; outline: none; }
.code-input::selection { background: rgba(184, 226, 106, 0.25); color: transparent; }
.hl-tag { color: #7fc4ff; }
.hl-attr { color: #ffc857; }
.hl-value { color: #b8e26a; }
.hl-rich { color: #c9a2ff; }
.hl-link { color: #ff8ad8; }
.hl-heading { color: #ffe27a; font-weight: 700; }
.hl-bullet { color: var(--accent); font-weight: 700; }
.hl-comment { color: var(--text-3); font-style: italic; }
.hl-colony { color: #1a1300; background: #ffc857; border-radius: 2px; }

/* in-game preview inside its card */
.preview-host { flex: 1 1 auto; min-height: 0; display: flex; border-radius: 9px; overflow: hidden; }
.preview-host .term-desk { padding: 8px; background: #0e1012; background-image: none; }

/* ------------------------------------------------------------- dialogs */

.modal {
  border: 0; padding: 0; color: var(--text);
  background: var(--surface); border-radius: 14px;
  width: min(540px, 94vw); max-height: 88vh;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6), inset 0 0 0 1px var(--hair-2);
}
.modal-wide { width: min(980px, 96vw); }
.modal::backdrop { background: rgba(5, 6, 8, 0.6); backdrop-filter: blur(2px); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 12px 4px 16px; }
.modal-title { font-weight: 600; font-size: 14px; }
.modal-head .btn-icon { background: none; }
.modal-body { padding: 8px 16px 16px; overflow-y: auto; max-height: calc(88vh - 52px); }
.help p { margin: 0 0 10px; color: var(--text-2); }
.help b { color: var(--text); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 8px; }
.chip { font: 11px var(--mono); background: var(--surface-2); color: var(--text-2); border: 0; box-shadow: inset 0 0 0 1px var(--hair); border-radius: 20px; padding: 3px 9px; cursor: pointer; }
.chip:hover { color: var(--text); background: var(--surface-3); }
.picker-info { font-size: 12px; margin: 6px 0; }
.state-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 6px; max-height: 46vh; overflow-y: auto; margin: 6px 0 10px; padding: 2px; }
.state-cell { background: var(--surface-2); border: 0; box-shadow: inset 0 0 0 1px var(--hair); border-radius: var(--radius-sm); padding: 6px 4px; cursor: pointer; color: var(--text); display: flex; flex-direction: column; align-items: center; gap: 3px; min-height: 104px; }
.state-cell:hover { background: var(--surface-3); }
.state-cell.chosen { box-shadow: inset 0 0 0 1.5px var(--accent); background: var(--accent-soft); }
.state-art { min-height: 64px; display: flex; align-items: center; justify-content: center; color: var(--text-3); font-size: 10px; border-radius: 6px; background: repeating-conic-gradient(#191c20 0 25%, #131518 0 50%) 0 0 / 8px 8px; width: 100%; }
.state-name { font: 11px var(--mono); word-break: break-all; text-align: center; }
.state-meta { font-size: 10px; color: var(--text-3); }
.rsi-browser { background: var(--bg); border-radius: var(--radius-sm); box-shadow: inset 0 0 0 1px var(--hair); padding: 8px; margin-bottom: 8px; max-height: 30vh; overflow-y: auto; }
.crumbs { font: 11px var(--mono); margin-bottom: 6px; color: var(--text-3); }
.crumb { background: none; border: 0; color: var(--info); cursor: pointer; font: inherit; padding: 0; }
.browse-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 3px; }
.browse-item { text-align: left; background: var(--surface-2); color: var(--text-2); border: 0; border-radius: 6px; padding: 4px 7px; font: 11px var(--mono); cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.browse-item.is-rsi { color: var(--accent); }
.browse-item:hover { background: var(--surface-3); color: var(--text); }
.ad-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 6px; max-height: 55vh; overflow-y: auto; margin-bottom: 8px; }
.ad-item { display: flex; gap: 8px; align-items: center; text-align: left; background: var(--surface-2); color: var(--text); border: 0; box-shadow: inset 0 0 0 1px var(--hair); border-radius: var(--radius-sm); padding: 6px 8px; cursor: pointer; font-size: 12px; }
.ad-item:hover { background: var(--surface-3); }
.ad-art { width: 34px; min-height: 32px; display: flex; align-items: center; justify-content: center; }

.toasts { position: fixed; right: 18px; bottom: calc(var(--status-h) + 14px); display: flex; flex-direction: column; gap: 8px; z-index: 70; max-width: min(420px, 90vw); }
.toast { padding: 10px 14px; border-radius: 10px; background: rgba(28, 31, 35, 0.94); backdrop-filter: blur(10px); box-shadow: 0 10px 40px rgba(0, 0, 0, 0.45), inset 0 0 0 1px var(--hair-2); font-size: 12.5px; border-left: 3px solid var(--accent); transition: opacity 0.4s; animation: toast-in 280ms var(--spring); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px) scale(0.98); } to { opacity: 1; transform: none; } }
.toast-error { border-left-color: var(--danger); }
.toast-warn { border-left-color: var(--warn); }
.toast-out { opacity: 0; }

/* ------------------------------------------------------------- welcome */

.welcome {
  position: absolute; inset: var(--pad); z-index: 15; display: grid; place-items: center;
  background: color-mix(in srgb, var(--bg) 80%, transparent); backdrop-filter: blur(3px); border-radius: var(--radius);
}
.welcome-card { width: min(660px, 94%); padding: 24px 24px 18px; gap: 14px; box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55), inset 0 0 0 1px var(--hair-2); }
.welcome-title { display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 600; }
.welcome-title img { width: 24px; height: 24px; }
.welcome-sub { color: var(--text-2); margin: 0; }
.welcome-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.welcome-option {
  display: flex; flex-direction: column; gap: 6px; text-align: left; padding: 14px; border: 0; border-radius: var(--radius-sm);
  background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--hair); color: var(--text); cursor: pointer;
  transition: background 140ms var(--ease), transform 160ms var(--ease), box-shadow 140ms var(--ease);
}
.welcome-option:hover { background: var(--surface-3); transform: translateY(-1px); }
.welcome-option.primary { box-shadow: inset 0 0 0 1px var(--accent-line); background: var(--accent-soft); }
.welcome-option .ico { width: 22px; height: 22px; color: var(--accent); }
.welcome-option strong { font-size: 13.5px; }
.welcome-option span { color: var(--text-3); font-size: 12px; }
.welcome-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; color: var(--text-3); font-size: 12px; }

.file-warning { max-width: 640px; margin: 10vh auto; padding: 22px; border-radius: var(--radius); background: var(--surface); box-shadow: inset 0 0 0 1px var(--hair-2); font: 14px var(--font); }
.file-warning h1 { font-size: 18px; color: var(--accent); }
.file-warning pre { background: var(--bg); padding: 8px; border-radius: 6px; color: var(--accent); }

/* ------------------------------------------------------------- woke: the CMU emblem clicked (as in Open Vehicles).
   The accent walks the pride colours, the title bar wears the flag and the main buttons run it. */
:root { transition: --accent 1100ms var(--ease), --accent-soft 1100ms var(--ease); }
:root.woke { --pride: #ff6b6b, #ffa94d, #ffd43b, #69db7c, #4dabf7, #b197fc, #ff6b6b; animation: pride 14s linear 1100ms infinite; }
@keyframes pride {
  0%, 100% { --accent: #ff8a8a; --accent-soft: rgba(255, 138, 138, 0.15); }
  17% { --accent: #ffb366; --accent-soft: rgba(255, 179, 102, 0.15); }
  33% { --accent: #ffe066; --accent-soft: rgba(255, 224, 102, 0.15); }
  50% { --accent: #7ee08a; --accent-soft: rgba(126, 224, 138, 0.15); }
  67% { --accent: #6cbcff; --accent-soft: rgba(108, 188, 255, 0.15); }
  83% { --accent: #c3a6ff; --accent-soft: rgba(195, 166, 255, 0.15); }
}
.titlebar::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; opacity: 0;
  background: linear-gradient(90deg, #e40303, #ff8c00, #ffed00, #008026, #24408e, #732982); transition: opacity 1100ms var(--ease); pointer-events: none; }
.woke .titlebar::after { opacity: 1; }
.woke .btn.btn-primary { background: linear-gradient(90deg, var(--pride)) 0 0 / 300% 100%; animation: pride-run 6s linear infinite; }
.woke .btn.btn-primary:hover { box-shadow: 0 6px 22px rgba(255, 255, 255, 0.12); }
@keyframes pride-run { to { background-position: 300% 0; } }

/* ------------------------------------------------------------- smaller windows */

@media (max-width: 1500px) {
  :root { --panel-w: 262px; --inspector-w: 360px; }
  .doc { max-width: 200px; }
}

@media (max-width: 1340px) {
  :root { --panel-w: 236px; --inspector-w: 330px; --pad: 10px; }
  .ghost:has(.ico) .lbl { display: none; }
  .ghost { padding: 6px 8px; }
  .preview-card { height: 42%; min-height: 200px; }
  .welcome-options { gap: 8px; }
}

@media (max-height: 780px) {
  .preview-card { height: 40%; min-height: 180px; }
}

@media (max-width: 1100px) {
  :root { --inspector-w: 300px; }
  .app, .app.panel-closed { grid-template-columns: var(--rail-w) 0 minmax(0, 1fr) var(--inspector-w); }
  .app .side-panel { visibility: hidden; padding: 0; }
  .app.panel-open .side-panel {
    visibility: visible; position: fixed; left: var(--rail-w); top: var(--topbar-h); bottom: var(--status-h);
    width: 280px; z-index: 25; background: var(--bg); padding: var(--pad); box-shadow: 16px 0 40px rgba(0, 0, 0, 0.5);
  }
  .welcome-options { grid-template-columns: 1fr; }
}
