:root {
  --bg: #07111f;
  --bg-soft: rgba(11, 25, 42, 0.82);
  --panel: rgba(9, 19, 33, 0.86);
  --panel-strong: #101c2f;
  --border: rgba(145, 170, 201, 0.16);
  --text: #edf4ff;
  --muted: #93a6c2;
  --primary: #d7ff5d;
  --primary-ink: #152100;
  --accent: #4fd1c5;
  --warning: #f5c451;
  --danger: #ff7f96;
  --success: #3ddc97;
  --shadow: 0 30px 80px rgba(0, 0, 0, 0.28);
  --radius: 24px;
  --radius-sm: 16px;
  --font: "Segoe UI", "Helvetica Neue", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(79, 209, 197, 0.18), transparent 32%),
    radial-gradient(circle at bottom right, rgba(215, 255, 93, 0.14), transparent 26%),
    linear-gradient(180deg, #08111d 0%, #050a12 100%);
  color: var(--text);
  font-family: var(--font);
}

body {
  position: relative;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

.ambient {
  position: fixed;
  width: 24rem;
  height: 24rem;
  border-radius: 999px;
  filter: blur(60px);
  opacity: 0.4;
  pointer-events: none;
}

.ambient-left {
  top: 1rem;
  left: -6rem;
  background: rgba(79, 209, 197, 0.26);
}

.ambient-right {
  bottom: -6rem;
  right: -4rem;
  background: rgba(215, 255, 93, 0.14);
}

.theme-shell,
.theme-app {
  min-height: 100vh;
}

.guest-shell,
.installer-shell {
  position: relative;
  z-index: 1;
  width: min(1120px, calc(100vw - 2rem));
  margin: 0 auto;
  padding: 2rem 0;
}

.guest-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.installer-shell {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 1.25rem;
  align-items: start;
}

.installer-sidebar,
.installer-panel,
.auth-card,
.panel,
.hero-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.installer-sidebar {
  padding: 2rem;
  position: sticky;
  top: 2rem;
}

.installer-panel,
.auth-card,
.panel,
.hero-card {
  padding: 2rem;
}

.brand-block h1,
.auth-card h1,
.panel h1,
.panel h2,
.hero-card h2,
.dashboard-hero h2 {
  margin: 0.2rem 0 0.8rem;
  font-size: clamp(1.8rem, 3vw, 3rem);
  line-height: 1.05;
}

.eyebrow {
  display: inline-block;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.75rem;
  color: var(--accent);
}

.brand-block p,
.panel p,
.hero-card p,
.auth-card p,
.dashboard-hero p {
  color: var(--muted);
  line-height: 1.6;
}

.step-list {
  list-style: none;
  padding: 0;
  margin: 2rem 0 0;
  display: grid;
  gap: 0.85rem;
}

.step-item {
  padding: 0.95rem 1rem;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
}

.step-item.active {
  background: rgba(79, 209, 197, 0.12);
  color: var(--text);
  border: 1px solid rgba(79, 209, 197, 0.3);
}

.progress-wrap {
  margin-top: 1.5rem;
  padding: 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.03);
}

.progress-meta {
  display: grid;
  gap: 0.4rem;
  margin-bottom: 1rem;
}

.progress-meta span {
  color: var(--muted);
}

.progress-bar {
  height: 14px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.07);
}

.progress-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
}

.progress-bar.is-pending span {
  background: linear-gradient(90deg, #e2a93a, var(--warning));
}

.progress-bar.is-ready span {
  background: linear-gradient(90deg, #26c47b, var(--success));
}

.status-list {
  display: grid;
  gap: 0.85rem;
  margin-top: 1.5rem;
}

.status-item {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  padding: 1rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.03);
}

.status-item p {
  margin: 0.35rem 0 0;
}

.badge {
  flex-shrink: 0;
  padding: 0.5rem 0.8rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
}

.badge-success {
  background: rgba(61, 220, 151, 0.16);
  color: #9ff4ca;
}

.badge-warning {
  background: rgba(245, 196, 81, 0.16);
  color: #ffd989;
}

.badge-danger {
  background: rgba(255, 127, 150, 0.14);
  color: #ffc2cf;
}

.card-grid {
  display: grid;
  gap: 1rem;
}

.card-grid-two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.card-grid-three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.action-card,
.mini-card {
  display: grid;
  gap: 0.55rem;
  padding: 1.25rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(17, 31, 52, 0.82), rgba(9, 18, 31, 0.9));
  transition: transform 0.18s ease, border-color 0.18s ease;
}

.action-card:hover,
.mini-card:hover,
.nav-link:hover {
  transform: translateY(-2px);
  border-color: rgba(79, 209, 197, 0.3);
}

.action-card strong {
  font-size: 1.05rem;
}

