body.template-mode { overflow-x: hidden; }

#view-root.template-active {
  padding: 0;
  max-width: none;
}

.template-shell {
  min-height: calc(100dvh - 56px);
  padding-bottom: max(18px, env(safe-area-inset-bottom));
  background: var(--bg, #070014);
  color: var(--standard, #404040);
  --template-line: color-mix(in srgb, var(--standard, #404040) 44%, transparent);
  --template-line-strong: color-mix(in srgb, var(--special, #5e02ff) 28%, var(--standard, #404040));
  --template-surface: color-mix(in srgb, var(--foreground, #0f0f0f) 96%, var(--special, #5e02ff) 4%);
}

.template-commandbar {
  min-height: 42px;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 7px;
  padding: 5px 9px;
  border-bottom: 1px solid var(--template-line-strong);
  background: color-mix(in srgb, var(--bg, #070014) 95%, transparent);
}

.template-home,
.template-tab,
.template-chip,
.template-primary,
.template-secondary,
.template-table-row {
  appearance: none;
  font: inherit;
}

.template-home {
  width: 31px;
  height: 31px;
  padding: 0 0 2px;
  border: 1px solid var(--template-line-strong);
  border-radius: 5px;
  background: var(--foreground, #0f0f0f);
  color: var(--special, #5e02ff);
  font-size: 24px;
  line-height: 1;
}

.template-heading {
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 7px;
}

.template-heading span,
.template-eyebrow,
.template-version,
.template-status,
.template-result-count {
  font: 8px/1.1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: .09em;
}

.template-heading span,
.template-eyebrow,
.template-status,
.template-result-count { color: var(--standard, #404040); }
.template-heading strong { color: var(--special, #5e02ff); font-size: 17px; font-weight: 500; letter-spacing: .07em; }
.template-version { color: color-mix(in srgb, var(--special, #5e02ff) 56%, #ffffff 44%); }

.template-tabs {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding: 5px 8px;
  border-bottom: 1px solid var(--template-line);
  background: color-mix(in srgb, var(--bg, #070014) 95%, transparent);
  backdrop-filter: blur(12px);
  scrollbar-width: none;
}
.template-tabs::-webkit-scrollbar { display: none; }

.template-tab,
.template-chip {
  flex: 0 0 auto;
  border: 1px solid var(--template-line);
  border-radius: 5px;
  background: var(--foreground, #0f0f0f);
  color: color-mix(in srgb, var(--standard, #404040) 56%, #ffffff 44%);
}

.template-tab { min-height: 30px; padding: 0 10px; font-size: 9px; letter-spacing: .06em; }
.template-chip { min-height: 25px; padding: 0 8px; font-size: 8px; letter-spacing: .04em; }

.template-tab.is-active,
.template-chip.is-active {
  border-color: color-mix(in srgb, var(--special, #5e02ff) 62%, var(--standard, #404040));
  background: color-mix(in srgb, var(--special, #5e02ff) 16%, var(--foreground, #0f0f0f));
  color: color-mix(in srgb, var(--special, #5e02ff) 58%, #ffffff 42%);
}

.template-stage { padding: 7px 8px 12px; }
.template-view[hidden] { display: none !important; }
.template-view { display: grid; gap: 7px; }

.template-panel {
  overflow: hidden;
  border: 1px solid var(--template-line);
  border-radius: 6px;
  background: var(--template-surface);
  padding: 9px;
}

.template-intro { display: grid; gap: 10px; }
.template-intro h1,
.template-panel h2 { margin: 2px 0 3px; color: color-mix(in srgb, var(--standard, #404040) 30%, #ffffff 70%); font-weight: 500; }
.template-intro h1 { font-size: 15px; }
.template-panel h2 { font-size: 13px; }
.template-intro p:not(.template-eyebrow),
.template-empty-state > p:not(.template-eyebrow) { margin: 0; font-size: 10px; line-height: 1.45; }

.template-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border: 1px solid var(--template-line);
  border-radius: 4px;
  overflow: hidden;
}
.template-stats span { min-width: 0; display: grid; gap: 2px; padding: 7px 5px; border-right: 1px solid var(--template-line); }
.template-stats span:last-child { border-right: 0; }
.template-stats b { color: var(--special, #5e02ff); font-size: 9px; font-weight: 500; }
.template-stats small { overflow: hidden; text-overflow: ellipsis; color: var(--standard, #404040); font-size: 8px; white-space: nowrap; }

.template-tool-panel { padding: 0; }
.template-toolbar { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 5px; padding: 6px; border-bottom: 1px solid var(--template-line); }
.template-search { min-width: 0; height: 30px; display: grid; grid-template-columns: 18px minmax(0,1fr); align-items: center; padding: 0 7px; border: 1px solid var(--template-line); border-radius: 5px; background: var(--foreground, #0f0f0f); }
.template-search span { color: var(--special, #5e02ff); }
.template-search input { min-width: 0; border: 0; outline: 0; background: transparent; color: color-mix(in srgb, var(--standard, #404040) 36%, #ffffff 64%); font: 10px/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.template-search input::placeholder { color: var(--standard, #404040); opacity: .9; }

.template-primary,
.template-secondary {
  min-height: 30px;
  padding: 0 10px;
  border-radius: 5px;
  font-size: 9px;
  letter-spacing: .05em;
}
.template-primary { border: 1px solid color-mix(in srgb, var(--special, #5e02ff) 64%, var(--standard, #404040)); background: color-mix(in srgb, var(--special, #5e02ff) 18%, var(--foreground, #0f0f0f)); color: color-mix(in srgb, var(--special, #5e02ff) 62%, #ffffff 38%); }
.template-secondary { border: 1px solid var(--template-line); background: var(--foreground, #0f0f0f); color: color-mix(in srgb, var(--standard, #404040) 42%, #ffffff 58%); }

.template-filter-strip { display: flex; gap: 4px; align-items: center; overflow-x: auto; padding: 5px 6px; border-bottom: 1px solid var(--template-line); scrollbar-width: none; }
.template-filter-strip::-webkit-scrollbar { display: none; }
.template-result-count { margin-left: auto; padding: 0 2px 0 8px; white-space: nowrap; }

.template-table-head,
.template-table-row { display: grid; grid-template-columns: minmax(0, 1fr) 76px 60px; align-items: center; }
.template-table-head { min-height: 24px; border-bottom: 1px solid var(--template-line-strong); color: var(--standard, #404040); font: 8px/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: .07em; }
.template-table-head span,
.template-table-row > * { padding: 0 7px; }
.template-table-head span:nth-child(n+2),
.template-table-row > *:nth-child(n+2) { border-left: 1px solid var(--template-line); }
.template-table-row { width: 100%; min-height: 27px; padding: 0; border: 0; border-bottom: 1px solid var(--template-line); background: transparent; color: color-mix(in srgb, var(--standard, #404040) 33%, #ffffff 67%); text-align: left; font: 10px/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.template-table-row > span:nth-child(2) { color: var(--special, #5e02ff); font-size: 8px; }
.template-table-row strong { text-align: right; font-weight: 500; }
.template-table-row:active { background: color-mix(in srgb, var(--special, #5e02ff) 11%, transparent); }
.template-empty-table { margin: 0; padding: 14px; text-align: center; font: 9px/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: .08em; }

.template-panel-head { display: flex; align-items: end; justify-content: space-between; gap: 8px; margin-bottom: 7px; }
.template-panel-head h2 { margin-bottom: 0; }
.template-field { display: grid; gap: 5px; }
.template-field > span { font-size: 9px; }
.template-field textarea { box-sizing: border-box; width: 100%; resize: vertical; min-height: 96px; padding: 7px; border: 1px solid var(--template-line); border-radius: 5px; outline: 0; background: var(--bg, #070014); color: color-mix(in srgb, var(--standard, #404040) 28%, #ffffff 72%); font: 10px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.template-field textarea:focus { border-color: color-mix(in srgb, var(--special, #5e02ff) 55%, var(--standard, #404040)); }
.template-actions { display: flex; justify-content: flex-end; gap: 5px; margin-top: 6px; }

.template-list { display: grid; margin-top: 5px; border-top: 1px solid var(--template-line); }
.template-list > div { min-height: 31px; display: grid; grid-template-columns: 88px minmax(0, 1fr); align-items: center; gap: 7px; border-bottom: 1px solid var(--template-line); }
.template-list strong { color: color-mix(in srgb, var(--standard, #404040) 28%, #ffffff 72%); font-size: 9px; font-weight: 500; }
.template-list span { overflow: hidden; text-overflow: ellipsis; font: 9px/1.2 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: nowrap; }

.template-empty-state { min-height: 260px; display: grid; place-items: center; align-content: center; gap: 6px; text-align: center; }
.template-empty-mark { color: var(--special, #5e02ff); font-size: 30px; line-height: 1; }
.template-empty-state .template-primary { margin-top: 5px; }

@media (min-width: 720px) {
  .template-stage { max-width: 760px; margin: 0 auto; }
  .template-intro { grid-template-columns: 1.2fr 1fr; align-items: center; }
}


.template-surface-panel { padding-bottom: 8px; }
.template-surface-head { margin-bottom: 6px; }
.template-surface-grid {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 12px;
}

.template-surface-tile {
  width: 104px;
  margin: 0;
}

.template-surface-frame {
  width: 98px;
  height: 98px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--template-line);
  border-radius: 13px;
  background: color-mix(in srgb, var(--foreground, #0f0f0f) 92%, var(--bg, #070014));
}

.template-surface-canvas {
  display: block;
  width: 98px;
  height: 98px;
}

.template-webgl-canvas {
  filter: drop-shadow(0 0 8px color-mix(in srgb, var(--special, #5e02ff) 18%, transparent));
}

.template-surface-tile figcaption {
  display: grid;
  gap: 2px;
  padding: 6px 3px 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.template-surface-tile figcaption strong {
  color: color-mix(in srgb, var(--special, #5e02ff) 68%, #ffffff 32%);
  font-size: 9px;
  font-weight: 650;
  line-height: 1;
  letter-spacing: .07em;
}

.template-surface-tile figcaption span {
  color: var(--standard, #404040);
  font-size: 7px;
  line-height: 1;
  letter-spacing: .06em;
}

.template-surface-canvas[data-surface-unavailable] {
  background: repeating-linear-gradient(135deg, transparent 0 5px, color-mix(in srgb, var(--standard, #404040) 14%, transparent) 5px 6px);
}
