﻿:root {
  --bg: hsl(220 14% 8%);
  --panel: hsl(220 13% 11%);
  --panel-2: hsl(220 12% 14%);
  --line: hsl(220 10% 22%);
  --text: hsl(220 14% 92%);
  --muted: hsl(220 9% 60%);
  --accent: hsl(28 92% 58%);
  --accent-ink: hsl(28 60% 10%);
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.app {
  display: grid;
  grid-template-columns: 336px 1fr;
  height: 100%;
}

/* ---------- Panel ---------- */
.panel {
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 22px 22px 32px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 26px;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand h1 { margin: 0; font-size: 19px; font-weight: 600; letter-spacing: -0.01em; }
.brand-sub { margin: 0; font-size: 12.5px; color: var(--muted); }
.brand-mark {
  width: 30px; height: 30px; border-radius: 8px; flex: none;
  background:
    linear-gradient(140deg, hsl(28 92% 60%), hsl(14 80% 46%));
  box-shadow: inset 0 1px 0 hsl(40 100% 82% / .55);
}

.block { display: flex; flex-direction: column; gap: 12px; }
.block-title {
  margin: 0;
  font-size: 11px;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}

/* ---------- Dropzone ---------- */
.drop {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 168px;
  padding: 14px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background:
    repeating-conic-gradient(hsl(220 12% 16%) 0% 25%, hsl(220 12% 13%) 0% 50%) 0 0 / 18px 18px;
  cursor: pointer;
  transition: border-color .18s ease, transform .18s ease;
}
.drop:hover, .drop:focus-visible, .drop.dragging { border-color: var(--accent); outline: none; }
.drop.dragging { transform: scale(1.01); }
.drop-hint {
  position: absolute; inset: 0;
  display: grid; place-content: center; text-align: center;
  color: var(--muted); font-size: 13px; padding: 16px;
  background: hsl(220 13% 11% / .78);
  border-radius: var(--radius);
}
.drop-hint small { color: hsl(220 9% 48%); }
.drop.has-image .drop-hint { display: none; }
#preview { max-width: 100%; height: auto; image-rendering: auto; border-radius: 6px; }

/* ---------- Fields ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label {
  font-size: 13px; color: var(--muted);
  display: flex; justify-content: space-between; align-items: center;
}
.field output { font-family: "JetBrains Mono", monospace; font-size: 12px; color: var(--text); }

select {
  width: 100%; padding: 9px 10px;
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px;
  font: inherit; font-size: 13.5px;
}
select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 4px; border-radius: 3px;
  background: var(--panel-2); border: 1px solid var(--line);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 15px; height: 15px; border-radius: 50%;
  background: var(--accent); border: none; cursor: pointer;
  transition: transform .15s ease;
}
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.18); }
input[type="range"]::-moz-range-thumb {
  width: 15px; height: 15px; border: none; border-radius: 50%; background: var(--accent); cursor: pointer;
}

.check {
  display: flex; align-items: center; gap: 8px;
  font-size: 13.5px; color: var(--muted); cursor: pointer;
}
.check input { accent-color: var(--accent); width: 15px; height: 15px; }

/* ---------- Buttons ---------- */
.row { display: flex; gap: 10px; }
.btn {
  flex: 1;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font: inherit; font-size: 13.5px; font-weight: 500;
  cursor: pointer;
  transition: background .16s ease, border-color .16s ease, transform .12s ease;
}
.btn:hover:not(:disabled) { background: hsl(220 12% 18%); border-color: hsl(220 10% 30%); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .42; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 600; }
.btn.primary:hover:not(:disabled) { background: hsl(28 92% 64%); }
.btn.ghost { background: transparent; }

.stat {
  margin: 0; font-family: "JetBrains Mono", monospace;
  font-size: 11.5px; color: var(--muted);
}

/* ---------- Stage ---------- */
.stage { position: relative; overflow: hidden; }
#viewport { position: absolute; inset: 0; }
#viewport canvas { display: block; }
.hud {
  position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%);
  margin: 0; padding: 7px 14px;
  font-size: 12px; color: var(--muted);
  background: hsl(220 14% 8% / .72);
  border: 1px solid var(--line); border-radius: 999px;
  backdrop-filter: blur(6px);
  pointer-events: none;
}

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; grid-template-rows: auto 60vh; }
  .panel { border-right: none; border-bottom: 1px solid var(--line); }
  .stage { min-height: 60vh; }
}

/* ---------- Mascot page ---------- */
.stage-warm { background: hsl(345 60% 58%); }

.note {
  margin: 0;
  font-size: 12.8px;
  line-height: 1.6;
  color: var(--muted);
  padding: 11px 12px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
}

input[type="color"] {
  width: 100%;
  height: 34px;
  padding: 2px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}
input[type="color"]::-webkit-color-swatch-wrapper { padding: 2px; }
input[type="color"]::-webkit-color-swatch { border: none; border-radius: 5px; }

