/* ---------- Gallery of examples (static/css/gallery.css) ---------- */
.gal, .gv {
  --gdino: #f0cf70;
  --gdepth: #a1a6f1;
  --inst1: #f39394;
  --inst2: #f5b3db;
  --inst3: #84debb;
  --point: #8fbfe6;
  --special: #9aa3ab;
  --m-depth: #80b5ff;
  --m-sam: #e89a95;
  --ok: #009e73;
}
.tok.point { background: var(--point); border-radius: 50%; width: 0.8em; height: 0.8em; vertical-align: -0.08em; }
.tok.empty { background: #fff; border-style: dashed; }
.tok.inst2 { background: var(--inst2); }
.tok.inst3 { background: var(--inst3); }

.gal-intro {
  max-width: 760px;
  margin: -6px auto 18px;
  text-align: center;
  font-size: 15.5px;
  color: var(--aff);
}
.gal-filters {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin: 0 0 22px;
}
.gal-filters button {
  padding: 6px 14px;
  border: 1px solid var(--panel-line);
  border-radius: 999px;
  background: #fff;
  color: var(--aff);
  font: 600 13.5px/1.2 var(--sans);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.gal-filters button span { margin-left: 4px; font-weight: 500; color: var(--note); }
.gal-filters button[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.gal-filters button[aria-pressed="true"] span { color: #c9d3dc; }

.gal-grid {
  overflow-anchor: none;   /* swapping cards must not make the browser re-anchor the scroll */
  align-content: start;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
}
.gal-grid.turn-r .gal-card:not([hidden]) { animation: gp-in-r 0.32s ease both; }
.gal-grid.turn-l .gal-card:not([hidden]) { animation: gp-in-l 0.32s ease both; }
@keyframes gp-in-r { from { opacity: 0; transform: translateX(18px); } }
@keyframes gp-in-l { from { opacity: 0; transform: translateX(-18px); } }
@media (prefers-reduced-motion: reduce) { .gal-grid .gal-card { animation: none !important; } }

.gal-pager {
  overflow-anchor: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 22px;
}
.gal-pager[hidden] { display: none; }
.gal-pager > button {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--panel-line);
  border-radius: 50%;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}
.gal-pager > button:hover:not(:disabled) { border-color: var(--ink); }
.gal-pager > button:disabled { opacity: 0.35; cursor: default; }
.gal-pager svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.gp-dots { display: flex; gap: 6px; }
.gp-dots button {
  width: 7px;
  height: 7px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: var(--panel-line);
  cursor: pointer;
  transition: width 0.2s, background 0.2s;
}
.gp-dots button[aria-current="true"] { width: 18px; background: var(--ink); }

.gal-card {
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--panel-line);
  border-radius: 12px;
  background: #fff;
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(.2, .8, .2, 1), box-shadow 0.2s, border-color 0.2s;
}
.gal-card[hidden] { display: none; }
.gal-card:hover {
  transform: translateY(-3px);
  border-color: #cfdae4;
  box-shadow: 0 12px 28px rgba(24, 35, 47, 0.1);
}
.gal-card:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.gc-media {
  display: block;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: var(--panel);
}
.gc-media img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s cubic-bezier(.2, .8, .2, 1);
}
.gal-card:hover .gc-media img { transform: scale(1.04); }
.gc-body { display: flex; flex-direction: column; gap: 9px; padding: 12px 14px 14px; flex: 1; }
.gc-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.gc-title {
  font-family: var(--display);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.gc-n { font-size: 12.5px; color: var(--note); white-space: nowrap; }
.gc-src { margin-top: -6px; font-size: 12px; color: var(--note); }
.gc-tags { display: flex; flex-wrap: wrap; gap: 5px; }
.gc-tag {
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--panel-line);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--aff);
  white-space: nowrap;
}
.gc-tag.g-R { background: rgba(91, 108, 123, 0.08); }
.gc-toks {
  display: flex;
  flex-wrap: wrap;
  gap: 3px 10px;
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px dashed var(--panel-line);
  font-size: 12px;
  color: var(--aff);
}
.gc-tk { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.gc-tk .tok { margin: 0; }
.gc-tk .tok + .tok { margin-left: -1px; }
.gc-ok, .gv-ans-ok {
  flex: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--ok) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6.5 12.5l3.6 3.6 7.4-8' fill='none' stroke='%23fff' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 13px no-repeat;
}
.gal-note {
  max-width: 860px;
  margin: 16px auto 0;
  text-align: center;
  font-size: 13.5px;
  color: var(--note);
}

