:root {
  color-scheme: light;
  font-family: Arial, "Microsoft YaHei", sans-serif;
  background: #f5f6f8;
  color: #151922;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  padding: 0 16px;
  color: #fff;
  background: #1769aa;
  cursor: pointer;
}

input,
select {
  min-height: 40px;
  border: 1px solid #cfd5df;
  border-radius: 6px;
  padding: 0 12px;
  background: #fff;
}

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

th,
td {
  padding: 10px 8px;
  border-bottom: 1px solid #eceff3;
  text-align: left;
}

th {
  color: #687184;
  font-weight: 600;
}

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 28px auto 48px;
}

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

.toolbar h1 {
  margin: 0 0 6px;
  font-size: 28px;
}

.toolbar p {
  margin: 0;
  color: #657084;
}

.panel,
.metric {
  background: #fff;
  border: 1px solid #e2e6ec;
  border-radius: 8px;
  padding: 18px;
}

.auth-panel {
  margin-bottom: 16px;
}

.auth-panel label {
  display: block;
  margin-bottom: 8px;
  color: #505b6f;
}

.row {
  display: flex;
  gap: 10px;
}

.row input {
  flex: 1;
  min-width: 0;
}

.metrics,
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.grid {
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.metric span {
  display: block;
  color: #687184;
  margin-bottom: 10px;
}

.metric strong {
  font-size: 30px;
}

.panel h2 {
  margin: 0 0 14px;
  font-size: 18px;
}

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

.section-head h2 {
  margin: 0;
}

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

.danger-button {
  background: #b42318;
}

.action-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.status {
  display: inline-block;
  min-width: 66px;
  border-radius: 999px;
  padding: 3px 8px;
  text-align: center;
  font-size: 12px;
}

.status.pending {
  color: #8a4b00;
  background: #fff3d6;
}

.status.paid {
  color: #0f6b3d;
  background: #dff7e9;
}

.status.canceled {
  color: #6b7280;
  background: #eef0f3;
}

.admin-users {
  margin-top: 16px;
}

.pricing-panel {
  margin-bottom: 16px;
}

.model-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.model-form button {
  white-space: nowrap;
}

.inline-check {
  min-height: 40px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #505b6f;
}

.inline-check input {
  min-height: auto;
}

.field {
  display: grid;
  gap: 8px;
  flex: 1;
}

.field span {
  color: #505b6f;
}

#pricingStatus {
  min-height: 22px;
  margin: 12px 0 0;
  color: #465366;
}

#checkout {
  min-height: 22px;
  margin: 12px 0 0;
}

#checkout a {
  color: #1769aa;
}

@media (max-width: 760px) {
  .toolbar,
  .row {
    align-items: stretch;
    flex-direction: column;
  }

  .metrics,
  .grid {
    grid-template-columns: 1fr;
  }
}

.studio-body {
  min-height: 100vh;
  background:
    radial-gradient(circle at 18% 8%, rgba(111, 76, 255, 0.22), transparent 28%),
    linear-gradient(135deg, #120d25 0%, #0d1721 42%, #102632 100%);
  color: #f7f8ff;
}

.studio-body input,
.studio-body select,
.studio-body textarea {
  color: #f8fafc;
  border-color: rgba(195, 207, 226, 0.28);
  background: rgba(255, 255, 255, 0.08);
  outline: none;
}

.studio-body input:focus,
.studio-body select:focus,
.studio-body textarea:focus {
  border-color: #8b6cff;
  box-shadow: 0 0 0 3px rgba(139, 108, 255, 0.18);
}

.studio-body input::placeholder,
.studio-body textarea::placeholder {
  color: rgba(228, 233, 244, 0.52);
}

.studio-body option {
  color: #151922;
}

.studio-nav {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 70px;
  padding: 0 max(24px, calc((100vw - 1280px) / 2));
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(70, 59, 95, 0.92);
  backdrop-filter: blur(14px);
}

.brand {
  color: #6ea3ff;
  text-decoration: none;
  font-size: 24px;
  font-weight: 800;
}

.studio-nav nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.studio-nav nav a {
  color: rgba(244, 247, 255, 0.72);
  text-decoration: none;
  border-radius: 8px;
  padding: 10px 14px;
}

.studio-nav nav a.active,
.studio-nav nav a:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
}

.studio-shell {
  width: min(1280px, calc(100% - 36px));
  margin: 58px auto 64px;
}

.studio-hero {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
}

.studio-hero h1 {
  margin: 0 0 10px;
  font-size: 42px;
  line-height: 1;
  letter-spacing: 0;
}

.studio-hero p,
.muted-line {
  margin: 0;
  color: rgba(225, 233, 246, 0.7);
}

.key-card,
.studio-panel,
.preview-panel,
.studio-metrics article {
  border: 1px solid rgba(202, 213, 233, 0.16);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.2);
}

