/* Architecture explorer (arch.js). All classes prefixed arch-. */
.arch-root { display: grid; gap: 22px; }

/* stepper */
.arch-top { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.arch-steps { display: flex; gap: 6px; flex-wrap: wrap; }
.arch-step {
  display: inline-flex; align-items: center; gap: 9px; padding: 7px 14px 7px 7px; border-radius: 99px;
  border: 1px solid var(--line); background: transparent; color: var(--muted); font-size: 13.5px; font-weight: 500; line-height: 1;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}
.arch-step i { font-style: normal; font-family: var(--mono); font-size: 11.5px; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: rgba(255, 255, 255, 0.08); color: var(--text); transition: background 0.2s, color 0.2s; }
.arch-step:hover { color: var(--text); border-color: var(--line-2); }
.arch-step[aria-pressed="true"] { color: var(--text); border-color: var(--line-2); background: rgba(255, 255, 255, 0.09); }
.arch-step[aria-pressed="true"] i { background: var(--text); color: #0a0b0e; }
.arch-ctl { display: flex; gap: 6px; align-items: center; }
.arch-ctl button { height: 36px; min-width: 36px; padding: 0 10px; border-radius: 99px; border: 1px solid var(--line-2); background: transparent; display: inline-flex; align-items: center; justify-content: center; gap: 7px; font-size: 13px; font-weight: 500; }
.arch-ctl button:hover { background: rgba(255, 255, 255, 0.08); }
.arch-ctl button:disabled { opacity: 0.35; cursor: default; }
.arch-ctl svg { width: 14px; height: 14px; }
.arch-play { padding: 0 14px 0 12px !important; }
.arch-progress { height: 2px; background: var(--line); border-radius: 2px; overflow: hidden; }
.arch-progress i { display: block; height: 100%; width: 0; background: var(--text); }
.arch-progress.is-playing i { animation: archProg var(--dur, 5s) linear forwards; }
@keyframes archProg { to { width: 100%; } }

/* explanation */
.arch-explain { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: 22px; align-items: center; min-height: 148px; }
.arch-explain h3 { font-size: clamp(25px, 2.6vw, 31px); margin-bottom: 8px; }
.arch-explain h3 span { font-family: var(--mono); font-size: 12px; letter-spacing: 0.14em; color: var(--muted); display: block; margin-bottom: 8px; text-transform: uppercase; }
.arch-explain p { color: var(--muted); font-size: 15px; max-width: 58ch; }
.arch-explain p a { color: var(--text); }
.arch-explain p code, .arch-tok code { font-family: var(--mono); font-size: 0.88em; color: var(--text); }
.arch-explain .formula { font-size: 14px; }
.arch-explain .formula + .formula { margin-top: 8px; }
.arch-swap { animation: archSwap 0.45s var(--ease); }
@keyframes archSwap { from { opacity: 0; transform: translateY(6px); } }
@media (max-width: 900px) { .arch-explain { grid-template-columns: minmax(0, 1fr); min-height: 0; } }

/* lanes */
.arch-lane { border: 1px solid var(--line); border-radius: var(--r); background: var(--bg-2); padding: 18px; display: grid; gap: 16px; min-width: 0; }
.arch-lane-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.arch-lane-head .tag b { color: var(--text); font-weight: 500; }

/* dimming driven by step */
.arch-root [data-s] { transition: opacity 0.45s, filter 0.45s; }
.arch-root [data-s]:not(.is-on) { opacity: 0.26; filter: saturate(0.35); }

/* row A: image -> models */
.arch-feed { display: grid; grid-template-columns: 132px minmax(0, 1fr); gap: 16px; align-items: stretch; }
.arch-thumb { position: relative; border-radius: 12px; overflow: hidden; border: 1px solid var(--line-2); aspect-ratio: 1; background: #000; align-self: center; }
.arch-thumb img { width: 100%; height: 100%; object-fit: cover; }
.arch-thumb span i { font-family: var(--serif); font-size: 13px; }
.arch-thumb span { position: absolute; left: 6px; bottom: 6px; font-family: var(--mono); font-size: 10px; letter-spacing: 0.08em; background: rgba(10, 11, 14, 0.78); padding: 3px 7px; border-radius: 99px; }
.arch-branches { display: grid; gap: 10px; min-width: 0; }
.arch-branch { display: flex; align-items: center; gap: 10px; min-width: 0; }
.arch-arrow { flex: none; width: 26px; height: 10px; position: relative; color: var(--dim); }
.arch-arrow::before { content: ""; position: absolute; left: 0; right: 2px; top: 4px; height: 1.5px; background: currentColor; }
.arch-arrow::after { content: ""; position: absolute; right: 0; top: 1px; width: 6px; height: 6px; border-top: 1.5px solid currentColor; border-right: 1.5px solid currentColor; transform: rotate(45deg); }
.arch-arrow.is-down { transform: rotate(90deg); }
.arch-mod {
  flex: none; font-family: var(--mono); font-size: 12px; line-height: 1.25; padding: 10px 12px; border-radius: 10px; text-align: center;
  border: 1px solid var(--line-2); background: var(--panel-2); color: var(--text);
}
.arch-mod small { display: block; color: var(--dim); font-size: 10px; letter-spacing: 0.06em; margin-top: 3px; }
.arch-prompts { flex: 1; min-width: 0; display: grid; gap: 3px; padding: 9px 12px; border-radius: 10px; border: 1px dashed var(--line-2); }
.arch-prompt { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); min-width: 0; }
.arch-prompt b { font-family: var(--mono); font-weight: 500; font-size: 10.5px; color: var(--c); flex: none; width: 20px; }
.arch-prompt span.t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1; }
.arch-prompt code { flex: none; font-family: var(--mono); font-size: 10px; color: var(--c); border: 1px solid color-mix(in srgb, var(--c) 40%, transparent); border-radius: 5px; padding: 1px 5px; }
.arch-imgtoks { display: flex; align-items: center; gap: 4px; flex: none; }
.arch-imgtoks i { width: 11px; height: 16px; border-radius: 3px; background: #7b8190; opacity: 0.85; }
.arch-imgtoks span { font-family: var(--mono); font-size: 11px; color: var(--dim); margin-left: 6px; }
@media (max-width: 720px) {
  .arch-feed { grid-template-columns: minmax(0, 1fr); }
  .arch-thumb { width: 120px; }
  .arch-branch { flex-wrap: wrap; }
  .arch-prompts { flex-basis: 100%; }
}

/* token strip: grid columns, rows = pill / model band / slot */
.arch-scroll { overflow-x: auto; overflow-y: hidden; padding-bottom: 4px; scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
.arch-strip { display: grid; grid-auto-flow: column; grid-auto-columns: max-content; grid-template-rows: auto 46px 14px auto; column-gap: 6px; justify-content: space-between; align-items: center; min-width: max-content; width: 100%; }
.arch-tok {
  grid-row: 1; font-family: var(--mono); font-size: 11px; line-height: 1; padding: 8px 9px; border-radius: 7px; white-space: nowrap; text-align: center;
  border: 1px solid var(--line-2); background: var(--panel-2); color: var(--muted); cursor: default; max-width: 300px; overflow: hidden; text-overflow: ellipsis;
}
.arch-tok:hover, .arch-tok:focus-visible { border-color: rgba(255, 255, 255, 0.4); color: var(--text); }
.arch-tok.is-text { font-family: var(--sans); font-size: 12px; border-style: dashed; border-color: color-mix(in srgb, var(--c, #fff) 45%, transparent); color: color-mix(in srgb, var(--c, #fff) 80%, #fff); }
.arch-tok.is-special { background: color-mix(in srgb, var(--c) 20%, var(--panel-2)); border-color: var(--c); color: var(--c); font-weight: 600; }
.arch-tok.is-eos { background: color-mix(in srgb, var(--glob) 16%, var(--panel-2)); border-color: var(--glob); color: var(--glob); font-weight: 600; }
.arch-tok.is-img { display: inline-flex; gap: 3px; align-items: center; padding: 6px 8px; }
.arch-tok.is-img i { width: 8px; height: 13px; border-radius: 2px; background: #7b8190; }
.arch-tok.is-img em { font-style: normal; margin-left: 4px; }
.arch-group-gap { grid-row: 1; width: 4px; }
.arch-band {
  grid-row: 2; align-self: stretch; margin: 8px 0; border-radius: 10px; position: relative; overflow: hidden;
  border: 1px solid var(--line-2); background: linear-gradient(180deg, #20232c, #171a21);
  display: flex; align-items: center; padding: 0 14px; font-family: var(--mono); font-size: 12px; letter-spacing: 0.08em; color: var(--muted);
}
.arch-band b { color: var(--text); font-weight: 500; margin-right: 10px; }
.arch-band::after { content: ""; position: absolute; inset: 0; background: linear-gradient(100deg, transparent 30%, rgba(255, 255, 255, 0.13) 50%, transparent 70%); transform: translateX(-100%); }
.arch-run .arch-band.is-on::after { animation: archSweep 1.5s var(--ease) 0.25s; }
@keyframes archSweep { to { transform: translateX(100%); } }
.arch-wire { grid-row: 2 / 4; justify-self: center; align-self: stretch; width: 2px; background: linear-gradient(180deg, transparent 0, var(--c) 18%, var(--c) 100%); position: relative; z-index: 1; opacity: 0.9; border-radius: 2px; }
.arch-wire::after { content: ""; position: absolute; left: -3px; top: 0; width: 8px; height: 8px; border-radius: 50%; background: var(--c); box-shadow: 0 0 10px var(--c); opacity: 0; }
.arch-run .arch-wire.is-on::after { animation: archDrop 0.9s var(--ease) calc(0.5s + var(--i, 0) * 0.09s) both; }
@keyframes archDrop { 0% { top: 0; opacity: 0; } 15% { opacity: 1; } 85% { opacity: 1; } 100% { top: calc(100% - 8px); opacity: 0; } }
.arch-wire.is-masked { background: repeating-linear-gradient(180deg, var(--dim) 0 3px, transparent 3px 7px); opacity: 0.6; }
.arch-wire.is-masked::after { display: none; }
.arch-slot { grid-row: 4; justify-self: center; display: grid; justify-items: center; gap: 5px; }
.arch-slot i { width: 22px; height: 22px; border-radius: 50%; background: var(--c); box-shadow: 0 0 0 4px color-mix(in srgb, var(--c) 20%, transparent); transition: background 0.3s, box-shadow 0.3s, border-color 0.3s; }
.arch-slot.is-glob i { border-radius: 5px; }
.arch-slot span { font-family: var(--mono); font-size: 10px; color: var(--c); letter-spacing: 0.04em; white-space: nowrap; }
.arch-slot.is-masked i { background: transparent; border: 1.5px dashed var(--dim); box-shadow: none; }
.arch-slot.is-masked span { color: var(--dim); }
.arch-run .arch-slot.is-on:not(.is-masked) i { animation: archPop 0.5s var(--ease) calc(1.2s + var(--i, 0) * 0.09s) backwards; }
@keyframes archPop { from { transform: scale(0); } 60% { transform: scale(1.25); } }
.arch-run .arch-tok.is-on { animation: archTok 0.4s var(--ease) calc(var(--i, 0) * 0.035s) backwards; }
@keyframes archTok { from { opacity: 0; transform: translateY(-6px); } }

.arch-legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12.5px; color: var(--dim); align-items: center; }
.arch-legend span { display: inline-flex; align-items: center; gap: 7px; }
.arch-legend i { width: 11px; height: 11px; border-radius: 50%; background: var(--muted); }
.arch-legend i.sq { border-radius: 3px; background: var(--glob); }
.arch-legend i.hollow { background: transparent; border: 1.5px dashed var(--dim); }

/* caption lane */
.arch-capbar { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.arch-capbar .tag { margin-right: 4px; }
.arch-caption { font-family: var(--serif); font-size: clamp(19px, 2vw, 23px); line-height: 1.28; color: var(--text); min-height: 2.6em; padding-left: 14px; border-left: 2px solid var(--c, var(--line-2)); transition: border-color 0.3s; }
.arch-caption small { display: block; font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--c, var(--muted)); margin-bottom: 6px; }
.arch-match { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding-top: 14px; border-top: 1px solid var(--line); }
.arch-pair { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 99px; border: 1px solid color-mix(in srgb, var(--c) 40%, transparent); font-family: var(--mono); font-size: 11px; color: var(--c); }
.arch-pair i { width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
.arch-pair i.sq { border-radius: 3px; }
.arch-pair em { font-style: normal; color: var(--dim); }
.arch-match .note { flex-basis: 100%; }

@media (prefers-reduced-motion: reduce) {
  .arch-run .arch-band.is-on::after, .arch-run .arch-wire.is-on::after { animation: none; }
}

.arch-hint { display: none; }
@media (max-width: 900px) { .arch-hint { display: block; margin-top: -8px; } }
