/* Ask page. Question mode: one column (question bar, answer visualization, written answer).
   Record links mode: links panel on the left, record graph on the right. Dark only. */
.ask-page { --b1: #ff9f43; --sf: #6ea8ff; --doc: #c6c5be; --link: #5ad6a0; --stage-h: 44vh; }
.ask-page [hidden] { display: none !important; }

.ask-layout { display: grid; }
.ask-layout[data-mode="links"] {
  grid-template-columns: minmax(360px, 460px) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto;
  height: calc(100dvh - var(--app-bar-h));
}
.ask-panel { display: flex; flex-direction: column; }
[data-mode="links"] .ask-panel {
  grid-column: 1; grid-row: 1; overflow-y: auto;
  padding: 0 24px 0 var(--gutter); border-right: 1px solid var(--rule); background: var(--bg-raised);
}
[data-mode="links"] .stage { grid-column: 2; grid-row: 1 / span 2; }
[data-mode="links"] .ask-foot {
  grid-column: 1; grid-row: 2; padding: 20px 24px 20px var(--gutter);
  border-right: 1px solid var(--rule); background: var(--bg-raised);
}

.ask-layout[data-mode="ask"] {
  grid-template-columns: minmax(0, 1fr); width: 100%; max-width: 1440px; margin: 0 auto;
  padding: 0 var(--gutter-r) 32px var(--gutter);
}
[data-mode="ask"] .stage { display: none; }
[data-mode="ask"] #pane-ask {
  display: grid; grid-template-columns: minmax(0, 560px) minmax(0, 1fr); grid-template-rows: auto auto 1fr;
  column-gap: 56px; align-items: start; padding-bottom: 24px;
}
[data-mode="ask"] #pane-ask > :not(.questions) { grid-column: 1; }
[data-mode="ask"] #pane-ask .questions { grid-column: 2; grid-row: 1 / span 3; }
[data-mode="ask"] .questions .block-title { margin-top: 20px; }

.dot { display: inline-block; flex: none; width: 8px; height: 8px; border-radius: 50%; }
.dot-b1 { background: var(--b1); }
.dot-sf { background: var(--sf); }
.dot-link { background: var(--link); }
.dot-doc { width: 7px; height: 7px; border-radius: 1px; background: var(--doc); transform: rotate(45deg); }

.mode-tabs { display: inline-flex; align-self: flex-start; margin-top: 20px; border: 1px solid var(--rule); border-radius: 2px; }
.mode-tabs button {
  min-height: 40px; padding: 0 14px; background: transparent; border: 0; cursor: pointer;
  color: var(--muted); font: 500 13.5px var(--font-display);
}
.mode-tabs button:hover { color: var(--text); }
.mode-tabs button[aria-selected="true"] { background: var(--surface); color: var(--text); }

.ask-title {
  margin: 20px 0 16px; color: var(--text); font: 300 26px/1.15 var(--font-display);
  letter-spacing: -0.01em; text-wrap: balance;
}
.block-title { margin: 24px 0 10px; color: var(--faint); font: 500 12px var(--font-mono); }

.ask-form { display: flex; gap: 8px; }
.ask-form input {
  flex: 1; min-width: 0; height: 48px; padding: 0 14px; background: var(--bg);
  border: 1px solid var(--rule-strong); border-radius: 2px; color: var(--text); font: 400 16px var(--font-display);
}
.ask-form input::placeholder { color: var(--faint); }
.ask-form input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.ask-form .btn { padding: 0 20px; }
.ask-note { margin: 10px 0 0; color: var(--muted); font-size: 13.5px; line-height: 1.4; }
.ask-note:empty { display: none; }

.question-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); }
.question-list button {
  display: block; width: 100%; min-height: 48px; padding: 12px 0; background: none; border: 0;
  border-bottom: 1px solid var(--rule); cursor: pointer; text-align: left;
  color: var(--text-body); font: 400 15px/1.35 var(--font-display);
}
.question-list button:hover { color: var(--text); }
.question-list button[aria-current="true"] { padding-left: 12px; color: var(--text); box-shadow: inset 2px 0 0 var(--accent); }