.key-card {
  display: grid;
  gap: 10px;
  padding: 18px;
  margin-bottom: 18px;
}

.key-card label {
  color: rgba(238, 243, 255, 0.72);
}

.key-row,
.recharge-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.recharge-row {
  grid-template-columns: 1fr 150px auto;
}

.studio-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.studio-metrics article {
  padding: 18px;
}

.studio-metrics span {
  display: block;
  color: rgba(224, 233, 248, 0.68);
  margin-bottom: 10px;
}

.studio-metrics strong {
  font-size: 28px;
}

.generator-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(380px, 0.95fr);
  gap: 24px;
  align-items: stretch;
  margin-bottom: 24px;
}

.generator-form {
  display: grid;
  gap: 18px;
}

.studio-panel,
.preview-panel {
  padding: 22px;
}

.studio-panel h2,
.preview-panel h2 {
  margin: 0 0 16px;
  font-size: 18px;
}

.studio-panel textarea {
  width: 100%;
  min-height: 140px;
  resize: vertical;
  border-radius: 8px;
  padding: 16px;
  line-height: 1.7;
}

.size-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.size-option {
  min-height: 54px;
  color: rgba(238, 244, 255, 0.78);
  border: 1px solid rgba(220, 228, 242, 0.22);
  background: rgba(255, 255, 255, 0.07);
}

.size-option.active {
  color: #fff;
  background: linear-gradient(135deg, #7049ff, #0ea5b8);
  border-color: transparent;
}

.control-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

.control-grid label {
  display: grid;
  gap: 8px;
  color: rgba(224, 233, 248, 0.72);
}

.generate-button {
  min-height: 58px;
  border-radius: 8px;
  font-size: 17px;
  font-weight: 700;
  background: linear-gradient(135deg, #7049ff 0%, #0e91a6 100%);
}

.generate-button:disabled {
  cursor: wait;
  opacity: 0.72;
}

.preview-panel {
  min-height: 620px;
  display: grid;
  grid-template-rows: auto 1fr;
}

.task-pill {
  border-radius: 999px;
  padding: 6px 12px;
  color: #bdc8dc;
  background: rgba(255, 255, 255, 0.08);
  font-size: 13px;
}

.task-pill[data-status="running"],
.task-pill[data-status="queued"] {
  color: #ffe7a3;
  background: rgba(255, 199, 77, 0.14);
}

.task-pill[data-status="succeeded"] {
  color: #b8f7ce;
  background: rgba(40, 199, 111, 0.14);
}

.task-pill[data-status="failed"] {
  color: #ffc9c9;
  background: rgba(255, 92, 92, 0.14);
}

.preview-box {
  position: relative;
  min-height: 520px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 8px;
  background:
    linear-gradient(45deg, rgba(255, 255, 255, 0.035) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(255, 255, 255, 0.035) 25%, transparent 25%),
    rgba(7, 12, 20, 0.25);
  background-size: 28px 28px;
}

.empty-preview {
  display: grid;
  justify-items: center;
  gap: 14px;
  color: rgba(225, 233, 246, 0.6);
  text-align: center;
}

.preview-mark {
  width: 72px;
  height: 72px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: rgba(248, 250, 252, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.08);
  font-weight: 800;
}

.loader {
  width: 54px;
  height: 54px;
  border: 4px solid rgba(255, 255, 255, 0.14);
  border-top-color: #8b6cff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.result-image {
  max-width: 100%;
  max-height: 520px;
  border-radius: 8px;
  object-fit: contain;
}

.result-actions {
  position: absolute;
  right: 26px;
  bottom: 26px;
}

.result-actions a {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 8px;
  color: #fff;
  text-decoration: none;
  background: rgba(14, 145, 166, 0.92);
}

.raw-result {
  max-width: 100%;
  max-height: 520px;
  overflow: auto;
  color: #d9e5f7;
  white-space: pre-wrap;
}

.studio-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 18px;
}

.studio-body table {
  color: rgba(245, 248, 255, 0.88);
}

.studio-body th,
.studio-body td {
  border-bottom-color: rgba(255, 255, 255, 0.08);
}

.studio-body th {
  color: rgba(224, 233, 248, 0.62);
}

.studio-body a {
  color: #8bdcff;
}

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

@media (max-width: 900px) {
  .studio-nav {
    height: auto;
    flex-direction: column;
    align-items: flex-start;
    padding: 14px 18px;
  }

  .studio-nav nav {
    width: 100%;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .studio-hero,
  .key-row,
  .recharge-row {
    align-items: stretch;
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .studio-metrics,
  .generator-grid,
  .studio-grid,
  .size-grid,
  .control-grid {
    grid-template-columns: 1fr;
  }

  .preview-panel {
    min-height: 460px;
  }

  .preview-box {
    min-height: 360px;
  }
}
