/* AI Studio — Mini App / veb-ilova. Telegram tema o'zgaruvchilariga moslashadi. */
:root {
  --bg: var(--tg-bg, #f7f7fb);
  --surface: var(--tg-secondary-bg, #ffffff);
  --surface-2: #eceef5;
  --border: #e3e4ec;
  --text: var(--tg-text, #15151f);
  --text-dim: var(--tg-hint, #6b6d82);
  --brand: var(--tg-button, #7c5cff);
  --brand-text: var(--tg-button-text, #ffffff);
  --brand-2: #22d3c9;
  --brand-grad: linear-gradient(135deg, var(--brand), var(--brand-2));
  --danger: #e5484d;
  --success: #2fb866;
  --radius: 16px;
  --tabbar-h: 62px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: var(--tg-bg, #0c0c14); --surface: var(--tg-secondary-bg, #181926);
    --surface-2: #21222f; --border: #2a2b3b; --text: var(--tg-text, #f3f3fa); --text-dim: var(--tg-hint, #9a9cb3);
  }
}
:root[data-theme="dark"] {
  --bg: var(--tg-bg, #0c0c14); --surface: var(--tg-secondary-bg, #181926);
  --surface-2: #21222f; --border: #2a2b3b; --text: var(--tg-text, #f3f3fa); --text-dim: var(--tg-hint, #9a9cb3);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text); overflow-x: hidden;
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
}
a { color: inherit; }
button { font: inherit; }
img { max-width: 100%; }

#topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px calc(10px + env(safe-area-inset-top)); background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--border);
}
#topbar h1 { font-size: 17px; margin: 0; font-weight: 800; }
#topbar .right { display: flex; gap: 8px; align-items: center; }
#topbar .coins { font-weight: 700; font-size: 13.5px; background: var(--surface-2); padding: 6px 12px; border-radius: 999px; }

#view { padding: 14px 16px 24px; max-width: 560px; margin: 0 auto; min-height: 60vh; }

#tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  background: var(--surface); border-top: 1px solid var(--border); display: flex; z-index: 30;
  padding-bottom: env(safe-area-inset-bottom);
}
#tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 11px; color: var(--text-dim); font-weight: 600; text-decoration: none;
}
#tabbar a .ic { font-size: 20px; }
#tabbar a.active { color: var(--brand); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: none; cursor: pointer;
  border-radius: 14px; padding: 13px 18px; font-weight: 700; font-size: 14.5px; width: 100%;
}
.btn-primary { background: var(--brand-grad); color: var(--brand-text); }
.btn-primary:disabled { opacity: .5; }
.btn-ghost { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { width: auto; padding: 9px 14px; font-size: 13px; border-radius: 10px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.muted { color: var(--text-dim); }
.row { display: flex; gap: 10px; align-items: center; }
.row.between { justify-content: space-between; }
.wrap-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }

.model-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 12px; cursor: pointer; text-align: left; position: relative; }
.model-card.sel { border-color: var(--brand); box-shadow: 0 0 0 2px color-mix(in srgb, var(--brand) 30%, transparent); }
.model-card .emo { font-size: 26px; }
.model-card h4 { margin: 8px 0 2px; font-size: 13.5px; }
.model-card p { margin: 0; font-size: 11.5px; color: var(--text-dim); }
.model-card .badge { position: absolute; top: 8px; right: 8px; font-size: 10px; background: var(--surface-2); padding: 2px 7px; border-radius: 999px; font-weight: 700; }

.chip-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.chip { padding: 8px 14px; border-radius: 999px; background: var(--surface-2); font-size: 13px; font-weight: 600; cursor: pointer; border: 1px solid transparent; }
.chip.active { background: var(--brand-grad); color: var(--brand-text); }

textarea, input[type=text], input[type=number] {
  width: 100%; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  border-radius: 12px; padding: 12px 14px; font-size: 14.5px; font-family: inherit;
}
textarea { min-height: 90px; resize: vertical; }
label.field { display: block; font-size: 12.5px; font-weight: 700; color: var(--text-dim); margin: 14px 0 6px; }

.drop {
  border: 1.5px dashed var(--border); border-radius: 14px; padding: 18px; text-align: center; cursor: pointer;
  color: var(--text-dim); font-size: 13px; position: relative; overflow: hidden; min-height: 92px;
  display: flex; align-items: center; justify-content: center;
}
.drop img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.drop .rm { position: absolute; top: 6px; right: 6px; background: rgba(0,0,0,.6); color: #fff; border-radius: 999px; width: 22px; height: 22px; display: flex; align-items: center; justify-content: center; font-size: 13px; z-index: 2; }

.price-bar {
  position: sticky; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 10px); background: var(--surface);
  border: 1px solid var(--border); border-radius: 16px; padding: 12px 14px; display: flex; align-items: center;
  justify-content: space-between; box-shadow: 0 8px 24px -8px rgba(0,0,0,.25); margin-top: 16px;
}
.price-bar b { font-size: 17px; }

.job-item { display: flex; gap: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 10px; margin-bottom: 10px; cursor: pointer; align-items: center; }
.job-item .thumb { width: 52px; height: 52px; border-radius: 10px; background: var(--surface-2); display: flex; align-items: center; justify-content: center; font-size: 22px; flex: none; overflow: hidden; }
.job-item .thumb img, .job-item .thumb video { width: 100%; height: 100%; object-fit: cover; }
.job-item .meta { flex: 1; min-width: 0; }
.job-item .meta .t { font-weight: 700; font-size: 13.5px; }
.job-item .meta .s { font-size: 12px; color: var(--text-dim); }
.pill { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; }
.pill.queued, .pill.submitting, .pill.running, .pill.postproc { background: #fff3cd; color: #8a6400; }
.pill.done { background: #d7f5e3; color: var(--success); }
.pill.failed, .pill.cancelled { background: #fde3e3; color: var(--danger); }
:root[data-theme="dark"] .pill.queued, :root[data-theme="dark"] .pill.submitting, :root[data-theme="dark"] .pill.running, :root[data-theme="dark"] .pill.postproc { background: #3a3014; color: #f0c766; }
:root[data-theme="dark"] .pill.done { background: #0f3324; color: #6bdc9e; }
:root[data-theme="dark"] .pill.failed, :root[data-theme="dark"] .pill.cancelled { background: #3a1a1c; color: #ff8f93; }

video.result, img.result { width: 100%; border-radius: 14px; background: #000; }

.wallet-hero { text-align: center; padding: 22px 0; }
.wallet-hero .big { font-size: 40px; font-weight: 800; }
.pkg-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 14px; text-align: center; position: relative; }
.pkg-card .tag { position: absolute; top: -9px; right: 10px; background: var(--brand-grad); color: var(--brand-text); font-size: 10px; font-weight: 800; padding: 3px 8px; border-radius: 999px; }
.pkg-card .coins { font-size: 19px; font-weight: 800; margin-bottom: 2px; }
.pkg-card .uzs { font-size: 13px; color: var(--text-dim); margin-bottom: 10px; }

.toast {
  position: fixed; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 14px); left: 16px; right: 16px;
  background: var(--text); color: var(--bg); padding: 12px 16px; border-radius: 12px; font-size: 13.5px;
  text-align: center; z-index: 50; opacity: 0; transition: opacity .25s, transform .25s; transform: translateY(8px);
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateY(0); }

.empty { text-align: center; padding: 40px 10px; color: var(--text-dim); }
.empty .ic { font-size: 40px; margin-bottom: 10px; }

.spinner { width: 20px; height: 20px; border-radius: 50%; border: 2.5px solid var(--border); border-top-color: var(--brand); animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.gate { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 70vh; text-align: center; gap: 14px; padding: 20px; }
