:root {
  color-scheme: light;
  --bg: #eef2f8;
  --surface: #ffffff;
  --ink: #0b1835;
  --muted: #758198;
  --faint: #aeb7c7;
  --line: #d9e0ea;
  --line-strong: #c6cfdd;
  --blue: #2d6cdf;
  --blue-soft: #edf4ff;
  --danger: #d92d20;
  --shadow-soft: 0 8px 22px rgba(31, 45, 71, 0.1);
  --shadow-float: 0 18px 48px rgba(31, 45, 71, 0.18);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
}

.maintenance-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 35;
  padding: 10px 16px;
  border-bottom: 1px solid #f2c97d;
  background: #fff8e6;
  color: #9a5b00;
  font-size: 14px;
  font-weight: 800;
  text-align: center;
  box-shadow: 0 8px 20px rgba(31, 45, 71, 0.08);
}

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

button {
  letter-spacing: 0;
}

h1,
h2,
h3,
p {
  margin: 0;
}

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

.workspace {
  min-height: 100vh;
}

.topbar {
  width: min(920px, calc(100vw - 32px));
  margin: 42px auto 20px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: #26324a;
  font-size: 14px;
  font-weight: 800;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: #172033;
  color: #f8fafc;
  font-size: 13px;
}

h1 {
  margin-top: 14px;
  font-size: 32px;
  line-height: 1.2;
}

.login-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
  gap: 28px;
  width: min(920px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow-float);
}

.login-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 10px;
}

.login-copy h2 {
  font-size: 28px;
}

.login-copy p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
}

.login-form {
  display: grid;
  gap: 12px;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.auth-tab {
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: #667085;
  cursor: pointer;
  font-weight: 800;
}

.auth-tab.active {
  border-color: #b8cef9;
  background: #edf4ff;
  color: #285bc4;
}

label,
.select-chip span {
  color: #344054;
  font-size: 12px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

input,
select {
  height: 42px;
  padding: 0 12px;
}

textarea {
  min-height: 74px;
  max-height: 170px;
  padding: 14px 8px 10px 0;
  border: 0;
  resize: vertical;
  line-height: 1.55;
  font-size: 14px;
}

textarea::placeholder {
  color: #728096;
}

input:focus,
select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(45, 108, 223, 0.12);
}

.password-field {
  position: relative;
}

.password-field input {
  padding-right: 42px;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 8px;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #667085;
  cursor: pointer;
  font-size: 14px;
}

.password-toggle svg {
  display: block;
}

.primary-button,
.ghost-button,
.toolbar-button,
.logout-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  border-radius: 7px;
  border: 1px solid transparent;
  padding: 0 12px;
  cursor: pointer;
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
  background: #fff;
  color: #263245;
}

.primary-button {
  min-height: 42px;
  background: #177245;
  color: #fff;
}

.ghost-button,
.toolbar-button,
.logout-button {
  border-color: var(--line);
  box-shadow: 0 3px 10px rgba(31, 45, 71, 0.08);
}

.danger-button {
  color: var(--danger);
}

.small-button {
  min-height: 32px;
  padding: 0 12px;
  font-size: 12px;
}

.tool-shell {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  height: 100vh;
  padding: 0 0 132px;
}

.tool-shell > .account {
  position: fixed;
  top: 18px;
  right: 22px;
  z-index: 15;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: calc(100vw - 44px);
}

.feed-panel {
  min-height: 0;
  overflow-y: auto;
  padding: 22px 24px 40px;
}

.generation-feed {
  display: flex;
  flex-direction: column;
  gap: 70px;
  width: min(980px, calc(100vw - 48px));
  min-height: 100%;
  margin: 0 auto;
  padding: 0 0 28px;
}

.feed-item {
  position: relative;
  width: min(430px, 100%);
  margin-left: 18px;
}

