:root {
  color-scheme: dark;
  --bg: #0b0d12;
  --panel: #141821;
  --card: #1b202b;
  --border: #2a3140;
  --text: #e6e9ef;
  --muted: #8b93a6;
  --accent: #4da3ff;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.shell { display: flex; flex-direction: column; height: 100vh; }

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}
header h1 { margin: 0; font-size: 1.1rem; }
.eyebrow { margin: 0; font-size: 0.7rem; letter-spacing: 0.04em; color: var(--accent); text-transform: uppercase; }

.brand { min-width: 0; }
.brand .eyebrow { font-size: 0.62rem; }
.topnav { display: flex; gap: 0.3rem; flex-wrap: wrap; justify-content: center; padding: 0 1rem; }
.topnav-link {
  font-size: 0.72rem; color: var(--muted); text-decoration: none;
  padding: 0.28rem 0.5rem; border: 1px solid transparent; border-radius: 6px;
}
.topnav-link:hover { color: var(--text); border-color: var(--border); background: #0f131b; }

main { flex: 1; display: flex; min-height: 0; }

.rail {
  flex: 0 0 12rem;
  overflow-y: auto;
  border-right: 1px solid var(--border);
  background: var(--panel);
  padding: 0.75rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.rail-title { margin: 0.6rem 0 0.2rem; font-size: 0.62rem; letter-spacing: 0.05em; color: var(--muted); text-transform: uppercase; }
.rail-title:first-child { margin-top: 0; }
.rail-link {
  font-size: 0.75rem; color: var(--muted); text-decoration: none;
  padding: 0.3rem 0.5rem; border-radius: 6px; border: 1px solid transparent;
}
.rail-link:hover { color: var(--text); border-color: var(--border); background: #0f131b; }

.stage { flex: 1; display: flex; flex-direction: column; min-width: 0; }
canvas.viewport { flex: 1; width: 100%; height: 100%; background: #05070a; touch-action: none; cursor: crosshair; }

.global-footer {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  flex-shrink: 0;
  padding: 0.15rem 1rem;
  font-size: 0.72rem; color: var(--muted); line-height: 1.2;
  border-top: 1px solid var(--border); background: var(--panel);
}
.global-footer .notice { padding: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.footer-right { display: flex; align-items: center; gap: 1rem; white-space: nowrap; }
.footer-facts,
.footer-right .facts { display: flex; align-items: center; list-style: none; margin: 0; padding: 0; gap: 0.45rem; font-size: 0.68rem; }
.footer-right .facts li { padding: 0; }
.footer-right .facts li + li::before { content: "·"; margin-right: 0.45rem; color: var(--muted); }
.footer-versions { display: flex; align-items: center; gap: 0.75rem; }
.footer-versions span { font-size: 0.68rem; color: var(--muted); }
.footer-stats { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

.panel {
  width: 340px;
  overflow-y: auto;
  border-left: 1px solid var(--border);
  background: var(--panel);
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.card { background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 0.75rem; }
.card .eyebrow { margin-bottom: 0.4rem; }
.facts { list-style: none; margin: 0; padding: 0; font-size: 0.8rem; }
.facts li { padding: 0.1rem 0; }
.scope { font-size: 0.75rem; color: var(--muted); margin: 0.2rem 0; }
.guid { font-family: monospace; font-size: 0.75rem; word-break: break-all; margin: 0.2rem 0; }

.field { display: flex; flex-direction: column; gap: 0.2rem; font-size: 0.75rem; color: var(--muted); margin: 0.4rem 0; }
.field input[type="text"] {
  background: #0f131b; border: 1px solid var(--border); border-radius: 4px;
  color: var(--text); padding: 0.35rem 0.5rem; font-size: 0.85rem;
}

.slider { display: flex; align-items: center; gap: 0.4rem; font-size: 0.75rem; color: var(--muted); }
.slider input[type="range"] { flex: 1; }

.row { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.5rem; }
.button, .chip {
  border: 1px solid var(--border); background: #0f131b; color: var(--text);
  border-radius: 6px; padding: 0.4rem 0.6rem; font-size: 0.75rem; cursor: pointer;
}
.button { background: var(--accent); color: #061018; border-color: var(--accent); font-weight: 600; }
.button:disabled { opacity: 0.5; cursor: default; }
.chip:hover { border-color: var(--accent); }
.chip.active { border-color: var(--accent); color: var(--accent); background: rgba(64, 162, 255, 0.1); }

.log { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; max-height: 260px; overflow-y: auto; }
.log pre { margin: 0.2rem 0 0; font-size: 0.68rem; white-space: pre-wrap; word-break: break-all; background: #0f131b; padding: 0.4rem; border-radius: 4px; border: 1px solid var(--border); }

.warn { font-size: 0.75rem; color: #ffb454; margin: 0.3rem 0; }
.conflict { font-size: 0.75rem; color: #ff6b6b; margin: 0.3rem 0; padding: 0.4rem; background: rgba(255, 107, 107, 0.08); border: 1px solid rgba(255, 107, 107, 0.35); border-radius: 4px; }

.proplist { list-style: none; margin: 0.3rem 0; padding: 0; display: flex; flex-direction: column; gap: 0.15rem; max-height: 180px; overflow-y: auto; }
.propitem {
  display: flex; justify-content: space-between; gap: 0.5rem;
  padding: 0.3rem 0.5rem; border-radius: 4px; cursor: pointer;
  border: 1px solid transparent; font-size: 0.75rem;
}
.propitem:hover { border-color: var(--border); }
.propitem.active { border-color: var(--accent); background: rgba(77, 163, 255, 0.1); }
.propname { color: var(--text); font-family: monospace; }
.propvalue { color: var(--muted); text-align: right; word-break: break-all; }

.model-tree-list { list-style: none; margin: 0.4rem 0 0; padding: 0; display: flex; flex-direction: column; gap: 0.35rem; max-height: 320px; overflow-y: auto; }
.model-tree-entry { display: flex; align-items: center; justify-content: space-between; gap: 0.4rem; border-top: 1px solid var(--border); padding-top: 0.35rem; }
.tree-entry-copy { min-width: 0; display: flex; flex-direction: column; gap: 0.08rem; }
.tree-collection { color: var(--accent); font-size: 0.68rem; }
.tree-guid { color: var(--text); font-family: monospace; font-size: 0.68rem; overflow-wrap: anywhere; }
.tree-actions { display: flex; flex-direction: column; gap: 0.25rem; flex: 0 0 auto; }
.tree-actions .chip { padding: 0.25rem 0.4rem; font-size: 0.68rem; }

.hierarchy-tabs { display: flex; gap: 0.25rem; margin: 0.5rem 0 0.4rem; flex-wrap: wrap; }
.hierarchy-tab {
  flex: 1 1 auto;
  padding: 0.3rem 0.5rem;
  font-size: 0.7rem;
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
}
.hierarchy-tab.active { color: var(--text); border-color: var(--accent); background: var(--panel); }
.hierarchy-list { list-style: none; margin: 0.4rem 0 0; padding: 0; display: flex; flex-direction: column; gap: 0.35rem; max-height: 320px; overflow-y: auto; }
.hierarchy-list .tree-group { color: var(--accent); font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; margin-top: 0.2rem; }
.hierarchy-awaiting { display: flex; flex-direction: column; gap: 0.35rem; padding: 0.5rem 0; border-top: 1px solid var(--border); }

.history { list-style: none; margin: 0.4rem 0 0; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; max-height: 320px; overflow-y: auto; }
.history li { border-top: 1px solid var(--border); padding-top: 0.4rem; }
.history-outcome { margin: 0.15rem 0; font-size: 0.68rem; color: var(--accent); }
.history-receipt { margin-top: 0.2rem; }
.history-receipt summary { font-size: 0.68rem; color: var(--muted); cursor: pointer; }
.history-receipt summary:hover { color: var(--text); }
.history-receipt pre { margin: 0.25rem 0 0; font-size: 0.62rem; white-space: pre-wrap; word-break: break-all; background: #0f131b; padding: 0.35rem; border-radius: 4px; border: 1px solid var(--border); max-height: 140px; overflow-y: auto; }

.kbd { display: inline-block; padding: 0.05rem 0.35rem; border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 4px; background: #0f131b; color: var(--text); font-size: 0.68rem; margin: 0 0.1rem; }
