/* Study graph page, in the frame from style.css. */
.graph-page { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
.graph-page .sheet { flex: 1; min-height: 0; width: 100%; display: flex; flex-direction: column; }

.intro { display: flex; align-items: baseline; justify-content: space-between; gap: 24px; padding: 24px 0 4px; }
.intro h1 { font-family: var(--serif); font-weight: 500; font-size: 28px; line-height: 1.2; letter-spacing: -0.3px; }
.intro p { color: var(--mute); font-size: 14px; }

/* tools row: exam segmented control | search | view toggle */
.tools { display: flex; align-items: center; gap: 16px; padding: 16px 0; }
.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--tint); border-radius: 8px; flex: none; }
.seg button {
  min-height: 36px; padding: 0 14px; border: none; border-radius: var(--radius); background: transparent;
  font-size: 14px; font-weight: 500; color: var(--mute); cursor: pointer; transition: color .15s, background-color .15s;
}
.seg button:hover { color: var(--ink); }
.seg button[aria-checked="true"] { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 0 0 1px var(--hair); }

.search { position: relative; flex: 1; min-width: 0; max-width: 420px; margin-left: auto; }
.search svg { position: absolute; left: 12px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%); color: var(--mute); pointer-events: none; }
.search input {
  width: 100%; min-height: 42px; padding: 0 12px 0 36px; font: 400 15px var(--sans);
  background: var(--surface); color: var(--ink); border: 1px solid var(--line-strong); border-radius: var(--radius);
}
.search input::placeholder { color: var(--mute); }
.search input:focus { outline: 2px solid var(--ring); outline-offset: -1px; border-color: transparent; }
#results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 20; list-style: none; padding: 4px;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius); max-height: 50vh; overflow: auto;
}
#results[hidden] { display: none; }
#results li { padding: 9px 10px; border-radius: 4px; cursor: pointer; display: flex; gap: 10px; align-items: center; font-weight: 500; font-size: 15px; }
#results li:hover, #results li.on { background: var(--tint); }
#results .sub { margin-left: auto; font-size: 13px; color: var(--mute); white-space: nowrap; }

/* graph box */
.stage { position: relative; flex: 1; min-height: 0; overflow: hidden; background: var(--surface); border: 1px solid var(--hair); border-radius: 8px; }
#graph { width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
#graph:active { cursor: grabbing; }
.link { stroke: var(--line-strong); stroke-width: 1; }
.link.related { stroke-dasharray: 2 4; }
.link.lit { stroke: var(--primary); stroke-opacity: 0.7; }
.node { cursor: pointer; }
.node circle { stroke: var(--surface); stroke-width: 1.5; transition: opacity .2s; }
.node.Topic circle { fill-opacity: 0.75; }
.node.Subtopic circle { fill-opacity: 0.45; }
.node.sel circle { stroke: var(--ring); stroke-width: 3; fill-opacity: 1; }
.node text {
  font-family: var(--sans); fill: var(--ink); pointer-events: none;
  paint-order: stroke; stroke: var(--surface); stroke-width: 3.5px; stroke-linejoin: round;
}
.node.Subject text { font-size: 13.5px; font-weight: 700; letter-spacing: -0.1px; }
.node.Topic text { font-size: 12px; font-weight: 600; display: none; }
.node.Subtopic text { font-size: 10.5px; font-weight: 500; display: none; }
#graph.z1 .node.Topic text, #graph.z2 .node.Subtopic text,
.node.lit text, .node.sel text, .node.match text { display: block; }
.node.dim, .link.dim { opacity: 0.12; }
.node.skip circle { opacity: 0.15; }
.node.skip text { fill: var(--mute); }
.node.match circle { stroke: var(--ring); stroke-width: 3; }

.draft, .legend { position: absolute; margin: 0; pointer-events: none; font-size: 13px; }
.draft { right: 12px; top: 12px; color: var(--mute); background: var(--tint); padding: 4px 10px; border-radius: 999px; }
.legend { left: 12px; top: 12px; display: flex; gap: 14px; padding: 4px 10px; color: var(--mute); background: var(--surface); border-radius: 999px; }
.legend[hidden], .draft[hidden], #list:not([hidden]) ~ .draft { display: none; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--ink); margin-right: 6px; vertical-align: 0; }
.dot.basic { width: 7px; height: 7px; opacity: .65; }
.dot.skip { width: 6px; height: 6px; opacity: .2; }

/* list view */
#list { position: absolute; inset: 0; overflow: auto; }
#list details + details { border-top: 1px solid var(--hair); }
#list summary { cursor: pointer; display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 0 20px; list-style: none; }
#list summary::-webkit-details-marker { display: none; }
#list summary::before {
  content: ''; width: 7px; height: 7px; flex: none; border-right: 1.5px solid var(--mute); border-bottom: 1.5px solid var(--mute);
  transform: rotate(-45deg); transition: transform .15s;
}
#list details[open] summary::before { transform: rotate(45deg); }
#list summary:hover { background: var(--tint); }
#list summary .nm { flex: 1; font-family: var(--serif); font-weight: 500; font-size: 19px; display: flex; align-items: center; gap: 10px; }
#list summary .count { font-size: 13px; color: var(--mute); }
#list ul { list-style: none; padding: 4px 20px 20px 39px; columns: 2 260px; column-gap: 32px; }
#list li { padding: 3px 0; break-inside: avoid; }
#list li ul { padding: 2px 0 4px 14px; columns: auto; border-left: 1px solid var(--hair); margin-top: 2px; }
#list a { color: var(--ink); text-decoration: none; font-weight: 500; font-size: 15px; }
#list li li a { font-weight: 400; color: var(--mute); }
#list a:hover { color: var(--link); text-decoration: underline; }
#list .lv { margin-left: 8px; font-size: 12px; color: var(--mute); }
.swatch { width: 10px; height: 10px; border-radius: 50%; flex: none; display: inline-block; }