.action-card span,
.mini-card {
  color: var(--muted);
}

.action-card.muted {
  opacity: 0.72;
}

.form-grid {
  margin-top: 1.5rem;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.form-grid label {
  display: grid;
  gap: 0.55rem;
}

.form-grid label span {
  color: var(--muted);
  font-size: 0.95rem;
}

.full-width {
  grid-column: 1 / -1;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid rgba(145, 170, 201, 0.2);
  background: rgba(2, 9, 18, 0.78);
  color: var(--text);
  border-radius: 14px;
  padding: 0.95rem 1rem;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(79, 209, 197, 0.48);
  box-shadow: 0 0 0 4px rgba(79, 209, 197, 0.08);
}

textarea {
  resize: vertical;
  min-height: 11rem;
}

.actions {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  margin-top: 1.5rem;
}

.primary-button,
.ghost-button,
.text-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border-radius: 999px;
  padding: 0.95rem 1.35rem;
  border: 1px solid transparent;
  cursor: pointer;
}

.primary-button {
  background: var(--primary);
  color: var(--primary-ink);
  font-weight: 700;
}

.ghost-button {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}

.text-link {
  padding-left: 0;
  color: var(--accent);
}

.is-disabled,
.primary-button:disabled {
  pointer-events: none;
  opacity: 0.45;
}

.flash,
.inline-error {
  margin-bottom: 1rem;
  padding: 0.95rem 1rem;
  border-radius: 14px;
}

.flash-success {
  background: rgba(61, 220, 151, 0.14);
  border: 1px solid rgba(61, 220, 151, 0.3);
}

.flash-error,
.inline-error {
  background: rgba(255, 127, 150, 0.12);
  border: 1px solid rgba(255, 127, 150, 0.28);
}

.strength-meter {
  display: grid;
  gap: 0.6rem;
}

.strength-track {
  height: 10px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  overflow: hidden;
}

.strength-track span {
  display: block;
  height: 100%;
  width: 10%;
  background: linear-gradient(90deg, #e2a93a, var(--warning));
}

.strength-track span.accepted {
  background: linear-gradient(90deg, #2bc77b, var(--success));
}

.strength-labels {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.92rem;
}

.auth-card {
  width: min(480px, 100%);
}

.panel-centered {
  max-width: 560px;
  margin: 0 auto;
}

.app-frame {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
}

.app-sidebar {
  padding: 1.5rem;
  border-right: 1px solid var(--border);
  background: rgba(3, 8, 15, 0.85);
  backdrop-filter: blur(14px);
}

.sidebar-nav {
  display: grid;
  gap: 0.5rem;
  margin-top: 1.5rem;
}

.nav-link {
  padding: 0.9rem 1rem;
  border-radius: 14px;
  color: var(--muted);
  border: 1px solid transparent;
}

.nav-link.active {
  background: rgba(215, 255, 93, 0.1);
  color: var(--text);
  border-color: rgba(215, 255, 93, 0.2);
}

.app-main {
  display: grid;
  grid-template-rows: auto 1fr;
}

.app-topbar {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: rgba(5, 11, 20, 0.76);
  backdrop-filter: blur(14px);
}

.app-content {
  padding: 1.5rem;
}

.dashboard-hero {
  display: flex;
  justify-content: space-between;
  gap: 1.5rem;
  align-items: end;
  padding: 1.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(79, 209, 197, 0.1), rgba(215, 255, 93, 0.08), rgba(8, 17, 29, 0.96));
}

.dashboard-pill {
  padding: 0.85rem 1rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  white-space: nowrap;
}

.secondary-grid {
  margin-top: 1rem;
}

.video-layout {
  margin-top: 1rem;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  gap: 1rem;
}

.video-storage-panel {
  margin-top: 1rem;
}

.video-storage-copy {
  margin-top: 0.75rem;
}

.video-storage-status {
  display: flex;
  align-items: center;
}

.video-mode-picker {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
  padding: 0;
  border: 0;
  margin: 0;
}

.video-mode-picker legend {
  margin-bottom: 0.85rem;
  font-weight: 600;
}

.video-mode-option {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.95rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.03);
  cursor: pointer;
}

.video-mode-option input {
  margin: 0;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: start;
}

.panel-head h2 {
  margin-bottom: 0;
}

.video-hint,
.meta-label,
.status-copy small {
  color: var(--muted);
}

.video-result-card {
  margin-top: 1.25rem;
  display: grid;
  gap: 1rem;
}

.video-action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.video-meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.03);
}

.video-meta-grid > div {
  display: grid;
  gap: 0.45rem;
}

.video-prompt-block {
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.03);
}

.video-prompt-block p {
  margin: 0.5rem 0 0;
}

.video-upload-grid,
.video-source-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.reference-media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
}

