:root {
  --pto-aiv-core-bg: #343434;
  --pto-aiv-core-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
  --pto-aiv-muted-panel-bg: rgba(164, 176, 189, 0.18);
  --pto-aiv-muted-panel-border: rgba(164, 176, 189, 0.26);
  --pto-aiv-muted-panel-border-soft: rgba(164, 176, 189, 0.22);
  --pto-aiv-buffer-bg: rgba(77, 151, 255, 0.16);
  --pto-aiv-buffer-border: rgba(77, 151, 255, 0.32);
  --pto-aiv-panel-highlight: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  --pto-aiv-label: #ffffff;
  --pto-aiv-label-secondary: rgba(255, 255, 255, 0.92);
  --pto-aiv-badge-border: rgba(255, 255, 255, 0.10);
  --pto-aiv-badge-bg: rgba(255, 255, 255, 0.05);
  --pto-aiv-badge-fg: rgba(255, 255, 255, 0.74);
}

:root[data-theme='light'] {
  --pto-aiv-core-bg: var(--surface-2);
  --pto-aiv-core-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.86), 0 1px 2px rgba(0, 0, 0, 0.05);
  --pto-aiv-muted-panel-bg: color-mix(in srgb, var(--surface-1) 72%, var(--surface-3));
  --pto-aiv-muted-panel-border: var(--border-default);
  --pto-aiv-muted-panel-border-soft: var(--border-subtle);
  --pto-aiv-buffer-bg: color-mix(in srgb, var(--primary) 11%, var(--surface-1));
  --pto-aiv-buffer-border: color-mix(in srgb, var(--primary) 28%, var(--border-default));
  --pto-aiv-panel-highlight: inset 0 1px 0 rgba(255, 255, 255, 0.82);
  --pto-aiv-label: var(--foreground);
  --pto-aiv-label-secondary: var(--foreground-secondary);
  --pto-aiv-badge-border: var(--comp-tag-border);
  --pto-aiv-badge-bg: var(--comp-tag-bg);
  --pto-aiv-badge-fg: var(--comp-tag-fg);
}

.pto-aiv-core-pattern-page {
  min-height: 100vh;
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font-sans);
}

.pto-aiv-core-pattern-main {
  width: 100%;
  padding: 28px 24px 44px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.pto-aiv-core-pattern-title {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  line-height: 1.15;
}

.pto-aiv-core-pattern-subtitle {
  margin: 0;
  max-width: 980px;
  color: var(--foreground-secondary);
  font-size: 13px;
  line-height: 1.6;
}

.pto-aiv-core-pattern-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pto-aiv-core-pattern-badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  border: 1px solid var(--pto-aiv-badge-border);
  background: var(--pto-aiv-badge-bg);
  color: var(--pto-aiv-badge-fg);
  font: 10px/1.2 var(--text-mono, ui-monospace, monospace);
}

.pto-aiv-core-pattern-stage {
  overflow-x: auto;
  overflow-y: hidden;
}

.pto-aiv-core {
  box-sizing: border-box;
  width: 1000px;
  max-width: 1000px;
  padding: 24px 24px 28px;
  border-radius: 30px;
  background: var(--pto-aiv-core-bg);
  box-shadow: var(--pto-aiv-core-shadow);
  position: relative;
}

.pto-aiv-core__title {
  margin: 0 0 22px;
  color: var(--pto-aiv-label);
  font-size: 24px;
  font-weight: 800;
  line-height: 1;
}

.pto-aiv-core__layout {
  display: flex;
  align-items: center;
  gap: 40px;
  position: relative;
  z-index: 1;
}

.pto-aiv-core__layout > * {
  flex: 0 0 auto;
}

.pto-aiv-core__cache-stack,
.pto-aiv-core__center-stack,
.pto-aiv-core__exec-stack {
  display: flex;
  flex-direction: column;
  flex: 0 0 auto;
}

.pto-aiv-core__cache-stack {
  gap: 28px;
}

.pto-aiv-core__center-stack {
  gap: 20px;
}

.pto-aiv-core__exec-stack {
  gap: 24px;
}

.pto-aiv-core__scalar-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 0 0 auto;
}

