:root {
  color-scheme: dark;
  --bg: #0a0f1f;
  --panel: #111827;
  --panel-strong: #0f172a;
  --line: #263449;
  --text: #eef2ff;
  --muted: #9aa8bd;
  --blue: #3b82f6;
  --blue-strong: #2563eb;
  --green: #22c55e;
  --amber: #f59e0b;
  --rose: #fb7185;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at 12% 0%, rgba(34, 197, 94, 0.12), transparent 28%),
    linear-gradient(135deg, #07101d 0%, #111827 48%, #151724 100%);
  color: var(--text);
  font-family: Inter, Segoe UI, Roboto, Arial, sans-serif;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.app-shell {
  min-height: 100vh;
  padding: 24px;
}

.workbench {
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 22px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 18px;
  background: rgba(15, 23, 42, 0.84);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--green);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 30px;
  line-height: 1.15;
}

h2 {
  font-size: 18px;
}

.actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.user-chip {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.7);
  color: #cbd5e1;
  font-size: 13px;
  font-weight: 800;
}

.logout-form {
  margin: 0;
}

.url-form {
  display: grid;
  gap: 9px;
}

.url-form label {
  color: #cbd5e1;
  font-size: 14px;
  font-weight: 700;
}

.field-grid {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(230px, 360px) 170px;
  gap: 12px;
  align-items: end;
}

.field-block {
  display: grid;
  gap: 9px;
}

input[type="url"],
input[type="password"],
input[type="text"] {
  width: 100%;
  min-height: 52px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
  background: #020617;
  color: var(--text);
}

input[type="url"]:focus,
input[type="password"]:focus,
input[type="text"]:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.16);
}

.secret-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 52px;
  gap: 8px;
}

.icon-button {
  min-height: 52px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #172033;
  color: #dbeafe;
  font-size: 12px;
  font-weight: 800;
}

.icon-button:hover {
  background: #22304a;
}

#fetchButton,
.secondary {
  min-height: 44px;
  border-radius: 10px;
  color: white;
  font-weight: 800;
}

#fetchButton {
  min-height: 52px;
  background: linear-gradient(135deg, var(--blue), var(--blue-strong));
}

#fetchButton:hover:not(:disabled) {
  filter: brightness(1.07);
}

.secondary {
  padding: 0 15px;
  background: #334155;
}

.secondary:hover:not(:disabled) {
  background: #475569;
}

.logout-button {
  background: #4b2530;
}

.logout-button:hover:not(:disabled) {
  background: #713244;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(460px, 100%);
  padding: 30px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 18px;
  background: rgba(15, 23, 42, 0.9);
  box-shadow: var(--shadow);
}

.login-panel h1 {
  margin-bottom: 10px;
}

.login-copy {
  margin: 0 0 22px;
  color: var(--muted);
  line-height: 1.55;
}

.login-error {
  margin-bottom: 18px;
  padding: 12px 14px;
  border: 1px solid rgba(251, 113, 133, 0.42);
  border-radius: 10px;
  background: rgba(251, 113, 133, 0.12);
  color: #fecdd3;
  font-weight: 700;
}

.login-form {
  display: grid;
  gap: 10px;
}

.login-form label {
  color: #cbd5e1;
  font-size: 14px;
  font-weight: 800;
}

.login-form input {
  margin-bottom: 8px;
}

.login-button {
  min-height: 52px;
  margin-top: 4px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--green), var(--blue-strong));
  color: white;
  font-weight: 900;
}

.login-button:hover {
  filter: brightness(1.06);
}

.status-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 18px 0 8px;
  color: var(--muted);
  font-size: 14px;
}

.progress-track {
  width: 100%;
  height: 12px;
  overflow: hidden;
  border-radius: 99px;
  background: #020617;
  border: 1px solid rgba(148, 163, 184, 0.2);
}

.progress-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--blue), var(--amber));
  transition: width 0.2s ease;
}

.layout {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 18px;
  margin-top: 18px;
}

.media-panel,
.content-panel {
  min-height: 560px;
  border: 1px solid rgba(148, 163, 184, 0.17);
  border-radius: 14px;
  background: rgba(17, 24, 39, 0.9);
}

.media-panel {
  padding: 16px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

#imageCount {
  min-width: 34px;
  padding: 5px 8px;
  border-radius: 999px;
  background: rgba(34, 197, 94, 0.15);
  color: #86efac;
  text-align: center;
  font-weight: 800;
}

.image-grid {
  display: grid;
  gap: 12px;
  max-height: 680px;
  overflow: auto;
  padding-right: 4px;
}

.image-item {
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 8px;
  background: #020617;
}

.image-item img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: contain;
  background: #f8fafc;
}

.image-item span {
  display: block;
  padding: 9px 10px;
  color: #cbd5e1;
  font-size: 13px;
  font-weight: 700;
}

.empty-state {
  display: grid;
  min-height: 240px;
  place-items: center;
  padding: 18px;
  border: 1px dashed rgba(148, 163, 184, 0.25);
  border-radius: 10px;
  color: var(--muted);
  text-align: center;
}

.content-panel {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  min-width: 0;
  padding: 16px;
}

.product-head {
  display: grid;
  gap: 4px;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.16);
}

.product-head span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

.product-head strong {
  color: var(--text);
  font-size: 20px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.tabs {
  display: flex;
  gap: 8px;
  margin: 14px 0;
  overflow-x: auto;
}

.tab {
  min-height: 38px;
  padding: 0 16px;
  border-radius: 999px;
  background: #020617;
  color: #cbd5e1;
  font-weight: 800;
  white-space: nowrap;
}

.tab.active {
  background: #e0f2fe;
  color: #082f49;
}

.tab-panel {
  display: none;
  min-height: 0;
}

.tab-panel.active {
  display: block;
  min-height: 0;
}

.output-text,
.output-code {
  width: 100%;
  height: 100%;
  min-height: 440px;
  max-height: 650px;
  margin: 0;
  overflow: auto;
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 10px;
  background: #020617;
  color: #e5e7eb;
  white-space: pre-wrap;
}

.output-text {
  padding: 18px;
  font-family: Inter, Segoe UI, Roboto, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.68;
}

.output-code {
  padding: 16px;
  font-family: Consolas, Monaco, monospace;
  font-size: 13px;
  line-height: 1.55;
}

.is-error {
  color: #fecdd3;
}

@media (max-width: 980px) {
  .app-shell {
    padding: 12px;
  }

  .workbench {
    padding: 16px;
    border-radius: 12px;
  }

  .topbar,
  .field-grid,
  .layout {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
  }

  .actions {
    justify-content: stretch;
  }

  .actions button,
  #fetchButton {
    width: 100%;
  }

  .logout-form,
  .user-chip {
    width: 100%;
  }

  .user-chip {
    justify-content: center;
  }

  h1 {
    font-size: 28px;
  }

  .tab {
    padding: 0 10px;
    font-size: 13px;
  }

  .tabs {
    gap: 6px;
  }

  .media-panel,
  .content-panel {
    min-height: auto;
  }
}