.answer { max-width: 760px; margin-top: 40px; padding-top: 24px; border-top: 1px solid var(--rule); }
.answer-question { margin: 0 0 16px; color: var(--text); font: 500 17px/1.3 var(--font-display); }

.answer-text p { margin: 0 0 12px; color: var(--text-body); font-size: 15.5px; line-height: 1.65; }
.cite {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%; margin: 0 1px; padding: 1px 7px 1px 6px;
  overflow: hidden; background: var(--surface); border: 1px solid var(--rule-strong); border-radius: 2px; cursor: pointer;
  color: var(--text); font: 500 12px/1.5 var(--font-mono); white-space: nowrap; text-overflow: ellipsis; vertical-align: baseline;
}
.cite:hover, .cite:focus-visible { border-color: var(--text); }

.run-stats { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 16px 0 0; color: var(--faint); font: 400 12px var(--font-mono); }

.links-lede { margin: 0; color: var(--text-body); font-size: 15px; line-height: 1.55; }
.link-total { margin: 18px 0 0; color: var(--muted); font-size: 14px; line-height: 1.35; }
.link-total strong { display: block; margin-bottom: 2px; color: var(--text); font: 300 34px/1.1 var(--font-display); letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.rule-list { display: grid; gap: 12px; list-style: none; margin: 0; padding: 0; }
.rule-row { display: grid; grid-template-columns: 1fr auto; gap: 5px 12px; color: var(--text-body); font-size: 13.5px; }
.rule-count { color: var(--text); font: 400 12.5px var(--font-mono); font-variant-numeric: tabular-nums; }
.rule-bar { grid-column: 1 / -1; height: 6px; background: var(--grid); border-radius: 0 3px 3px 0; }
.rule-bar i { display: block; height: 100%; min-width: 2px; background: var(--link); border-radius: 0 3px 3px 0; }
.rule-bar.is-held i { background: var(--faint); }
.bridge-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); }
.bridge-list button {
  display: grid; gap: 2px; width: 100%; min-height: 48px; padding: 10px 0; background: none; border: 0;
  border-bottom: 1px solid var(--rule); cursor: pointer; text-align: left; color: var(--text); font: 400 14.5px/1.35 var(--font-display);
}
.bridge-meta { color: var(--faint); font: 400 12px var(--font-mono); }
.bridge-list button:hover .bridge-meta { color: var(--text-body); }

.ask-foot { margin: 0; padding-top: 40px; color: var(--faint); font-size: 12px; }

.stage { position: relative; min-width: 0; overflow: hidden; background: var(--bg); }
.stage::before {
  content: ""; position: absolute; left: 50%; top: 0; bottom: 0; width: 1px;
  background: linear-gradient(to bottom, transparent, var(--rule) 14%, var(--rule) 86%, transparent);
}
.stage.is-portrait::before {
  left: 0; right: 0; top: 50%; bottom: auto; width: auto; height: 1px;
  background: linear-gradient(to right, transparent, var(--rule) 14%, var(--rule) 86%, transparent);
}
/* The canvas stops short of the top and bottom strips, so records never sit under the labels. */
.stage canvas { position: absolute; left: 0; top: 44px; display: block; width: 100%; height: calc(100% - 96px); }
.system-tag {
  position: absolute; top: 16px; display: flex; align-items: center; gap: 8px; margin: 0; pointer-events: none;
  color: var(--text); font: 500 12.5px var(--font-mono);
}
.system-tag i { width: 8px; height: 8px; border-radius: 50%; }
.system-tag span { color: var(--faint); font-weight: 400; }
.system-b1 { left: 20px; }
.system-b1 i { background: var(--b1); }
.system-sf { right: 20px; }
.system-sf i { background: var(--sf); }
.stage.is-portrait .system-tag { top: 10px; left: 14px; right: auto; }
.stage.is-portrait .system-sf { top: auto; bottom: 10px; }
.stage.is-portrait .system-tag span { display: none; }

