:root {
  --bg: #0f1115;
  --panel: #171a21;
  --text: #e8eaef;
  --muted: #9aa3b2;
  --accent: #7c5cff;
  --accent2: #3dd6c3;
  --border: #2a3140;
  --err: #ff6b6b;
  --radius: 12px;
  --font: "Segoe UI", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}

.banner-warn {
  margin: 0;
  padding: 0.75rem 1.25rem;
  background: #2a2208;
  border-bottom: 1px solid #6b5416;
  color: #fde8b0;
  font-size: 0.92rem;
  line-height: 1.4;
}

.banner-warn.hidden {
  display: none;
}

.banner-warn code {
  font-size: 0.84em;
  background: rgba(0, 0, 0, 0.25);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

.banner-warn a {
  color: #98f5e8;
}

.banner-warn strong {
  color: #fff5d6;
}

.top {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.brand h1 {
  margin: 0;
  font-size: 1.35rem;
  letter-spacing: 0.02em;
}

.sub {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
  max-width: 42rem;
}

.actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.portal-back {
  margin-left: auto;
  font-weight: 600;
}

.hint-link {
  color: var(--accent2);
  text-decoration: none;
  font-size: 0.9rem;
}

.hint-link:hover {
  text-decoration: underline;
}

.panel {
  margin: 1rem 1.5rem;
  padding: 1rem 1.25rem;
  background: var(--panel);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.panel h2 {
  margin: 0 0 0.6rem;
  font-size: 1.1rem;
}

.note {
  color: var(--muted);
  font-size: 0.88rem;
  margin: 0 0 0.75rem;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.grow {
  width: 100%;
  margin-top: 0.75rem;
  resize: vertical;
  min-height: 4rem;
}

textarea,
input[type="password"],
input[type="number"],
select {
  font: inherit;
  color: var(--text);
  background: #10131a;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.65rem;
}

textarea:focus,
select:focus,
input:focus {
  outline: 2px solid rgba(124, 92, 255, 0.45);
  outline-offset: 1px;
}

.grid-tools {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
}

.grid-tools .span-2 {
  grid-column: 1 / -1;
}

.field-hint {
  margin: 0.4rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.field-hint a {
  color: var(--accent2);
}

.grid-tools label {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.preview-wrap {
  margin-top: 0.75rem;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  max-width: 220px;
  background: #0b0d12;
}

.preview-wrap img {
  display: block;
  width: 100%;
  height: auto;
}

.hidden {
  display: none !important;
}

.scenes-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.scene-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.scene-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem;
  background: #12151c;
}

.scene-item header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.scene-num {
  background: rgba(124, 92, 255, 0.2);
  color: #d4cbff;
  font-size: 0.78rem;
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
}

.scene-item textarea {
  width: 100%;
  min-height: 4.5rem;
  margin-bottom: 0.5rem;
}

.out-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: flex-start;
}

.out-row img {
  max-width: 140px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #0b0d12;
}

.scene-progress {
  margin: 0.5rem 0 0.25rem;
}

.prog-track {
  height: 10px;
  background: #2a3140;
  border-radius: 6px;
  overflow: hidden;
}

.prog-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #6a4bff, #3dd6c3);
  transition: width 0.45s ease;
}

.scene-progress.indet .prog-fill {
  width: 40% !important;
  animation: prog-indet 1.1s ease-in-out infinite alternate;
}

@keyframes prog-indet {
  from {
    transform: translateX(-30%);
  }
  to {
    transform: translateX(130%);
  }
}

.scene-log {
  margin: 0.35rem 0 0;
  font-size: 0.78rem;
  color: var(--muted);
  white-space: pre-wrap;
  max-height: 5.2rem;
  overflow: auto;
  font-family: ui-monospace, Consolas, monospace;
  line-height: 1.35;
}

.btn {
  font: inherit;
  cursor: pointer;
  border: 1px solid var(--border);
  background: #1e2430;
  color: var(--text);
  padding: 0.45rem 0.85rem;
  border-radius: 8px;
}

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

.btn.primary {
  background: linear-gradient(135deg, #6a4bff, #3dd6c3);
  border: none;
  color: #0a0c10;
  font-weight: 600;
}

.btn.secondary {
  border-color: #3d4558;
}

.btn.tertiary {
  background: transparent;
}

.status {
  color: var(--muted);
  font-size: 0.88rem;
}

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

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: grid;
  place-items: center;
  padding: 1rem;
  z-index: 50;
}

.modal-card {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.modal-card input {
  width: 100%;
  margin-top: 0.5rem;
}

.modal-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
}
