/* ═══════════════════════════════════════════════
   Live2D Inspector — NullKit Terminal Style
   ═══════════════════════════════════════════════ */

:root {
  --bg: #050508;
  --bg-panel: #0a0a0f;
  --bg-surface: #0e0e14;
  --bg-hover: #14141e;
  --bg-active: #1a1a28;
  --accent: #00ff9f;
  --accent-dim: #00ff9f33;
  --accent-mid: #00ff9f88;
  --text: #c8c8d0;
  --text-dim: #606070;
  --text-bright: #e8e8f0;
  --border: #1a1a24;
  --border-accent: #00ff9f22;
  --danger: #ff4060;
  --warning: #ffaa00;
  --font: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
  --radius: 4px;
  --transition: 150ms ease;
  --topbar-h: 40px;
  --statusbar-h: 24px;
  --inspector-w: 320px;
}

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

::selection {
  background: var(--accent);
  color: var(--bg);
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 12px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── Top Bar ────────────────────────────────── */

#topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  z-index: 100;
  user-select: none;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 6px;
}

.logo-glyph {
  color: var(--accent);
  font-size: 14px;
  font-weight: 700;
  animation: blink 2s step-end infinite;
}

@keyframes blink {
  50% { opacity: 0; }
}

.logo-text {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-bright);
  letter-spacing: -0.3px;
}

.logo-text .accent { color: var(--accent); }

.logo-version {
  font-size: 10px;
  color: var(--text-dim);
  background: var(--bg-surface);
  padding: 1px 5px;
  border-radius: 3px;
  border: 1px solid var(--border);
}

.topbar-center {
  font-size: 11px;
  color: var(--text-dim);
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 4px;
}

.toolbar-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 28px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--text-dim);
  cursor: pointer;
  transition: all var(--transition);
}

.toolbar-btn:hover:not(:disabled) {
  color: var(--accent);
  background: var(--accent-dim);
  border-color: var(--border-accent);
}

.toolbar-btn:active:not(:disabled) {
  transform: scale(0.94);
}

.toolbar-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

/* ── Main Layout ────────────────────────────── */

#app {
  display: flex;
  height: calc(100% - var(--topbar-h) - var(--statusbar-h));
  position: relative;
}

/* ── Viewport ───────────────────────────────── */

#viewport {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: var(--bg);
}

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

/* Checkerboard pattern via CSS */
#viewport.bg-checker {
  background-image:
    linear-gradient(45deg, #1a1a24 25%, transparent 25%),
    linear-gradient(-45deg, #1a1a24 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #1a1a24 75%),
    linear-gradient(-45deg, transparent 75%, #1a1a24 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  background-color: #101018;
}

#viewport.bg-white {
  background: #f0f0f0;
}

#viewport.bg-black {
  background: #000000;
}

/* ── Drop Zone ──────────────────────────────── */

.dropzone-active {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  background: var(--bg);
}

.dropzone-active::before {
  content: '';
  position: absolute;
  inset: 16px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  pointer-events: none;
  transition: all 0.3s ease;
}

.dropzone-active.drag-over::before {
  border-color: var(--accent);
  box-shadow: inset 0 0 40px var(--accent-dim), 0 0 40px var(--accent-dim);
}

.drop-content {
  text-align: center;
  z-index: 1;
}

.drop-icon {
  color: var(--text-dim);
  margin-bottom: 16px;
  transition: color 0.3s;
}

.drag-over .drop-icon { color: var(--accent); }

.drop-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-bright);
  margin-bottom: 8px;
  letter-spacing: -0.5px;
}

.drop-subtitle {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 12px;
}

.file-label {
  color: var(--accent);
  cursor: pointer;
  border-bottom: 1px dashed var(--accent-mid);
  transition: border-color var(--transition);
}

.file-label:hover {
  border-color: var(--accent);
}

.drop-hint {
  font-size: 10px;
  color: var(--text-dim);
  opacity: 0.6;
}

/* ── Loading ────────────────────────────────── */

#loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(5, 5, 8, 0.85);
  backdrop-filter: blur(4px);
  z-index: 60;
}

.loading-spinner {
  width: 32px;
  height: 32px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 12px;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-text {
  font-size: 12px;
  color: var(--text-dim);
}

/* ── Inspector Panel ────────────────────────── */

#inspector {
  width: var(--inspector-w);
  min-width: var(--inspector-w);
  background: var(--bg-panel);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: slideIn 0.2s ease;
}

