:root {
  --bg-deep: #080a10;
  --bg-surface: #11141d;
  --bg-elevated: #191d28;
  --bg-input: #0c0f16;
  --ink: #e4e6ed;
  --ink-muted: #8b90a6;
  --ink-faint: #484d5e;
  --accent: #6366f1;
  --accent-dim: color-mix(in oklab, var(--accent) 15%, var(--bg-surface));
  --accent-glow: color-mix(in oklab, var(--accent) 40%, transparent);
  --line: color-mix(in oklab, var(--ink) 8%, transparent);
  --radius: 14px;
  --shadow: 0 32px 100px -24px rgba(0,0,0,0.8);
  --font-sans: "Inter", "Hiragino Sans", "Yu Gothic", "Noto Sans JP", sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", "Noto Sans JP", monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { width: 100%; min-height: 100vh; background: var(--bg-deep); color: var(--ink); font-family: var(--font-sans); }

header { position: sticky; top: 0; z-index: 50; background: color-mix(in oklab, var(--bg-deep) 90%, transparent); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.nav { max-width: 1100px; margin: 0 auto; padding: 0.85rem 1.5rem; display: flex; align-items: center; justify-content: space-between; }
.logo { font-weight: 700; font-size: 1.12rem; letter-spacing: -0.02em; color: var(--ink); text-decoration: none; }
.logo span { color: var(--accent); margin-left: 0.3rem; font-size: 0.85rem; font-weight: 400; }
.nav-links a { color: var(--ink-muted); text-decoration: none; font-size: 0.82rem; margin-left: 1.4rem; transition: color 0.15s; }
.nav-links a:hover { color: var(--ink); }

.hero { position: relative; padding: 4rem 1.5rem 2rem; text-align: center; overflow: hidden; }
.hero::before { content: ""; position: absolute; inset: 0; background: radial-gradient(ellipse 55% 45% at 50% -8%, var(--accent-glow), transparent 72%), radial-gradient(ellipse 30% 30% at 85% 80%, rgba(99,102,241,0.05), transparent 60%); pointer-events: none; }
.hero-inner { position: relative; z-index: 2; max-width: 700px; margin: 0 auto; }
.hero h1 { font-size: clamp(1.5rem, 4.2vw, 2.5rem); font-weight: 700; line-height: 1.12; letter-spacing: -0.03em; margin-bottom: 0.8rem; }
.hero h1 span { color: var(--accent); }
.hero > .hero-inner > p { color: var(--ink-muted); font-size: clamp(0.88rem, 1.7vw, 1.02rem); line-height: 1.75; margin-bottom: 1.6rem; }

.tabs { display: inline-flex; gap: 0.3rem; background: var(--bg-surface); border: 1px solid var(--line); border-radius: 10px; padding: 0.3rem; margin-bottom: 1rem; }
.tab-btn { padding: 0.45rem 1rem; border-radius: 8px; border: none; background: transparent; color: var(--ink-muted); font-size: 0.82rem; font-family: var(--font-sans); font-weight: 500; cursor: pointer; transition: all 0.15s; }
.tab-btn:hover { color: var(--ink); }
.tab-btn.active { background: var(--accent-dim); color: var(--accent); }

.form-box { max-width: 600px; margin: 0 auto; text-align: left; }
.field { margin-bottom: 0.7rem; }
.field label { display: block; font-size: 0.78rem; color: var(--ink-muted); margin-bottom: 0.3rem; font-weight: 500; }
.url-input-wrap { position: relative; }
.url-input-wrap::before { content: "https://"; position: absolute; left: 1rem; top: 50%; transform: translateY(-50%); color: var(--ink-faint); font-family: var(--font-mono); font-size: 0.82rem; pointer-events: none; }
.url-input { width: 100%; padding: 0.75rem 1rem 0.75rem 5.2rem; border-radius: var(--radius); border: 1px solid var(--line); background: var(--bg-input); color: var(--ink); font-size: 0.9rem; font-family: var(--font-sans); outline: none; transition: border-color 0.2s, box-shadow 0.2s; }
.url-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
.url-input::placeholder { color: var(--ink-faint); }
.row-2 { display: grid; grid-template-columns: 1fr 130px; gap: 0.6rem; }
select { width: 100%; padding: 0.75rem 1rem; border-radius: var(--radius); border: 1px solid var(--line); background: var(--bg-input); color: var(--ink); font-size: 0.9rem; font-family: var(--font-sans); outline: none; cursor: pointer; }
select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }

.dropzone { max-width: 600px; margin: 0 auto 1rem; border: 2px dashed var(--ink-faint); border-radius: var(--radius); padding: 2.5rem 1.5rem; background: var(--bg-input); transition: all 0.2s ease; cursor: pointer; }
.dropzone:hover, .dropzone.dragover { border-color: var(--accent); background: var(--accent-dim); }
.dropzone-icon { font-size: 2rem; margin-bottom: 0.6rem; }
.dropzone-title { font-size: 1rem; font-weight: 600; margin-bottom: 0.3rem; }
.dropzone-desc { font-size: 0.8rem; color: var(--ink-muted); }
#file-input { display: none; }

.json-input { width: 100%; min-height: 140px; padding: 0.85rem 1rem; border-radius: var(--radius); border: 1px solid var(--line); background: var(--bg-input); color: var(--ink); font-size: 0.82rem; font-family: var(--font-mono); line-height: 1.6; outline: none; resize: vertical; }
.json-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem; padding: 0.75rem 1.5rem; border-radius: var(--radius); font-size: 0.92rem; font-weight: 600; text-decoration: none; transition: all 0.2s ease; cursor: pointer; border: none; width: 100%; }
.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 8px 28px -8px var(--accent-glow); }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 12px 36px -8px var(--accent-glow); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.status-bar { display: none; align-items: center; gap: 0.7rem; max-width: 600px; margin: 1rem auto 0; padding: 0.7rem 1rem; background: var(--bg-elevated); border: 1px solid var(--line); border-radius: 10px; }
.status-bar.visible { display: flex; }
.spinner { width: 16px; height: 16px; border: 2px solid var(--ink-faint); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; flex-shrink: 0; }
@keyframes spin { to { transform: rotate(360deg); } }
.status-text { font-size: 0.82rem; color: var(--ink-muted); }
.status-text b { color: var(--ink); font-weight: 600; }

