@import url('https://fonts.googleapis.com/css2?family=Barlow+Condensed:wght@500;600;700&family=IBM+Plex+Mono:wght@400;500&family=Inter:wght@400;500;600&display=swap');

:root {
  --bg: #0c0d10;
  --panel: #13151a;
  --panel-2: #191c22;
  --line: #252934;
  --text: #e8e9ed;
  --muted: #8b90a0;
  --accent: #e62429;
  --accent-2: #f0b429;
  --ok: #57d38c;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  overflow: hidden;
}

#app {
  display: grid;
  grid-template-columns: 292px 1fr;
  grid-template-rows: 64px 1fr;
  height: 100vh;
}

/* ---------- top bar ---------- */
.topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  background: linear-gradient(180deg, #15171d, #0f1115);
  border-bottom: 1px solid var(--line);
  z-index: 5;
}

.brand { display: flex; align-items: center; gap: 14px; }

.brand-mark {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 700;
  font-size: 30px;
  letter-spacing: 0.5px;
  color: var(--text);
  background: var(--accent);
  padding: 2px 10px 1px;
  clip-path: polygon(8% 0, 100% 0, 92% 100%, 0 100%);
}
.brand-mark span { color: #fff; opacity: 0.85; }

.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 14px; font-weight: 600; letter-spacing: 0.2px; }
.brand-text span { font-size: 11px; color: var(--muted); font-family: 'IBM Plex Mono', monospace; }

.status {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  color: var(--ok);
  padding: 6px 10px;
  border: 1px solid rgba(87, 211, 140, 0.25);
  background: rgba(87, 211, 140, 0.06);
  border-radius: 3px;
}

/* ---------- sidebar ---------- */
.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 22px 16px;
  overflow-y: auto;
}

.sidebar-label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 6px 10px;
}

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

.model-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.model-btn:hover { background: var(--panel-2); }
.model-btn.active {
  background: linear-gradient(90deg, rgba(230, 36, 41, 0.14), rgba(230, 36, 41, 0.02));
  border-color: rgba(230, 36, 41, 0.35);
}
.model-btn .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--dot, var(--accent));
  box-shadow: 0 0 10px var(--dot, var(--accent));
  flex: 0 0 auto;
}
.model-btn .idx {
  margin-left: auto;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  color: var(--muted);
}

.about {
  font-size: 11.5px;
  line-height: 1.65;
  color: var(--muted);
  margin: 0 6px;
}
.about b { color: var(--text); font-weight: 500; }

.hint {
  margin: 16px 6px 0;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  color: #5e6373;
}
kbd {
  display: inline-block;
  padding: 1px 5px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 3px;
  background: var(--panel-2);
  color: var(--muted);
  font-family: inherit;
  font-size: 9.5px;
}

/* ---------- stage ---------- */
.stage { position: relative; overflow: hidden; }
#viewport { position: absolute; inset: 0; }
#viewport canvas { display: block; width: 100%; height: 100%; }

.vignette {
  position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse at 50% 42%, transparent 55%, rgba(0,0,0,0.45) 100%);
}

.stage-caption {
  position: absolute;
  left: 28px;
  bottom: 28px;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
#model-name {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 42px;
  font-weight: 600;
  letter-spacing: 0.5px;
  line-height: 1;
  text-transform: uppercase;
  text-shadow: 0 2px 20px rgba(0,0,0,0.6);
}
.meta {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10.5px;
  color: var(--muted);
  letter-spacing: 0.4px;
}

.anim-control {
  position: absolute;
  top: 20px;
  right: 24px;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 10;
}
.anim-select {
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(19, 21, 26, 0.88);
  color: var(--text);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  outline: none;
  cursor: pointer;
  backdrop-filter: blur(8px);
  transition: all 0.15s;
}
.anim-select:hover, .anim-select:focus {
  border-color: rgba(230, 36, 41, 0.5);
}
.anim-select option {
  background: var(--panel);
  color: var(--text);
}

