:root {
      color-scheme: dark;
      --bg: #070806;
      --surface: #11130f;
      --surface-2: #1b1d17;
      --surface-3: #25251d;
      --text: #f5ecd9;
      --muted: #c1b391;
      --faint: #897d64;
      --line: #393426;
      --line-strong: #716040;
      --gold: #d8ba69;
      --gold-2: #95713a;
      --gold-soft: rgba(217, 183, 101, 0.14);
      --red: #b9665b;
      --green: #82ad82;
      --blue: #86a9bd;
      --teal: #7baaa5;
      --paper: #0d0c09;
      --mark: rgba(201, 162, 77, 0.28);
      --shadow: 0 18px 42px rgba(0, 0, 0, 0.34);
      --radius: 8px;
      --reading-width: 920px;
      font-family: "Noto Sans KR", "Malgun Gothic", "Apple SD Gothic Neo", system-ui, sans-serif;
    }
    body.light {
      color-scheme: light;
      --bg: #f5f1e8;
      --surface: #fffaf1;
      --surface-2: #eee8da;
      --surface-3: #e2d8c7;
      --text: #27231b;
      --muted: #685f4e;
      --faint: #8c816d;
      --line: #d2c5ac;
      --line-strong: #b6a37e;
      --gold: #8f6724;
      --red: #9b4f49;
      --green: #517c57;
      --blue: #466f88;
      --teal: #477d78;
      --paper: #fffdf8;
      --mark: rgba(180, 129, 35, 0.24);
      --shadow: 0 16px 42px rgba(64, 43, 18, 0.12);
    }
    * { box-sizing: border-box; }
    html, body { min-height: 100%; margin: 0; }
    html { scroll-behavior: smooth; }
    body {
      background:
        linear-gradient(120deg, rgba(15, 24, 24, 0.78), transparent 38%),
        linear-gradient(180deg, #070806 0%, #0d0d0a 48%, #080907 100%);
      color: var(--text);
      font-size: 15.5px;
      line-height: 1.72;
      text-rendering: optimizeLegibility;
      -webkit-font-smoothing: antialiased;
    }
    button, input, select { font: inherit; }
    a { color: inherit; }
    ::selection { background: rgba(216, 186, 105, 0.28); color: var(--text); }
    :focus-visible {
      outline: 2px solid color-mix(in srgb, var(--gold) 78%, white 8%);
      outline-offset: 3px;
    }
    .skip-link {
      position: fixed;
      left: 14px;
      top: -60px;
      z-index: 100;
      border: 1px solid var(--gold);
      border-radius: 8px;
      background: var(--paper);
      color: var(--gold);
      padding: 8px 11px;
      text-decoration: none;
      transition: top 0.12s ease;
    }
    .skip-link:focus { top: 12px; }
    .app {
      min-height: 100vh;
      display: grid;
      grid-template-columns: 292px minmax(0, 1fr);
      grid-template-rows: 64px minmax(0, 1fr);
    }
    .topbar {
      grid-column: 1 / -1;
      position: sticky;
      top: 0;
      z-index: 20;
      display: flex;
      align-items: center;
      gap: 16px;
      padding: 11px 20px;
      background:
        linear-gradient(90deg, rgba(7, 8, 6, 0.98), rgba(18, 19, 14, 0.95));
      border-bottom: 1px solid color-mix(in srgb, var(--gold) 34%, var(--line));
      backdrop-filter: blur(16px);
    }
    .brand {
      display: flex;
      align-items: center;
      gap: 10px;
      min-width: 248px;
      cursor: pointer;
      user-select: none;
    }
    .brand::before {
      content: "";
      width: 28px;
      height: 28px;
      flex: 0 0 auto;
      border: 1px solid color-mix(in srgb, var(--gold) 70%, var(--line));
      border-radius: 50%;
      background:
        linear-gradient(90deg, transparent 43%, rgba(216, 186, 105, 0.55) 45% 55%, transparent 57%),
        linear-gradient(145deg, rgba(216, 186, 105, 0.2), rgba(123, 170, 165, 0.1));
      box-shadow: inset 0 0 0 5px rgba(216, 186, 105, 0.05);
    }
    .brand strong {
      color: var(--gold);
      font-size: 16px;
      letter-spacing: 0;
      text-shadow: 0 0 18px rgba(217, 183, 101, 0.22);
      white-space: nowrap;
    }
    .brand span {
      color: var(--muted);
      font-size: 11px;
      letter-spacing: 0.08em;
      white-space: nowrap;
    }
    .searchbox {
      position: relative;
      flex: 1;
      max-width: 760px;
    }
    .searchbox input {
      width: 100%;
      height: 40px;
      border: 1px solid var(--line);
      border-radius: 8px;
      background: color-mix(in srgb, var(--paper) 82%, black 10%);
      color: var(--text);
      padding: 0 92px 0 38px;
      outline: none;
    }
    .searchbox input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(201, 162, 77, 0.14); }
    .searchbox .icon {
      position: absolute;
      left: 13px;
      top: 8px;
      color: var(--faint);
      font-size: 15px;
    }
    .searchbox .count {
      position: absolute;
      right: 12px;
      top: 9px;
      color: var(--faint);
      font-size: 12px;
    }
    .toolbar {
      margin-left: auto;
      display: flex;
      align-items: center;
      gap: 8px;
    }
    .privacy-chip,
    .tool-btn,
    .source-link {
      height: 34px;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: 7px;
      padding: 0 11px;
      border-radius: 8px;
      border: 1px solid var(--line);
      background: linear-gradient(180deg, rgba(35, 30, 20, 0.92), rgba(17, 16, 13, 0.92));
      color: var(--text);
      text-decoration: none;
      white-space: nowrap;
    }
    .tool-btn { cursor: pointer; }
    .tool-btn:hover, .source-link:hover { border-color: var(--gold); color: var(--gold); }
    .privacy-chip {
      color: var(--green);
      border-color: color-mix(in srgb, var(--green) 52%, var(--line));
      font-size: 12px;
    }
    .sidebar {
      border-right: 1px solid color-mix(in srgb, var(--gold) 26%, var(--line));
      background:
        linear-gradient(180deg, rgba(15, 16, 12, 0.98), rgba(7, 8, 6, 0.98));
      padding: 10px 11px;
      overflow: auto;
      scrollbar-color: color-mix(in srgb, var(--gold) 42%, var(--line)) transparent;
    }
    .side-section { margin-bottom: 6px; }
    .side-title {
      color: var(--faint);
      font-size: 11px;
      letter-spacing: 0.1em;
      margin: 10px 6px 8px;
      text-transform: uppercase;
    }
    .category-title-btn {
      display: grid;
      grid-template-columns: 18px minmax(0, 1fr) auto;
      align-items: center;
      gap: 6px;
      margin: 3px 0;
      color: var(--gold);
      font-weight: 700;
      letter-spacing: 0;
    }
    .category-title-btn .chev {
      color: var(--faint);
      font-size: 12px;
      transition: transform 0.12s ease;
    }
    .category-title-btn.active .chev {
      transform: rotate(90deg);
      color: var(--gold);
    }
    .subnav {
      display: none;
      margin: 0 0 5px 6px;
      padding-left: 7px;
      border-left: 1px solid var(--line);
    }
    .subnav.open {
      display: grid;
      gap: 2px;
    }
    .subnav .nav-item {
      padding-top: 4px;
      padding-bottom: 4px;
      color: var(--muted);
      font-size: 12px;
    }
    .nav-home,
    .nav-item,
    .filter-chip,
    .category-title-btn {
      width: 100%;
      border: 1px solid transparent;
      background: transparent;
      color: var(--text);
      border-radius: 8px;
      padding: 5px 8px;
      text-align: left;
      cursor: pointer;
    }
    .nav-home {
      background: linear-gradient(135deg, rgba(217, 183, 101, 0.13), rgba(20, 18, 13, 0.96));
      border-color: color-mix(in srgb, var(--gold) 36%, var(--line));
      font-weight: 700;
      margin-bottom: 5px;
    }
    .nav-item {
      display: grid;
      grid-template-columns: minmax(0, 1fr) auto;
      gap: 8px;
      margin: 2px 0;
      line-height: 1.35;
    }
    .nav-item:hover,
    .nav-item.active,
    .filter-chip:hover,
    .filter-chip.active,
    .category-title-btn:hover,
    .category-title-btn.active {
      background: var(--surface-2);
      border-color: color-mix(in srgb, var(--gold) 28%, var(--line));
    }
    .nav-item.active {
      border-color: color-mix(in srgb, var(--gold) 72%, var(--line));
      color: var(--gold);
    }
    .nav-meta,
    .nav-count {
      color: var(--faint);
      font-size: 11px;
    }
    .nav-title {
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    .content {
      min-width: 0;
      overflow: auto;
      padding: 34px 38px 78px;
      scrollbar-color: color-mix(in srgb, var(--gold) 42%, var(--line)) transparent;
    }
    .shell {
      max-width: 1220px;
      margin: 0 auto;
    }
    .hero {
      display: grid;
      grid-template-columns: minmax(0, 1.18fr) minmax(288px, 0.82fr);
      gap: 16px;
      align-items: stretch;
      margin-bottom: 20px;
    }
    .hero-main,
    .panel,
    .card,
    .doc-body,
    .doc-header,
    .result-item {
      border: 1px solid var(--line);
      background:
        linear-gradient(180deg, rgba(20, 21, 16, 0.96), rgba(10, 10, 8, 0.96));
      border-radius: var(--radius);
      box-shadow: var(--shadow);
    }
    .hero-main {
      position: relative;
      overflow: hidden;
      padding: 32px;
      min-height: 220px;
      display: flex;
      flex-direction: column;
      justify-content: space-between;
      border-color: color-mix(in srgb, var(--gold) 38%, var(--line));
    }
    .hero-main::after {
      content: "";
      position: absolute;
      inset: 0;
      pointer-events: none;
      background:
        linear-gradient(90deg, rgba(216, 186, 105, 0.13), transparent 30%),
        repeating-linear-gradient(90deg, transparent 0 22px, rgba(216, 186, 105, 0.035) 22px 23px);
    }
    .eyebrow {
      color: var(--muted);
      font-size: 12px;
      letter-spacing: 0.12em;
      text-transform: uppercase;
    }
    h1 {
      margin: 8px 0 10px;
      font-size: 30px;
      line-height: 1.25;
      color: var(--text);
      letter-spacing: 0;
      text-shadow: 0 0 24px rgba(217, 183, 101, 0.15);
    }
    .hero-main p {
      color: var(--muted);
      max-width: 720px;
      margin: 0;
    }
    body.roomy .hero-main p,
    body.roomy .md {
      line-height: 1.86;
    }
    .stat-grid {
      display: grid;
      grid-template-columns: repeat(4, minmax(0, 1fr));
      gap: 10px;
      padding: 16px;
      margin-bottom: 20px;
    }
    .stat {
      padding: 15px;
      background: color-mix(in srgb, var(--paper) 82%, var(--surface-2) 18%);
      border: 1px solid var(--line);
      border-radius: 8px;
    }
    .stat .num {
      color: var(--gold);
      font-weight: 800;
      font-size: 22px;
      line-height: 1.1;
    }
    .stat .label {
      color: var(--muted);
      font-size: 12px;
      margin-top: 4px;
    }
    .sigil-card {
      position: relative;
      overflow: hidden;
      min-height: 210px;
      padding: 18px;
      border-color: color-mix(in srgb, var(--gold) 36%, var(--line));
      display: grid;
      grid-template-rows: 1fr auto;
      gap: 12px;
      place-items: center;
    }
    .sigil-card::before {
      content: "";
      position: absolute;
      inset: -40%;
      background:
        linear-gradient(45deg, transparent 0 46%, rgba(216, 186, 105, 0.12) 48% 52%, transparent 54%),
        conic-gradient(from 15deg, transparent, rgba(123, 170, 165, 0.12), transparent 24%, rgba(216, 186, 105, 0.12), transparent 48%);
      opacity: 0.58;
      animation: sigilSpin 48s linear infinite;
    }
    .sigil-art {
      position: relative;
      z-index: 1;
      width: min(230px, 92%);
      aspect-ratio: 1;
      display: grid;
      place-items: center;
      filter: drop-shadow(0 0 22px rgba(217, 183, 101, 0.18));
    }
    .sigil-art svg {
      width: 100%;
      height: 100%;
      display: block;
    }
    .sigil-caption {
      position: relative;
      z-index: 1;
      width: 100%;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 10px;
      color: var(--faint);
      font-size: 11px;
      letter-spacing: 0.1em;
      text-transform: uppercase;
    }
    .sigil-caption strong {
      color: var(--gold);
      font-size: 12px;
      letter-spacing: 0.08em;
    }
    @keyframes sigilSpin {
      from { transform: rotate(0deg); }
      to { transform: rotate(360deg); }
    }
    .section-head {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      margin: 24px 0 12px;
    }
    .section-head h2 {
      margin: 0;
      color: var(--text);
      font-size: 17px;
    }
    .section-head span {
      color: var(--faint);
      font-size: 12px;
    }
    .card-grid {
      display: grid;
      grid-template-columns: repeat(3, minmax(0, 1fr));
      gap: 13px;
    }
    .card {
      cursor: pointer;
      padding: 17px;
      min-height: 176px;
      display: flex;
      flex-direction: column;
      gap: 10px;
      transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease;
    }
    .card:hover {
      transform: translateY(-2px);
      border-color: color-mix(in srgb, var(--gold) 60%, var(--line));
      background:
        linear-gradient(180deg, rgba(30, 30, 22, 0.98), rgba(13, 13, 10, 0.98));
    }
    .card-top,
    .doc-actions,
    .meta-row {
      display: flex;
      align-items: center;
      gap: 8px;
      flex-wrap: wrap;
    }
    .badge {
      display: inline-flex;
      align-items: center;
      border: 1px solid var(--line);
      background: var(--surface-2);
      color: var(--muted);
      border-radius: 999px;
      padding: 2px 8px;
      font-size: 11px;
      line-height: 1.5;
    }
    .badge.gold { color: var(--gold); border-color: color-mix(in srgb, var(--gold) 45%, var(--line)); }
    .badge.green { color: var(--green); border-color: color-mix(in srgb, var(--green) 45%, var(--line)); }
    .badge.blue { color: var(--blue); border-color: color-mix(in srgb, var(--blue) 45%, var(--line)); }
    .card h3 {
      margin: 0;
      font-size: 17px;
      line-height: 1.35;
      color: var(--text);
    }
    .card p {
      margin: 0;
      color: var(--muted);
      font-size: 13px;
      flex: 1;
      word-break: keep-all;
    }
    .file-line {
      color: var(--faint);
      font-size: 12px;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    .doc-header {
      padding: 22px 24px;
      margin-bottom: 12px;
      box-shadow: none;
    }
    .doc-header h1 {
      margin: 6px 0 12px;
      font-size: 28px;
    }
    .doc-layout {
      display: grid;
      grid-template-columns: minmax(0, 1fr) 250px;
      gap: 12px;
      align-items: start;
    }
    .category-stack {
      display: grid;
      gap: 16px;
    }
    .category-doc {
      border: 1px solid var(--line);
      background: var(--paper);
      border-radius: var(--radius);
      overflow: hidden;
      box-shadow: 0 16px 34px rgba(0, 0, 0, 0.18);
    }
    .category-doc-head {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      padding: 14px 18px;
      background:
        linear-gradient(90deg, rgba(25, 21, 14, 0.98), rgba(13, 12, 9, 0.98));
      border-bottom: 1px solid color-mix(in srgb, var(--gold) 24%, var(--line));
    }
    .category-doc-head h3 {
      margin: 0;
      font-size: 17px;
      line-height: 1.35;
    }
    .category-doc .doc-body {
      border: 0;
      border-radius: 0;
      box-shadow: none;
    }
    .character-hub {
      display: grid;
      gap: 14px;
      margin-bottom: 16px;
    }
    .character-panel,
    .raw-doc-toggle {
      border: 1px solid var(--line);
      background: var(--surface);
      border-radius: var(--radius);
      overflow: hidden;
    }
    .character-panel {
      padding: 18px;
    }
    .setting-index-grid {
      display: grid;
      grid-template-columns: repeat(3, minmax(0, 1fr));
      gap: 10px;
    }
    .setting-part-card {
      min-height: 178px;
      border: 1px solid var(--line);
      border-radius: 8px;
      background:
        radial-gradient(circle at 92% 8%, rgba(217, 183, 101, 0.12), transparent 30%),
        rgba(13, 12, 9, 0.78);
      color: inherit;
      font: inherit;
      text-align: left;
      cursor: pointer;
      padding: 13px;
      display: flex;
      flex-direction: column;
      gap: 8px;
    }
    .setting-part-card:hover,
    .setting-part-card:focus-visible {
      border-color: var(--gold);
      background:
        radial-gradient(circle at 92% 8%, rgba(217, 183, 101, 0.18), transparent 32%),
        rgba(217, 183, 101, 0.08);
    }
    .setting-part-card h3 {
      margin: 0;
      color: var(--text);
      font-size: 16px;
      line-height: 1.35;
    }
    .setting-part-card p {
      margin: 0;
      color: var(--muted);
      font-size: 12px;
      line-height: 1.55;
    }
    .setting-mini-list {
      display: flex;
      flex-wrap: wrap;
      gap: 5px;
      margin-top: auto;
    }
    .setting-mini-list span {
      display: inline-flex;
      max-width: 100%;
      border: 1px solid rgba(217, 183, 101, 0.22);
      border-radius: 999px;
      color: var(--faint);
      background: rgba(7, 7, 5, 0.46);
      padding: 2px 7px;
      font-size: 11px;
      line-height: 1.45;
    }
    .setting-local-index {
      display: flex;
      flex-wrap: wrap;
      gap: 6px;
      margin: -2px 0 14px;
    }
    .setting-local-index a {
      border: 1px solid color-mix(in srgb, var(--gold) 30%, var(--line));
      border-radius: 999px;
      color: var(--muted);
      background: rgba(217, 183, 101, 0.06);
      text-decoration: none;
      padding: 4px 9px;
      font-size: 12px;
      line-height: 1.45;
    }
    .setting-local-index a:hover {
      color: var(--gold);
      border-color: var(--gold);
    }
    .setting-section-list {
      display: grid;
      gap: 18px;
    }
    .setting-section {
      border-top: 1px solid color-mix(in srgb, var(--gold) 24%, var(--line));
      padding-top: 4px;
      scroll-margin-top: 82px;
    }
    .setting-section.md h2 {
      margin-top: 16px;
    }
    .character-toolbar {
      display: flex;
      align-items: center;
      gap: 8px;
      flex-wrap: wrap;
      margin: 12px 0 14px;
    }
    .character-filter,
    .character-search {
      border: 1px solid var(--line);
      background: var(--paper);
      color: var(--text);
      border-radius: 8px;
      min-height: 32px;
    }
    .character-filter {
      padding: 5px 10px;
      cursor: pointer;
      font-size: 12px;
    }
    .character-filter.active,
    .character-filter:hover {
      border-color: var(--gold);
      color: var(--gold);
      background: rgba(217, 183, 101, 0.1);
    }
    .character-search {
      flex: 1 1 220px;
      padding: 5px 10px;
      outline: none;
    }
    .character-grid {
      display: grid;
      grid-template-columns: repeat(3, minmax(0, 1fr));
      gap: 10px;
    }
    .character-card {
      border: 1px solid var(--line);
      background: rgba(13, 12, 9, 0.78);
      color: inherit;
      font: inherit;
      text-align: left;
      cursor: pointer;
      border-radius: 8px;
      padding: 12px;
      min-height: 118px;
    }
    .character-card:hover,
    .character-card:focus-visible {
      border-color: var(--gold);
      background: rgba(217, 183, 101, 0.08);
    }
    .character-card h3 {
      margin: 0 0 6px;
      font-size: 16px;
      color: var(--text);
    }
    .character-card p {
      margin: 6px 0 0;
      color: var(--muted);
      font-size: 12px;
      line-height: 1.55;
    }
    .character-card .role {
      color: var(--gold);
      font-size: 12px;
      line-height: 1.45;
    }
    .character-group-grid {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 10px;
    }
    .character-group {
      border: 1px solid var(--line);
      border-radius: 8px;
      background: rgba(10, 9, 7, 0.72);
      padding: 12px;
    }
    .character-group h3 {
      margin: 0 0 8px;
      font-size: 15px;
      color: var(--gold);
    }
    .character-chip-row {
      display: flex;
      flex-wrap: wrap;
      gap: 6px;
    }
    .character-chip {
      display: inline-flex;
      align-items: center;
      border: 1px solid color-mix(in srgb, var(--gold) 36%, var(--line));
      background: rgba(217, 183, 101, 0.08);
      color: var(--text);
      font: inherit;
      cursor: pointer;
      border-radius: 999px;
      padding: 3px 8px;
      font-size: 12px;
      text-decoration: none;
    }
    .character-chip:hover,
    .character-chip:focus-visible {
      border-color: var(--gold);
      color: var(--gold);
    }
    .relation-board {
      display: grid;
      grid-template-columns: repeat(3, minmax(0, 1fr));
      gap: 10px;
    }
    .relation-node {
      border: 1px solid var(--line);
      background: rgba(13, 12, 9, 0.76);
      border-radius: 8px;
      padding: 12px;
    }
    .relation-node strong {
      color: var(--gold);
      display: block;
      margin-bottom: 7px;
    }
    .relation-map.cluster {
      position: relative;
      min-height: 720px;
      border: 1px solid color-mix(in srgb, var(--gold) 30%, var(--line));
      border-radius: var(--radius);
      background:
        radial-gradient(circle at 50% 50%, rgba(217, 183, 101, 0.12), transparent 23%),
        radial-gradient(circle at 14% 16%, rgba(217, 183, 101, 0.08), transparent 20%),
        radial-gradient(circle at 86% 80%, rgba(217, 183, 101, 0.08), transparent 22%),
        linear-gradient(180deg, rgba(13, 12, 9, 0.9), rgba(6, 6, 4, 0.96));
      overflow: hidden;
    }
    .relation-map.cluster::before {
      content: "";
      position: absolute;
      inset: 22px;
      border: 1px solid rgba(217, 183, 101, 0.12);
      border-radius: 50%;
      pointer-events: none;
    }
    .relation-lines {
      position: absolute;
      inset: 0;
      width: 100%;
      height: 100%;
      pointer-events: none;
    }
    .relation-lines line {
      stroke: rgba(217, 183, 101, 0.42);
      stroke-width: 1.1;
    }
    .relation-lines text {
      fill: var(--muted);
      font-size: 10px;
      paint-order: stroke;
      stroke: var(--paper);
      stroke-width: 4px;
      stroke-linejoin: round;
    }
    .relation-cluster {
      position: absolute;
      width: 238px;
      min-height: 154px;
      transform: translate(-50%, -50%);
      border: 1px solid color-mix(in srgb, var(--gold) 36%, var(--line));
      border-radius: 14px;
      background:
        radial-gradient(circle at 92% 8%, rgba(217, 183, 101, 0.13), transparent 32%),
        linear-gradient(160deg, rgba(25, 21, 14, 0.9), rgba(8, 8, 6, 0.94));
      box-shadow: 0 18px 42px rgba(0, 0, 0, 0.28);
      padding: 13px;
    }
    .relation-cluster::before {
      content: "";
      position: absolute;
      right: 10px;
      top: 10px;
      width: 52px;
      height: 52px;
      border-radius: 50%;
      border: 1px solid rgba(217, 183, 101, 0.18);
      box-shadow: inset 0 0 0 8px rgba(217, 183, 101, 0.03);
      pointer-events: none;
    }
    .relation-cluster h3 {
      position: relative;
      margin: 0 0 9px;
      color: var(--gold);
      font-size: 14px;
      letter-spacing: 0;
    }
    .relation-cluster.center {
      width: 250px;
      min-height: 176px;
      border-color: color-mix(in srgb, var(--gold) 62%, var(--line));
      background:
        radial-gradient(circle at 50% 28%, rgba(217, 183, 101, 0.18), transparent 38%),
        linear-gradient(160deg, rgba(37, 29, 16, 0.96), rgba(8, 8, 6, 0.96));
    }
    .relation-cluster-people {
      position: relative;
      display: flex;
      flex-wrap: wrap;
      gap: 7px;
      align-items: flex-start;
    }
    .relation-person {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      max-width: 100%;
      border: 1px solid rgba(217, 183, 101, 0.28);
      border-radius: 999px;
      background: rgba(7, 7, 5, 0.76);
      color: var(--text);
      font: inherit;
      font-size: 12px;
      padding: 4px 8px 4px 5px;
      cursor: pointer;
    }
    .relation-person:hover,
    .relation-person:focus-visible {
      border-color: var(--gold);
      color: var(--gold);
      box-shadow: 0 0 18px rgba(217, 183, 101, 0.16);
    }
    .relation-person .avatar {
      width: 24px;
      height: 24px;
      display: grid;
      place-items: center;
      border-radius: 50%;
      border: 1px solid color-mix(in srgb, var(--gold) 62%, var(--line));
      background:
        radial-gradient(circle at 35% 30%, rgba(243, 214, 138, 0.24), transparent 38%),
        linear-gradient(145deg, #17130d, #050504);
      color: var(--gold);
      font-weight: 800;
      font-size: 10px;
      flex: 0 0 auto;
    }
    .relation-person .name {
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    .character-detail {
      display: grid;
      gap: 12px;
    }
    .character-detail-head {
      border: 1px solid color-mix(in srgb, var(--gold) 34%, var(--line));
      background:
        linear-gradient(135deg, rgba(31, 26, 17, 0.98), rgba(8, 8, 6, 0.98));
      border-radius: var(--radius);
      padding: 20px 22px;
    }
    .character-detail-head h1 {
      margin: 4px 0 10px;
    }
    .character-detail-body {
      border: 1px solid var(--line);
      background: var(--paper);
      border-radius: var(--radius);
      padding: 30px 34px;
    }
    .raw-doc-toggle summary {
      cursor: pointer;
      padding: 13px 16px;
      color: var(--gold);
      background: linear-gradient(90deg, rgba(25, 21, 14, 0.98), rgba(13, 12, 9, 0.98));
      border-bottom: 1px solid var(--line);
    }
    .doc-body {
      padding: 30px 34px;
      box-shadow: none;
      background: var(--paper);
      overflow-wrap: anywhere;
      word-break: keep-all;
    }
    body.roomy .doc-body,
    body.roomy .character-detail-body {
      padding: 36px 42px;
    }
    .outline {
      position: sticky;
      top: 76px;
      border: 1px solid var(--line);
      background: var(--surface);
      border-radius: var(--radius);
      padding: 12px;
      max-height: calc(100vh - 100px);
      overflow: auto;
    }
    .outline a {
      display: block;
      color: var(--muted);
      text-decoration: none;
      font-size: 12px;
      line-height: 1.45;
      padding: 5px 6px;
      border-radius: 6px;
    }
    .outline a:hover { background: var(--surface-2); color: var(--gold); }
    .outline .lv2 { padding-left: 14px; }
    .outline .lv3 { padding-left: 24px; }
    .outline .lv4 { padding-left: 34px; }
    .md h1, .md h2, .md h3, .md h4 {
      color: var(--text);
      line-height: 1.35;
      letter-spacing: 0;
      scroll-margin-top: 82px;
      word-break: keep-all;
    }
    .md h1 {
      font-size: 28px;
      border-bottom: 1px solid var(--line);
      padding-bottom: 12px;
      margin: 0 0 18px;
    }
    .md h2 {
      font-size: 21px;
      margin: 32px 0 12px;
      padding-left: 12px;
      border-left: 3px solid var(--gold);
    }
    .md h3 { font-size: 17px; margin: 24px 0 8px; color: color-mix(in srgb, var(--text) 82%, var(--gold)); }
    .md h4 { font-size: 15px; margin: 18px 0 6px; color: var(--muted); }
    .md p { margin: 10px 0; max-width: var(--reading-width); }
    .md ul, .md ol { padding-left: 24px; margin: 10px 0; max-width: var(--reading-width); }
    .md li { margin: 5px 0; }
    .md blockquote {
      margin: 12px 0;
      padding: 10px 16px;
      border-left: 3px solid var(--gold);
      background: var(--surface-2);
      color: var(--muted);
      max-width: var(--reading-width);
    }
    .md table {
      width: 100%;
      border-collapse: collapse;
      margin: 14px 0;
      font-size: 13px;
      line-height: 1.58;
      overflow-wrap: normal;
      word-break: keep-all;
    }
    .md th, .md td {
      border: 1px solid var(--line);
      padding: 8px 10px;
      vertical-align: top;
    }
    .md th {
      background: var(--surface-2);
      color: var(--gold);
      text-align: left;
      white-space: nowrap;
    }
    .md tr:nth-child(even) td {
      background: color-mix(in srgb, var(--surface) 72%, transparent);
    }
    .md code {
      background: var(--surface-2);
      color: var(--gold);
      border-radius: 5px;
      padding: 2px 5px;
      font-family: Consolas, "Cascadia Code", monospace;
      font-size: 0.92em;
    }
    .md pre {
      background: #0c0c0b;
      color: #f2ead8;
      padding: 14px;
      border-radius: 8px;
      overflow: auto;
      border: 1px solid var(--line);
      max-width: 100%;
    }
    body.light .md pre { background: #29251c; }
    .md hr {
      border: 0;
      border-top: 1px solid var(--line);
      margin: 24px 0;
    }
    .mark {
      background: var(--mark);
      color: var(--text);
      border-radius: 3px;
      padding: 0 2px;
    }
    .result-list {
      display: grid;
      gap: 10px;
    }
    .result-item {
      padding: 16px 18px;
      box-shadow: none;
      cursor: pointer;
    }
    .result-item:hover { border-color: var(--gold); }
    .result-item h3 {
      margin: 4px 0 6px;
      font-size: 16px;
    }
    .snippet {
      color: var(--muted);
      font-size: 13px;
      margin: 0;
      word-break: keep-all;
    }
    .asset-frame {
      min-height: 420px;
      display: grid;
      place-items: center;
      padding: 14px;
      background: var(--surface-2);
      border: 1px solid var(--line);
      border-radius: 8px;
    }
    .asset-frame img {
      max-width: 100%;
      max-height: 72vh;
      border-radius: 6px;
    }
    .annual-plan,
    .master-plan,
    .schedule-notes,
    .world-visual,
    .faction-board {
      border: 1px solid var(--line);
      background: var(--surface);
      border-radius: var(--radius);
      padding: 18px;
      margin-bottom: 16px;
      overflow: hidden;
    }
    .annual-scroll {
      overflow-x: auto;
      padding-bottom: 6px;
    }
    .annual-table {
      width: 100%;
      min-width: 1260px;
      border-collapse: collapse;
      table-layout: fixed;
      background: var(--paper);
      border: 1px solid var(--line);
      font-size: 12px;
      line-height: 1.35;
    }
    .annual-table th,
    .annual-table td {
      border: 1px solid var(--line);
      height: 48px;
      padding: 7px 8px;
      vertical-align: middle;
    }
    .annual-table th {
      background: color-mix(in srgb, var(--surface-2) 74%, var(--paper));
      color: var(--muted);
      font-weight: 900;
      text-align: center;
      white-space: nowrap;
    }
    .annual-table thead tr:first-child th {
      height: 34px;
    }
    .annual-table thead tr:nth-child(2) th {
      height: 38px;
    }
    .annual-year {
      background: color-mix(in srgb, var(--surface-3) 82%, var(--paper)) !important;
      color: var(--text) !important;
      font-size: 15px;
      letter-spacing: 0;
    }
    .annual-stage {
      width: 220px;
      background: color-mix(in srgb, var(--surface-2) 84%, var(--paper));
      color: var(--text);
      font-weight: 850;
      word-break: keep-all;
    }
    .annual-stage-head {
      text-align: center;
    }
    .annual-stage strong {
      color: var(--gold);
      margin-right: 6px;
    }
    .annual-slot {
      position: relative;
      background:
        linear-gradient(90deg, rgba(255,255,255,0.022), transparent),
        var(--paper);
      text-align: center;
    }
    .annual-slot.active {
      background:
        linear-gradient(180deg, color-mix(in srgb, var(--bar-color) 70%, transparent), color-mix(in srgb, var(--bar-color) 54%, var(--paper)));
      border-color: color-mix(in srgb, var(--bar-color) 72%, var(--line));
      color: #fffaf0;
      box-shadow: inset 0 0 0 1px rgba(255, 250, 240, 0.08);
    }
    .annual-segment-label {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      max-width: 100%;
      min-height: 24px;
      border-radius: 999px;
      padding: 2px 8px;
      background: rgba(0, 0, 0, 0.22);
      color: #fffaf0;
      font-weight: 900;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .master-table-wrap {
      overflow-x: auto;
    }
    .master-table {
      width: 100%;
      border-collapse: collapse;
      font-size: 13px;
      line-height: 1.55;
      min-width: 920px;
    }
    .master-table th,
    .master-table td {
      border: 1px solid var(--line);
      padding: 9px 10px;
      vertical-align: top;
    }
    .master-table th {
      background: var(--surface-2);
      color: var(--gold);
      text-align: left;
      white-space: nowrap;
    }
    .master-table .phase-no {
      color: var(--gold);
      font-weight: 900;
      text-align: center;
      white-space: nowrap;
    }
    .schedule-note-layout {
      display: grid;
      grid-template-columns: minmax(0, 0.9fr) minmax(280px, 1.1fr);
      gap: 12px;
      align-items: start;
    }
    .schedule-note-grid {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 10px;
    }
    .schedule-note-card {
      position: relative;
      min-height: 92px;
      border: 1px solid var(--line);
      border-radius: 8px;
      background:
        radial-gradient(circle at 92% 10%, rgba(216, 186, 105, 0.12), transparent 30%),
        var(--paper);
      color: inherit;
      font: inherit;
      text-align: left;
      cursor: pointer;
      padding: 12px;
    }
    .schedule-note-card:hover,
    .schedule-note-card.active {
      border-color: var(--gold);
      background:
        radial-gradient(circle at 92% 10%, rgba(216, 186, 105, 0.18), transparent 32%),
        color-mix(in srgb, var(--paper) 88%, var(--gold) 12%);
    }
    .schedule-note-card::after {
      content: attr(data-preview);
      position: absolute;
      left: 10px;
      right: 10px;
      bottom: calc(100% + 8px);
      z-index: 5;
      display: none;
      border: 1px solid color-mix(in srgb, var(--gold) 42%, var(--line));
      border-radius: 8px;
      background: var(--paper);
      color: var(--muted);
      padding: 8px 10px;
      font-size: 12px;
      line-height: 1.45;
      box-shadow: var(--shadow);
    }
    .schedule-note-card:hover::after { display: block; }
    .schedule-note-card h3 {
      margin: 0 0 8px;
      color: var(--text);
      font-size: 15px;
      line-height: 1.35;
    }
    .schedule-note-detail {
      min-height: 280px;
      border: 1px solid var(--line);
      border-radius: 8px;
      background: var(--paper);
      padding: 18px;
    }
    .world-visual-grid,
    .faction-grid {
      display: grid;
      grid-template-columns: repeat(4, minmax(0, 1fr));
      gap: 10px;
    }
    .world-symbol-card,
    .faction-card {
      border: 1px solid var(--line);
      border-radius: 8px;
      background:
        radial-gradient(circle at 82% 8%, rgba(123, 170, 165, 0.14), transparent 30%),
        var(--paper);
      padding: 14px;
      color: inherit;
      text-decoration: none;
      min-height: 142px;
      display: flex;
      flex-direction: column;
      gap: 8px;
    }
    .world-symbol-card:hover,
    .faction-card:hover {
      border-color: var(--gold);
      color: var(--text);
    }
    .abstract-mark {
      width: 42px;
      height: 42px;
      border: 1px solid color-mix(in srgb, var(--gold) 58%, var(--line));
      border-radius: 50%;
      background:
        linear-gradient(90deg, transparent 44%, rgba(216, 186, 105, 0.55) 46% 54%, transparent 56%),
        linear-gradient(0deg, transparent 44%, rgba(123, 170, 165, 0.45) 46% 54%, transparent 56%),
        radial-gradient(circle, rgba(216, 186, 105, 0.15), transparent 58%);
      box-shadow: inset 0 0 0 7px rgba(216, 186, 105, 0.035);
      flex: 0 0 auto;
    }
    .faction-card h3,
    .world-symbol-card h3 {
      margin: 0;
      color: var(--gold);
      font-size: 15px;
      line-height: 1.35;
    }
    .faction-card p,
    .world-symbol-card p {
      margin: 0;
      color: var(--muted);
      font-size: 12px;
      line-height: 1.55;
      word-break: keep-all;
    }
    .timeline-panel {
      border: 1px solid var(--line);
      background: var(--surface);
      border-radius: var(--radius);
      padding: 18px;
      margin-bottom: 16px;
      overflow: hidden;
    }
    .timeline-scroll {
      overflow-x: auto;
      padding: 16px 0 6px;
    }
    .timeline-canvas {
      position: relative;
      min-width: 1600px;
      height: 520px;
      margin: 0 auto;
    }
    .timeline-axis {
      position: absolute;
      left: 36px;
      right: 36px;
      top: 252px;
      height: 58px;
      border-radius: 999px;
      background: color-mix(in srgb, var(--paper) 82%, white 8%);
      box-shadow: 0 10px 26px rgba(0, 0, 0, 0.24);
      border: 1px solid var(--line);
    }
    .timeline-axis::before {
      content: "";
      position: absolute;
      left: 28px;
      right: 28px;
      top: 28px;
      height: 2px;
      background: var(--line-strong);
    }
    .timeline-tick {
      position: absolute;
      top: 254px;
      height: 56px;
      width: 1px;
      background: var(--line);
    }
    .timeline-tick span {
      position: absolute;
      top: 15px;
      transform: translateX(-50%);
      color: var(--faint);
      font-weight: 800;
      font-size: 13px;
      white-space: nowrap;
    }
    .timeline-event {
      position: absolute;
      width: 148px;
      transform: translateX(-50%);
      text-align: center;
      color: var(--text);
    }
    .timeline-event.top { bottom: 292px; }
    .timeline-event.bottom { top: 324px; }
    .timeline-event::after {
      content: "";
      position: absolute;
      left: 50%;
      width: 1px;
      height: 48px;
      background: var(--event-color);
      opacity: 0.76;
    }
    .timeline-event.top::after { top: 100%; }
    .timeline-event.bottom::after { bottom: 100%; }
    .timeline-dot {
      position: absolute;
      left: 50%;
      width: 15px;
      height: 15px;
      border-radius: 4px;
      transform: translateX(-50%) rotate(45deg);
      background: var(--event-color);
      border: 2px solid var(--surface);
      z-index: 2;
    }
    .timeline-event.top .timeline-dot { top: calc(100% + 40px); }
    .timeline-event.bottom .timeline-dot { bottom: calc(100% + 40px); }
    .timeline-year {
      color: var(--faint);
      font-size: 11px;
      line-height: 1.2;
      margin-bottom: 4px;
    }
    .timeline-event.bottom .timeline-year {
      margin-top: 4px;
      margin-bottom: 0;
    }
    .timeline-title {
      font-size: 12px;
      line-height: 1.32;
      overflow-wrap: anywhere;
    }
    .timeline-kind {
      display: inline-flex;
      margin-top: 5px;
      padding: 1px 6px;
      border-radius: 999px;
      border: 1px solid color-mix(in srgb, var(--event-color) 48%, var(--line));
      color: var(--event-color);
      font-size: 10px;
    }
    .timeline-legend {
      display: flex;
      gap: 8px;
      flex-wrap: wrap;
      margin-top: 8px;
    }
    .note-panel {
      padding: 12px 14px;
      border: 1px solid var(--line);
      background: var(--surface-2);
      border-radius: 8px;
      color: var(--muted);
      font-size: 13px;
    }
    .empty {
      padding: 32px;
      border: 1px dashed var(--line-strong);
      color: var(--muted);
      border-radius: 8px;
      text-align: center;
    }
    body.focus .sidebar,
    body.focus .outline {
      display: none;
    }
    body.focus .app {
      grid-template-columns: 1fr;
    }
    body.focus .content {
      padding-left: 18px;
      padding-right: 18px;
    }
    body.focus .doc-layout {
      grid-template-columns: minmax(0, 1fr);
    }
    body.focus .shell {
      max-width: 1040px;
    }
    body.focus .doc-body {
      max-width: 980px;
      margin: 0 auto;
    }
    @media (prefers-reduced-motion: reduce) {
      *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
        transition-duration: 0.001ms !important;
      }
    }
    @media (max-width: 1080px) {
      .app { grid-template-columns: 248px minmax(0, 1fr); }
      .card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
      .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
      .setting-index-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
      .world-visual-grid,
      .faction-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
      .schedule-note-layout { grid-template-columns: 1fr; }
      .character-grid,
      .relation-board { grid-template-columns: repeat(2, minmax(0, 1fr)); }
      .character-group-grid { grid-template-columns: 1fr; }
      .doc-layout { grid-template-columns: minmax(0, 1fr); }
      .outline { position: static; max-height: none; }
      .relation-map.cluster { min-height: 900px; }
      .relation-cluster { width: 220px; }
    }
    @media (max-width: 760px) {
      .app { display: block; }
      .topbar { position: sticky; flex-wrap: wrap; height: auto; padding: 10px 12px; }
      .brand { min-width: 100%; }
      .toolbar { margin-left: 0; width: 100%; overflow-x: auto; }
      .privacy-chip { display: none; }
      .sidebar { border-right: 0; border-bottom: 1px solid var(--line); max-height: 280px; }
      .content { padding: 18px 14px 50px; }
      .hero { grid-template-columns: 1fr; }
      .hero-main { padding: 24px; min-height: 190px; }
      h1 { font-size: 25px; }
      .card-grid { grid-template-columns: 1fr; }
      .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
      .setting-index-grid { grid-template-columns: 1fr; }
      .world-visual-grid,
      .faction-grid,
      .schedule-note-grid { grid-template-columns: 1fr; }
      .character-grid,
      .relation-board { grid-template-columns: 1fr; }
      .relation-map.cluster { min-height: 1180px; }
      .doc-body { padding: 22px 17px; }
      body.roomy .doc-body,
      body.roomy .character-detail-body { padding: 24px 18px; }
      .searchbox { max-width: none; min-width: 100%; }
    }

.backup-status {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(0, 0, 0, 0.12);
  white-space: nowrap;
  font-size: 12px;
}
.account-btn {
  position: relative;
  gap: 7px;
}
.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 0 3px rgba(185, 102, 91, 0.16);
}
.account-btn.ready .status-dot {
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(130, 173, 130, 0.18);
}
.tool-btn[disabled] {
  cursor: not-allowed;
  opacity: 0.48;
}
.loading-panel,
.error-panel {
  min-height: 300px;
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--surface), var(--surface-2));
  box-shadow: var(--shadow);
}
.loading-panel h1,
.error-panel h1 {
  margin: 8px 0;
}
.error-panel {
  border-color: color-mix(in srgb, var(--red) 56%, var(--line));
}
.toast-region {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 100;
  display: grid;
  gap: 8px;
  max-width: min(420px, calc(100vw - 36px));
}
.toast,
.status-banner {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 12px 14px;
  color: var(--text);
  background: color-mix(in srgb, var(--surface) 90%, black);
  box-shadow: var(--shadow);
  font-size: 13px;
}
.toast.ok {
  border-color: color-mix(in srgb, var(--green) 62%, var(--line));
}
.toast.warn,
.toast.error {
  border-color: color-mix(in srgb, var(--red) 62%, var(--line));
}
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.62);
}
.account-modal {
  width: min(620px, 100%);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.account-modal header,
.account-modal footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}
.account-modal footer {
  justify-content: flex-end;
  border-top: 1px solid var(--line);
  border-bottom: 0;
}
.account-modal h2 {
  margin: 0;
  font-size: 18px;
}
.account-modal .modal-body {
  display: grid;
  gap: 14px;
  padding: 18px;
}
.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.field {
  display: grid;
  gap: 6px;
}
.field label {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0;
}
.field input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 10px;
  color: var(--text);
  background: var(--paper);
}
.modal-help {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}
.modal-warning {
  border: 1px solid color-mix(in srgb, var(--red) 46%, var(--line));
  border-radius: var(--radius);
  padding: 10px 12px;
  color: var(--text);
  background: rgba(185, 102, 91, 0.12);
  font-size: 13px;
}
@media (max-width: 760px) {
  .backup-status { width: 100%; justify-content: center; }
  .field-grid { grid-template-columns: 1fr; }
}
