:root {
  color-scheme: dark;
  --bg: #050506;
  --panel: rgba(24, 24, 27, 0.74);
  --panel-soft: rgba(32, 32, 36, 0.72);
  --panel-raised: rgba(43, 43, 47, 0.76);
  --line: rgba(255, 255, 255, 0.085);
  --line-strong: rgba(255, 255, 255, 0.16);
  --text: #f5f5f7;
  --muted: #b3b3bb;
  --subtle: #7f8088;
  --accent: #f5f5f7;
  --accent-strong: #ffffff;
  --brand: #ffae4d;
  --green: #44d38a;
  --red: #ff6767;
  --blue: #8cc8ff;
  --shadow: 0 28px 90px rgba(0, 0, 0, 0.38);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  color: var(--text);
  background:
    radial-gradient(circle at 50% -16%, rgba(255, 255, 255, 0.12), transparent 360px),
    linear-gradient(180deg, #0c0c0f 0%, #050506 46%, #030304 100%),
    var(--bg);
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.topbar {
  height: 60px;
  display: grid;
  grid-template-columns: minmax(170px, 1fr) auto minmax(250px, 1fr);
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.075);
  background: rgba(10, 10, 12, 0.72);
  backdrop-filter: blur(26px) saturate(1.18);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  font-weight: 780;
}

.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  color: #111;
  background: linear-gradient(135deg, #ff9d2e, #ffc170);
  box-shadow: 0 12px 28px rgba(255, 157, 46, 0.2);
}

.main-nav {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.055);
}

.main-nav button {
  height: 34px;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  background: transparent;
  color: var(--muted);
}

.main-nav button.active {
  color: #09090a;
  background: var(--accent);
  font-weight: 760;
}