.toolbar {
  position: absolute;
  right: 24px;
  bottom: 26px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
  max-width: 60%;
}
.chip {
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(19, 21, 26, 0.82);
  color: var(--muted);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10.5px;
  cursor: pointer;
  backdrop-filter: blur(8px);
  transition: all 0.15s;
}
.chip:hover { color: var(--text); border-color: #3a3f4d; }
.chip.active {
  color: #fff;
  border-color: rgba(230, 36, 41, 0.5);
  background: rgba(230, 36, 41, 0.16);
}

/* ---------- loading ---------- */
.loading {
  position: fixed; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 16px;
  background: rgba(12, 13, 16, 0.92);
  backdrop-filter: blur(4px);
  z-index: 50;
  transition: opacity 0.35s;
}
.loading.hidden { opacity: 0; pointer-events: none; }
.spinner {
  width: 34px; height: 34px;
  border: 2px solid rgba(255,255,255,0.12);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#loading-text {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  color: var(--muted);
}

@media (max-width: 820px) {
  #app { grid-template-columns: 1fr; grid-template-rows: 58px 1fr; }
  .sidebar { display: none; }
  #model-name { font-size: 30px; }
  .toolbar { max-width: 90%; right: 14px; bottom: 14px; }
  .stage-caption { left: 16px; bottom: 16px; }
}

/* ---------- VFX gallery ---------- */
.modal {
  position: fixed; inset: 0; z-index: 80;
  display: none;
  grid-template-rows: auto 1fr;
  background: rgba(10, 11, 14, 0.96);
  backdrop-filter: blur(10px);
}
.modal.open { display: grid; }
.modal-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 26px 30px 18px;
  border-bottom: 1px solid var(--line);
}
.modal-head h2 {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 34px; font-weight: 600; margin: 2px 0 2px; letter-spacing: 0.5px;
  text-transform: uppercase;
}
.modal-sub { margin: 0; color: var(--muted); font-size: 12px; }
.modal-head code {
  background: var(--panel-2); border: 1px solid var(--line);
  padding: 1px 5px; border-radius: 3px; font-family: 'IBM Plex Mono', monospace;
  font-size: 10px; color: var(--accent-2);
}
.modal-close {
  width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--panel); color: var(--muted);
  font-size: 15px; cursor: pointer;
}
.modal-close:hover { color: #fff; border-color: var(--accent); }

.modal-body {
  display: grid; grid-template-columns: 1fr 340px;
  gap: 0; min-height: 0;
}
.vfx-grid {
  overflow-y: auto;
  padding: 20px 24px 40px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 12px;
  align-content: start;
}
.vfx-card {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s;
}
.vfx-card:hover { transform: translateY(-2px); border-color: rgba(230,36,41,0.45); }
.vfx-card.active { border-color: var(--accent); box-shadow: 0 0 0 1px rgba(230,36,41,0.4); }
.vfx-card img {
  width: 100%; aspect-ratio: 1; object-fit: contain;
  background: radial-gradient(circle at 50% 45%, #1d2028, #0b0c0f 70%);
  display: block;
}
.vfx-card .vfx-name {
  padding: 8px 10px 2px; font-size: 11px; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.vfx-card .vfx-path {
  padding: 0 10px 9px; font-family: 'IBM Plex Mono', monospace;
  font-size: 8.5px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.vfx-detail {
  border-left: 1px solid var(--line);
  padding: 22px;
  overflow-y: auto;
  background: var(--panel);
}
.vfx-empty { color: var(--muted); font-size: 12px; line-height: 1.6; }
.vfx-detail h3 {
  font-family: 'Barlow Condensed', sans-serif;
  text-transform: uppercase; letter-spacing: 0.5px;
  font-size: 26px; margin: 0 0 4px;
}
.vfx-detail .effect-path {
  font-family: 'IBM Plex Mono', monospace; font-size: 9.5px;
  color: var(--muted); word-break: break-all; margin-bottom: 16px;
}
.vfx-preview {
  position: relative;
  border-radius: 8px;
  background: radial-gradient(circle at 50% 45%, #20242d, #0a0b0e 70%);
  border: 1px solid var(--line);
  display: grid; place-items: center;
  padding: 16px;
  overflow: hidden;
}
.vfx-preview img {
  width: 100%; max-height: 260px; object-fit: contain;
  filter: drop-shadow(0 0 18px rgba(255, 120, 40, 0.35));
  animation: vfxPulse 2.8s ease-in-out infinite;
}
@keyframes vfxPulse {
  0%, 100% { transform: scale(0.97); filter: drop-shadow(0 0 10px rgba(255,120,40,0.25)); }
  50% { transform: scale(1.04); filter: drop-shadow(0 0 26px rgba(255,150,60,0.55)); }
}
.vfx-tex-list { margin: 16px 0 0; padding: 0; list-style: none; }
.vfx-tex-list li {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px; color: var(--muted);
  padding: 5px 0; border-bottom: 1px dashed var(--line);
  word-break: break-all;
}
.vfx-note {
  margin-top: 16px; font-size: 10.5px; line-height: 1.6;
  color: var(--muted); border-left: 2px solid var(--accent-2);
  padding-left: 10px;
}
@media (max-width: 900px) {
  .modal-body { grid-template-columns: 1fr; }
  .vfx-detail { display: none; }
}

.model-search {
  width: calc(100% - 12px);
  margin: 0 6px 10px;
  padding: 8px 10px;
  border-radius: 5px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  outline: none;
}
.model-search:focus { border-color: rgba(230,36,41,0.5); }
.model-search::placeholder { color: #5e6373; }
.model-btn .costume {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 8.5px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  border: 1px solid var(--line);
  padding: 1px 4px;
  border-radius: 3px;
  flex: 0 0 auto;
}
.model-btn .name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
