/* Guide. Color names how a module connects. Row order is a separate sort. */
#guide, .guide-host { overflow-x: clip; }
#guide[hidden] { display: none; }

#guide, .guide-host {
  --g-top: #e7edff;
  --g-top-ink: #1e3a8a;
  --g-top-line: #3451c7;
  --g-bottom: #e5f6f2;
  --g-bottom-ink: #115e59;
  --g-bottom-line: #0f766e;
  --g-middle: #f8f0dc;
  --g-middle-ink: #7a4b12;
  --g-middle-line: #b7791f;
  --g-loose: #eef0f4;
  --g-loose-ink: #3f4658;
  --g-loose-line: #6b7280;
  --g-cycle: #6d28d9;
  --g-m1: #e4ebff;
  --g-m1-ink: #121726;
  --g-m2: #b7c6fb;
  --g-m2-ink: #121726;
  --g-m3: #243fa8;
  --g-m3-ink: #ffffff;
}
:root:not([data-theme="light"]) #guide,
:root:not([data-theme="light"]) .guide-host {
  --g-top: #1a2744;
  --g-top-ink: #dbe4ff;
  --g-top-line: #93a8f8;
  --g-bottom: #132e2c;
  --g-bottom-ink: #ccfbf1;
  --g-bottom-line: #5eead4;
  --g-middle: #2c2416;
  --g-middle-ink: #f6e2b8;
  --g-middle-line: #e3b341;
  --g-loose: #1c2230;
  --g-loose-ink: #e6e9f2;
  --g-loose-line: #9aa3b8;
  --g-cycle: #c4b5fd;
  --g-m1: #8aa0e6;
  --g-m1-ink: #121726;
  --g-m2: #31468a;
  --g-m2-ink: #e8ebf4;
  --g-m3: #152044;
  --g-m3-ink: #e8ebf4;
}

.guide-q { margin: 4px 0 2px; font-size: 15px; font-weight: 600; }
.guide-how { margin: 0 0 10px; font-size: 14px; }
.guide-ori, .guide-order, .guide-note, .guide-reach, .guide-meta, .guide-secondary, .guide-caption { color: var(--muted); font-size: 13px; }
.guide-order { margin: 0 0 12px; }
.guide-keyline { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; margin: 0 0 10px; min-height: 28px; }
.guide-keyline .guide-ori { margin: 0; line-height: 28px; }
.guide-file { display: inline-flex; align-items: center; text-decoration: none; font: inherit; color: var(--fg); cursor: pointer; text-align: left; }
.guide-links {
  font: inherit; cursor: pointer; text-align: center; color: var(--fg);
}
/* The reading-order bar reuses focus's Previous / Next. The pressed toggle has to beat .spot-bar button. */
.guide-walk { margin-bottom: 12px; }
.guide-walk .tgl svg { display: none; }
.guide-walk .tgl[aria-pressed="true"] { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); font-weight: 600; }
.guide-walk button:disabled { color: var(--muted); cursor: default; opacity: .55; }
.guide-flows { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.guide-flow { display: flex; flex-direction: column; gap: 0; margin: 0; }
.guide-flow h3 { margin: 0 0 4px; font-size: 12px; font-weight: 600; color: var(--muted); }
.guide-flow-row {
  display: grid; grid-template-columns: minmax(8em, 14em) minmax(0, 1fr) auto;
  gap: 4px 12px; align-items: baseline; width: 100%; min-height: 32px;
  padding: 6px 8px; border: 0; border-bottom: 1px solid var(--line);
  background: transparent; color: inherit; font: inherit; text-align: left; cursor: default;
}
button.guide-flow-row { cursor: pointer; }
button.guide-flow-row:hover, button.guide-flow-row:focus-visible { background: var(--chip); }
.guide-flow-row .guide-name { font-weight: 700; font-size: 14px; }
.guide-flow-row .guide-path { margin: 0; color: var(--muted); font-size: 12px; font-family: var(--font-mono); overflow-wrap: break-word; }
.guide-flow-row .guide-kind { color: var(--muted); font-size: 12px; white-space: nowrap; }

.guide-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; list-style: none; margin: 0; padding: 0; }
.guide-key { display: inline-flex; align-items: center; gap: 6px; min-height: 28px; font-size: 13px; line-height: 1; }
.guide-swatch {
  width: 16px; height: 16px; border-radius: 4px; display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; line-height: 1; border: 2px solid transparent; flex: 0 0 auto;
}
.guide-key-top .guide-swatch { background: var(--g-top-line); border-color: var(--g-top-line); }
.guide-key-bottom .guide-swatch { background: var(--g-bottom-line); border-color: var(--g-bottom-line); }
.guide-key-middle .guide-swatch { background: var(--g-middle-line); border-color: var(--g-middle-line); }
.guide-key-loose .guide-swatch { background: var(--g-loose-line); border-color: var(--g-loose-line); }
.guide-key-cycle .guide-swatch { background: var(--card); color: var(--g-cycle); border: 2px dashed var(--g-cycle); }
.guide-legend .chip { height: 22px; }