.note { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0 6px; font-size: 13px; color: var(--mute); }
.graph-page .disclaimer { padding-bottom: 12px; font-size: 12px; }

/* ---------- topic panel ---------- */
#panel {
  position: fixed; z-index: 30; right: 0; top: 0; bottom: 0; width: min(440px, 100%);
  background: var(--surface); border-left: 1px solid var(--line-strong); overflow: auto;
}
#panel[hidden] { display: none; }
.p-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 20px; position: sticky; top: 0; background: var(--surface); border-bottom: 1px solid var(--hair); z-index: 2; }
.p-top .crumb { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; color: var(--mute); }
.p-top .crumb a { color: var(--mute); text-decoration: none; }
.p-top .crumb a:hover { color: var(--ink); text-decoration: underline; }
.p-head { padding: 20px 20px 16px; }
.p-head .kind { font-size: 13px; font-weight: 600; color: var(--primary); }
.p-head h2 { font-family: var(--serif); font-weight: 500; font-size: 32px; line-height: 1.15; margin-top: 4px; overflow-wrap: anywhere; }
.p-head .yr { display: inline-block; margin-top: 10px; font-size: 13px; font-weight: 500; padding: 2px 8px; border-radius: 999px; background: var(--tint); color: var(--mute); }
.exams { display: grid; grid-template-columns: repeat(4, 1fr); margin: 0 20px; border: 1px solid var(--hair); border-radius: var(--radius); }
.exams div { padding: 10px 12px; }
.exams div + div { border-left: 1px solid var(--hair); }
.exams b { display: block; font-size: 12px; font-weight: 500; color: var(--mute); margin-bottom: 2px; }
.exams span { font-size: 14px; font-weight: 600; }
.exams .Deep span { color: var(--primary); }
.exams .Skip span { color: var(--mute); font-weight: 400; }
.p-sum { padding: 18px 20px 8px; font-size: 16px; line-height: 1.6; }
.p-tip { margin: 8px 20px 4px; padding: 12px 14px; border-left: 3px solid var(--primary); background: var(--primary-soft); border-radius: 0 var(--radius) var(--radius) 0; }
.p-tip b { display: block; font-size: 13px; color: var(--primary); margin-bottom: 2px; }
.p-tip p { font-size: 15px; line-height: 1.5; }
.p-sec { padding: 20px 20px 4px; }
.p-sec h3 { font-size: 13px; font-weight: 600; color: var(--mute); margin-bottom: 4px; }
.res { list-style: none; }
.res li + li { border-top: 1px solid var(--hair); }
.res a { display: flex; align-items: flex-start; gap: 12px; color: var(--ink); text-decoration: none; padding: 12px 0; }
.res a:hover .t { color: var(--link); text-decoration: underline; }
.res .t { font-weight: 600; line-height: 1.35; }
.res .m { display: block; margin-top: 2px; font-size: 13px; color: var(--mute); }
.res .go { margin-left: auto; flex: none; width: 16px; height: 16px; margin-top: 3px; color: var(--mute); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 0 12px; }
.chips button {
  font-size: 14px; font-weight: 500; min-height: 36px; padding: 0 12px; background: var(--surface); color: var(--ink);
  border: 1px solid var(--line-strong); border-radius: 999px; cursor: pointer; display: flex; align-items: center; gap: 8px;
}
.chips button:hover { background: var(--tint); }
.empty { color: var(--mute); padding: 4px 0 14px; }
.p-foot { height: 24px; }

@media (max-width: 1000px) {
  .intro p { display: none; }
  .tools { flex-wrap: wrap; }
  .search { max-width: none; margin-left: 0; flex-basis: 220px; }
}
@media (max-width: 760px) {
  .intro { padding-top: 16px; }
  .intro h1 { font-size: 22px; }
  .tools { gap: 10px; padding: 12px 0; }
  .seg { width: 100%; }
  .seg button { flex: 1; padding: 0 8px; min-height: 40px; font-size: 13px; white-space: nowrap; }
  .lens button[data-lens="All"] .wide { display: none; }
  .tools .view { width: auto; }
  .stage { margin: 0 -16px; border-radius: 0; border-left: none; border-right: none; }
  .graph-page .note { padding: 8px 0 2px; }
  .graph-page .disclaimer { font-size: 11px; padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
  #list summary { padding: 0 16px; }
  #list ul { padding-left: 35px; columns: auto; }
  #panel { top: auto; left: 0; width: 100%; max-height: 66vh; border-left: none; border-top: 1px solid var(--line-strong); border-radius: 12px 12px 0 0; }
  .p-head h2 { font-size: 28px; }
  .p-foot { height: calc(20px + env(safe-area-inset-bottom)); }
}
@media (prefers-reduced-motion: reduce) { .node circle { transition: none; } }
