:root {
  --bg: #0d1117;
  --surface: #161b22;
  --border: #30363d;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --accent: #58a6ff;
  --accent-hover: #79b8ff;
  --panel-radius: 10px;
  --sidebar-width: 320px;
}

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

html, body {
  height: 100%;
  overflow: hidden;
  font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
}

#app {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  grid-template-rows: auto 1fr;
  height: 100vh;
}

.header {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.header h1 {
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.header__subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.header__subtitle strong {
  color: #f0c674;
  font-weight: 600;
}

.error-banner {
  background: #3d1214;
  border-bottom: 1px solid #8b2f33;
  color: #ffb4b4;
  padding: 10px 16px;
  font-size: 0.82rem;
}

.select {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 0.82rem;
}

.meta {
  margin-top: 8px;
  font-size: 0.72rem;
  line-height: 1.5;
  color: var(--text-muted);
}

.header__citation a {
  font-size: 0.75rem;
  color: var(--accent);
  text-decoration: none;
}

.header__citation a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

.sidebar {
  overflow-y: auto;
  padding: 16px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.panel {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--panel-radius);
  padding: 14px;
}

.panel h2 {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.view-buttons {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.btn {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 0.82rem;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, border-color 0.15s;
}

.btn:hover {
  background: #21262d;
  border-color: #484f58;
}

.btn.active {
  background: #1f3a5f;
  border-color: var(--accent);
  color: var(--accent-hover);
}

.layer-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.layer-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  cursor: pointer;
}

.layer-item input {
  accent-color: var(--accent);
}

.layer-swatch {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  flex-shrink: 0;
}

.slider-label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.slider-label input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  margin-top: 10px;
  cursor: pointer;
}

.toggle input {
  accent-color: var(--accent);
}

.panel--info p {
  font-size: 0.82rem;
  line-height: 1.6;
  color: var(--text-muted);
}

.panel--info h2 {
  color: var(--text);
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.9rem;
}

.legend {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.legend li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.swatch {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  flex-shrink: 0;
}

.disclaimer {
  margin-top: 10px;
  font-size: 0.72rem;
  line-height: 1.5;
  color: var(--text-muted);
}

.disclaimer a {
  color: var(--accent);
  text-decoration: none;
}

.disclaimer a:hover {
  text-decoration: underline;
}

.viewport {
  position: relative;
  overflow: hidden;
}

#canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.viewport__overlay {
  position: absolute;
  bottom: 16px;
  left: 16px;
  right: 16px;
  pointer-events: none;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}

.axes {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.axis {
  font-size: 0.7rem;
  padding: 3px 8px;
  background: rgba(13, 17, 23, 0.75);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-muted);
}

.hint {
  font-size: 0.7rem;
  color: var(--text-muted);
  background: rgba(13, 17, 23, 0.75);
  padding: 4px 10px;
  border-radius: 4px;
}

@media (max-width: 900px) {
  #app {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto 1fr;
  }

  .sidebar {
    max-height: 40vh;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
}