:root {
  color-scheme: dark;
  --bg: #121a1f;
  --panel: rgba(16, 27, 34, 0.88);
  --panel-border: rgba(166, 200, 213, 0.18);
  --accent: #e89a3d;
  --accent-strong: #ffb14a;
  --text: #eef3f5;
  --muted: #a7b8c1;
  --danger: #ff8b7b;
  --success: #7ee0ab;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Aptos", "Trebuchet MS", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(232, 154, 61, 0.18), transparent 30%),
    radial-gradient(circle at top right, rgba(84, 153, 199, 0.16), transparent 32%),
    linear-gradient(180deg, #1e2b33 0%, #0b1115 100%);
}

.app-shell {
  width: min(1200px, calc(100% - 32px));
  margin: 0 auto;
  padding: 36px 0 48px;
}

.hero {
  margin-bottom: 28px;
}

.eyebrow,
.panel-label,
.gallery-count,
.job-status,
#preview-empty,
.gallery-empty,
.gallery-title,
.gallery-link,
.error-message {
  color: var(--muted);
}

.eyebrow,
.panel-label {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.72rem;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-family: "Iowan Old Style", "Palatino Linotype", serif;
  font-size: clamp(2.4rem, 5vw, 4.2rem);
  line-height: 0.94;
}

h2 {
  font-family: "Iowan Old Style", "Palatino Linotype", serif;
  font-size: 1.6rem;
}

.hero-copy {
  max-width: 680px;
  margin-top: 12px;
  line-height: 1.5;
}

.status-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 18px;
}

.progress-bar {
  width: min(560px, 100%);
  height: 10px;
  margin-top: 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.progress-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent-strong) 100%);
  transition: width 220ms ease;
}

.admin-access {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 14px;
}

.admin-access input {
  min-width: 220px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(6, 10, 13, 0.55);
  color: var(--text);
  padding: 12px 16px;
}

.badge {
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.04);
  font-size: 0.92rem;
}

.badge-online {
  color: var(--success);
}

.badge-offline {
  color: var(--danger);
}

.workspace {
  display: grid;
  gap: 20px;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 24px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.controls-panel {
  padding: 24px;
}

.gallery-panel {
  padding: 24px;
  min-height: 500px;
}

.admin-panel {
  margin-top: 20px;
  padding: 24px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 12px;
  margin-bottom: 18px;
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
}

.field-prompt {
  margin-top: 18px;
}

.toggle-field {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
  color: var(--text);
}

.toggle-field input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent-strong);
}

.field span {
  font-size: 0.94rem;
}

.range-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

input[type="file"],
input[type="range"],
textarea,
button {
  font: inherit;
}

input[type="file"],
textarea {
  width: 100%;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(6, 10, 13, 0.55);
  color: var(--text);
}

input[type="file"] {
  padding: 14px;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent-strong);
}

textarea {
  resize: vertical;
  min-height: 140px;
  padding: 16px;
  line-height: 1.5;
}

.preview-frame {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 280px;
  margin-bottom: 18px;
  border-radius: 22px;
  border: 1px dashed rgba(255, 255, 255, 0.18);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.02)),
    rgba(0, 0, 0, 0.18);
  overflow: hidden;
  cursor: pointer;
}

.preview-frame img {
  width: 100%;
  height: 100%;
  max-height: 420px;
  object-fit: contain;
}

.preview-frame.is-dragover {
  border-color: rgba(255, 177, 74, 0.8);
  background:
    linear-gradient(135deg, rgba(255, 177, 74, 0.12), rgba(255, 255, 255, 0.04)),
    rgba(0, 0, 0, 0.22);
}

.preview-frame.is-text-only {
  border-color: rgba(255, 177, 74, 0.34);
  background:
    linear-gradient(135deg, rgba(255, 177, 74, 0.08), rgba(255, 255, 255, 0.02)),
    rgba(0, 0, 0, 0.18);
}

.preview-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 18px;
  background: linear-gradient(180deg, rgba(7, 11, 14, 0.1), rgba(7, 11, 14, 0.5));
  opacity: 0;
  transition: opacity 140ms ease;
  pointer-events: none;
}

.preview-frame.is-empty .preview-overlay {
  opacity: 1;
}

.preview-frame:hover .preview-overlay,
.preview-frame:focus-visible .preview-overlay,
.preview-frame.is-dragover .preview-overlay {
  opacity: 1;
}

.preview-action {
  pointer-events: auto;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
  color: #201000;
  font-weight: 700;
}

.preview-action-secondary {
  background: rgba(8, 11, 13, 0.82);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.action-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.action-row-primary {
  justify-content: center;
}

button {
  border: 0;
  border-radius: 999px;
  padding: 14px 22px;
  cursor: pointer;
  transition: transform 120ms ease, opacity 120ms ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
}

button:disabled {
  opacity: 0.6;
  cursor: wait;
}

#generate-button {
  min-width: 280px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
  color: #201000;
  font-weight: 700;
}

.button-secondary {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.error-message {
  margin-top: 16px;
  color: var(--danger);
  line-height: 1.45;
}

.gallery-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

.gallery-empty {
  padding: 48px 0 16px;
}

.gallery-card {
  position: relative;
  overflow: hidden;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.gallery-delete {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 999px;
  background: rgba(8, 11, 13, 0.78);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.14);
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 120ms ease, transform 120ms ease, background 120ms ease;
}

.gallery-card:hover .gallery-delete,
.gallery-delete:focus-visible {
  opacity: 1;
  transform: translateY(0);
}

.gallery-delete:hover {
  background: rgba(160, 35, 35, 0.92);
}

.gallery-image {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  background: rgba(0, 0, 0, 0.24);
  cursor: zoom-in;
}

.gallery-meta {
  padding: 12px 14px 14px;
}

.gallery-title {
  margin-bottom: 8px;
  color: var(--text);
  font-size: 0.92rem;
  word-break: break-word;
}

.gallery-link {
  text-decoration: none;
}

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

.admin-table-wrap {
  overflow: auto;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
}

.admin-table th,
.admin-table td {
  text-align: left;
  padding: 12px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.92rem;
}

.admin-table th {
  color: var(--muted);
  font-weight: 600;
}

.blocked-list {
  display: grid;
  gap: 12px;
}

.tab-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.tab-button.is-active {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
  color: #201000;
  border-color: transparent;
}

.card-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.blocked-card {
  padding: 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.gallery-detail {
  margin-top: 6px;
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.45;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 20px;
}

.lightbox[hidden] {
  display: none;
}

.lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 6, 8, 0.82);
  backdrop-filter: blur(10px);
}

.lightbox-dialog {
  position: relative;
  z-index: 1;
  width: min(1100px, 100%);
  max-height: calc(100vh - 40px);
  padding: 18px;
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(12, 18, 22, 0.96);
  box-shadow: var(--shadow);
}

.lightbox-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.lightbox-close {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.lightbox-frame {
  display: grid;
  place-items: center;
  min-height: 320px;
  max-height: calc(100vh - 140px);
  overflow: auto;
  border-radius: 18px;
  background: rgba(0, 0, 0, 0.26);
}

.lightbox-frame img {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 160px);
  object-fit: contain;
}

@media (max-width: 900px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .app-shell {
    width: min(100% - 20px, 1200px);
    padding-top: 24px;
  }

  .controls-panel,
  .gallery-panel {
    padding: 18px;
  }
}
