* {
  box-sizing: border-box;
}

:root {
  --bg: #0f1117;
  --bg-soft: #171a23;
  --panel: #1c202b;
  --border: #2a2f3d;
  --text: #e8eaf0;
  --text-dim: #9aa2b5;
  --accent: #4f8cff;
  --accent-2: #8b5cf6;
  --ok: #34d399;
  --warn: #fbbf24;
  --danger: #f87171;
}

html {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans", "Noto Sans JP", sans-serif;
  color-scheme: dark;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.7;
}

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

a:hover {
  text-decoration: underline;
}

header.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 24px;
  background: rgba(15, 17, 23, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

header.nav .brand {
  font-weight: 700;
  font-size: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

header.nav .brand .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

header.nav nav {
  margin-left: auto;
  display: flex;
  gap: 16px;
  align-items: center;
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px;
}

.btn {
  display: inline-block;
  padding: 9px 18px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  transition: filter 0.15s, border-color 0.15s;
}

.btn:hover {
  border-color: var(--accent);
  filter: brightness(1.15);
}

.btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border: none;
  font-weight: 600;
}

.btn.secondary {
  background: transparent;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
}

.tag {
  display: inline-block;
  font-size: 12px;
  padding: 2px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-dim);
  background: var(--bg-soft);
}

code, pre {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

pre {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.55;
}

kbd {
  background: var(--panel);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 12px;
}

/* --- tool view sepcific --- */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
}

.toolbar .spacer {
  flex: 1;
}

.status {
  font-size: 13px;
  color: var(--text-dim);
}

.status.warn {
  color: var(--warn);
}

canvas.heatmap {
  display: block;
  background: #0b0d12;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: crosshair;
  touch-action: none;
}

.rows {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 16px;
  align-items: start;
}

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

.side .card + .card {
  margin-top: 12px;
}

.side h3 {
  margin: 0 0 10px;
  font-size: 14px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.field {
  margin-bottom: 10px;
}

.field label {
  display: block;
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 4px;
}

.field select, .field input[type="range"] {
  width: 100%;
}

.field select {
  background: var(--bg-soft);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 13px;
}

input[type="range"] {
  accent-color: var(--accent);
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  padding: 3px 0;
  color: var(--text);
}

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

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

.row-range {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--text-dim);
  white-space: nowrap;
}

.row-range input {
  width: 100%;
}

.deck-panel {
  display: flex;
  align-items: center;
  gap: 20px;
  background: linear-gradient(180deg, #3a3a3a, #26262a);
  border: 1px solid #0a0a0a;
  border-radius: 10px;
  padding: 10px 16px;
  margin: 12px 0;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.deck-panel .lbl {
  font-size: 10px;
  letter-spacing: 0.18em;
  color: #b9a889;
  font-family: ui-monospace, Menlo, monospace;
}

.deck-panel .lcd {
  font-family: ui-monospace, Menlo, monospace;
  color: #6eff7f;
  background: #101410;
  border: 1px solid #000;
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 18px;
  letter-spacing: 0.1em;
  text-shadow: 0 0 6px rgba(110, 255, 127, 0.55);
  min-width: 170px;
}

.deck-panel .deck-meter {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
}

#levelMeter {
  display: flex;
  gap: 3px;
  align-items: center;
  flex-wrap: wrap;
}

#levelMeter .seg {
  width: 10px;
  height: 16px;
  border-radius: 2px;
  background: #33333a;
  border: 1px solid #000;
  box-shadow: inset 0 0 2px rgba(0, 0, 0, 0.7);
}

#levelMeter .seg.on {
  background: #22c55e;
  box-shadow: 0 0 6px rgba(34, 197, 94, 0.85);
}

#levelMeter .seg:nth-child(n+7).on {
  background: #facc15;
  box-shadow: 0 0 6px rgba(250, 204, 21, 0.85);
}

#levelMeter .seg:nth-child(n+10).on {
  background: #f94a2e;
  box-shadow: 0 0 6px rgba(249, 74, 46, 0.9);
}

.deck-panel .deck-lamp {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #202028;
  border: 1px solid #000;
}

.deck-panel .deck-lamp.on {
  background: #f94a2e;
  box-shadow: 0 0 8px rgba(249, 74, 46, 0.95);
}

.layer-list li {
  font-family: ui-monospace, Menlo, monospace;
  font-size: 12px;
  color: var(--text-dim);
  list-style: none;
  padding: 2px 0;
  display: flex;
  gap: 8px;
  align-items: center;
}

.swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex: none;
}

.statusbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  font-size: 12.5px;
  color: var(--text-dim);
  margin-top: 10px;
}

.statusbar span b {
  color: var(--text);
}

.inspector {
  margin-top: 14px;
}

.inspector .head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.inspector .head code {
  color: var(--accent);
}

.hexgrid {
  display: grid;
  grid-template-columns: 70px 12ch 1fr;
  gap: 0 8px;
  font-family: ui-monospace, Menlo, monospace;
  font-size: 12px;
  line-height: 1.5;
}

.hexgrid .addr {
  color: var(--text-dim);
}

.hexgrid .hex {
  color: var(--text);
  word-break: break-all;
}

.hexgrid .ascii {
  color: var(--accent-2);
  word-break: break-all;
}

.tooltip {
  position: fixed;
  z-index: 100;
  padding: 8px 10px;
  background: rgba(12, 14, 20, 0.95);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.12s;
  max-width: 260px;
}

.tooltip code {
  color: var(--accent);
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 6px;
}