.feed-copy {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.feed-copy h3 {
  max-width: 680px;
  color: #061435;
  font-size: 15px;
  font-weight: 800;
  line-height: 1.55;
}

.reference-strip {
  display: flex;
  align-items: center;
  gap: 5px;
  max-width: 420px;
  overflow: hidden;
}

.reference-strip img {
  width: 28px;
  height: 36px;
  border-radius: 5px;
  object-fit: cover;
  background: #dfe5ee;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.meta-chip {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 9px;
  border: 1px solid #d7dee9;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: #718098;
  font-size: 12px;
  white-space: nowrap;
}

.blue-chip {
  border-color: #bdd1ff;
  background: #eaf2ff;
  color: #2d64d4;
}

.redeem-panel {
  position: fixed;
  right: 22px;
  bottom: 18px;
  z-index: 12;
  display: grid;
  grid-template-columns: minmax(190px, 280px) auto auto;
  gap: 8px;
  pointer-events: auto;
}

.redeem-panel input {
  height: 34px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 6px 20px rgba(31, 45, 71, 0.08);
}

.purchase-key-button[hidden] {
  display: none;
}

.result-frame {
  display: grid;
  place-items: center;
  width: 250px;
  aspect-ratio: 1 / 1;
  border: 1px solid #dbe2ec;
  border-radius: 7px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(30, 44, 69, 0.13);
  overflow: hidden;
  cursor: zoom-in;
}

.result-frame img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #e6ebf2;
}

.image-modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 28px;
}

.image-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 14, 28, 0.64);
}

.image-modal-body {
  position: relative;
  display: grid;
  place-items: center;
  max-width: min(92vw, 1120px);
  max-height: 90vh;
}

.image-modal-body img {
  display: block;
  max-width: min(92vw, 1120px);
  max-height: 84vh;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.32);
}

.modal-close {
  position: absolute;
  top: -16px;
  right: -16px;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: #fff;
  color: #1d2939;
  cursor: pointer;
  font-size: 24px;
  box-shadow: var(--shadow-float);
}

.modal-download {
  position: absolute;
  right: 12px;
  bottom: 12px;
  min-height: 36px;
}

.image-loading,
.error-text,
.failed-frame p,
.pending-frame p {
  color: #344054;
  font-size: 13px;
}

.failed-frame {
  border-color: #f0b7b2;
  background: #fff5f4;
  color: var(--danger);
  padding: 14px;
  text-align: center;
}

.pending-frame {
  gap: 16px;
  background: #fff;
}

.spinner {
  position: relative;
  width: 78px;
  height: 78px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.34) 0 17%, rgba(99, 102, 241, 0.1) 18% 48%, transparent 49%);
  box-shadow: 0 0 24px rgba(99, 102, 241, 0.3);
}

.spinner::before,
.spinner::after {
  position: absolute;
  inset: 8px;
  content: "";
  border: 2px solid rgba(99, 102, 241, 0.38);
  border-top-color: #6366f1;
  border-radius: 50%;
  animation: spin 1.1s linear infinite;
}