@keyframes slideIn {
  from { transform: translateX(20px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

#inspector.hidden { display: none; }

.inspector-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.inspector-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.inspector-close {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 12px;
  padding: 2px 4px;
  border-radius: 2px;
  transition: all var(--transition);
}

.inspector-close:hover {
  color: var(--danger);
  background: rgba(255, 64, 96, 0.1);
}

.inspector-body {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ── Tabs ───────────────────────────────────── */

.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.tab {
  flex: 1;
  padding: 7px 0;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-dim);
  font-family: var(--font);
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: all var(--transition);
}

.tab:hover { color: var(--text); background: var(--bg-hover); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.tab-content {
  display: none;
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.tab-content.active { display: block; }

/* ── Info Tab ───────────────────────────────── */

.info-grid {
  display: grid;
  gap: 2px;
}

.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 8px;
  border-radius: var(--radius);
  transition: background var(--transition);
}

.info-row:hover { background: var(--bg-hover); }

.info-label {
  font-size: 10px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.info-value {
  font-size: 11px;
  color: var(--text-bright);
  font-weight: 500;
}

/* ── Params Tab ─────────────────────────────── */

.params-search {
  padding: 0 0 8px;
  flex-shrink: 0;
}

.params-search input {
  width: 100%;
  padding: 6px 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  font-size: 11px;
  outline: none;
  transition: border-color var(--transition);
}

.params-search input:focus {
  border-color: var(--accent-mid);
}

.params-search input::placeholder {
  color: var(--text-dim);
}

.params-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.param-item {
  padding: 6px 8px;
  border-radius: var(--radius);
  transition: background var(--transition);
}

.param-item:hover { background: var(--bg-hover); }

.param-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 3px;
}

.param-name {
  font-size: 10px;
  color: var(--text);
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.param-value {
  font-size: 10px;
  color: var(--accent);
  font-weight: 500;
  min-width: 50px;
  text-align: right;
}

/* Custom Range Slider */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: var(--bg-surface);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg-panel);
  cursor: pointer;
  transition: transform 0.1s;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

input[type="range"]::-webkit-slider-thumb:active {
  transform: scale(1.3);
  box-shadow: 0 0 8px var(--accent-dim);
}

input[type="range"]::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg-panel);
  cursor: pointer;
}

/* ── Parts Tab ──────────────────────────────── */

.parts-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.part-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 8px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--transition);
}

.part-item:hover { background: var(--bg-hover); }

.part-name {
  font-size: 10px;
  color: var(--text);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-right: 8px;
}

.part-toggle {
  width: 28px;
  height: 16px;
  border-radius: 8px;
  background: var(--border);
  position: relative;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
}

.part-toggle.on { background: var(--accent); }

.part-toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--bg-panel);
  transition: transform 0.2s;
}

.part-toggle.on::after {
  transform: translateX(12px);
}

/* ── Expressions Tab ────────────────────────── */

.expr-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.expr-item {
  padding: 6px 10px;
  border-radius: var(--radius);
  font-size: 11px;
  color: var(--text);
  cursor: pointer;
  transition: all var(--transition);
  border: 1px solid transparent;
}

.expr-item:hover {
  background: var(--bg-hover);
  border-color: var(--border);
}

.expr-item.active {
  background: var(--accent-dim);
  border-color: var(--accent-mid);
  color: var(--accent);
}

.expr-item::before {
  content: '◇ ';
  opacity: 0.4;
}

.expr-item.active::before {
  content: '◆ ';
  opacity: 1;
}

/* ── Motions Tab ────────────────────────────── */

.motion-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.motion-group-title {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 6px 8px 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2px;
}

.motion-item {
  padding: 5px 10px;
  border-radius: var(--radius);
  font-size: 11px;
  color: var(--text);
  cursor: pointer;
  transition: all var(--transition);
}

.motion-item:hover {
  background: var(--bg-hover);
  color: var(--text-bright);
}

.motion-item.playing {
  color: var(--accent);
}

.motion-item::before {
  content: '▹ ';
  opacity: 0.4;
}

.motion-item.playing::before {
  content: '▸ ';
  opacity: 1;
  color: var(--accent);
}

/* ── Status Bar ─────────────────────────────── */

#statusbar {
  height: var(--statusbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  background: var(--bg-panel);
  border-top: 1px solid var(--border);
  font-size: 10px;
  color: var(--text-dim);
  user-select: none;
}

.status-link {
  color: var(--text-dim);
  text-decoration: none;
  transition: color var(--transition);
}

.status-link:hover { color: var(--accent); }

.status-sep {
  margin: 0 6px;
  opacity: 0.3;
}

/* ── Utilities ──────────────────────────────── */

.hidden { display: none !important; }

.empty-state {
  padding: 24px 16px;
  text-align: center;
  color: var(--text-dim);
  font-size: 11px;
}

.empty-state::before {
  content: '∅';
  display: block;
  font-size: 20px;
  margin-bottom: 8px;
  opacity: 0.3;
}

/* ── Responsive ─────────────────────────────── */

@media (max-width: 768px) {
  :root {
    --inspector-w: 260px;
  }

  #inspector {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    z-index: 90;
    box-shadow: -4px 0 20px rgba(0,0,0,0.5);
  }
}

/* ── Scanline Effect (subtle) ───────────────── */

#viewport::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 255, 159, 0.008) 2px,
    rgba(0, 255, 159, 0.008) 4px
  );
  z-index: 1;
}

/* ── Glow pulse on accent elements ──────────── */

@keyframes glowPulse {
  0%, 100% { text-shadow: 0 0 6px var(--accent-dim); }
  50% { text-shadow: 0 0 12px var(--accent-mid); }
}

.logo-text .accent {
  animation: glowPulse 4s ease-in-out infinite;
}