.guide-board { display: flex; flex-direction: column; gap: 14px; }
.guide-rank { display: flex; flex-wrap: wrap; align-items: stretch; gap: 10px; }
.guide-layer { background: transparent; border: 0; padding: 0; }
.role-top { --band-bg: var(--g-top); --band-ink: var(--g-top-ink); --band-line: var(--g-top-line); }
.role-bottom { --band-bg: var(--g-bottom); --band-ink: var(--g-bottom-ink); --band-line: var(--g-bottom-line); }
.role-middle { --band-bg: var(--g-middle); --band-ink: var(--g-middle-ink); --band-line: var(--g-middle-line); }
.role-loose { --band-bg: var(--g-loose); --band-ink: var(--g-loose-ink); --band-line: var(--g-loose-line); }
.guide-layer h3 { display: flex; align-items: center; min-height: 24px; margin: 0 0 8px; padding-bottom: 4px; border-bottom: 1px solid var(--line); font-size: 13px; font-weight: 600; color: var(--fg); }
.guide-glyph { font-weight: 700; }

.guide-tiles { display: flex; flex-wrap: wrap; gap: 10px; align-items: stretch; }
.guide-tile {
  flex: 1 1 320px;
  max-width: 440px;
  min-width: min(100%, 320px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  column-gap: 10px;
  row-gap: 8px;
  align-items: center;
  background: var(--band-bg, var(--card));
  color: var(--fg);
  border: 1px solid var(--band-line, var(--line));
  border-radius: 12px;
  padding: 10px 12px;
}
.guide-tile.is-cycle, .guide-hero.is-cycle { outline: 2px dashed var(--g-cycle); outline-offset: 2px; }
.guide-tile.is-on { box-shadow: 0 0 0 2px var(--accent); }
.guide-tile.is-peer { box-shadow: inset 0 0 0 2px var(--band-line); }
.guide-tile-open {
  display: grid; grid-template-columns: 2.4em minmax(0, 1fr) auto; column-gap: 10px; align-items: center;
  grid-column: 1 / -1; width: 100%; min-height: 44px; padding: 0; border: 0; background: transparent; color: inherit;
  font: inherit; cursor: pointer; text-align: left;
}
.guide-go, .guide-tile .guide-links, .guide-filecard > .guide-links {
  display: inline-flex; align-items: center; justify-content: center; text-align: center;
  width: 5.25em; min-height: 32px; padding: 2px 8px; font-size: 13px; font-weight: 700;
  border: 1px solid var(--band-line, var(--line)); border-radius: 8px; background: var(--card); color: var(--fg);
}
.guide-go { justify-self: end; }
.guide-id { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.guide-num { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 22px; line-height: 1; color: var(--band-ink, var(--fg)); }
.guide-name { font-weight: 700; font-size: 15px; line-height: 1.25; overflow-wrap: break-word; }
.guide-path, .guide-label, .guide-file, .guide-crumb { overflow-wrap: break-word; }
.guide-tile .guide-path, .guide-chip .guide-path, .guide-hero .guide-path { margin: 0; color: var(--muted); font-size: 12px; font-family: var(--font-mono); }
.guide-tile-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; min-height: 32px; margin: 0; padding: 0 0 0 calc(2.4em + 10px); }
.guide-tile .guide-links { justify-self: end; }
.guide-counts { font-size: 12px; color: var(--muted); white-space: nowrap; line-height: 22px; }
.guide-links[aria-expanded="true"] { border-color: var(--accent); color: var(--accent); }
.guide-cycle { font-size: 12px; font-weight: 700; color: var(--g-cycle); }

.guide-links-panel {
  margin: 12px 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
}
.guide-links-panel h3 { margin: 0 0 8px; font-size: 14px; }
.guide-split { display: grid; grid-template-columns: minmax(200px, 280px) 1fr; gap: 14px; align-items: start; margin: 8px 0 14px; }
.guide-hero {
  border: 1px solid var(--band-line, var(--line));
  border-left-width: 8px;
  background: var(--band-bg, var(--card));
  border-radius: 14px;
  padding: 12px;
}
.guide-hero.has-num { display: grid; grid-template-columns: 2.4em minmax(0, 1fr); column-gap: 10px; row-gap: 2px; align-items: center; }
.guide-hero.has-num .guide-num { grid-column: 1; grid-row: 1 / -1; align-self: center; }
.guide-hero.has-num > :not(.guide-num) { grid-column: 2; }
.guide-hero h2 { margin: 0; font-size: 18px; line-height: 1.25; }
.guide-hero .guide-meta, .guide-hero .guide-cycle { margin: 0; }
.guide-files { display: flex; flex-wrap: wrap; align-items: stretch; gap: 10px; }
.guide-file { flex-direction: column; align-items: flex-start; justify-content: center; gap: 2px; border: 0; background: transparent; padding: 0; min-height: 0; }
.guide-filecard, .guide-file-block {
  flex: 1 1 320px;
  max-width: 440px;
  min-width: min(100%, 320px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  column-gap: 10px;
  row-gap: 6px;
  align-items: center;
  border: 1px solid var(--line);
  border-left-width: 6px;
  border-radius: 12px;
  padding: 10px 12px;
  background: var(--card);
}
.guide-filecard-top { display: grid; grid-template-columns: 2.4em minmax(0, 1fr); column-gap: 10px; row-gap: 4px; align-items: center; }
.guide-filecard .guide-num { grid-row: 1 / span 2; align-self: center; }
.guide-filecard .guide-id { grid-column: 2; grid-row: 1; }
.guide-file-side { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; grid-column: 2; grid-row: 2; min-height: 22px; }
.guide-next {
  display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 999px;
  background: var(--accent); color: var(--accent-fg); font-size: 12px; font-weight: 700; line-height: 1;
}
.guide-filecard:has(.chip.good) { border-left-color: var(--good); }
.guide-filecard:has(.chip.warn) { border-left-color: var(--warn); }
.guide-filecard:has(.chip.bad) { border-left-color: var(--bad); }
.guide-filecard.is-cycle, .guide-file-block.is-cycle { outline: 2px dashed var(--g-cycle); outline-offset: 1px; }
.guide-filecard > .guide-links { align-self: center; }
.guide-more-body { grid-column: 1 / -1; margin: 0; padding-left: calc(2.4em + 10px); }
.guide-more-body p { margin: 4px 0; }
.guide-together { margin: 4px 0; font-size: 13px; font-weight: 700; color: var(--g-cycle); }
.guide-detail { margin: 8px 0; font-size: 13px; }

@media (max-width: 860px) {
  .guide-tile, .guide-filecard, .guide-file-block { flex: 1 1 100%; max-width: none; min-width: 0; }
  .guide-split { grid-template-columns: 1fr; }
  .guide-flow-row { grid-template-columns: minmax(0, 1fr) auto; min-height: 44px; }
  .guide-flow-row .guide-path { grid-column: 1 / -1; }
  .guide-go, .guide-tile .guide-links, .guide-filecard > .guide-links, .guide-file { min-height: 44px; }
}