.top-actions {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

.user-email {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.points,
.balance,
.eyebrow {
  color: var(--brand);
}

.points,
.balance {
  font-weight: 760;
}

.eyebrow {
  font-size: 11px;
  font-weight: 790;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.ghost-btn,
.primary-btn {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  padding: 0 14px;
}

.ghost-btn:hover {
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.09);
}

.primary-btn {
  border-color: transparent;
  color: #070708;
  background: linear-gradient(180deg, #ffffff, #e9e9ed);
  font-weight: 790;
  box-shadow: 0 18px 46px rgba(255, 255, 255, 0.14);
}

.primary-btn:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.stretch {
  width: 100%;
}

.auth-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 30px;
}

.auth-panel {
  width: min(920px, 100%);
  display: grid;
  grid-template-columns: 1.08fr 0.92fr;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(18, 20, 25, 0.82);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.auth-copy {
  padding: 44px;
  background: linear-gradient(135deg, rgba(255, 139, 32, 0.16), rgba(130, 207, 255, 0.08));
}

.auth-copy .eyebrow {
  display: block;
  margin-top: 52px;
}

.auth-copy h1 {
  margin: 12px 0;
  font-size: 36px;
  letter-spacing: 0;
}

.auth-copy p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.auth-form {
  padding: 44px;
  display: grid;
  align-content: center;
  gap: 18px;
  background: rgba(7, 8, 10, 0.44);
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.auth-tabs button {
  height: 34px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
}

.auth-tabs button.active {
  color: #15110d;
  background: var(--accent);
  font-weight: 760;
}

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

.field span,
.group-title span,
.muted {
  color: var(--subtle);
  font-size: 12px;
}

.field input,
.prompt-group textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
  color: var(--text);
  background: rgba(255, 255, 255, 0.055);
  padding: 12px 13px;
}

.field input:focus,
.prompt-group textarea:focus {
  border-color: rgba(255, 180, 95, 0.78);
  box-shadow: 0 0 0 3px rgba(255, 180, 95, 0.12);
}

.studio-shell {
  display: grid;
  grid-template-columns: 380px minmax(0, 1fr) 320px;
  gap: 14px;
  padding: 16px;
  min-height: calc(100vh - 58px);
}

.create-panel,
.result-panel,
.side-panel,
.api-card,
.api-hero > div {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: 0 18px 56px rgba(0, 0, 0, 0.18);
  backdrop-filter: blur(24px) saturate(1.14);
}

.create-panel,
.side-panel {
  position: sticky;
  top: 74px;
  max-height: calc(100vh - 90px);
  overflow: auto;
}

.create-panel {
  display: grid;
  grid-template-rows: auto auto auto minmax(180px, 1fr) auto;
  gap: 15px;
  padding: 16px;
}

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

.panel-head h1 {
  margin: 5px 0 0;
  font-size: 24px;
  letter-spacing: 0;
}

.balance {
  white-space: nowrap;
  padding: 6px 9px;
  border-radius: 7px;
  background: rgba(255, 180, 95, 0.1);
}

.field-group {
  display: grid;
  gap: 10px;
}

.group-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.group-title strong {
  font-size: 13px;
  font-weight: 680;
}

.model-list {
  display: grid;
  gap: 9px;
}

.model-card {
  width: 100%;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  text-align: left;
  color: var(--text);
  background: rgba(255, 255, 255, 0.045);
}

.model-card.active {
  border-color: rgba(255, 255, 255, 0.24);
  background: rgba(255, 255, 255, 0.11);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 26px;
  padding: 0 8px;
  border-radius: 9px;
  color: var(--blue);
  background: rgba(130, 207, 255, 0.11);
  font-size: 12px;
  font-weight: 790;
}

.badge.pro {
  color: #111;
  background: linear-gradient(135deg, #ff9d2e, #ffc170);
}

.model-copy {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.model-copy strong,
.generate-bar strong {
  font-size: 13px;
}

.model-copy small,
.cost,
.generate-bar span,
.generate-bar small,
.api-shortcut span,
.quick-metric span {
  color: var(--subtle);
  font-size: 11px;
}

.cost {
  white-space: nowrap;
}

.split-controls {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.chip {
  height: 34px;
  min-width: 45px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.045);
  padding: 0 10px;
}

.chip.active {
  border-color: transparent;
  color: #070708;
  background: var(--accent);
  font-weight: 760;
}

.upload-box {
  min-height: 74px;
  border: 1px dashed rgba(255, 255, 255, 0.24);
  border-radius: 12px;
  display: grid;
  place-items: center;
  gap: 4px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.035);
}

.upload-box:hover {
  border-color: rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.07);
}

.upload-box span {
  color: var(--subtle);
  font-size: 12px;
}

.file-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.file-preview {
  display: grid;
  grid-template-columns: 54px 1fr auto;
  gap: 8px;
  align-items: center;
  min-width: 0;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.file-preview img {
  width: 54px;
  height: 44px;
  border-radius: 6px;
  object-fit: cover;
  background: #07080a;
}

.file-preview div {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.file-preview strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.file-preview span {
  color: var(--subtle);
  font-size: 11px;
}

.file-preview button {
  width: 25px;
  height: 25px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  line-height: 1;
  padding: 0;
}

.file-preview button:hover {
  color: var(--red);
  border-color: rgba(255, 103, 103, 0.42);
}

.prompt-group textarea {
  min-height: 160px;
  resize: vertical;
  line-height: 1.6;
  border-radius: 12px;
}

.generate-bar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.generate-bar div {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.generate-bar strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-panel {
  min-width: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  background: rgba(10, 10, 12, 0.62);
}

.result-toolbar {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
}

.result-toolbar div {
  display: grid;
  gap: 2px;
}

.result-toolbar span {
  color: var(--subtle);
  font-size: 12px;
}

.result-toolbar a {
  color: var(--brand);
  text-decoration: none;
  font-size: 13px;
}

.result-stage {
  min-height: 500px;
  display: grid;
  place-items: center;
  background: #050506;
  padding: 24px;
}

.result-stage img {
  max-width: 100%;
  max-height: calc(100vh - 188px);
  object-fit: contain;
  border-radius: 14px;
  display: block;
  box-shadow: 0 26px 80px rgba(0, 0, 0, 0.46);
}

.result-panel.empty {
  min-height: 500px;
  place-items: center;
  align-content: center;
  gap: 12px;
  text-align: center;
  padding: 28px;
  color: var(--muted);
  background: rgba(10, 10, 12, 0.62);
}

.result-panel.empty strong {
  color: var(--text);
  font-size: 18px;
}

.result-panel.empty span {
  max-width: 420px;
  line-height: 1.7;
}

.empty-visual {
  width: 82px;
  height: 64px;
  border-radius: 14px;
  border: 1px solid var(--line-strong);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.04));
}

.side-panel {
  display: grid;
  align-content: start;
  gap: 14px;
  padding: 14px;
}

.api-shortcut,
.task-panel {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
}

.api-shortcut {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.api-shortcut div {
  display: grid;
  gap: 5px;
}

.task-panel {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.task-list {
  display: grid;
  gap: 8px;
}

.task-item {
  display: grid;
  grid-template-columns: 52px 1fr auto;
  gap: 9px;
  align-items: center;
  width: 100%;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  text-align: left;
  background: rgba(255, 255, 255, 0.04);
}

.task-item.clickable:hover {
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.075);
}

.task-thumb {
  width: 52px;
  height: 42px;
  border-radius: 9px;
  object-fit: cover;
  background: #07080a;
  border: 1px solid var(--line);
}

.task-body {
  min-width: 0;
}

.task-prompt {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.task-meta,
.task-retention,
.task-error {
  margin-top: 4px;
  color: var(--subtle);
  font-size: 11px;
}

.task-retention {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.task-error {
  color: var(--red);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.task-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 28px;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(10px);
}

.task-dialog {
  width: min(1040px, 100%);
  max-height: min(860px, calc(100vh - 56px));
  display: grid;
  grid-template-rows: auto minmax(260px, 1fr) auto;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: rgba(18, 20, 25, 0.98);
  box-shadow: var(--shadow);
}

.task-dialog-head {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.task-dialog-head div {
  display: grid;
  gap: 3px;
}

.task-dialog-head span,
.task-dialog-prompt span,
.task-dialog-error span {
  color: var(--subtle);
  font-size: 12px;
}

.task-dialog-image {
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: auto;
  padding: 14px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    #07080a;
  background-size: 34px 34px;
}

.task-dialog-image img {
  max-width: 100%;
  max-height: 58vh;
  object-fit: contain;
  border-radius: 8px;
}

.task-dialog-empty {
  display: grid;
  place-items: center;
  min-height: 260px;
  color: var(--muted);
  background: #07080a;
}

.task-dialog-prompt,
.task-dialog-error {
  display: grid;
  gap: 8px;
  padding: 14px;
  border-top: 1px solid var(--line);
}

.task-dialog-prompt p,
.task-dialog-error p {
  margin: 0;
  color: var(--text);
  line-height: 1.65;
  white-space: pre-wrap;
}

.task-dialog-error p {
  color: var(--red);
}

.status {
  height: 23px;
  display: inline-flex;
  align-items: center;
  border-radius: 6px;
  padding: 0 7px;
  font-size: 11px;
  font-weight: 760;
}

.status.ok {
  color: var(--green);
  background: rgba(68, 211, 138, 0.1);
}

.status.failed {
  color: var(--red);
  background: rgba(255, 103, 103, 0.1);
}

.status.working {
  color: var(--blue);
  background: rgba(130, 207, 255, 0.1);
}

.toast {
  position: fixed;
  top: 72px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 40;
  max-width: min(620px, calc(100vw - 32px));
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 12px 16px;
  background: rgba(18, 20, 25, 0.97);
  box-shadow: var(--shadow);
}

.api-page {
  padding: 20px;
  display: grid;
  gap: 16px;
}

.api-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  gap: 16px;
}

.api-hero > div:first-child {
  padding: 22px;
  background: linear-gradient(135deg, rgba(255, 139, 32, 0.13), rgba(130, 207, 255, 0.07));
}

.api-hero h1 {
  margin: 8px 0;
  font-size: 28px;
}

.api-hero p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.api-base {
  display: grid;
  align-content: center;
  gap: 10px;
  padding: 22px;
}

.api-base span {
  color: var(--subtle);
  font-size: 12px;
}

.api-base strong {
  overflow-wrap: anywhere;
}

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

.api-card {
  padding: 18px;
  overflow: hidden;
}

.api-card.wide {
  grid-column: span 2;
}

.api-card h2 {
  margin: 0 0 12px;
  font-size: 16px;
}

.api-card p {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.6;
  font-size: 13px;
}

.api-card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.api-card-title h2 {
  margin: 0;
}

.key-box {
  min-height: 42px;
  display: flex;
  align-items: center;
  overflow-wrap: anywhere;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  color: #dce7f2;
  background: #07080a;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12px;
}

.danger-btn {
  margin-top: 12px;
  min-height: 34px;
  border: 1px solid rgba(255, 103, 103, 0.28);
  border-radius: 8px;
  color: var(--red);
  background: rgba(255, 103, 103, 0.08);
  padding: 0 12px;
}

.danger-btn:hover {
  border-color: rgba(255, 103, 103, 0.46);
  background: rgba(255, 103, 103, 0.12);
}

.model-table-wrap {
  max-height: 360px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #07080a;
}

.model-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

.model-table th,
.model-table td {
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  text-align: left;
  font-size: 12px;
}

.model-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: var(--muted);
  background: #0d0f13;
}

.model-table td {
  color: var(--text);
}

.model-table code {
  color: var(--blue);
  white-space: nowrap;
}

.api-card pre {
  margin: 0;
  padding: 14px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #07080a;
  color: #dce7f2;
  line-height: 1.55;
}

.api-card code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12px;
}

@media (max-width: 1460px) {
  .studio-shell {
    grid-template-columns: 360px minmax(0, 1fr);
  }

  .side-panel {
    grid-column: 1 / -1;
    position: static;
    max-height: none;
    grid-template-columns: 300px 280px minmax(0, 1fr);
  }

  .task-panel {
    min-width: 0;
  }
}

@media (max-width: 1040px) {
  .topbar,
  .studio-shell,
  .api-hero,
  .api-grid {
    grid-template-columns: 1fr;
  }

  .top-actions,
  .main-nav {
    justify-self: start;
  }

  .create-panel,
  .side-panel {
    position: static;
    max-height: none;
  }

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

  .result-stage {
    min-height: 360px;
  }

  .api-card.wide {
    grid-column: span 1;
  }
}

@media (max-width: 640px) {
  .topbar,
  .studio-shell,
  .api-page {
    padding-left: 12px;
    padding-right: 12px;
  }

  .topbar {
    height: auto;
    padding-top: 12px;
    padding-bottom: 12px;
  }

  .auth-panel,
  .split-controls,
  .file-list {
    grid-template-columns: 1fr;
  }

  .auth-copy,
  .auth-form {
    padding: 28px;
  }

  .generate-bar {
    grid-template-columns: 1fr;
  }

  .task-item {
    grid-template-columns: 50px 1fr;
  }

  .task-item .status {
    grid-column: 2;
    justify-self: start;
  }
}
