:root {
  color-scheme: dark;
  --bg: #11110f;
  --panel: #181815;
  --panel-raised: #1e1e1a;
  --line: #303029;
  --line-soft: #252520;
  --text: #f1efe6;
  --muted: #98978d;
  --accent: #d6f04b;
  --accent-soft: rgba(214, 240, 75, 0.12);
  --danger: #ff755f;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; overflow: hidden; }
body { background: var(--bg); color: var(--text); }
button, input, select { font: inherit; }
button, select { user-select: none; }

.app-shell { height: 100%; display: grid; grid-template-rows: 72px minmax(0, 1fr); }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(17, 17, 15, 0.96);
  z-index: 5;
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 270px; }
.brand-mark {
  width: 38px; height: 38px; display: grid; place-items: center;
  border: 1px solid #73784a; border-radius: 50%; color: var(--accent);
  font: 800 19px/1 Georgia, serif; box-shadow: inset 0 0 0 3px #202319;
}
.brand h1 { margin: 0; font-size: 15px; letter-spacing: .045em; text-transform: uppercase; }
.brand p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }

.toolbar { display: flex; gap: 8px; align-items: center; }
.tool-button, .icon-button {
  border: 1px solid var(--line); color: #cbc9bf; background: var(--panel);
  border-radius: 6px; cursor: pointer; transition: .15s ease;
}
.tool-button { padding: 8px 12px; font-size: 12px; font-weight: 650; }
.tool-button:hover, .icon-button:hover { border-color: #555548; color: #fff; background: #23231e; }
.tool-button.is-active { color: var(--accent); border-color: #626942; background: var(--accent-soft); }
.tool-button-primary { color: #15160d; background: var(--accent); border-color: var(--accent); }
.tool-button-primary:hover { color: #111; background: #e3fa63; border-color: #e3fa63; }

.workspace { min-height: 0; display: grid; grid-template-columns: 260px minmax(320px, 1fr) 280px; }
.sidebar, .inspector { min-height: 0; background: var(--panel); }
.sidebar { display: flex; flex-direction: column; border-right: 1px solid var(--line); }
.inspector { display: grid; grid-template-rows: 44px minmax(0, 1fr); border-left: 1px solid var(--line); }
.inspector-tabs { display: grid; grid-template-columns: 1fr 1fr; border-bottom: 1px solid var(--line); background: #121210; }
.inspector-tab {
  position: relative; border: 0; color: #74746b; background: transparent; cursor: pointer;
  font-size: 10px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase;
}
.inspector-tab::after { content: ""; position: absolute; right: 0; bottom: -1px; left: 0; height: 2px; background: transparent; }
.inspector-tab:hover { color: #c9c8be; background: #171714; }
.inspector-tab.is-active { color: var(--accent); }
.inspector-tab.is-active::after { background: var(--accent); }
.inspector-panel { min-height: 0; padding: 22px; overflow-y: auto; scrollbar-color: #3e3e36 transparent; }
.inspector-panel:not(.is-active) { display: none; }

.sidebar-controls { padding: 16px 14px 12px; border-bottom: 1px solid var(--line-soft); }
.search-box { position: relative; display: flex; align-items: center; margin-bottom: 14px; }
.search-box svg { position: absolute; left: 10px; width: 15px; fill: none; stroke: #818177; stroke-width: 1.7; }
.search-box input {
  width: 100%; height: 38px; padding: 0 38px 0 34px; color: var(--text);
  border: 1px solid var(--line); border-radius: 6px; outline: none; background: #131310;
}
.search-box input:focus { border-color: #788342; box-shadow: 0 0 0 3px var(--accent-soft); }
.search-box kbd { position: absolute; right: 9px; color: #68685f; font: 11px ui-monospace, monospace; }
.package-label { display: block; margin-bottom: 6px; color: var(--muted); font-size: 10px; font-weight: 750; letter-spacing: .12em; text-transform: uppercase; }
.sidebar select {
  width: 100%; height: 36px; padding: 0 10px; border: 1px solid var(--line);
  border-radius: 6px; color: #dddcd3; background: #131310; outline: none;
}
.list-summary { padding: 10px 14px 8px; color: #707068; font-size: 11px; }
.model-list { min-height: 0; overflow-y: auto; padding: 0 8px 12px; scrollbar-color: #3e3e36 transparent; }
.model-item {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 9px 9px; border: 0; border-left: 2px solid transparent; border-radius: 3px;
  color: #c7c5bb; background: transparent; text-align: left; cursor: pointer;
}
.model-item:hover { background: #20201b; color: #fff; }
.model-item.is-selected { border-left-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.model-item-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.model-item-count { flex: none; color: #66665e; font: 10px ui-monospace, monospace; }

.viewport { position: relative; min-width: 0; min-height: 0; overflow: hidden; background: radial-gradient(circle at 50% 42%, #282821 0, #171714 48%, #10100e 100%); }
#canvas { display: block; width: 100%; height: 100%; outline: none; }
.viewport-badge, .viewport-hint { position: absolute; z-index: 2; color: #77776e; pointer-events: none; font-size: 10px; letter-spacing: .1em; }
.viewport-badge { top: 14px; left: 16px; padding: 5px 7px; border: 1px solid #3b3b33; border-radius: 4px; background: rgba(17,17,15,.72); }
.viewport-hint { bottom: 13px; left: 50%; transform: translateX(-50%); white-space: nowrap; letter-spacing: .025em; }
.loading-panel, .empty-state {
  position: absolute; inset: 0; z-index: 4; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 9px; background: rgba(15,15,13,.78); backdrop-filter: blur(5px);
}
[hidden] { display: none !important; }
.loading-panel { color: #b9b8ae; font-size: 12px; }
.spinner { width: 28px; height: 28px; border: 2px solid #45453c; border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty-state span { color: var(--muted); font-size: 12px; }

.inspector-heading { position: relative; padding-right: 32px; }
.eyebrow { color: var(--accent); font-size: 10px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.inspector h2 { margin: 6px 0 0; font-size: 22px; line-height: 1.15; overflow-wrap: anywhere; }
.icon-button { position: absolute; top: 2px; right: 0; width: 30px; height: 30px; padding: 6px; }
.icon-button svg { width: 100%; fill: none; stroke: currentColor; stroke-width: 1.8; }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; margin: 22px 0; border: 1px solid var(--line); background: var(--line); }
.stat-grid div { padding: 12px; background: #151512; }
.stat-grid span { display: block; margin-bottom: 5px; color: #74746b; font-size: 9px; font-weight: 750; letter-spacing: .1em; text-transform: uppercase; }
.stat-grid strong { font: 650 15px ui-monospace, SFMono-Regular, Consolas, monospace; }
.detail-section { padding: 17px 0; border-top: 1px solid var(--line-soft); }
.detail-section h3 { margin: 0 0 12px; color: #8c8b82; font-size: 10px; letter-spacing: .1em; text-transform: uppercase; }
.detail-list { margin: 0; }
.detail-list div { display: flex; justify-content: space-between; gap: 16px; padding: 5px 0; font-size: 11px; }
.detail-list dt { color: #77776e; }
.detail-list dd { margin: 0; color: #d1cfc5; text-align: right; }
.path-section code { display: block; padding: 9px; color: #b5b4aa; background: #121210; border-radius: 4px; font: 10px/1.5 ui-monospace, monospace; overflow-wrap: anywhere; }
.archive-note { margin: 3px 0; color: #74746b; font-size: 10px; line-height: 1.55; }
.archive-note code { color: #a9a89e; }
.panel-lede { margin: 12px 0 22px; color: #aaa99f; font-size: 12px; line-height: 1.65; }
.panel-lede strong { color: var(--text); }
.sidebar-card { margin-bottom: 8px; padding: 16px; border: 1px solid #303327; border-radius: 7px; background: #151612; }
.sidebar-card h3, #archive-panel .detail-section h3 { color: var(--accent); font-weight: 800; }
.sidebar-card h3 { margin: 0 0 10px; font-size: 10px; letter-spacing: .1em; text-transform: uppercase; }
.sidebar-card p, #archive-panel .detail-section p { margin: 0; color: #9e9d93; font-size: 11px; line-height: 1.65; }
.sidebar-card kbd { padding: 1px 4px; border: 1px solid #424239; border-radius: 3px; color: #d4d2c8; background: #11110f; font: 10px ui-monospace, monospace; }

.toast { position: fixed; left: 50%; bottom: 22px; z-index: 10; transform: translate(-50%, 16px); padding: 9px 13px; border: 1px solid #4b4b41; border-radius: 5px; color: #e4e2d8; background: #22221d; opacity: 0; pointer-events: none; transition: .2s ease; font-size: 12px; }
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@media (max-width: 900px) {
  .workspace { grid-template-columns: 220px minmax(300px, 1fr); }
  .inspector { display: none; }
  .toolbar .tool-button:not(.tool-button-primary) { display: none; }
}

@media (max-width: 620px) {
  .app-shell { grid-template-rows: 62px minmax(0, 1fr); }
  .workspace { grid-template-columns: 1fr; grid-template-rows: 210px minmax(280px, 1fr); }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); }
  .topbar { padding: 0 12px; }
  .brand p { display: none; }
  .brand { min-width: 0; }
  .model-list { display: grid; grid-template-columns: 1fr 1fr; }
}