.pto-aiv-core__instruction-slot {
  flex: 0 0 auto;
}

.pto-aiv-core__instruction-slot:empty {
  display: none;
}

.pto-aiv-core__cache,
.pto-aiv-core__buffer,
.pto-aiv-core__exec {
  box-sizing: border-box;
  padding: 14px 14px 12px;
  border-radius: 18px;
  position: relative;
  z-index: 2;
  flex: 0 0 auto;
}

.pto-aiv-core__cache {
  background: var(--pto-aiv-muted-panel-bg);
  border: 1px solid var(--pto-aiv-muted-panel-border);
  box-shadow: var(--pto-aiv-panel-highlight);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.pto-aiv-core__cache-label,
.pto-aiv-core__buffer-label,
.pto-aiv-core__exec-label,
.pto-aiv-core__buffer-capacity,
.pto-aiv-core__scalar-label,
.pto-aiv-core__vector-label {
  font-size: 14px;
}

.pto-aiv-core__cache-label,
.pto-aiv-core__exec-label,
.pto-aiv-core__buffer-label {
  color: var(--pto-aiv-label);
  font-weight: 800;
  line-height: 1;
}

.pto-aiv-core__scalar {
  box-sizing: border-box;
  border-radius: 12px;
  background: rgba(48, 139, 48, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  position: relative;
  z-index: 2;
  flex: 0 0 auto;
}

.pto-aiv-core__scalar-label,
.pto-aiv-core__vector-label {
  color: #ffffff;
  font-weight: 700;
  line-height: 1;
}

.pto-aiv-core__buffer {
  background: var(--pto-aiv-buffer-bg);
  border: 1px solid var(--pto-aiv-buffer-border);
  box-shadow: var(--pto-aiv-panel-highlight);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.pto-aiv-core__buffer-header,
.pto-aiv-core__exec-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.pto-aiv-core__buffer-capacity {
  color: var(--pto-aiv-label-secondary);
  font-weight: 500;
  line-height: 1;
}

.pto-aiv-core__simt-cache {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  margin: -2px 2px 0;
  border-radius: 12px;
  border: 1px solid color-mix(in srgb, var(--primary) 34%, var(--border-default));
  background: color-mix(in srgb, var(--primary) 18%, var(--surface-1));
  color: var(--foreground-secondary);
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.48);
}

.pto-aiv-core__exec {
  background: var(--pto-aiv-muted-panel-bg);
  border: 1px solid var(--pto-aiv-muted-panel-border-soft);
  box-shadow: var(--pto-aiv-panel-highlight);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 12px;
}

.pto-aiv-core__exec-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 52px;
  height: 28px;
  padding: 0 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
}

.pto-aiv-core__exec-label,
.pto-aiv-core__vector-label {
  line-height: 1.15;
  text-align: center;
}

.pto-aiv-core__reg-file {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 0 12px;
  border-radius: 14px;
  border: 1px solid rgba(192, 232, 255, 0.72);
  background: #3d9bdf;
  color: var(--foreground-inverse, #ffffff);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.15;
  text-align: center;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.34),
    0 1px 2px rgba(0, 0, 0, 0.12);
}

.pto-aiv-core__exec-chip.is-control {
  background: #28c9a3;
  color: #ffffff;
}

.pto-aiv-core__exec-chip.is-compute {
  background: #28c9a3;
  color: #ffffff;
}

.pto-aiv-core__vector {
  box-sizing: border-box;
  border-radius: 18px;
  background: rgba(29, 192, 108, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  position: relative;
  z-index: 2;
  flex: 0 0 auto;
}

.pto-aiv-core__grid {
  display: inline-grid;
  grid-template-columns: repeat(var(--pto-aiv-grid-cols, 8), var(--pto-aiv-grid-cell-size, 12px));
  grid-auto-rows: var(--pto-aiv-grid-cell-size, 12px);
  gap: var(--pto-aiv-grid-gap, 1px);
  width: max-content;
  align-self: flex-start;
}

.pto-aiv-core__cell {
  display: block;
  border-radius: 1px;
}

.pto-aiv-core__cell--memory {
  background: #2d75df;
  box-shadow: inset 0 0 0 1px rgba(192, 232, 255, 0.72);
}

.pto-aiv-core__cell--memory.is-band {
  background: #2d75df;
  box-shadow: inset 0 0 0 1px rgba(192, 232, 255, 0.72);
}

:root[data-theme='light'] .pto-aiv-core__cell--memory {
  background: color-mix(in srgb, var(--primary) 28%, var(--surface-1));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--primary) 22%, var(--surface-1));
}

