:root {
  color-scheme: light;
  --ink: #20192e;
  --muted: #625b70;
  --soft: #eae6f0;
  --paper: #faf9fc;
  --purple: #6949c5;
  --purple-dark: #5237a2;
  --lavender: #f1ecfc;
  font-family: "Hiragino Sans", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
  line-height: 1.5;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; }
button, input { font: inherit; }
button { cursor: pointer; }
a { color: var(--purple-dark); text-underline-offset: 3px; }
button:focus-visible, a:focus-visible, .node:focus-visible { outline: 2px solid var(--purple); outline-offset: 4px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }

.masthead { border-bottom: 1px solid var(--soft); background: #fff; }
.masthead-inner { max-width: 1160px; margin: auto; padding: 0 34px; height: 65px; display: flex; align-items: center; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-size: 14px; font-weight: 750; letter-spacing: .03em; }
.brand-icon { display: grid; place-items: center; width: 31px; height: 31px; background: var(--purple); border-radius: 9px; color: white; }
.brand-icon svg { width: 29px; height: 29px; }
.brand-icon path { fill: none; stroke: currentColor; stroke-width: 1.5; }
.brand-icon circle { fill: currentColor; }

main { width: min(960px, calc(100% - 64px)); margin: 0 auto; }
.intro { text-align: center; margin: 68px auto 35px; }
.intro h1 { margin: 0; font-size: clamp(29px, 5.2vw, 51px); font-weight: 800; line-height: 1.27; letter-spacing: -.045em; }
.period { color: var(--purple); }
.intro p { margin: 15px 0 0; color: var(--muted); font-size: 14px; letter-spacing: .035em; }
.workspace { max-width: 656px; margin: 0 auto 31px; }
.modes { display: inline-flex; align-items: center; gap: 2px; border: 1px solid #e9e3f1; background: #f0edf5; border-radius: 12px; padding: 4px; }
.modes button { display: flex; align-items: center; gap: 7px; padding: 7px 13px; background: transparent; color: var(--muted); border: 0; border-radius: 8px; font-size: 13px; font-weight: 700; white-space: nowrap; }
.modes button:hover { color: var(--purple-dark); }
.modes button[aria-selected="true"] { color: var(--purple-dark); background: #fff; box-shadow: 0 1px 3px #29174214; }
button svg, .field svg { width: 18px; height: 18px; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; fill: none; flex: none; }

#search { display: flex; gap: 9px; margin-top: 10px; }
.field { flex: 1; display: flex; align-items: center; gap: 11px; min-width: 0; padding: 0 14px; border: 1px solid #e0dbe8; border-radius: 11px; background: #fff; color: #81778f; transition: box-shadow .18s, border-color .18s; }
.field:focus-within { border-color: #9b82dc; box-shadow: 0 0 0 3px #a489e329; color: var(--purple); }
.field svg { width: 20px; height: 20px; }
.field input { width: 100%; height: 49px; min-width: 0; padding: 0; border: 0; outline: none; background: transparent; color: var(--ink); font-size: 15px; }
.field input::placeholder { color: #70677c; }
.submit { display: inline-flex; align-items: center; justify-content: center; gap: 11px; flex-shrink: 0; padding: 0 17px; background: var(--purple); color: #fff; border: 1px solid transparent; border-radius: 11px; font-size: 14px; font-weight: 750; transition: background .18s, transform .18s; }
.submit:hover { background: var(--purple-dark); }
.submit:active { transform: translateY(1px); }
.submit:disabled { opacity: .58; cursor: default; }
.examples { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-top: 11px; min-height: 27px; color: var(--muted); font-size: 12px; }
.examples span { margin-right: 3px; }
.examples button { padding: 3px 9px; color: #594c6d; background: #fff; border: 1px solid var(--soft); border-radius: 20px; }
.examples button:hover { background: var(--lavender); border-color: #d8c8f1; color: var(--purple-dark); }

.board { border: 1px solid var(--soft); border-radius: 17px; background: #fff; overflow: hidden; box-shadow: 0 14px 40px #28164307, 0 2px 6px #28164304; }
.board-bar { min-height: 54px; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 18px; border-bottom: 1px solid var(--soft); }
.board-heading { display: flex; flex-wrap: wrap; align-items: baseline; gap: 5px 10px; min-width: 0; }
.board h2 { margin: 0; font-size: 14px; font-weight: 750; overflow-wrap: anywhere; }
#counts { color: var(--muted); font-size: 11px; }
.controls { display: flex; flex: none; gap: 2px; align-items: center; border: 1px solid var(--soft); border-radius: 8px; padding: 2px; }
.controls button { display: grid; place-items: center; width: 31px; height: 28px; padding: 0; border: 0; background: transparent; border-radius: 5px; color: var(--muted); }
.controls button:hover { color: var(--purple-dark); background: var(--lavender); }
.surface { position: relative; display: grid; place-items: center; min-height: 337px; isolation: isolate; background-color: #fcfbfe; background-image: radial-gradient(circle, #dcd1ec 0.72px, transparent 0.9px); background-size: 18px 18px; background-position: center; }
.surface::before { content: ""; position: absolute; z-index: -1; inset: 0; background: radial-gradient(ellipse at center, transparent 18%, #fcfbfe4f 72%, #fcfbfead); pointer-events: none; }
.state { display: grid; place-items: center; padding: 23px 16px; text-align: center; }
.state p { margin: 0; color: var(--muted); font-size: 13px; }
.empty-lines { width: 216px; height: auto; margin-bottom: 12px; overflow: visible; }
.empty-rings { fill: none; stroke: #ded1f1; stroke-width: .9; stroke-dasharray: 2 4; }
.empty-edges { fill: none; stroke: #cdb9eb; stroke-width: 1; }
.empty-points { stroke: #b29adf; stroke-width: 1; fill: #e3d8f8; }
.empty-core-halo { fill: #dfcff8; opacity: .85; }
.empty-core { fill: #8661d6; stroke: white; stroke-width: 2; }
.loading canvas { width: 270px; height: 200px; margin-top: -14px; }
.loading p { color: var(--purple-dark); font-weight: 700; }
.quiet-button { border: 0; background: transparent; color: var(--purple-dark); font-size: 12px; padding: 8px 11px; margin-top: 5px; border-radius: 6px; }
.quiet-button:hover { background: var(--lavender); text-decoration: underline; }
.failure p { max-width: 360px; color: #6e4559; }

.diagram { display: block; width: 100%; height: 485px; overflow: hidden; touch-action: pan-y; }
.diagram.zoomed { touch-action: none; }
.diagram.can-pan { cursor: grab; }
.diagram.dragging { cursor: grabbing; }
.graph-guide { fill: none; stroke: #d7c8ee; stroke-dasharray: 2.5 5; stroke-width: 1; opacity: .75; }
.edge { fill: none; stroke: #ac91de; stroke-linecap: round; transition: opacity .18s, stroke .18s; }
.edge.active { stroke: #7950cf; opacity: 1; }
.edge.muted, .node.muted { opacity: .24; }
.node { cursor: pointer; outline: none; transition: opacity .18s; }
.node rect { fill: #fff; stroke: #d9caed; stroke-width: 1.2; filter: drop-shadow(0 2px 3px #37286c14); }
.node text { fill: #302447; font-size: 13px; font-weight: 750; text-anchor: middle; dominant-baseline: central; pointer-events: none; }
.node.center rect { fill: #6d49ca; stroke: #6d49ca; }
.node.center text { fill: #fff; }
.node:is(:hover, :focus-visible, .active) rect { stroke: #8460d6; stroke-width: 2.5; }
.node.center:is(:hover, :focus-visible, .active) rect { stroke: #412083; }
.board-footer { display: flex; justify-content: space-between; align-items: center; gap: 8px; min-height: 46px; padding: 8px 18px; border-top: 1px solid var(--soft); font-size: 11px; }
.legend { display: flex; gap: 13px; flex-wrap: wrap; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.center-key { width: 8px; height: 8px; border-radius: 50%; background: var(--purple); }
.line-key { width: 14px; border-top: 2px solid #a38ad3; border-radius: 2px; }

.details { border-top: 1px solid var(--soft); padding: 14px 18px 17px; color: var(--muted); }
.detail-header { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; align-items: center; }
.details h3 { margin: 0; color: var(--ink); font-size: 15px; overflow-wrap: anywhere; }
.details a, .details p { font-size: 12px; }
.details ul { padding: 0; margin: 10px 0 0; list-style: none; display: grid; gap: 6px; }
.details li { display: flex; flex-wrap: wrap; gap: 3px 10px; align-items: baseline; font-size: 12px; }
.details li strong { color: var(--ink); }
.edge-score { font-variant-numeric: tabular-nums; color: var(--purple-dark); }
.page-footer { margin: 17px 0 23px; color: var(--muted); font-size: 11px; text-align: right; }

@media (max-width: 600px) {
  main { width: calc(100% - 32px); }
  .masthead-inner { height: 57px; padding: 0 16px; }
  .intro { margin: 43px auto 25px; }
  .intro p { font-size: 12px; letter-spacing: 0; }
  .workspace { margin-bottom: 23px; }
  .field { padding: 0 9px; gap: 7px; }
  .field input { height: 45px; font-size: 16px; }
  .field input::placeholder { font-size: 12px; }
  .field svg { width: 17px; height: 17px; }
  .submit { padding: 0 10px; gap: 4px; font-size: 12px; }
  .submit svg { width: 14px; height: 14px; }
  .board-bar, .board-footer, .details { padding-right: 12px; padding-left: 12px; }
  .surface { min-height: 308px; }
  .diagram { height: 380px; }
  .node text { font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
