:root {
  --bg: #0b0b0d;
  --surface: #17171a;
  --surface-2: #202024;
  --border: #2a2a2e;
  --text: #ede9e2;
  --text-dim: #8f8d8a;
  --accent: #e8a356;
  --accent-dim: #7a5a34;
  --success: #4fb886;
  --danger: #d9705f;

  --font-display: "Fraunces", serif;
  --font-body: "Manrope", sans-serif;
  --font-mono: "JetBrains Mono", monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 560px;
  margin: 0 auto;
  padding: 20px 16px 96px;
  min-height: 100vh;
}

.screen { animation: fade-in 0.2s ease; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

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

.eyebrow {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 22px;
  letter-spacing: -0.01em;
}

.balance-chip {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--accent);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 999px;
}

.soon {
  font-size: 10px;
  font-family: var(--font-mono);
  margin-left: 4px;
  opacity: 0.8;
}

/* ===== Selector row (Тип / Модель) — открывает bottom sheet ===== */
.selector-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  color: var(--text);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  margin-bottom: 16px;
  text-align: left;
}

.selector-icon { font-size: 18px; }
.selector-label { flex: 1; }
.chevron { color: var(--text-dim); font-size: 14px; }

/* ===== Bottom sheet ===== */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 40;
}

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 41;
  background: var(--surface);
  border-top-left-radius: 20px;
  border-top-right-radius: 20px;
  padding: 10px 16px max(16px, env(safe-area-inset-bottom));
  max-height: 75vh;
  overflow-y: auto;
  animation: sheet-up 0.2s ease;
}

@keyframes sheet-up {
  from { transform: translateY(16px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.sheet-handle {
  width: 36px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 4px auto 14px;
}

.sheet-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 18px;
  margin: 0 0 12px;
}

.sheet-list { display: flex; flex-direction: column; gap: 8px; }

.sheet-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  cursor: pointer;
}

.sheet-item.selected { border-color: var(--accent-dim); }

.sheet-item.unavailable { opacity: 0.5; }

.sheet-item-icon { font-size: 18px; }

.sheet-item-body { flex: 1; }

.sheet-item-title {
  font-weight: 600;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.sheet-item-desc {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 2px;
}

.sheet-item-badge {
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--accent);
  background: rgba(232, 163, 86, 0.12);
  border-radius: 999px;
  padding: 2px 8px;
  white-space: nowrap;
}

.sheet-item-check { color: var(--accent); font-weight: 700; }

.prompt-input {
  width: 100%;
  min-height: 92px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  padding: 14px;
  resize: vertical;
  margin-bottom: 10px;
}

.prompt-input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.suggestions {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin-bottom: 20px;
  padding-bottom: 2px;
}

.suggestion-chip {
  font-size: 13px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 14px;
  white-space: nowrap;
  cursor: pointer;
}

.field-group { margin-bottom: 16px; }

.field-label {
  display: block;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.chip-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
}

.chip {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-dim);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  cursor: pointer;
  white-space: nowrap;
}

.chip.active {
  color: var(--accent);
  border-color: var(--accent-dim);
  background: rgba(232, 163, 86, 0.1);
}

.cost-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 14px 0;
  border-top: 1px solid var(--border);
  margin-top: 4px;
  margin-bottom: 16px;
  color: var(--text-dim);
  font-size: 14px;
}

.cost-value {
  font-family: var(--font-mono);
  font-size: 20px;
  color: var(--text);
}

.cta {
  width: 100%;
  padding: 16px;
  border-radius: 14px;
  border: none;
  background: var(--accent);
  color: var(--bg);
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 16px;
  cursor: pointer;
}

.cta:disabled { opacity: 0.5; cursor: default; }

.cta-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  margin-top: 12px;
}

.render-status { margin-top: 20px; }

.render-bar {
  height: 3px;
  background: var(--surface-2);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 10px;
}

.render-sweep {
  width: 40%;
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  animation: sweep 1.4s ease-in-out infinite;
}

@keyframes sweep {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(350%); }
}

#render-status-text {
  font-size: 13px;
  color: var(--text-dim);
  text-align: center;
}

.result { margin-top: 20px; }
.result video { width: 100%; border-radius: 14px; background: #000; }

.history-list { display: flex; flex-direction: column; gap: 10px; }

.history-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
}

.history-item-top {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
}

.history-status { font-weight: 500; }
.history-status.done { color: var(--success); }
.history-status.failed { color: var(--danger); }
.history-status.processing, .history-status.pending { color: var(--accent); }

.history-prompt {
  font-size: 14px;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-dim);
}

.balance-card, .referral-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
  margin-bottom: 14px;
}

.balance-big {
  display: block;
  font-family: var(--font-display);
  font-size: 40px;
  font-weight: 600;
  margin: 4px 0 14px;
}

.referral-desc {
  font-size: 13px;
  color: var(--text-dim);
  margin: 4px 0 12px;
  line-height: 1.5;
}

.referral-link-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  border-radius: 10px;
  padding: 10px 12px;
}

.referral-link {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.copy-btn {
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 8px 0 max(8px, env(safe-area-inset-bottom));
}

.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-family: var(--font-body);
  font-size: 11px;
  padding: 6px 0;
  cursor: pointer;
}

.tab.active { color: var(--accent); }
.tab-icon { font-size: 18px; }

.tab-create {
  flex: 0 0 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  margin: -6px 6px 0;
}

.tab-create .tab-icon { font-size: 20px; color: var(--accent); }

/* ===== Идеи ===== */
.screen-subtitle {
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.5;
  margin: 0 0 16px;
}

.idea-list { display: flex; flex-direction: column; gap: 10px; }

.idea-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
}

.idea-card-label {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 6px;
}

.idea-card-prompt {
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.45;
  margin-bottom: 10px;
}

.idea-use-btn {
  background: var(--surface-2);
  color: var(--accent);
  border: 1px solid var(--accent-dim);
  border-radius: 10px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

/* ===== История: фильтры ===== */
.filter-row { margin-bottom: 16px; }

/* ===== Профиль: подвкладки ===== */
.subtab-row {
  display: flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 18px;
}

.subtab {
  flex: 1;
  background: none;
  border: none;
  border-radius: 9px;
  padding: 10px 0;
  color: var(--text-dim);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}

.subtab.active { background: var(--accent); color: var(--bg); }

.account-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 14px;
}

.avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--surface-2);
  background-size: cover;
  background-position: center;
  flex-shrink: 0;
}

.account-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 18px;
}

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
}

.stat-value {
  display: block;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 22px;
  margin-top: 4px;
}