:root[data-theme='light'] .pto-aiv-core__cell--memory.is-band {
  background: color-mix(in srgb, var(--primary) 28%, var(--surface-1));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--primary) 22%, var(--surface-1));
}

.pto-aiv-core__cell--cache {
  background: #778190;
  box-shadow: inset 0 0 0 1px rgba(239, 244, 249, 0.82);
}

.pto-aiv-core__cell--cache.is-band {
  background: #7f8998;
}

:root[data-theme='light'] .pto-aiv-core__cell--cache {
  background: color-mix(in srgb, var(--foreground-muted) 34%, var(--surface-1));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--foreground-muted) 20%, var(--surface-1));
}

:root[data-theme='light'] .pto-aiv-core__cell--cache.is-band {
  background: color-mix(in srgb, var(--foreground-muted) 38%, var(--surface-1));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--foreground-muted) 22%, var(--surface-1));
}

.pto-aiv-core__cell.is-buffer-block {
  background: color-mix(in srgb, var(--primary, #4d97ff) 76%, #2d75df);
  box-shadow:
    inset 0 0 0 1px color-mix(in srgb, var(--foreground, #ffffff) 82%, transparent),
    0 0 8px color-mix(in srgb, var(--primary, #4d97ff) 42%, transparent);
}

.pto-aiv-core__cell.is-buffer-block-tone-output,
.pto-aiv-core__cell.is-buffer-block-state-committed {
  background: color-mix(in srgb, var(--success, #29c7a6) 78%, #2d75df);
  box-shadow:
    inset 0 0 0 1px color-mix(in srgb, var(--foreground, #ffffff) 82%, transparent),
    0 0 8px color-mix(in srgb, var(--success, #29c7a6) 44%, transparent);
}

.pto-aiv-core__cell.is-buffer-block-tone-accumulator,
.pto-aiv-core__cell.is-buffer-block-state-accumulating {
  background: color-mix(in srgb, var(--warning, #ffcf59) 82%, #2d75df);
  box-shadow:
    inset 0 0 0 1px color-mix(in srgb, var(--background, #111111) 60%, transparent),
    0 0 8px color-mix(in srgb, var(--warning, #ffcf59) 48%, transparent);
}

.pto-aiv-core__cell.is-buffer-block-state-avoided {
  background: color-mix(in srgb, var(--foreground-muted, #a4b0bd) 56%, #2d75df);
  opacity: 0.48;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--foreground-muted, #a4b0bd) 58%, transparent);
}

:root[data-theme='light'] .pto-aiv-core__cell.is-buffer-block {
  background: color-mix(in srgb, var(--primary) 64%, var(--surface-1));
  box-shadow:
    inset 0 0 0 1px color-mix(in srgb, var(--primary) 28%, white),
    0 0 8px color-mix(in srgb, var(--primary) 24%, transparent);
}

.pto-aiv-core__overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 3;
  overflow: visible;
}

.pto-aiv-core__route {
  opacity: 0.92;
}

html[data-embed-preview='true'] .pto-aiv-core-pattern-page {
  height: auto;
  min-height: 0;
  background: transparent;
  overflow: hidden;
}

html[data-embed-preview='true'] .pto-aiv-core-pattern-main {
  padding: 0;
  gap: 0;
}

html[data-embed-preview='true'] .pto-aiv-core-pattern-title,
html[data-embed-preview='true'] .pto-aiv-core-pattern-subtitle,
html[data-embed-preview='true'] .pto-aiv-core-pattern-meta {
  display: none;
}

html[data-embed-preview='true'] .pto-aiv-core-pattern-stage {
  overflow: visible;
}