.spinner::after {
  inset: 18px;
  animation-duration: 1.8s;
  animation-direction: reverse;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.feed-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.feed-time {
  position: absolute;
  left: min(760px, calc(100vw - 230px));
  bottom: 16px;
  min-width: 170px;
  color: #b5bfce;
  font-size: 12px;
  white-space: nowrap;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 160px;
  color: var(--muted);
  text-align: center;
}

.composer-panel {
  position: fixed;
  right: 50%;
  bottom: 18px;
  z-index: 10;
  width: min(1120px, calc(100vw - 48px));
  transform: translateX(50%);
  pointer-events: none;
}

.upload-list {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: calc(100% - 260px);
  margin: 0 0 10px 14px;
  overflow-x: auto;
  pointer-events: auto;
}

.composer-status-row {
  display: flex;
  justify-content: flex-end;
  min-height: 0;
  padding: 0 10px 8px;
  pointer-events: none;
}

.upload-thumb {
  position: relative;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  overflow: hidden;
  background: #dfe5ef;
  box-shadow: 0 4px 12px rgba(31, 45, 71, 0.12);
}

.upload-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.thumb-remove {
  position: absolute;
  top: -5px;
  right: -5px;
  display: grid;
  place-items: center;
  width: 17px;
  height: 17px;
  border: 1px solid rgba(255, 255, 255, 0.88);
  border-radius: 50%;
  background: rgba(16, 24, 40, 0.74);
  color: #fff;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
}

.radial-progress {
  --progress: 0;
  position: absolute;
  inset: 4px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background:
    conic-gradient(#2d6cdf calc(var(--progress) * 1%), rgba(255, 255, 255, 0.42) 0),
    rgba(10, 18, 32, 0.28);
}

.radial-progress::before {
  position: absolute;
  inset: 6px;
  content: "";
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.88);
}

.radial-progress span {
  position: relative;
  z-index: 1;
  color: #1d4ed8;
  font-size: 9px;
  font-weight: 800;
}

.upload-error {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(185, 28, 28, 0.78);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
}

.generation-form {
  pointer-events: auto;
}

.composer-card {
  position: relative;
  border: 1px solid #d8dee8;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow-float);
  overflow: hidden;
  transition:
    border-color 140ms ease,
    box-shadow 140ms ease,
    background 140ms ease;
}

.current-cost {
  position: absolute;
  top: 12px;
  right: 16px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border: 1px solid #ffd394;
  border-radius: 999px;
  background: #fffaf2;
  color: #d97706;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.submit-status {
  max-width: min(860px, calc(100vw - 72px));
  padding: 8px 10px;
  border: 1px solid #d7dee9;
  border-radius: 8px;
  background: #f8fafc;
  color: #475467;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.45;
  box-shadow: 0 8px 20px rgba(31, 45, 71, 0.1);
}

.submit-status[data-state="pending"] {
  border-color: #b8cef9;
  background: #edf4ff;
  color: #285bc4;
}

.submit-status[data-state="success"] {
  border-color: #b8dec9;
  background: #effaf4;
  color: #177245;
}

.submit-status[data-state="error"] {
  border-color: #f0b7b2;
  background: #fff5f4;
  color: var(--danger);
}

.submit-status[data-state="maintenance"] {
  border-color: #f2c97d;
  background: #fff8e6;
  color: #9a5b00;
}

.composer-card.dragging {
  border-color: #a8c2ff;
  box-shadow: 0 18px 54px rgba(31, 45, 71, 0.2), 0 0 0 3px rgba(45, 108, 223, 0.1);
}

.composer-card:focus-within {
  box-shadow: 0 18px 50px rgba(31, 45, 71, 0.18);
}

.composer-main-row {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 44px;
  align-items: start;
  gap: 10px;
  min-height: 94px;
  padding: 14px 16px 0;
}

.add-image-button {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  margin-top: 4px;
  border: 1px dashed #c5cfdd;
  border-radius: 9px;
  background: #fff;
  color: #9aa5b7;
  cursor: pointer;
  font-size: 24px;
  line-height: 1;
}

.send-button {
  display: grid;
  place-items: center;
  align-self: end;
  width: 34px;
  height: 34px;
  margin: 0 0 12px;
  border: 0;
  border-radius: 50%;
  background: #06a9bf;
  color: #fff;
  cursor: pointer;
  font-size: 22px;
  font-weight: 900;
  box-shadow: 0 5px 14px rgba(6, 169, 191, 0.28);
}

.send-button:disabled {
  cursor: wait;
  opacity: 0.62;
}

.composer-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 16px 12px;
  flex-wrap: wrap;
}

.toolbar-button {
  height: 32px;
  min-height: 32px;
  color: #667085;
}

.url-panel {
  display: inline-grid;
  grid-template-columns: minmax(190px, 320px) auto;
  gap: 8px;
  align-items: center;
}

.url-panel input {
  height: 32px;
}

.select-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
}

.select-chip select {
  width: auto;
  min-width: 96px;
  height: 28px;
  padding: 0 20px 0 2px;
  border: 0;
  background: transparent;
  color: #475467;
  font-size: 12px;
}

.account-pill {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  max-width: 190px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.86);
  overflow: hidden;
  color: #58657a;
  font-size: 12px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
  box-shadow: 0 6px 20px rgba(31, 45, 71, 0.08);
}

.credit-pill {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid #c9ddff;
  border-radius: 999px;
  background: #f4f8ff;
  color: #2759c7;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
  box-shadow: 0 6px 20px rgba(31, 45, 71, 0.08);
}

.logout-button {
  min-height: 32px;
  padding: 0 11px;
  color: #667085;
  box-shadow: 0 6px 20px rgba(31, 45, 71, 0.08);
}

.runtime-meta {
  display: none;
}

.toast {
  position: fixed;
  left: 50%;
  top: 18px;
  z-index: 20;
  max-width: min(420px, calc(100vw - 44px));
  padding: 11px 13px;
  border-radius: 8px;
  background: #172033;
  color: #fff;
  font-size: 14px;
  box-shadow: var(--shadow-float);
  opacity: 0;
  transform: translate(-50%, 10px);
  pointer-events: none;
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.admin-page {
  min-height: 100vh;
  overflow: auto;
}

.admin-shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 32px 0 60px;
}

