/* Person relationship graph layout and component styles. */
:root {
      --bg: #0b1020;
      --panel: #121830;
      --ink: #d7e2ff;
      --muted: #8aa0d6;
      --line: #2a3a6b;
    }
    html, body {
      width: 100%;
      height: 100%;
      margin: 0;
      overflow: hidden;
      background: var(--bg);
      color: var(--ink);
      font-family: ui-sans-serif, system-ui, -apple-system, "Noto Sans TC", sans-serif;
    }
    .app {
      display: grid;
      grid-template-columns: 340px 1fr;
      grid-template-rows: auto minmax(0, 1fr);
      width: 100%;
      height: 100vh;
      overflow: hidden;
      background: var(--bg);
    }
    header {
      grid-column: 1 / 3;
      padding: 10px 16px;
      background: linear-gradient(90deg, #0e1530, #0b1020 50%);
      border-bottom: 1px solid #1f2a50;
    }
    h1 { margin: 0; font-size: 18px; }
    .small { color: var(--muted); font-size: 12px; line-height: 1.6; }
    .panel-toggle,
    .panel-backdrop { display: none; }
    .panel-toggle {
      cursor: pointer;
      align-items: center;
      justify-content: center;
      padding: 8px 11px;
      border-radius: 10px;
      border: 1px solid var(--line);
      background: #0d1633;
      color: #cfe2ff;
      font-size: 13px;
    }
    aside {
      min-height: 0;
      background: var(--panel);
      padding: 12px 12px 16px;
      border-right: 1px solid #1f2a50;
      overflow: auto;
      overscroll-behavior: contain;
    }
    main { position: relative; min-width: 0; min-height: 0; overflow: hidden; background: var(--bg); }
    #graph { width: 100%; height: 100%; display: block; }
    .toolbar { display: grid; gap: 10px; }
    .card {
      background: #0f1733;
      border: 1px solid #22305b;
      border-radius: 12px;
      padding: 10px;
    }
    .card h3 { margin: 0 0 6px; font-size: 14px; color: #bcd0ff; }
    label { display: flex; align-items: center; gap: 8px; margin: 6px 0; }
    input, select {
      width: 100%;
      box-sizing: border-box;
      padding: 8px 10px;
      border-radius: 10px;
      border: 1px solid var(--line);
      background: #0c1430;
      color: var(--ink);
    }
    input[type="checkbox"] { width: auto; accent-color: #5fbfff; }
    input[type="number"] { width: 100px; }
    select { width: 100px; }
    input[type="file"] { padding: 6px; }
    .param-row { display: grid; grid-template-columns: 88px minmax(0, 1fr) 44px; align-items: center; gap: 8px; margin: 8px 0; color: var(--ink); font-size: 13px; }
    .param-row input[type="range"] { padding: 0; }
    .param-value { color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
    .graph-action-row { margin-top: 8px; display: flex; gap: 8px; flex-wrap: wrap; }
    .graph-rebuild-row { margin-top: 8px; }
    .btn {
      cursor: pointer;
      display: inline-flex;
      align-items: center;
      gap: 8px;
      padding: 8px 10px;
      border-radius: 10px;
      border: 1px solid var(--line);
      background: #0d1633;
      color: #cfe2ff;
    }
    .btn:hover { border-color: #4164d6; }
    .legend { display: flex; flex-wrap: wrap; gap: 6px; }
    .badge {
      display: inline-flex;
      gap: 6px;
      align-items: center;
      padding: 4px 8px;
      border-radius: 999px;
      border: 1px solid var(--line);
      background: #111a3a;
      font-size: 12px;
      cursor: pointer;
    }
    .dot { width: 10px; height: 10px; border-radius: 50%; }
    .dot.family-dot { border-radius: 3px; }
    .line-sample { width: 28px; height: 0; border-top: 1.5px solid #7792d9; display: inline-block; flex: 0 0 auto; }
    .line-sample.rel-family { border-color: #f8fafc; }
    .line-sample.rel-kin { border-color: #4ade80; border-top-style: dotted; }
    .line-sample.rel-marriage { border-color: #ff89a7; border-top-style: dashed; }
    .line-sample.rel-romance { border-color: #ff4fa3; border-top-style: dashed; }
    .line-sample.rel-servant { border-color: #b8a5ff; border-top-style: dotted; }
    .line-sample.rel-ally { border-color: #64d5ff; }
    .line-sample.rel-conflict { border-color: #ff9f43; border-top-style: dashed; }
    .line-sample.rel-rival { border-color: #ffd166; border-top-style: dashed; }
    .link { fill: none; stroke-linecap: round; }
    .link.source-co_occurrence { stroke: #6f7fae; stroke-opacity: .16; }
    .link.source-family { stroke-opacity: .42; }
    .link.source-semantic { stroke-opacity: .68; }
    .link.rel-family { stroke: #f8fafc; }
    .link.rel-kin { stroke: #4ade80; stroke-dasharray: 1 5; }
    .link.rel-marriage { stroke: #ff89a7; stroke-dasharray: 9 5; }
    .link.rel-romance { stroke: #ff4fa3; stroke-dasharray: 3 5; }
    .link.rel-servant { stroke: #b8a5ff; stroke-dasharray: 1 4; }
    .link.rel-ally { stroke: #64d5ff; stroke-dasharray: 8 5; }
    .link.rel-conflict { stroke: #ff9f43; stroke-dasharray: 10 4; }
    .link.rel-rival { stroke: #ffd166; stroke-dasharray: 8 4 2 4; }
    .link.hover { stroke-opacity: .9; }
    .link.dim { opacity: .06; }
    .node circle { stroke: #0b1020; stroke-width: 2.6; }
    .node rect { stroke: #f8fafc; stroke-width: 1; rx: 4; }
    .node text {
      font-size: 12px;
      fill: #dfe7ff;
      paint-order: stroke;
      stroke: #0b1020;
      stroke-width: 3;
      stroke-linejoin: round;
    }
    .node.dim circle, .node.dim text { opacity: .18; }
    .tooltip {
      position: absolute;
      pointer-events: none;
      background: #101835;
      border: 1px solid var(--line);
      border-radius: 10px;
      padding: 8px 10px;
      color: #e8f0ff;
      font-size: 12px;
      box-shadow: 0 6px 18px rgba(0,0,0,.35);
      max-width: 330px;
    }
    .tooltip.is-hidden { display: none; }
    .tooltip-separator { border: 0; border-top: 1px solid #2a3a6b; }
    .watermark { position: absolute; right: 16px; bottom: 10px; color: #5c6ea8; font-size: 12px; }
    @media (max-width: 900px) {
      .app { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); }
      header {
        grid-column: 1;
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: center;
        gap: 10px;
      }
      h1 { min-width: 0; font-size: 16px; line-height: 1.35; }
      .panel-toggle { display: inline-flex; position: relative; z-index: 25; }
      aside {
        position: fixed;
        z-index: 20;
        left: 0;
        top: 0;
        bottom: 0;
        width: min(86vw, 340px);
        box-sizing: border-box;
        transform: translateX(-105%);
        transition: transform .22s ease;
        box-shadow: 20px 0 48px rgba(0,0,0,.34);
      }
      body.panel-open aside { transform: translateX(0); }
      .panel-backdrop {
        position: fixed;
        inset: 0;
        z-index: 15;
        border: 0;
        background: rgba(3, 7, 18, .48);
      }
      body.panel-open .panel-backdrop { display: block; }
      main { grid-column: 1; grid-row: 2; }
      .watermark { left: 12px; right: auto; bottom: 8px; }
    }