/* ---------- viewer ---------- */
body.gv-open { overflow: hidden; }
.gv {
  width: min(1180px, calc(100vw - 40px));
  max-width: none;
  max-height: calc(100vh - 40px);
  padding: 0;
  border: 0;
  border-radius: 16px;
  background: transparent;
  overflow: visible;
}
.gv::backdrop { background: rgba(17, 24, 32, 0.55); backdrop-filter: blur(3px); }
.gv[open] { animation: gv-in 260ms cubic-bezier(.2, .8, .2, 1); }
@keyframes gv-in { from { opacity: 0; transform: translateY(14px) scale(0.985); } }
.gv-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  height: min(680px, calc(100vh - 40px));
  padding: 18px 18px 12px;
  border: 1px solid var(--panel-line);
  border-radius: 16px;
  background: var(--panel);
  box-shadow: 0 24px 60px rgba(17, 24, 32, 0.3);
}
.gv-close {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 3;
  width: 34px;
  height: 34px;
  border: 1px solid var(--panel-line);
  border-radius: 50%;
  background: #fff;
  color: var(--aff);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.gv-close:hover { color: var(--ink); }

.gv-stage {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 28% minmax(0, 1fr) 200px;
  gap: 22px;
  padding: 18px;
  border: 1px solid var(--panel-line);
  border-radius: 12px;
  background: #fff;
}
.gv-left { display: flex; flex-direction: column; gap: 12px; min-height: 0; overflow-y: auto; }
.gv-media { margin: 0; border-radius: 8px; overflow: hidden; background: var(--panel); }
.gv-img { display: block; width: 100%; max-height: 330px; object-fit: contain; }
.gv-kind {
  margin: 0;
  font-family: var(--display);
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--aff);
}
/* question list */
.gv-qs { display: flex; flex-direction: column; gap: 6px; }
.gv-qbtn {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 9px;
  padding: 8px 10px;
  border: 1px solid var(--panel-line);
  border-radius: 9px;
  background: #fff;
  text-align: left;
  font: inherit;
  color: var(--aff);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.gv-qbtn:hover { border-color: #c9d5df; color: var(--ink); }
.gv-qbtn:focus-visible { outline: 2px solid var(--ink); outline-offset: 1px; }
.gv-qbtn .qn {
  grid-row: span 2;
  align-self: start;
  padding: 1px 6px;
  border-radius: 5px;
  background: var(--panel);
  border: 1px solid var(--panel-line);
  font: 700 11.5px/1.4 var(--sans);
  color: var(--aff);
}
.gv-qbtn .qt {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.45;
  white-space: pre-line;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.gv-qbtn .qg { font-size: 11.5px; color: var(--note); }
.gv-qbtn[aria-pressed="true"] {
  border-color: var(--ink);
  background: var(--panel);
  color: var(--ink);
}
.gv-qbtn[aria-pressed="true"] .qn { background: var(--ink); border-color: var(--ink); color: #fff; }
.gv-qbtn[aria-pressed="true"] .qt { -webkit-line-clamp: unset; display: block; }
/* a single question needs no picker look */
.gv-qs.single .gv-qbtn { cursor: default; border-color: transparent; background: none; padding: 0; }
.gv-qs.single .qn { display: none; }
.gv-qs.single .gv-qbtn { grid-template-columns: 1fr; }
.gv-src { margin: auto 0 0; font-size: 12px; color: var(--note); }

.gv-mid { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.gv-trace {
  flex: 1 1 0;
  min-height: 0;
  margin: 0;
  padding: 2px 10px 6px 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  font-size: 13.5px;
  line-height: 1.8;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--term-text);
  scrollbar-width: thin;
  scrollbar-color: #cdd7e0 transparent;
}
.gv-trace .tag { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.86em; color: #9aa8b4; }
.gv-trace .w { animation: word-in 380ms ease-out both; }
.gv-trace .tok { animation: tok-in 220ms cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.gv-trace .tok-group {
  padding: 2px 1px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s;
}
.gv-trace .tok-group:hover { background: rgba(30, 42, 54, 0.07); }
.gv-trace .tok-group:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--aff); }
.gv-trace .tok-group.focus { background: rgba(30, 42, 54, 0.1); box-shadow: 0 0 0 1.5px var(--ink); }
.gv-trace .tok-group.sent .tok:not(.sp) { box-shadow: 0 0 0 2px rgba(30, 42, 54, 0.12); }
/* a point refers back to this instance */
.gv-trace .tok-group.ping { animation: gv-ping 1.1s ease-out; }
@keyframes gv-ping {
  0% { box-shadow: 0 0 0 0 rgba(143, 191, 230, 0.9); background: rgba(143, 191, 230, 0.35); }
  60% { box-shadow: 0 0 0 7px rgba(143, 191, 230, 0); background: rgba(143, 191, 230, 0.18); }
  100% { box-shadow: 0 0 0 0 rgba(143, 191, 230, 0); background: transparent; }
}
.point-flyer { transition-property: transform; transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); }
.gv-answer {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding-top: 10px;
  border-top: 1px dashed var(--panel-line);
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  opacity: 0;
  transition: opacity 400ms ease;
}
.gv-answer.on { opacity: 1; }
.gv-answer .ans-tag { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; font-weight: 400; color: #9aa8b4; }
.gv-ans-box { padding: 1px 10px; border: 1.5px solid var(--ink); border-radius: 3px; }
.gv-ans-choice:empty { display: none; }

.gv-dec {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding-left: 20px;
  border-left: 1px dashed var(--panel-line);
  overflow-y: auto;
}
.gv-dec.idle .dec-title::after { content: " \00b7  none for this example"; font-family: var(--sans); font-weight: 500; text-transform: none; letter-spacing: 0; }
.gv-dec.idle.textonly .dec-title::after { content: " \00b7  no visual tokens in this answer"; }
.gc-none { color: var(--note); font-style: italic; }
.gv .dec-title {
  margin: 0;
  font-family: var(--display);
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--aff);
}
.gv .dec-title span { font-family: var(--sans); font-weight: 500; text-transform: none; letter-spacing: 0; }
.gdec[hidden] { display: none; }
.gdec { display: flex; flex-direction: column; gap: 8px; }

.gv .dec-box {
  display: inline-grid;
  place-items: center;
  align-self: flex-start;
  height: auto;
  padding: 5px 12px;
  border: 1.5px solid var(--ink);
  border-radius: 8px;
  background: color-mix(in srgb, var(--m-depth) 55%, #fff);
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  transition: transform 250ms ease, box-shadow 250ms ease;
}
.gv .dec-box::after { display: none; }
.gv .dec-box.sam { background: color-mix(in srgb, var(--m-sam) 60%, #fff); }
.gv .dec-box.busy { transform: scale(1.06); box-shadow: 0 0 0 5px color-mix(in srgb, var(--m-depth) 30%, transparent); }
.gv .dec-box.sam.busy { box-shadow: 0 0 0 5px color-mix(in srgb, var(--m-sam) 30%, transparent); }
.gdec-out {
  position: relative;
  width: 100%;
  max-width: 180px;
  max-height: 200px;
  aspect-ratio: 1;
  border: 1.5px dashed #c5d0da;
  border-radius: 8px;
  overflow: hidden;
  background: var(--panel);
}
.gdec.on .gdec-out { border-style: solid; border-color: var(--ink); }
.gdec.focus .gdec-out { box-shadow: 0 0 0 3px color-mix(in srgb, var(--ink) 25%, transparent); }
.gdec-out img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0;
  transition: opacity 450ms ease;
}
.gdec.on .gv-depth { opacity: 1; object-fit: fill; }
.gv-inst img.layer.on { opacity: 1; }
.gv-inst.overlay img.base { filter: brightness(0.6); }
.gdec.on .gv-inst.overlay img.base { opacity: 1; }
.gv-picks { display: flex; flex-wrap: wrap; gap: 6px; }
.gv-picks .tok {
  width: 24px;
  height: 24px;
  margin: 0;
  border-radius: 6px;
  font: 700 11.5px/1 var(--sans);
  color: var(--ink);
  cursor: pointer;
  animation: none;
}
.gv-picks .tok:disabled { opacity: 0.3; cursor: default; }
.gv-picks .tok[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--ink); }

.gv-pop {
  position: absolute;
  z-index: 4;
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-size: 12px;
  line-height: 1.35;
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.15s, transform 0.15s;
}
.gv-pop.on { opacity: 1; transform: none; }
.gv-pop span { color: #c9d3dc; }

.gv-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 2px 0;
}
.gv-bar button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--panel-line);
  border-radius: 999px;
  background: #fff;
  color: var(--aff);
  font: 600 13px/1 var(--sans);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.gv-bar button:hover { color: var(--ink); border-color: #c9d5df; }
.gv-bar button:focus-visible { outline: 2px solid var(--ink); outline-offset: 1px; }
.gv-bar svg { width: 14px; height: 14px; fill: currentColor; }
.gv-play[hidden] { display: none; }
.gv-play .i-play { display: none; }
.gv-play[aria-pressed="true"] .i-play { display: block; }
.gv-play[aria-pressed="true"] .i-pause { display: none; }
.gv-count { margin: 0 auto; font-size: 13px; color: var(--note); font-variant-numeric: tabular-nums; }
.gv-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  font-size: 12px;
  color: var(--aff);
}
.gv-legend .tok { animation: none; }

@media (max-width: 1000px) {
  .gal-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .gal-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .gc-head { flex-direction: column; align-items: flex-start; gap: 2px; }
  .gc-title { font-size: 16px; }
  .gc-body { padding: 10px 10px 12px; }
  .gc-q { font-size: 13px; }
  .gc-toks { display: none; }

  .gv { width: 100vw; max-height: 100dvh; margin: 0; border-radius: 0; }
  .gv-panel { height: 100dvh; padding: 10px 10px 8px; border-radius: 0; }
  .gv-stage {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr) auto;
    gap: 12px;
    padding: 12px;
  }
  .gv-left { display: grid; grid-template-columns: 38% 1fr; gap: 4px 12px; overflow: visible; }
  .gv-media { grid-row: span 3; }
  .gv-img { max-height: 150px; }
  .gv-left { grid-template-columns: 34% 1fr; grid-auto-flow: row dense; align-items: start; }
  .gv-media { grid-row: span 2; }
  .gv-qs { grid-column: 1 / -1; flex-direction: row; overflow-x: auto; gap: 6px; padding-bottom: 2px; }
  .gv-qs.single { flex-direction: column; }
  .gv-qbtn { flex: 0 0 78%; }
  .gv-qs.single .gv-qbtn { flex: none; }
  .gv-qbtn .qt { font-size: 12.5px; }
  .gv-src { margin: 0; }
  .gv-trace { font-size: 13px; }
  .gv-dec { flex-direction: row; padding: 10px 0 0; border-left: 0; border-top: 1px dashed var(--panel-line); overflow: visible; }
  .gv-dec .dec-title { display: none; }
  .gdec { flex: 1; flex-direction: row; align-items: flex-start; }
  .gdec-out { width: 76px; flex: none; }
  .gv .dec-box { font-size: 11px; padding: 4px 8px; }
  .gv-bar { gap: 6px; }
  .gv-bar .lbl { display: none; }
  .gv-legend { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .gal-card, .gc-media img { transition: none; }
  .gv[open] { animation: none; }
}