.parts {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}
.parts li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 11px;
  font-family: "JetBrains Mono", monospace;
  font-size: 11.5px;
  color: var(--muted);
  border-bottom: 1px solid hsl(220 10% 18%);
}
.parts li:last-child { border-bottom: none; }
.parts li span { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.parts li em { font-style: normal; flex: none; }

/* ---------- X\u01b0\u1edfng 3D ---------- */
.stage-studio { background: hsl(215 14% 19%); }

textarea {
  width: 100%;
  padding: 10px 11px;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  font-size: 13.5px;
  line-height: 1.5;
  resize: vertical;
  min-height: 62px;
}
textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
textarea::placeholder { color: hsl(220 9% 45%); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 5px 10px;
  font: inherit;
  font-size: 11.5px;
  color: var(--muted);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  transition: color .15s ease, border-color .15s ease, background .15s ease;
}
.chip:hover { color: var(--text); border-color: var(--accent); background: hsl(220 12% 17%); }

.block-btn { width: 100%; flex: none; }

.disclosure {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  overflow: hidden;
}
.disclosure summary {
  padding: 9px 11px;
  font-size: 12.5px;
  color: var(--muted);
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.disclosure summary::-webkit-details-marker { display: none; }
.disclosure summary::before { content: "\25B8  "; }
.disclosure[open] summary::before { content: "\25BE  "; }
.disclosure summary:hover { color: var(--text); }
.disclosure-body {
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 0 11px 11px;
  border-top: 1px solid var(--line);
  padding-top: 11px;
}

input[type="password"], input[type="text"] {
  width: 100%;
  padding: 9px 10px;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  font-size: 13px;
}
input[type="password"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.note-sm { margin: 0; font-size: 11.5px; line-height: 1.55; color: hsl(220 9% 52%); }
.note-sm strong { color: var(--muted); font-weight: 500; }

.stat.is-error { color: hsl(6 70% 62%); }

.busy {
  position: absolute;
  left: 50%; top: 22px;
  transform: translateX(-50%);
  display: flex; align-items: center; gap: 9px;
  padding: 9px 16px;
  font-size: 12.5px;
  color: var(--text);
  background: hsl(220 14% 10% / .88);
  border: 1px solid var(--line);
  border-radius: 999px;
  backdrop-filter: blur(6px);
}
.spinner {
  width: 13px; height: 13px; flex: none;
  border: 2px solid hsl(220 10% 34%);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Banner tr\u1ea1ng th\u00e1i ---------- */
.status {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  font-size: 12.5px;
  line-height: 1.5;
  transition: border-color .2s ease, background .2s ease;
}
.status-icon { flex: none; font-size: 12px; line-height: 1.55; }
.status-text { color: var(--text); }

.status-idle  { color: var(--muted); }
.status-idle  .status-icon { color: hsl(220 9% 45%); }

.status-busy  { border-color: hsl(38 80% 42%); background: hsl(38 40% 14%); }
.status-busy  .status-icon { color: hsl(38 90% 60%); animation: spin 1.1s linear infinite; }

.status-ok    { border-color: hsl(145 45% 34%); background: hsl(145 30% 12%); }
.status-ok    .status-icon { color: hsl(145 60% 55%); }

.status-warn  { border-color: hsl(38 60% 40%); background: hsl(38 32% 13%); }
.status-warn  .status-icon { color: hsl(38 90% 62%); }

.status-error { border-color: hsl(4 55% 44%); background: hsl(4 34% 14%); }
.status-error .status-icon { color: hsl(4 80% 64%); }

.log {
  margin: 0;
  padding: 9px 10px;
  max-height: 190px;
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  line-height: 1.55;
  color: hsl(4 55% 72%);
  white-space: pre-wrap;
  word-break: break-word;
}

/* Thu\u1ed9c t\u00ednh hidden ph\u1ea3i th\u1eafng display c\u1ee7a component */
[hidden] { display: none !important; }

/* ---------- N\u00fat \u0111\u1ed9ng t\u00e1c ---------- */
.actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.act {
  padding: 9px 6px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--muted);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: .01em;
  cursor: pointer;
  transition: background .15s ease, color .15s ease,
              border-color .15s ease, transform .1s ease;
}
.act:hover {
  background: hsl(220 10% 22%);
  color: var(--text);
  border-color: hsl(220 9% 34%);
}
.act:active { transform: translateY(1px); }
.act.is-on {
  background: hsl(28 72% 46%);
  border-color: hsl(28 72% 52%);
  color: hsl(28 60% 96%);
}
.act.is-on:hover { background: hsl(28 72% 50%); }

/* ---------- Saved API key summary ---------- */
.key-saved {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border-radius: 7px;
  border: 1px solid hsl(145 30% 30%);
  background: hsl(145 25% 14%);
  font-size: 12px;
}
.key-saved-icon {
  color: hsl(145 60% 55%);
  font-weight: 600;
  flex: none;
}
.key-saved-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
  color: hsl(145 20% 82%);
}
.key-saved-hint {
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.link-btn {
  flex: none;
  background: none;
  border: none;
  padding: 2px 4px;
  color: hsl(210 70% 66%);
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.link-btn:hover { color: hsl(210 80% 74%); }