.legend {
  position: absolute; left: 20px; right: 20px; bottom: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 22px;
  height: 52px; list-style: none; margin: 0; padding: 0; pointer-events: none; color: var(--muted); font-size: 12.5px;
}
.legend li { display: flex; align-items: center; gap: 9px; }
.key { flex: none; width: 9px; height: 9px; border-radius: 50%; }
.key-b1 { background: var(--b1); }
.key-sf { background: var(--sf); }
.key-doc { width: 8px; height: 8px; border-radius: 1px; background: var(--doc); transform: rotate(45deg); }
.key-link { width: 16px; height: 2px; margin: 0 -3.5px; border-radius: 0; background: var(--link); }

.record-card {
  position: fixed; right: 16px; top: calc(var(--app-bar-h) + 16px); z-index: 40; width: 340px;
  max-height: calc(100dvh - var(--app-bar-h) - 32px); overflow-y: auto;
  padding: 14px 16px 16px; background: rgba(17, 18, 20, 0.95); border: 1px solid var(--rule-strong); border-radius: 2px;
}
.record-card:focus { outline: none; }
.card-head { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 2px 12px; }
.card-source { display: flex; align-items: center; gap: 8px; margin: 0; color: var(--text-body); font: 400 12px var(--font-mono); }
.card-source span { color: var(--faint); }
.card-close {
  min-height: 32px; padding: 0 10px; background: none; border: 1px solid var(--rule); border-radius: 2px; cursor: pointer;
  color: var(--muted); font: 500 12.5px var(--font-display);
}
.card-close:hover { color: var(--text); border-color: var(--rule-strong); }
.card-type { grid-column: 1 / -1; margin: 10px 0 0; color: var(--muted); font-size: 12.5px; }
.card-title { grid-column: 1 / -1; margin: 0; color: var(--text); font: 500 18px/1.25 var(--font-display); overflow-wrap: anywhere; }
.card-fields { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 7px 12px; margin: 14px 0 0; font-size: 13.5px; line-height: 1.4; }
.card-fields dt { color: var(--faint); font: 400 11.5px/1.6 var(--font-mono); }
.card-fields dd { margin: 0; color: var(--text); overflow-wrap: anywhere; }
.card-sub { margin: 16px 0 6px; color: var(--faint); font: 500 12px var(--font-mono); }
.record-links ul { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); }
.link-row {
  display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 0 9px; width: 100%; min-height: 40px;
  padding: 7px 0; background: none; border: 0; border-bottom: 1px solid var(--rule); cursor: pointer; text-align: left;
  color: var(--text); font: 400 13.5px/1.3 var(--font-display);
}
.link-rel { grid-column: 2; color: var(--faint); font: 400 11.5px var(--font-mono); }
.link-row:hover .link-rel { color: var(--text-body); }

@media (max-width: 1100px) {
  .ask-layout[data-mode="links"] { grid-template-columns: 380px minmax(0, 1fr); }
  [data-mode="links"] .ask-panel, [data-mode="links"] .ask-foot { padding-right: 20px; }
}

@media (max-width: 900px) {
  .ask-layout[data-mode="links"] { display: flex; flex-direction: column; height: auto; }
  [data-mode="ask"] #pane-ask { display: block; }
  [data-mode="links"] .ask-foot { padding: 28px var(--gutter) 24px; border-right: 0; }
  .stage {
    order: -1; position: sticky; top: var(--app-bar-h); z-index: 5; flex: none;
    height: var(--stage-h); min-height: 280px; border-bottom: 1px solid var(--rule);
  }
  [data-mode="links"] .ask-panel {
    overflow: visible; min-height: calc(100dvh - var(--app-bar-h) - var(--stage-h) - 80px);
    padding: 0 var(--gutter) 0; border-right: 0;
  }
  .legend { display: none; }
  .stage canvas { top: 34px; height: calc(100% - 44px); }
  .system-tag { top: 10px; font-size: 11.5px; }
  .system-b1 { left: 14px; }
  .system-sf { right: 14px; }
  .system-tag span { display: none; }
  .record-card {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; width: auto; max-height: 54vh;
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px)); border-width: 1px 0 0;
  }
}