.graph-section { padding: 1rem 1rem 4rem; display: none; }
.graph-section.active { display: block; }

.stats-bar { max-width: 1100px; margin: 0 auto 1rem; display: grid; grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); gap: 0.6rem; }
.stat-card { background: var(--bg-surface); border: 1px solid var(--line); border-radius: 10px; padding: 0.7rem 1rem; }
.stat-value { font-size: 1.3rem; font-weight: 700; color: var(--accent); line-height: 1; }
.stat-label { font-size: 0.72rem; color: var(--ink-muted); margin-top: 0.25rem; }

.graph-toolbar { max-width: 1100px; margin: 0 auto 0.8rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.graph-info h2 { font-size: 1.1rem; font-weight: 600; }
.graph-info p { font-size: 0.8rem; color: var(--ink-muted); margin-top: 0.1rem; }
.graph-actions { display: flex; gap: 0.5rem; align-items: center; }

.layout-switch { display: flex; gap: 0.25rem; background: var(--bg-surface); border: 1px solid var(--line); border-radius: 8px; padding: 0.2rem; }
.layout-btn { padding: 0.4rem 0.6rem; border-radius: 6px; border: none; background: transparent; color: var(--ink-muted); cursor: pointer; transition: all 0.15s; display: flex; align-items: center; justify-content: center; }
.layout-btn:hover { color: var(--ink); }
.layout-btn.active { background: var(--accent-dim); color: var(--accent); }

.action-btn { padding: 0.4rem 0.8rem; border-radius: 8px; background: var(--bg-elevated); border: 1px solid var(--line); color: var(--ink-muted); font-size: 0.78rem; font-family: var(--font-sans); cursor: pointer; transition: all 0.15s; }
.action-btn:hover { color: var(--ink); border-color: var(--ink-faint); }
#btn-stop { background: color-mix(in oklab, #ef4444 15%, var(--bg-elevated)); border-color: color-mix(in oklab, #ef4444 30%, transparent); color: #ef4444; }
#btn-stop:hover { background: color-mix(in oklab, #ef4444 25%, var(--bg-elevated)); }

.graph-container { position: relative; max-width: 1100px; margin: 0 auto; height: 640px; background: var(--bg-surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
#graph-canvas { width: 100%; height: 100%; display: block; cursor: grab; }
#graph-canvas:active { cursor: grabbing; }

.tooltip { position: absolute; pointer-events: none; background: var(--bg-elevated); border: 1px solid var(--line); border-radius: 10px; padding: 0.7rem 1rem; font-size: 0.82rem; color: var(--ink); box-shadow: 0 12px 40px -10px rgba(0,0,0,0.55); opacity: 0; transition: opacity 0.15s ease; z-index: 10; max-width: 260px; }
.tooltip.visible { opacity: 1; }
.tooltip-title { font-weight: 600; margin-bottom: 0.2rem; color: var(--accent); }
.tooltip-meta { color: var(--ink-faint); font-size: 0.75rem; }

.legend { position: absolute; bottom: 1rem; left: 1rem; display: flex; gap: 0.9rem; background: color-mix(in oklab, var(--bg-deep) 82%, transparent); backdrop-filter: blur(8px); padding: 0.5rem 0.9rem; border-radius: 10px; border: 1px solid var(--line); }
.legend-item { display: flex; align-items: center; gap: 0.4rem; font-size: 0.75rem; color: var(--ink-muted); }
.legend-dot { width: 9px; height: 9px; border-radius: 50%; }

.depth-legend { position: absolute; top: 1rem; left: 1rem; background: color-mix(in oklab, var(--bg-deep) 85%, transparent); backdrop-filter: blur(8px); border: 1px solid var(--line); border-radius: 10px; padding: 0.7rem 0.9rem; }
.depth-legend-title { font-size: 0.72rem; color: var(--ink-muted); margin-bottom: 0.35rem; font-weight: 600; }
.depth-row { display: flex; align-items: center; gap: 0.5rem; font-size: 0.75rem; color: var(--ink-muted); margin-bottom: 0.2rem; }
.depth-row:last-child { margin-bottom: 0; }
.depth-dot { width: 9px; height: 9px; border-radius: 50%; }

.side-panel { position: absolute; top: 1rem; right: 1rem; width: 270px; max-height: calc(100% - 2rem); overflow-y: auto; background: color-mix(in oklab, var(--bg-deep) 92%, transparent); backdrop-filter: blur(12px); border: 1px solid var(--line); border-radius: 12px; padding: 1rem; z-index: 5; transform: translateX(130%); transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1); }
.side-panel.open { transform: translateX(0); }
.side-panel h3 { font-size: 0.95rem; font-weight: 600; margin-bottom: 0.25rem; word-break: break-all; }
.panel-url { font-size: 0.75rem; color: var(--accent); font-family: var(--font-mono); margin-bottom: 0.5rem; display: block; text-decoration: none; }
.panel-url:hover { text-decoration: underline; }
.panel-meta { font-size: 0.78rem; color: var(--ink-muted); margin-bottom: 0.7rem; }
.panel-section { font-size: 0.72rem; font-weight: 600; color: var(--ink-muted); text-transform: uppercase; letter-spacing: 0.06em; margin: 0.7rem 0 0.25rem; }
.link-list { list-style: none; }
.link-list li { font-size: 0.8rem; color: var(--ink-faint); padding: 0.3rem 0; border-bottom: 1px solid var(--line); cursor: pointer; transition: color 0.15s; word-break: break-all; }
.link-list li:hover { color: var(--accent); }
.link-list li:last-child { border-bottom: none; }
.panel-close { position: absolute; top: 0.6rem; right: 0.7rem; background: none; border: none; color: var(--ink-faint); font-size: 1.2rem; cursor: pointer; line-height: 1; }
.panel-close:hover { color: var(--ink); }

.how { max-width: 1100px; margin: 0 auto; padding: 4rem 1.5rem; }
.how h2 { font-size: 1.25rem; font-weight: 600; margin-bottom: 1.5rem; text-align: center; }
.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; }
.step { background: var(--bg-surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.5rem; }
.step-num { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 50%; background: var(--accent-dim); color: var(--accent); font-size: 0.8rem; font-weight: 700; margin-bottom: 0.7rem; }
.step h3 { font-size: 0.98rem; font-weight: 600; margin-bottom: 0.35rem; }
.step p { font-size: 0.85rem; color: var(--ink-muted); line-height: 1.65; }

.code-block { max-width: 1100px; margin: 0 auto 4rem; padding: 0 1.5rem; }
.code-block h3 { font-size: 1.05rem; font-weight: 600; margin-bottom: 0.7rem; }
pre { background: var(--bg-surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.2rem 1.5rem; overflow-x: auto; font-family: var(--font-mono); font-size: 0.82rem; line-height: 1.7; color: var(--ink-muted); }
code .k { color: #c084fc; } code .s { color: #34d399; } code .c { color: #6b7280; } code .f { color: #60a5fa; }

footer { text-align: center; padding: 2.5rem 1.5rem; color: var(--ink-faint); font-size: 0.78rem; border-top: 1px solid var(--line); }

@media (max-width: 640px) {
  .row-2 { grid-template-columns: 1fr; }
  .graph-container { height: 440px; }
  .side-panel { width: 200px; }
  .legend, .depth-legend { display: none; }
  .graph-toolbar { flex-direction: column; align-items: flex-start; }
}
@media (prefers-reduced-motion: reduce) {
  .spinner { animation: none; }
  .side-panel { transition: none; }
}