.upload-field,
.video-source-card {
  display: grid;
  gap: 0.65rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.03);
}

.upload-field small,
.history-source-links a {
  color: var(--muted);
}

.file-pill-list {
  display: grid;
  gap: 0.6rem;
  margin-top: 0.8rem;
}

.file-pill {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: center;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
}

.file-pill span {
  color: var(--text);
  word-break: break-word;
}

.file-pill button {
  width: auto;
  padding: 0.45rem 0.8rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.video-source-card {
  margin: 0;
}

.video-source-card img {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.25);
}

.reference-media-card {
  display: grid;
  gap: 0.7rem;
  align-content: start;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.03);
}

.reference-media-card img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 16px;
}

.reference-media-type {
  display: inline-flex;
  width: fit-content;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  background: rgba(79, 209, 197, 0.12);
  color: var(--accent);
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.generated-video {
  width: 100%;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: #000;
  overflow: hidden;
}

.status-item-stack {
  align-items: start;
}

.status-copy {
  min-width: 0;
}

.status-copy p {
  margin: 0.45rem 0;
}

.history-storage-line {
  margin-top: 0.45rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.history-source-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem;
  margin-top: 0.5rem;
}

.status-actions {
  display: grid;
  gap: 0.75rem;
  justify-items: end;
}

.character-layout {
  margin-top: 1rem;
  display: grid;
  grid-template-columns: minmax(320px, 0.9fr) minmax(0, 1.1fr);
  gap: 1rem;
  align-items: start;
}

.character-card-list,
.character-image-grid {
  display: grid;
  gap: 1rem;
}

.character-card {
  display: grid;
  grid-template-columns: 108px minmax(0, 1fr);
  gap: 1rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.03);
}

.character-card.is-selected {
  border-color: rgba(79, 209, 197, 0.35);
  background: rgba(79, 209, 197, 0.08);
}

.character-card-thumb {
  width: 108px;
  aspect-ratio: 3 / 4;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: rgba(2, 9, 18, 0.78);
  overflow: hidden;
  display: grid;
  place-items: center;
  color: var(--muted);
  text-align: center;
  padding: 0.75rem;
}

.character-card-thumb img,
.character-image-card img,
.character-primary-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.character-card-copy {
  display: grid;
  gap: 0.45rem;
  min-width: 0;
}

.character-card-actions,
.character-inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 0.4rem;
}

.character-progress {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin: 1rem 0 1.5rem;
}

.character-progress-step {
  padding: 0.55rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.03);
}

.character-progress-step.is-active {
  color: var(--text);
  border-color: rgba(79, 209, 197, 0.35);
  background: rgba(79, 209, 197, 0.12);
}

.character-section {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.character-primary-card {
  display: grid;
  grid-template-columns: minmax(180px, 240px) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.03);
}

.character-primary-card img {
  aspect-ratio: 3 / 4;
  border-radius: 18px;
  border: 1px solid var(--border);
}

.character-primary-copy {
  display: grid;
  gap: 0.65rem;
}

.character-action-grid,
.character-preset-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.character-preset-grid form,
.character-action-grid form {
  display: grid;
}

.character-image-card {
  display: grid;
  grid-template-columns: minmax(160px, 220px) minmax(0, 1fr);
  gap: 1rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.03);
}

.character-image-card img {
  aspect-ratio: 3 / 4;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.25);
}

.character-image-copy {
  display: grid;
  gap: 0.65rem;
}

.character-image-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.upload-inline-form {
  align-items: center;
}

.inline-warning {
  border-color: rgba(240, 180, 41, 0.35);
  background: rgba(240, 180, 41, 0.12);
}

.ghost-button-danger {
  border-color: rgba(234, 96, 96, 0.35);
  color: #ffb6b6;
}

.menu-button {
  display: none;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  padding: 0.7rem 1rem;
}

@media (max-width: 960px) {
  .installer-shell,
  .app-frame,
  .card-grid-two,
  .card-grid-three,
  .form-grid,
  .video-layout,
  .character-layout,
  .video-meta-grid,
  .video-mode-picker,
  .video-upload-grid,
  .video-source-grid,
  .reference-media-grid,
  .character-action-grid,
  .character-preset-grid,
  .character-image-card,
  .character-card,
  .character-primary-card {
    grid-template-columns: 1fr;
  }

  .installer-sidebar {
    position: static;
  }

  .app-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(82vw, 320px);
    transform: translateX(-105%);
    transition: transform 0.2s ease;
    z-index: 20;
  }

  .app-sidebar.is-open {
    transform: translateX(0);
  }

  .menu-button {
    display: inline-flex;
  }

  .dashboard-hero,
  .app-topbar,
  .actions,
  .panel-head {
    flex-direction: column;
    align-items: stretch;
  }

  .status-actions {
    justify-items: start;
  }
}