.admin-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.admin-login {
  margin: 0;
}

.admin-workspace {
  display: grid;
  gap: 20px;
}

.admin-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.summary-card,
.admin-section {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow-soft);
}

.summary-card {
  display: grid;
  gap: 7px;
  padding: 16px;
}

.summary-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.summary-card strong {
  font-size: 24px;
}

.admin-section {
  padding: 18px;
}

.admin-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.admin-section h2 {
  font-size: 18px;
}

.admin-form {
  display: grid;
  grid-template-columns: 120px 120px minmax(180px, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.admin-form label {
  display: grid;
  gap: 6px;
}

.maintenance-form {
  display: grid;
  grid-template-columns: 150px minmax(240px, 1fr) 220px auto;
  gap: 10px;
  align-items: end;
}

.provider-form {
  display: grid;
  grid-template-columns: minmax(180px, 280px) auto;
  gap: 10px;
  align-items: end;
}

.provider-form label {
  display: grid;
  gap: 6px;
}

.maintenance-form label {
  display: grid;
  gap: 6px;
}

.maintenance-toggle {
  display: flex !important;
  align-items: center;
  gap: 8px;
  min-height: 42px;
}

.maintenance-toggle input {
  width: 18px;
  height: 18px;
}

.maintenance-status {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.maintenance-status.active {
  border-color: #f2c97d;
  background: #fff8e6;
  color: #9a5b00;
}

.pricing-wrap {
  max-height: 520px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.pricing-table th {
  position: sticky;
  top: 0;
  background: #f8fafc;
  z-index: 1;
}

.pricing-table .pricing-input {
  width: 76px;
  height: 32px;
  padding: 0 8px;
}

.pricing-save {
  margin-top: 12px;
}

.admin-export {
  width: 100%;
  min-height: 120px;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}

.admin-pager {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  padding: 10px 9px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: #475467;
  font-size: 12px;
  font-weight: 900;
}

[hidden] {
  display: none !important;
}

@media (max-width: 860px) {
  body {
    overflow: auto;
  }

  .login-panel {
    grid-template-columns: 1fr;
  }

  .tool-shell {
    height: 100svh;
    padding-bottom: 186px;
  }

  .feed-panel {
    padding: 18px 16px 34px;
  }

  .generation-feed {
    width: 100%;
    gap: 52px;
  }

  .feed-item {
    width: 100%;
    margin-left: 0;
  }

  .result-frame {
    width: min(100%, 300px);
  }

  .feed-time {
    position: static;
    display: block;
    margin-top: 10px;
  }

  .composer-panel {
    bottom: 10px;
    width: calc(100vw - 20px);
  }

  .upload-list {
    max-width: 100%;
    margin-left: 8px;
  }

  .composer-main-row {
    grid-template-columns: 40px minmax(0, 1fr) 40px;
    min-height: 92px;
    padding: 12px 12px 0;
  }

  .composer-toolbar {
    gap: 8px;
    padding: 0 12px 12px;
  }

  .url-panel {
    width: 100%;
    grid-template-columns: 1fr auto;
  }

  .tool-shell > .account {
    top: 10px;
    right: 10px;
    gap: 6px;
  }

  .redeem-panel {
    left: 10px;
    right: 10px;
    bottom: 220px;
    grid-template-columns: minmax(0, 1fr) minmax(96px, auto);
    width: auto;
  }

  .redeem-panel input {
    grid-column: 1 / -1;
  }

  .redeem-panel .toolbar-button,
  .redeem-panel .purchase-key-button {
    width: 100%;
  }

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

  .admin-form {
    grid-template-columns: 1fr;
  }

  .maintenance-form {
    grid-template-columns: 1fr;
  }

  .provider-form {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .topbar,
  .login-panel {
    width: calc(100vw - 24px);
  }

  .login-panel {
    padding: 18px;
  }

  h1 {
    font-size: 26px;
  }

  .feed-copy h3 {
    font-size: 14px;
  }

  .meta-chip {
    font-size: 11px;
  }

  .select-chip select {
    min-width: 78px;
  }

  .tool-shell > .account .account-pill {
    display: none;
  }

  .credit-pill {
    min-height: 30px;
    padding: 0 8px;
  }
}
