﻿:root {
  --bg: #0c0b09;
  --bg-soft: #121009;
  --panel: #17150f;
  --panel-2: #1d1a13;
  --panel-3: #211d15;
  --border: #2b2719;
  --border-strong: #3d3625;
  --text: #ece7da;
  --muted: #9b927b;
  --accent: #d9b45b;
  --accent-soft: rgba(217, 180, 91, 0.12);
  --link: rgba(217, 180, 91, 0.24);
  --link-match: rgba(255, 233, 176, 0.8);
  --label-fill: #b5ab92;
  --text-stroke: rgba(12, 11, 9, 0.92);
  --fade-a: rgba(12, 11, 9, 0.85);
  --fade-b: rgba(12, 11, 9, 0.4);
  --nebula-bg:
    radial-gradient(1200px 700px at 12% 8%, #3b2b12 0%, transparent 60%),
    radial-gradient(900px 620px at 88% 82%, #33180d 0%, transparent 60%),
    radial-gradient(1000px 780px at 74% 12%, #2b2412 0%, transparent 55%),
    linear-gradient(180deg, #14100a 0%, #0c0b09 100%);
  --n1: rgba(255, 190, 80, 0.3);
  --n2: rgba(255, 140, 60, 0.26);
  --n3: rgba(255, 96, 128, 0.14);
  --n4: rgba(255, 226, 150, 0.2);
  --topbar-bg: rgba(12, 11, 9, 0.88);
  --title-glow: 0 0 40px rgba(217, 180, 91, 0.35), 0 0 90px rgba(255, 160, 80, 0.2);
  --shadow-1: 0 10px 34px rgba(0, 0, 0, 0.5);
  --shadow-2: 0 18px 48px rgba(0, 0, 0, 0.6);
  --shadow-3: 0 30px 90px rgba(0, 0, 0, 0.65);
  --shadow-tip: 0 14px 40px rgba(0, 0, 0, 0.55);
  --serif: "Noto Serif JP", "Hiragino Mincho ProN", "Yu Mincho", "MS PMincho", serif;
  --sans: "Inter", "Noto Sans JP", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", sans-serif;
  color-scheme: dark;
}

/* ---------- themes ---------- */
html[data-theme="nebula"] {
  --bg: #0c0a14; --bg-soft: #120e1c; --panel: #161226; --panel-2: #1c1730; --panel-3: #221b3a;
  --border: #2b2245; --border-strong: #3e3160;
  --text: #eee8f7; --muted: #9d92b8; --accent: #b58ce0; --accent-soft: rgba(181, 140, 224, 0.13);
  --link: rgba(181, 140, 224, 0.26); --link-match: rgba(235, 215, 255, 0.85);
  --label-fill: #b7a8d8; --text-stroke: rgba(12, 10, 20, 0.92);
  --fade-a: rgba(12, 10, 20, 0.85); --fade-b: rgba(12, 10, 20, 0.4);
  --nebula-bg:
    radial-gradient(1200px 700px at 12% 8%, #2e1a4d 0%, transparent 60%),
    radial-gradient(900px 620px at 88% 82%, #2a1150 0%, transparent 60%),
    radial-gradient(1000px 780px at 74% 12%, #1d1440 0%, transparent 55%),
    linear-gradient(180deg, #120e20 0%, #0c0a14 100%);
  --n1: rgba(160, 110, 255, 0.32); --n2: rgba(120, 80, 230, 0.26);
  --n3: rgba(220, 120, 255, 0.16); --n4: rgba(180, 150, 255, 0.22);
}
html[data-theme="crimson"] {
  --bg: #120a0a; --bg-soft: #180e0b; --panel: #1c1210; --panel-2: #241713; --panel-3: #2c1a15;
  --border: #3a2118; --border-strong: #512e22;
  --text: #f5e8e0; --muted: #b3938a; --accent: #e07a5f; --accent-soft: rgba(224, 122, 95, 0.14);
  --link: rgba(224, 122, 95, 0.26); --link-match: rgba(255, 200, 180, 0.85);
  --label-fill: #c99a8e; --text-stroke: rgba(18, 10, 10, 0.92);
  --fade-a: rgba(18, 10, 10, 0.85); --fade-b: rgba(18, 10, 10, 0.4);
  --nebula-bg:
    radial-gradient(1200px 700px at 12% 8%, #4d1f14 0%, transparent 60%),
    radial-gradient(900px 620px at 88% 82%, #4d1210 0%, transparent 60%),
    radial-gradient(1000px 780px at 74% 12%, #3d1810 0%, transparent 55%),
    linear-gradient(180deg, #1c0f0c 0%, #120a0a 100%);
  --n1: rgba(255, 90, 70, 0.3); --n2: rgba(200, 50, 60, 0.26);
  --n3: rgba(255, 150, 110, 0.14); --n4: rgba(255, 120, 90, 0.2);
}
html[data-theme="ocean"] {
  --bg: #081018; --bg-soft: #0a1520; --panel: #0e1a26; --panel-2: #122030; --panel-3: #16263a;
  --border: #1e3350; --border-strong: #2d4a70;
  --text: #e4eef7; --muted: #93a8bf; --accent: #6fb3e8; --accent-soft: rgba(111, 179, 232, 0.13);
  --link: rgba(111, 179, 232, 0.26); --link-match: rgba(200, 230, 255, 0.85);
  --label-fill: #a9c4dd; --text-stroke: rgba(8, 16, 24, 0.92);
  --fade-a: rgba(8, 16, 24, 0.85); --fade-b: rgba(8, 16, 24, 0.4);
  --nebula-bg:
    radial-gradient(1200px 700px at 12% 8%, #0f2e52 0%, transparent 60%),
    radial-gradient(900px 620px at 88% 82%, #0b2145 0%, transparent 60%),
    radial-gradient(1000px 780px at 74% 12%, #0e2450 0%, transparent 55%),
    linear-gradient(180deg, #0a1726 0%, #081018 100%);
  --n1: rgba(80, 150, 255, 0.3); --n2: rgba(60, 110, 220, 0.26);
  --n3: rgba(100, 220, 255, 0.14); --n4: rgba(140, 190, 255, 0.2);
}
html[data-theme="solitude"] {
  --bg: #140b12; --bg-soft: #1a0f18; --panel: #1e1220; --panel-2: #261627; --panel-3: #2e1a30;
  --border: #402840; --border-strong: #5c3a5c;
  --text: #f7e8f0; --muted: #c09aae; --accent: #e89ab8; --accent-soft: rgba(232, 154, 184, 0.14);
  --link: rgba(232, 154, 184, 0.26); --link-match: rgba(255, 215, 232, 0.85);
  --label-fill: #d3a8bc; --text-stroke: rgba(20, 11, 18, 0.92);
  --fade-a: rgba(20, 11, 18, 0.85); --fade-b: rgba(20, 11, 18, 0.4);
  --nebula-bg:
    radial-gradient(1200px 700px at 12% 8%, #45152e 0%, transparent 60%),
    radial-gradient(900px 620px at 88% 82%, #40102e 0%, transparent 60%),
    radial-gradient(1000px 780px at 74% 12%, #38152c 0%, transparent 55%),
    linear-gradient(180deg, #1e1020 0%, #140b12 100%);
  --n1: rgba(255, 120, 180, 0.28); --n2: rgba(240, 90, 150, 0.22);
  --n3: rgba(255, 180, 210, 0.14); --n4: rgba(255, 140, 190, 0.2);
}
html[data-theme="garden"] {
  --bg: #0a120b; --bg-soft: #0d1710; --panel: #122016; --panel-2: #162618; --panel-3: #1b2e1d;
  --border: #27402a; --border-strong: #3a5c3d;
  --text: #e8f4e6; --muted: #9cba96; --accent: #8fd08a; --accent-soft: rgba(143, 208, 138, 0.13);
  --link: rgba(143, 208, 138, 0.26); --link-match: rgba(215, 255, 205, 0.85);
  --label-fill: #abd4a4; --text-stroke: rgba(10, 18, 11, 0.92);
  --fade-a: rgba(10, 18, 11, 0.85); --fade-b: rgba(10, 18, 11, 0.4);
  --nebula-bg:
    radial-gradient(1200px 700px at 12% 8%, #16381c 0%, transparent 60%),
    radial-gradient(900px 620px at 88% 82%, #103318 0%, transparent 60%),
    radial-gradient(1000px 780px at 74% 12%, #153a18 0%, transparent 55%),
    linear-gradient(180deg, #0d1a10 0%, #0a120b 100%);
  --n1: rgba(110, 220, 130, 0.28); --n2: rgba(80, 180, 120, 0.24);
  --n3: rgba(180, 240, 150, 0.14); --n4: rgba(140, 230, 160, 0.2);
}
html[data-theme="paper"] {
  color-scheme: light;
  --bg: #f2e9d8; --bg-soft: #efe4cc; --panel: #f8f1e2; --panel-2: #efe4cc; --panel-3: #e9dcbf;
  --border: #d9c9a8; --border-strong: #c4ae85;
  --text: #332f26; --muted: #7c7260; --accent: #a06c3c; --accent-soft: rgba(160, 108, 60, 0.14);
  --link: rgba(120, 80, 30, 0.45); --link-match: rgba(120, 80, 30, 0.65);
  --label-fill: #4f4838; --text-stroke: rgba(243, 234, 216, 0.95);
  --fade-a: rgba(242, 233, 216, 0.9); --fade-b: rgba(242, 233, 216, 0.45);
  --topbar-bg: rgba(248, 241, 226, 0.94);
  --title-glow: 0 0 34px rgba(190, 150, 90, 0.3), 0 0 70px rgba(200, 170, 120, 0.18);
  --shadow-1: 0 10px 28px rgba(110, 85, 50, 0.22);
  --shadow-2: 0 16px 38px rgba(110, 85, 50, 0.26);
  --shadow-3: 0 26px 70px rgba(110, 85, 50, 0.3);
  --shadow-tip: 0 12px 32px rgba(110, 85, 50, 0.24);
  --nebula-bg:
    radial-gradient(1200px 700px at 12% 8%, #f7e6c4 0%, transparent 60%),
    radial-gradient(900px 620px at 88% 82%, #f2dcc0 0%, transparent 60%),
    radial-gradient(1000px 780px at 74% 12%, #f5e6cf 0%, transparent 55%),
    linear-gradient(180deg, #f7efdd 0%, #f2e9d8 100%);
  --n1: rgba(190, 150, 90, 0.3); --n2: rgba(170, 130, 80, 0.24);
  --n3: rgba(210, 170, 120, 0.16); --n4: rgba(200, 160, 100, 0.22);
}
html[data-theme="paper"] .nebula i { mix-blend-mode: multiply; }
html[data-theme="paper"] #graph .node .star { stroke: rgba(90, 65, 40, 0.6); }
html[data-theme="paper"] mark { background: rgba(190, 150, 80, 0.35); color: #6b4e22; }
html[data-theme="paper"] .article strong { color: #7a5b2e; }
html[data-theme="paper"] .v-tag.lv { color: color-mix(in srgb, var(--vl) 80%, #000); }
html[data-theme="paper"] .chip.active { color: #f8f1e2; }
html[data-theme="aurora"] {
  --bg: #050d10; --bg-soft: #071318; --panel: #0c1a1e; --panel-2: #102228; --panel-3: #142a30;
  --border: #1c3a40; --border-strong: #2a5560;
  --text: #e2f2f4; --muted: #8fb0b8; --accent: #5fd6c8; --accent-soft: rgba(95, 214, 200, 0.13);
  --link: rgba(95, 214, 200, 0.26); --link-match: rgba(200, 255, 240, 0.85);
  --label-fill: #a3ccd0; --text-stroke: rgba(5, 13, 16, 0.92);
  --fade-a: rgba(5, 13, 16, 0.85); --fade-b: rgba(5, 13, 16, 0.4);
  --nebula-bg:
    radial-gradient(1200px 700px at 12% 8%, #0d3a3a 0%, transparent 60%),
    radial-gradient(900px 620px at 88% 82%, #0a2e42 0%, transparent 60%),
    radial-gradient(1000px 780px at 74% 12%, #0c3340 0%, transparent 55%),
    linear-gradient(180deg, #071520 0%, #050d10 100%);
  --n1: rgba(60, 255, 190, 0.2); --n2: rgba(50, 180, 255, 0.18);
  --n3: rgba(180, 255, 220, 0.12); --n4: rgba(120, 220, 255, 0.16);
}
html[data-theme="spring"], html[data-theme="sakura"] {
  --bg: #1d1524; --bg-soft: #241a2e; --panel: #2a1f36; --panel-2: #332645; --panel-3: #3c2d4f;
  --border: #4a3555; --border-strong: #6b4f7c;
  --text: #fdf0f6; --muted: #d3aec4; --accent: #ff9ec4; --accent-soft: rgba(255, 158, 196, 0.16);
  --link: rgba(255, 158, 196, 0.3); --link-match: rgba(255, 225, 240, 0.9);
  --label-fill: #e8c8d8; --text-stroke: rgba(29, 21, 36, 0.92);
  --fade-a: rgba(29, 21, 36, 0.85); --fade-b: rgba(29, 21, 36, 0.4);
  --nebula-bg:
    radial-gradient(1200px 700px at 12% 8%, #46204e 0%, transparent 60%),
    radial-gradient(900px 620px at 88% 82%, #3d1a3f 0%, transparent 60%),
    radial-gradient(1000px 780px at 74% 12%, #233a1e 0%, transparent 55%),
    linear-gradient(180deg, #251a2c 0%, #1d1524 100%);
  --n1: rgba(255, 150, 200, 0.32); --n2: rgba(190, 120, 230, 0.22);
  --n3: rgba(140, 225, 130, 0.16); --n4: rgba(255, 210, 235, 0.26);
}
html[data-theme="summer"] {
  --bg: #070f13; --bg-soft: #0a1519; --panel: #0e1a1c; --panel-2: #122021; --panel-3: #162624;
  --border: #1f3a33; --border-strong: #2d5347;
  --text: #eaf3e8; --muted: #9db8a6; --accent: #f2d06b; --accent-soft: rgba(242, 208, 107, 0.14);
  --link: rgba(242, 208, 107, 0.26); --link-match: rgba(255, 240, 190, 0.85);
  --label-fill: #b8d0b8; --text-stroke: rgba(7, 15, 19, 0.92);
  --fade-a: rgba(7, 15, 19, 0.85); --fade-b: rgba(7, 15, 19, 0.4);
  --nebula-bg:
    radial-gradient(1200px 700px at 12% 8%, #0d3a2c 0%, transparent 60%),
    radial-gradient(900px 620px at 88% 82%, #0a3328 0%, transparent 60%),
    radial-gradient(1000px 780px at 74% 12%, #0d3527 0%, transparent 55%),
    linear-gradient(180deg, #091b1e 0%, #070f13 100%);
  --n1: rgba(150, 255, 170, 0.18); --n2: rgba(80, 200, 160, 0.16);
  --n3: rgba(255, 230, 140, 0.14); --n4: rgba(120, 220, 180, 0.14);
}
html[data-theme="autumn"] {
  --bg: #130d08; --bg-soft: #180f09; --panel: #1e1510; --panel-2: #261a12; --panel-3: #2e2116;
  --border: #40301a; --border-strong: #5c4526;
  --text: #f5ead9; --muted: #c0a98c; --accent: #e8935f; --accent-soft: rgba(232, 147, 95, 0.14);
  --link: rgba(232, 147, 95, 0.26); --link-match: rgba(255, 210, 170, 0.85);
  --label-fill: #cfb192; --text-stroke: rgba(19, 13, 8, 0.92);
  --fade-a: rgba(19, 13, 8, 0.85); --fade-b: rgba(19, 13, 8, 0.4);
  --nebula-bg:
    radial-gradient(1200px 700px at 12% 8%, #4d2a10 0%, transparent 60%),
    radial-gradient(900px 620px at 88% 82%, #4d1c0c 0%, transparent 60%),
    radial-gradient(1000px 780px at 74% 12%, #40240c 0%, transparent 55%),
    linear-gradient(180deg, #20140a 0%, #130d08 100%);
  --n1: rgba(255, 150, 70, 0.26); --n2: rgba(200, 90, 50, 0.22);
  --n3: rgba(255, 190, 100, 0.16); --n4: rgba(255, 160, 90, 0.2);
}
html[data-theme="winter"] {
  --bg: #0b1018; --bg-soft: #0e1520; --panel: #121a26; --panel-2: #161f2e; --panel-3: #1b2536;
  --border: #24344c; --border-strong: #364a6b;
  --text: #e8eef7; --muted: #9db0c9; --accent: #a8c8e8; --accent-soft: rgba(168, 200, 232, 0.13);
  --link: rgba(168, 200, 232, 0.26); --link-match: rgba(225, 240, 255, 0.85);
  --label-fill: #b6c8de; --text-stroke: rgba(11, 16, 24, 0.92);
  --fade-a: rgba(11, 16, 24, 0.85); --fade-b: rgba(11, 16, 24, 0.4);
  --nebula-bg:
    radial-gradient(1200px 700px at 12% 8%, #14294d 0%, transparent 60%),
    radial-gradient(900px 620px at 88% 82%, #101f42 0%, transparent 60%),
    radial-gradient(1000px 780px at 74% 12%, #12224a 0%, transparent 55%),
    linear-gradient(180deg, #0e1628 0%, #0b1018 100%);
  --n1: rgba(150, 190, 255, 0.2); --n2: rgba(110, 150, 230, 0.16);
  --n3: rgba(220, 235, 255, 0.14); --n4: rgba(170, 205, 255, 0.16);
}
html[data-theme="aurora"] .nebula::after {
  content: '';
  position: absolute;
  inset: -30%;
  background:
    linear-gradient(115deg, transparent 30%, rgba(80, 255, 190, 0.18) 40%, transparent 52%, rgba(90, 180, 255, 0.16) 62%, transparent 74%),
    linear-gradient(295deg, transparent 35%, rgba(180, 255, 220, 0.12) 46%, transparent 60%, rgba(60, 200, 255, 0.14) 70%, transparent 82%);
  background-size: 220% 220%;
  mix-blend-mode: screen;
  animation: auroraShift 26s ease-in-out infinite alternate;
}
@keyframes auroraShift {
  from { transform: translate3d(-4%, -2%, 0) rotate(-6deg); }
  to { transform: translate3d(4%, 2%, 0) rotate(6deg); }
}
#fx { position: fixed; inset: 0; z-index: 1; pointer-events: none; overflow: hidden; }
.fx {
  position: absolute;
  top: -6vh;
  animation: fxFall linear infinite;
}
.fx.petal {
  width: 10px;
  height: 14px;
  border-radius: 70% 0 70% 0;
  background: linear-gradient(135deg, #ffd9e8, #f6a8c8);
}
.fx.leaf {
  width: 11px;
  height: 15px;
  background: linear-gradient(135deg, #e05a30, #a0301e);
  clip-path: polygon(50% 0%, 61% 9%, 72% 4%, 76% 17%, 91% 12%, 88% 26%, 100% 33%, 86% 40%, 92% 54%, 78% 58%, 83% 73%, 66% 69%, 64% 87%, 50% 76%, 36% 87%, 34% 69%, 17% 73%, 22% 58%, 8% 54%, 14% 40%, 0% 33%, 12% 26%, 9% 12%, 24% 17%, 28% 4%, 39% 9%);
}
.fx.leaf.green {
  background: linear-gradient(135deg, #6fbf5e, #2e8b4e);
}
.fx.mote {
  border-radius: 50%;
  background: radial-gradient(circle, #ffffff 0%, rgba(255, 255, 255, 0.4) 55%, transparent 75%);
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.65);
  animation-name: fxDrift;
  animation-iteration-count: infinite;
}
.fx.mote.gold {
  background: radial-gradient(circle, #ffe9a8 0%, rgba(255, 214, 120, 0.45) 55%, transparent 75%);
  box-shadow: 0 0 8px rgba(255, 205, 90, 0.7);
}
.fx.snow {
  top: -3vh;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: rgba(240, 248, 255, 0.9);
  box-shadow: 0 0 6px rgba(240, 248, 255, 0.6);
  animation-name: fxSnow;
  animation-iteration-count: infinite;
}
.fx.firefly {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: radial-gradient(circle, #fff7c0 0%, #f2d06b 55%, transparent 78%);
  animation-name: fxFirefly;
  animation-iteration-count: infinite;
  animation-direction: alternate;
}
.fx.wind {
  top: var(--wtop, 30vh);
  left: 0;
  height: 3px;
  border-radius: 50%;
  background: linear-gradient(90deg, transparent, rgba(205, 250, 228, 0.85) 32%, #ffffff 52%, rgba(205, 250, 228, 0.7) 72%, transparent);
  box-shadow: 0 0 12px rgba(180, 245, 215, 0.5);
  animation-name: fxWind;
  animation-duration: var(--wd, 16s);
  animation-iteration-count: infinite;
}
.fx.wind::before,
.fx.wind::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: inherit;
}
.fx.wind::before {
  transform: translateY(-7px) scaleX(0.55);
  opacity: 0.5;
}
.fx.wind::after {
  transform: translateY(6px) scaleX(0.35);
  opacity: 0.3;
}
@keyframes fxWind {
  0% { transform: translateX(-20vw) translateY(0); opacity: 0; }
  8% { opacity: var(--wo, 0.35); }
  50% { transform: translateX(50vw) translateY(var(--wobble, 3vh)); }
  92% { opacity: var(--wo, 0.35); }
  100% { transform: translateX(115vw) translateY(0); opacity: 0; }
}
@keyframes fxFall {
  0% { transform: translate3d(0, -6vh, 0) rotate(0deg); }
  100% { transform: translate3d(var(--sway, 12vw), 112vh, 0) rotate(var(--spin, 420deg)); }
}
@keyframes fxSnow {
  0% { transform: translate3d(0, -3vh, 0); opacity: 0; }
  8% { opacity: 0.9; }
  100% { transform: translate3d(var(--sway, 6vw), 108vh, 0); opacity: 0.5; }
}
@keyframes fxFirefly {
  0%, 100% { transform: translate3d(0, 0, 0) scale(0.6); opacity: 0.12; }
  50% { transform: translate3d(var(--dx, 6vw), var(--dy, -4vh), 0) scale(1.2); opacity: 0.95; }
}
@keyframes fxDrift {
  0% { transform: translate3d(-8vw, 0, 0); opacity: 0; }
  10% { opacity: var(--mo, 0.6); }
  88% { opacity: var(--mo, 0.6); }
  100% { transform: translate3d(105vw, var(--sway, 0), 0); opacity: 0; }
}
.themes { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.theme-swatch {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}
.theme-swatch:hover { transform: scale(1.18); }
.theme-swatch.on { border-color: var(--accent); box-shadow: 0 0 8px var(--accent); }

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  min-height: 100%;
}

/* ---------- galaxy background ---------- */
.nebula {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  background: var(--nebula-bg);
}
.nebula i {
  position: absolute;
  border-radius: 50%;
  background: radial-gradient(circle at center, var(--nb), transparent 72%);
  mix-blend-mode: screen;
  opacity: var(--nebula-opacity, 1);
  animation: drift 36s ease-in-out infinite alternate;
}
.nebula-scroll {
  position: absolute;
  inset: 0;
  will-change: transform;
}
body.no-nebula .nebula { display: none; }
body.no-starfield #starfield { display: none; }
.nebula .n1 { width: 46vmax; height: 46vmax; left: -8vmax; top: -6vmax; --nb: var(--n1); }
.nebula .n2 { width: 40vmax; height: 40vmax; right: -6vmax; top: 10vmax; --nb: var(--n2); animation-delay: -12s; animation-duration: 46s; }
.nebula .n3 { width: 34vmax; height: 34vmax; left: 30%; bottom: -11vmax; --nb: var(--n3); animation-delay: -24s; animation-duration: 41s; }
.nebula .n4 { width: 26vmax; height: 26vmax; left: 55%; top: 28%; --nb: var(--n4); animation-delay: -7s; animation-duration: 54s; }

@keyframes drift {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to { transform: translate3d(5vmax, 4vmax, 0) scale(1.18); }
}

#starfield {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

#graph {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  cursor: grab;
  touch-action: none;
  user-select: none;
}
#graph.dragging { cursor: grabbing; }

#graph .link {
  stroke: var(--link);
  stroke-width: 1;
  transition: opacity 0.3s;
}
#graph .link.dim { opacity: 0; }
#graph .link.match { stroke: var(--link-match); }

#graph .node {
  pointer-events: auto;
  cursor: pointer;
  transition: opacity 0.35s;
}
#graph .node.dim { opacity: 0; pointer-events: none; }
#graph .node .hit { pointer-events: all; }
#graph .node .inner {
  transform-box: fill-box;
  transform-origin: center;
  transition: transform 0.25s;
}
#graph .node.hover .inner, #graph .node.match .inner, #graph .node.dragging .inner { transform: scale(1.32); }
#graph .node.dragging .star {
  filter: drop-shadow(0 0 14px var(--glow, #d9b45b)) brightness(1.4);
}
#graph .node .star {
  transform: scale(var(--star-scale, 1));
  transform-box: fill-box;
  transform-origin: center;
  animation: twinkle calc(var(--td, 2.6s) * var(--twinkle-mult, 1)) ease-in-out infinite;
  animation-delay: var(--tdelay, 0s);
  filter: drop-shadow(0 0 calc(var(--star-glow-blur, 5px) * var(--rich, 1)) var(--glow, #d9b45b));
}
#graph .node.match .star, #graph .node.hover .star {
  filter: drop-shadow(0 0 calc(var(--star-glow-blur-h, 11px) * var(--rich, 1)) var(--glow, #d9b45b)) brightness(1.25);
}

body.no-links #graph .link { display: none; }

@keyframes twinkle {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

#graph .node text {
  fill: var(--label-fill);
  font-family: var(--serif);
  font-size: 12px;
  text-anchor: middle;
  paint-order: stroke;
  stroke: var(--text-stroke);
  stroke-width: 3px;
  pointer-events: none;
  transition: opacity 0.3s;
}

.fade {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 32%, var(--fade-a) 0%, var(--fade-b) 45%, rgba(0, 0, 0, 0) 70%);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--border);
}

.brand {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 19px;
  letter-spacing: 0.12em;
  color: var(--text);
  text-decoration: none;
}
.brand::before { content: "📖 "; letter-spacing: 0; }

.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 13px;
}

#langSel {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 13px;
  font-family: var(--sans);
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s;
}
#langSel:hover { border-color: var(--accent); }
#langSel option { background: var(--panel-2); color: var(--text); }

.btn {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
  font-family: var(--sans);
  transition: border-color 0.15s, background 0.15s;
}
.btn:hover { border-color: var(--accent); background: var(--accent-soft); }
.btn:disabled { opacity: 0.4; cursor: default; }
.btn:disabled:hover { border-color: var(--border); background: var(--panel-2); }

/* ---------- settings ---------- */
.settings {
  position: fixed;
  top: 58px;
  right: 16px;
  z-index: 40;
  width: 300px;
  background: var(--panel-2);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  padding: 16px 18px;
  box-shadow: var(--shadow-2);
}
.set-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 12.5px;
  color: var(--muted);
  margin: 9px 0;
  cursor: pointer;
}
.set-row input[type="range"] {
  width: 110px;
  accent-color: var(--accent);
  cursor: pointer;
}
.set-row input[type="checkbox"] {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
  cursor: pointer;
}
.set-val {
  display: inline-block;
  min-width: 38px;
  text-align: right;
  color: var(--accent);
  font-weight: 600;
  font-size: 12px;
}
.set-actions { display: flex; justify-content: flex-end; margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--border); }

#main { position: relative; z-index: 1; pointer-events: none; }
#main .searchbox, #main #chips, #main #levelchips, #main #favs, #main #recent, #main .back, #main .article { pointer-events: auto; }

.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 60px);
  padding: 6vh 20px 8vh;
  text-align: center;
}

.title {
  font-family: var(--serif);
  font-size: clamp(44px, 8vw, 76px);
  font-weight: 700;
  letter-spacing: 0.04em;
  margin: 0 0 14px;
  color: var(--text);
  text-shadow: var(--title-glow);
}

.sub {
  color: var(--muted);
  font-size: 14.5px;
  line-height: 1.8;
  margin: 0 0 34px;
}

code.inline {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 7px;
  font-size: 0.92em;
  color: var(--accent);
}

.searchbox {
  position: relative;
  width: min(620px, 92vw);
}

#search {
  width: 100%;
  min-height: 58px;
  padding: 14px 22px;
  font-size: 16px;
  font-family: var(--sans);
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  outline: none;
  box-shadow: var(--shadow-1);
  transition: border-color 0.15s, box-shadow 0.15s;
}
#search::placeholder { color: #6d6652; }
#search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow-1);
}

.suggest {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow-2);
  text-align: left;
  z-index: 30;
}

.suggest-item {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 12px 18px;
  cursor: pointer;
}
.suggest-item:hover, .suggest-item.active { background: var(--accent-soft); }
.suggest-item .s-title { font-size: 15px; font-weight: 600; }
.suggest-item .s-summary {
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.suggest-item .s-summary.s-alias { color: var(--accent); }
.suggest-item .s-cat {
  margin-left: auto;
  flex-shrink: 0;
  font-size: 11px;
  color: var(--accent);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2px 10px;
}
.suggest-empty { padding: 14px 18px; color: var(--muted); font-size: 13.5px; }

mark { background: rgba(217, 180, 91, 0.35); color: #ffe9b0; border-radius: 3px; padding: 0 1px; }

.stats { margin: 14px 0 0; font-size: 12.5px; }

#chips, #levelchips, #favs, #recent {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 16px;
}
#levelchips { margin-top: 8px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 14px;
  cursor: pointer;
  transition: all 0.15s;
}
.chip .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.chip:hover { border-color: var(--accent); color: var(--text); }
.chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #1a1406;
  font-weight: 600;
}
.chip.active .dot { outline: 1px solid rgba(0, 0, 0, 0.4); }

.graph-hint {
  text-align: center;
  font-size: 12px;
  color: #6d6652;
  margin: -6px 0 48px;
}

/* ---------- detail ---------- */
#detail { width: min(1180px, 94vw); margin: 30px auto 80px; }

.back {
  display: inline-block;
  color: var(--muted);
  text-decoration: none;
  font-size: 13.5px;
  margin-bottom: 20px;
}
.back:hover { color: var(--accent); }

.article {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px 44px;
  line-height: 1.95;
  font-size: 15px;
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 30px;
  align-items: start;
}
.detail-main { min-width: 0; }

.lang-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 20px; }
.lang-tab {
  font-size: 12.5px;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 14px;
  cursor: pointer;
  font-family: var(--sans);
  transition: all 0.15s;
}
.lang-tab:hover { border-color: var(--accent); color: var(--text); }
.lang-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #1a1406;
  font-weight: 600;
}
.detail-aside {
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  top: 84px;
}

.aside-card {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px 18px;
}
.aside-card h3 {
  font-family: var(--serif);
  font-size: 12.5px;
  letter-spacing: 0.14em;
  color: var(--accent);
  margin: 0 0 10px;
  text-transform: uppercase;
}
.meta-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 7px 0;
  border-bottom: 1px dashed var(--border);
  font-size: 13px;
}
.meta-row:last-of-type { border-bottom: none; }
.meta-row .k { color: var(--muted); flex-shrink: 0; }
.meta-row .v { color: var(--text); text-align: right; line-height: 1.6; }
.meta-row .v.level { color: var(--accent); font-weight: 600; }
.meta-row .v.alias { color: var(--accent); }

.toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.toc-list li { margin: 0; }
.toc-list a {
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  line-height: 1.5;
  display: block;
  padding: 3px 0 3px 13px;
  border-left: 2px solid var(--border);
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  border-radius: 0 6px 6px 0;
}
.toc-list a:hover {
  color: var(--accent);
  border-left-color: var(--accent);
  background: var(--accent-soft);
}
.toc-list .toc-h3 a {
  padding-left: 27px;
  border-left-style: dashed;
  font-size: 12.5px;
  color: #7d756a;
}
.toc-list .toc-h3 a:hover { color: var(--accent); border-left-color: var(--accent); }

.article .src { font-size: 12.5px; color: var(--muted); margin: 0; line-height: 1.6; word-break: break-all; }

.sources { display: flex; flex-direction: column; gap: 9px; }
.src-item {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
  line-height: 1.35;
  padding: 7px 9px;
  border-radius: 9px;
  background: var(--panel-3);
  border: 1px solid var(--border);
  transition: border-color 0.15s, background 0.15s;
}
.src-item:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}
.src-ico {
  flex: none;
  width: 20px;
  height: 20px;
  color: var(--accent);
  opacity: 0.85;
}
.src-ico svg { width: 100%; height: 100%; display: block; }
.src-label { word-break: break-word; }
.article .lead {
  font-size: 15.5px;
  color: var(--muted);
  border-left: 3px solid var(--accent);
  padding-left: 14px;
  margin: 0 0 26px;
}
.article h1 {
  font-family: var(--serif);
  font-size: 38px;
  margin: 0 0 16px;
  letter-spacing: 0.03em;
}
.article h2, .article h3 { scroll-margin-top: 90px; }
.article .content { min-width: 0; }

@media (max-width: 1080px) {
  .detail-grid { grid-template-columns: 1fr; }
  .detail-aside { position: static; }
}
.article h2 {
  font-family: var(--serif);
  font-size: 20px;
  color: var(--accent);
  margin: 34px 0 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.article h3 { font-size: 16px; margin: 24px 0 8px; color: var(--text); }
.article p { margin: 10px 0; }
.article ul, .article ol { padding-left: 26px; margin: 10px 0; }
.article li { margin: 5px 0; }
.article .ex-tr, .cmp-col .ex-tr {
  display: block;
  margin: 3px 0 2px 1.4em;
  color: var(--muted);
  font-size: 0.92em;
}
.article .ex-tr::before, .cmp-col .ex-tr::before { content: '→ '; opacity: 0.65; }
.article .content a, .cmp-col .content a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--accent) 35%, transparent);
  text-underline-offset: 3px;
}
.article .content a:hover, .cmp-col .content a:hover { text-decoration-color: var(--accent); }
.article a.tt-link, .cmp-col a.tt-link { text-decoration: none; }
.article .tt, .cmp-col .tt {
  position: relative;
  color: var(--accent);
  cursor: help;
  text-decoration: underline dotted;
  text-decoration-color: color-mix(in srgb, var(--accent) 45%, transparent);
  text-underline-offset: 3px;
}
.article .tt::after, .cmp-col .tt::after {
  content: attr(data-tip);
  position: absolute;
  bottom: 1.35em;
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  background: var(--panel-2);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  color: var(--text);
  font-size: 11.5px;
  line-height: 1.5;
  font-weight: 400;
  letter-spacing: 0.03em;
  padding: 4px 10px;
  width: max-content;
  max-width: 320px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s, transform 0.15s;
  z-index: 5;
}
.article .tt:hover::after, .cmp-col .tt:hover::after { opacity: 1; transform: translateX(-50%) translateY(0); }
.article .ex-fold, .cmp-col .ex-fold { display: block; margin: 6px 0 4px 1.4em; }
.article .ex-fold::before, .cmp-col .ex-fold::before { content: none; }
.article .ex-fold summary, .cmp-col .ex-fold summary {
  list-style: none;
  display: inline-flex;
  align-items: center;
  width: max-content;
  cursor: pointer;
  user-select: none;
  font-size: 12px;
  letter-spacing: 0.05em;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 12px;
  transition: all 0.15s;
}
.article .ex-fold summary::-webkit-details-marker, .cmp-col .ex-fold summary::-webkit-details-marker { display: none; }
.article .ex-fold summary::before, .cmp-col .ex-fold summary::before { content: '＋'; opacity: 0.8; margin-right: 5px; }
.article .ex-fold[open] summary::before, .cmp-col .ex-fold[open] summary::before { content: '−'; }
.article .ex-fold summary:hover,
.article .ex-fold[open] summary,
.cmp-col .ex-fold summary:hover,
.cmp-col .ex-fold[open] summary {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
}
.article .ex-fold .fold-body, .cmp-col .ex-fold .fold-body {
  margin: 6px 0 2px 10px;
  padding-left: 14px;
  border-left: 2px solid var(--border);
  color: var(--muted);
  font-size: 0.92em;
}
.article strong { color: color-mix(in srgb, var(--accent) 55%, #ffffff 45%); font-weight: 600; }
.article code {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 6px;
  font-size: 0.9em;
  color: var(--accent);
}
.article ruby, .cmp-col ruby { ruby-position: over; }
.article rt, .cmp-col rt {
  font-size: 0.52em;
  color: var(--muted);
  font-weight: 400;
  letter-spacing: 0;
  user-select: none;
}
.article pre {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
  overflow-x: auto;
  font-size: 13px;
}
.article pre code { background: none; border: none; padding: 0; color: var(--text); }
.article blockquote {
  margin: 14px 0;
  padding: 10px 18px;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  border-radius: 0 8px 8px 0;
  color: var(--muted);
}
.article table {
  width: 100%;
  border-collapse: collapse;
  margin: 14px 0;
  font-size: 14px;
}
.article th, .article td {
  border: 1px solid var(--border-strong);
  padding: 8px 14px;
  text-align: left;
}
.article th { background: var(--panel-2); color: var(--accent); font-weight: 600; }
:is(.article, .cmp-col) table.tbl-formula { width: auto; margin: 18px auto; }
:is(.article, .cmp-col) .tbl-formula th {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  background: none;
  border: none;
  padding: 2px 8px 6px;
}
:is(.article, .cmp-col) .tbl-formula td {
  font-family: "Cambria Math", "STIX Two Math", "XITS Math", "Cambria", "Times New Roman", "Yu Mincho", "MS Mincho", serif;
  font-size: 1.35em;
  line-height: 1.9;
  letter-spacing: 0.02em;
  text-align: center;
  color: var(--muted);
}
:is(.article, .cmp-col) .tbl-formula td strong {
  color: var(--accent);
  font-weight: 700;
  text-shadow: 0 0 14px color-mix(in srgb, var(--accent) 55%, transparent);
}
:is(.article, .cmp-col) .tbl-formula td ruby rt { color: var(--muted); }
.article hr { border: none; border-top: 1px solid var(--border); margin: 26px 0; }

.article .related { display: flex; flex-wrap: wrap; gap: 10px; }
.related-chip {
  display: inline-block;
  font-size: 13px;
  color: var(--accent);
  border: 1px solid var(--accent-soft);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 6px 16px;
  text-decoration: none;
  transition: all 0.15s;
}
.related-chip:hover { border-color: var(--accent); background: rgba(217, 180, 91, 0.22); }

/* ---------- variants (書き方) inline tags ---------- */
.v-text { line-height: 1.9; }
.v-tag {
  position: relative;
  display: inline;
  cursor: default;
  transition: color 0.15s, text-shadow 0.15s;
}
.v-tag.any { color: var(--muted); }
.v-tag.any:hover { color: var(--accent); }
.v-tag.lv { color: color-mix(in srgb, var(--vl) 72%, #fff); }
.v-tag.lv:hover {
  color: color-mix(in srgb, var(--vl) 92%, #fff);
  text-shadow: 0 0 12px color-mix(in srgb, var(--vl) 60%, transparent);
}
.v-tag::after {
  content: attr(data-levels);
  position: absolute;
  bottom: 1.35em;
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  background: var(--panel-2);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  color: var(--vl, var(--muted));
  font-size: 10.5px;
  letter-spacing: 0.06em;
  padding: 2px 8px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s, transform 0.15s;
  z-index: 5;
}
.v-tag.any::after { content: '全レベル'; color: var(--muted); }
.v-tag:hover::after { opacity: 1; transform: translateX(-50%) translateY(0); }
.v-tag.cst::before {
  content: attr(data-hover);
  position: absolute;
  bottom: 4em;
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  background: var(--panel-2);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  color: var(--vh, var(--muted));
  font-size: 10.5px;
  letter-spacing: 0.06em;
  padding: 2px 8px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s, transform 0.15s;
  z-index: 6;
}
.v-tag.cst:hover::before { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- toast ---------- */
#toast {
  position: fixed;
  left: 50%;
  bottom: 30px;
  transform: translateX(-50%) translateY(16px);
  background: var(--panel-2);
  border: 1px solid var(--accent);
  color: var(--text);
  font-size: 13px;
  padding: 10px 20px;
  border-radius: 999px;
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 50;
  pointer-events: none;
  box-shadow: var(--shadow-1);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 640px) {
  .topbar {
    padding: 8px 12px;
    gap: 8px;
    flex-wrap: wrap;
  }
  .brand { font-size: 15px; letter-spacing: 0.08em; }
  .topbar-right {
    gap: 6px;
    font-size: 12px;
    flex-wrap: wrap;
    justify-content: flex-end;
    width: 100%;
  }
  #topStats { display: none; }
  .btn { padding: 5px 10px; font-size: 12px; }
  #langSel { padding: 5px 7px; font-size: 12px; }
  .title { font-size: 34px; }
  .hero { min-height: calc(100vh - 46px); padding: 4vh 14px 6vh; }
  .searchbox { width: min(620px, 94vw); }
  #search { min-height: 48px; padding: 12px 16px; font-size: 15px; }
  .settings { top: 8px; right: 8px; left: 8px; width: auto; }
  .favpanel { width: auto; }
  .starp { max-width: 240px; }
  #compare { padding: 8px; }
  .compare-head { padding: 10px 12px; gap: 8px; flex-wrap: wrap; }
  .compare-head h2 { font-size: 15px; }
  .cmp-col { padding: 16px 14px; }
  .article { padding: 22px 16px; }
  .article h1 { font-size: 24px; }
  .article pre { padding: 12px 14px; font-size: 12px; }
  .lang-tabs { flex-wrap: wrap; }
  .detail-grid { grid-template-columns: 1fr; }
  .detail-aside { position: static; }
  .v-tag { font-size: 9.5px; padding: 2px 6px; }
}

/* ---------- favorites / history panel ---------- */
.favpanel { width: 280px; }
.favpanel .panel-sec { margin: 4px 0 10px; }
.favpanel h3 {
  margin: 0 0 8px;
  font-size: 12px;
  letter-spacing: 0.12em;
  color: var(--accent);
  font-family: var(--serif);
}
.plist { display: flex; flex-direction: column; gap: 6px; max-height: 220px; overflow-y: auto; }
.plist-item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 9px;
  background: var(--panel-3);
  border: 1px dashed var(--border);
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
  transition: border-color 0.15s, background 0.15s;
}
.plist-item:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.plist-title { font-weight: 500; }
.plist-meta { font-size: 11px; color: var(--muted); white-space: nowrap; }
.plist-empty { font-size: 12px; color: #6d6652; margin: 2px 0; }

/* ---------- star preview tooltip ---------- */
.starp {
  position: fixed;
  z-index: 45;
  max-width: 300px;
  background: var(--panel-2);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 10px 14px;
  box-shadow: var(--shadow-tip);
  pointer-events: none;
}
.starp .sp-title { font-size: 14px; color: var(--accent); font-weight: 600; margin-bottom: 4px; }
.starp .sp-summary { font-size: 12.5px; color: var(--muted); line-height: 1.55; }

/* ---------- detail action buttons ---------- */
.d-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 2px 0 14px;
}
.act-btn { font-size: 12.5px; padding: 5px 13px; }
.act-btn.on { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

/* ---------- compare overlay ---------- */
#compare {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
#compare[hidden] { display: none; }
.compare-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 4, 2, 0.78);
}
.compare-panel {
  position: relative;
  width: min(1400px, 96vw);
  max-height: 90vh;
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-3);
}
.compare-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--panel-2);
}
.compare-head h2 {
  font-family: var(--serif);
  font-size: 17px;
  color: var(--accent);
  margin: 0;
  white-space: nowrap;
}
#cmpSearch {
  flex: 1;
  min-width: 0;
  max-width: 300px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 13px;
}
#cmpSearch:focus { outline: none; border-color: var(--accent); }
#cmpSearch::placeholder { color: #6d6652; }
.cmp-col .cmp-head { display: flex; justify-content: flex-end; margin-bottom: 8px; }
.cmp-lang {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 8px;
  font-size: 12px;
}
.cmp-lang option { background: var(--panel-2); color: var(--text); }
.compare-pick { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1; justify-content: center; flex-wrap: wrap; }
.compare-pick select {
  max-width: 42%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 13px;
}
.compare-pick select option { background: var(--panel-2); color: var(--text); }
.compare-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  overflow-y: auto;
}
.compare-cols[data-n="3"] { grid-template-columns: 1fr 1fr 1fr; }
.compare-cols[data-n="4"] { grid-template-columns: 1fr 1fr 1fr 1fr; }
.cmp-col {
  padding: 24px 26px;
  min-width: 0;
  line-height: 1.85;
  font-size: 14.5px;
}
.cmp-col + .cmp-col { border-left: 1px solid var(--border); }
.cmp-remove { padding: 4px 9px; font-size: 13px; line-height: 1; }
.cmp-add { padding: 5px 12px; }
.cmp-col h2 {
  font-family: var(--serif);
  font-size: 19px;
  color: var(--accent);
  margin: 0 0 6px;
}
.cmp-meta { font-size: 12.5px; color: var(--muted); margin: 0 0 14px; }
.cmp-lead {
  font-size: 14px;
  color: var(--muted);
  border-left: 3px solid var(--accent);
  padding-left: 12px;
  margin: 0 0 18px;
}
.cmp-col h3 { font-size: 15px; color: var(--text); margin: 22px 0 8px; }
.cmp-col .content { min-width: 0; }
.cmp-col p { margin: 8px 0; }
.cmp-col ul, .cmp-col ol { padding-left: 24px; margin: 8px 0; }
.cmp-col li { margin: 4px 0; }
.cmp-col strong { color: color-mix(in srgb, var(--accent) 55%, #ffffff 45%); font-weight: 600; }
.cmp-col code {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 6px;
  font-size: 0.9em;
  color: var(--accent);
}
.cmp-col table { width: 100%; border-collapse: collapse; margin: 10px 0; font-size: 13.5px; }
.cmp-col th, .cmp-col td { border: 1px solid var(--border-strong); padding: 6px 10px; text-align: left; }
.cmp-col th { background: var(--panel-2); color: var(--accent); font-weight: 600; }

@media (max-width: 900px) {
  .compare-cols[data-n] { grid-template-columns: 1fr; }
  .cmp-col + .cmp-col { border-left: none; border-top: 1px solid var(--border); }
  .compare-head { flex-wrap: wrap; }
  .compare-pick { order: 3; width: 100%; }
  .compare-pick select { max-width: 44%; }
}

/* ---------- info panel (stats & credits) ---------- */
#infoFab {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 50;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--accent);
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  overflow: hidden;
  justify-content: center;
  box-shadow: var(--shadow-1);
  transition: border-color 0.15s, background 0.15s, transform 0.15s;
  pointer-events: auto;
}
#infoFab:hover { border-color: var(--accent); background: var(--accent-soft); transform: scale(1.08); }
#infoFab.active { background: var(--accent); color: var(--bg); border-color: var(--accent); }

#infoBackdrop {
  position: fixed;
  inset: 0;
  z-index: 49;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  display: none;
}
#infoBackdrop.show { display: block; }

#infoPanel {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  pointer-events: auto;
  animation: infoFadeIn 0.2s ease;
}
@keyframes infoFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
#infoPanel.hidden { display: none; }
.info-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  font-family: var(--serif);
  font-size: 16px;
  color: var(--accent);
  letter-spacing: 0.08em;
  flex-shrink: 0;
}
.info-close {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 20px;
  padding: 4px 8px;
  border-radius: 6px;
}
.info-close:hover { color: var(--text); background: var(--accent-soft); }
.info-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.info-section-title {
  font-family: var(--serif);
  font-size: 13px;
  letter-spacing: 0.1em;
  color: var(--accent);
  margin: 0;
  text-transform: uppercase;
}
.info-credits {
  width: 100%;
  min-height: 160px;
  background: var(--panel-3);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
  padding: 12px;
  resize: vertical;
  outline: none;
  transition: border-color 0.15s;
  line-height: 1.6;
}
.info-credits:focus { border-color: var(--accent); }
.info-credits-output {
  width: 100%;
  background: var(--panel-3);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  padding: 12px;
  line-height: 1.6;
}
.info-table {
  width: 100%;
  max-width: 100%;
  border-collapse: collapse;
  font-size: clamp(11px, 1.3vw, 15px);
}
.info-table th, .info-table td {
  padding: clamp(6px, 0.8vw, 10px);
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
  word-wrap: break-word;
}
.info-table th {
  font-family: var(--serif);
  color: var(--accent);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: clamp(10px, 1.1vw, 13px);
  background: var(--panel-3);
}
.info-table th:first-child { text-align: center; }
.info-table td:first-child { text-align: center; font-weight: 700; color: var(--accent); font-size: clamp(14px, 1.6vw, 22px); }
.info-cell-count { text-align: center; font-weight: 700; }
.lv-ja .info-cell-count { color: #ffd77a; }
.lv-en .info-cell-count { color: #7ec8ff; }
.lv-es .info-cell-count { color: #ff9191; }
.lv-sv .info-cell-count { color: #85ffab; }
.info-grammar-item {
  color: var(--muted);
  font-size: clamp(11px, 1.3vw, 14px);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
}
.info-grammar-item:hover { background: var(--accent-soft); color: var(--text); }
#infoStats { display: block; width: 100%; overflow-x: auto; }
@media (max-width: 600px) {
  #infoPanel { padding: 16px; }
  #infoFab { bottom: 12px; right: 12px; width: 38px; height: 38px; font-size: 16px; }
}
