:root {
  color-scheme: dark;
  --bg: #040406;
  --surface: #0b0d12;
  --surface-2: #11151f;
  --line: #1f2532;
  --text: #f3f5fc;
  --muted: #8f98b0;
  --accent: #7b6dff;
  --accent-2: #9f95ff;
  --success: #7ce5a6;
  --warning: #ffd447;
  --danger: #ff8a96;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

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

.app-shell {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.app-header {
  height: 76px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  background: rgba(4, 4, 6, 0.96);
  backdrop-filter: blur(8px);
  z-index: 12;
}

.avatar-chip {
  width: 44px;
  height: 44px;
  border: 1px solid #2a3241;
  border-radius: 999px;
  background: #121722;
  color: #fff;
  font-weight: 700;
  font-size: 18px;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.brand-title {
  text-align: center;
  font-size: 20px;
  line-height: 1;
  font-weight: 700;
  letter-spacing: 0;
}

.credits-chip {
  border: 1px solid rgba(155, 139, 255, 0.7);
  background: rgba(88, 72, 200, 0.2);
  color: #f7f4ff;
  border-radius: 999px;
  min-width: 72px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 12px;
  font-weight: 700;
  cursor: pointer;
}

.credits-chip svg,
.icon-btn svg,
.nav-btn svg,
.soft-btn svg,
.bot-link svg,
.dropzone-icon svg {
  width: 18px;
  height: 18px;
  stroke-width: 2;
}

.app-main {
  padding: 14px 14px 94px;
}

.screen {
  display: none;
  gap: 12px;
}

.screen-active {
  display: grid;
}

.section-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.section-row h2,
.section-row h3 {
  margin: 0;
  font-size: 34px;
  line-height: 1.12;
  letter-spacing: 0;
}

.section-row-tight h3 {
  font-size: 22px;
}

.section-row-tight span {
  font-size: 13px;
  color: var(--muted);
}

.icon-btn {
  width: 36px;
  height: 36px;
  border: 1px solid #2a3241;
  border-radius: 999px;
  background: #101621;
  color: var(--text);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
}

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

.tool-card {
  position: relative;
  height: 180px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #253043;
  background: #11161f;
}

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

.tool-overlay {
  position: absolute;
  inset: auto 0 0 0;
  padding: 10px;
  background: linear-gradient(to top, rgba(4, 4, 6, 0.86), rgba(4, 4, 6, 0));
  display: grid;
  gap: 6px;
}

.tool-overlay strong {
  font-size: 18px;
  line-height: 1.15;
}

.tool-overlay p {
  margin: 0;
  color: #d6dbee;
  font-size: 13px;
}

.tool-overlay button {
  justify-self: start;
}

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

.feed-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0b111c;
  padding: 12px;
  display: grid;
  gap: 10px;
}

.feed-card h3 {
  margin: 0;
  font-size: 19px;
}

.feed-card p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.3;
}

.placeholder-row {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(180px, 1fr);
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.placeholder-row::-webkit-scrollbar {
  display: none;
}

.placeholder-tile {
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #253043;
  background: #0f1520;
  aspect-ratio: 3 / 4;
}

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

.segmented {
  border: 1px solid #242b3c;
  border-radius: 8px;
  background: #0b1019;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  padding: 4px;
  gap: 4px;
}

.segmented-btn {
  height: 36px;
  border-radius: 8px;
  border: 0;
  background: transparent;
  color: #b0b7cc;
  font-weight: 600;
  cursor: pointer;
}

.segmented-btn.is-active {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
}

.info-banner {
  border: 1px solid rgba(150, 124, 255, 0.45);
  border-radius: 8px;
  background: rgba(92, 74, 203, 0.18);
  padding: 12px;
  display: grid;
  gap: 4px;
}

.info-banner strong {
  font-size: 16px;
}

.info-banner span {
  color: #d7dcf2;
  font-size: 13px;
}

.upload-dropzone {
  border: 1px dashed #333f58;
  border-radius: 8px;
  background: #0a0f18;
  min-height: 180px;
  display: grid;
  place-items: center;
  gap: 8px;
  text-align: center;
  color: #cfd5ea;
  cursor: pointer;
  padding: 16px;
}

.dropzone-icon {
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: 1px solid #2f3a50;
  display: grid;
  place-items: center;
  background: #141b28;
}

.dropzone-title {
  display: block;
  font-size: 18px;
  font-weight: 600;
}

.dropzone-subtitle {
  display: block;
  color: var(--muted);
  font-size: 14px;
}

.panel-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 12px;
  display: grid;
  gap: 10px;
}

.panel-card textarea {
  width: 100%;
  border: 1px solid #2b3345;
  border-radius: 8px;
  background: #090e17;
  color: var(--text);
  padding: 12px;
  font-size: 16px;
  line-height: 1.4;
  resize: vertical;
  min-height: 134px;
}

.inline-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.muted-inline {
  font-size: 13px;
  color: var(--muted);
}

.soft-btn {
  height: 42px;
  border-radius: 8px;
  border: 1px solid #2e3648;
  background: #111825;
  color: #ecf0ff;
  padding: 0 14px;
  font-weight: 600;
  cursor: pointer;
}

.soft-btn-icon {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.settings-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  overflow: hidden;
}

.settings-panel > summary {
  list-style: none;
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  font-weight: 600;
}

.settings-panel > summary::-webkit-details-marker {
  display: none;
}

.settings-panel[open] > summary svg {
  transform: rotate(180deg);
}

.settings-body {
  padding: 0 12px 12px;
  display: grid;
  gap: 14px;
}

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

.chip-field-title {
  color: var(--muted);
  font-size: 14px;
}

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

.choice-chip {
  min-height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid #252b38;
  background: #151a24;
  color: #a5afc6;
  font-size: 15px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.choice-chip:hover:not(:disabled) {
  border-color: #3a4254;
  color: #d6dcef;
}

.choice-chip[aria-checked="true"] {
  border-color: #f5dd4a;
  background: #f5dd4a;
  color: #111318;
}

.choice-chip:disabled {
  cursor: default;
  opacity: 0.52;
}

.choice-chip .chip-lock {
  margin-left: 6px;
  font-size: 12px;
  vertical-align: middle;
}

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

.field span {
  color: var(--muted);
  font-size: 13px;
}

.field input,
.field select {
  width: 100%;
  height: 42px;
  border: 1px solid #2b3345;
  border-radius: 8px;
  background: #0a101b;
  color: var(--text);
  padding: 0 12px;
  font-size: 15px;
}

.primary-action {
  width: 100%;
  height: 54px;
  border: 1px solid #8f84ff;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  font-size: 20px;
  font-weight: 700;
  cursor: pointer;
}

.note {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.result-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 12px;
  display: grid;
  gap: 10px;
}

.active-result {
  border: 1px solid #242c3d;
  border-radius: 8px;
  background: #0e1420;
  min-height: 170px;
  display: grid;
  place-items: center;
  color: var(--muted);
  overflow: hidden;
}

.active-result-has-image {
  grid-template-rows: minmax(0, 1fr) auto;
  place-items: stretch;
}

.active-result img {
  width: 100%;
  max-height: 420px;
  object-fit: contain;
  display: block;
}

.empty-result {
  padding: 14px;
  text-align: center;
}

.image-actions {
  padding: 8px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  border-top: 1px solid #242c3d;
}

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

.history-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0b1019;
  padding: 8px;
  display: grid;
  gap: 8px;
}

.history-thumb {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #273047;
  background: #0f1522;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
}

.history-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.history-body {
  display: grid;
  gap: 7px;
}

.history-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.chip {
  border: 1px solid #3a4358;
  border-radius: 999px;
  color: #d3daef;
  font-size: 11px;
  padding: 3px 8px;
}

.status-pill {
  border: 1px solid #3a4358;
  border-radius: 999px;
  color: #d3daef;
  font-size: 11px;
  padding: 3px 8px;
}

.status-done {
  border-color: rgba(84, 217, 146, 0.5);
  color: var(--success);
}

.status-failed,
.status-cancelled {
  border-color: rgba(255, 138, 150, 0.55);
  color: var(--danger);
}

.status-processing,
.status-queued {
  border-color: rgba(159, 149, 255, 0.55);
  color: #cfc6ff;
}

.history-prompt {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.plan-meta {
  color: #aab2c8;
  font-size: 12px;
}

.history-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
}

.btn-compact {
  width: 100%;
  height: 36px;
  font-size: 13px;
}

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

.plan-card {
  border: 1px solid #2a3347;
  border-radius: 8px;
  background: #0e141f;
  padding: 12px;
  display: grid;
  gap: 8px;
  cursor: pointer;
}

.plan-card.is-selected {
  border-color: rgba(156, 143, 255, 0.8);
  background: rgba(93, 76, 210, 0.2);
}

.plan-title-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}

.plan-card h3 {
  margin: 0;
  font-size: 18px;
}

.plan-price {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: 0;
}

.profile-card {
  grid-template-columns: 1fr;
}

.stat {
  border: 1px solid #283145;
  border-radius: 8px;
  background: #111827;
  padding: 10px;
  display: grid;
  gap: 6px;
}

.stat span {
  font-size: 12px;
  color: var(--muted);
}

.stat strong {
  font-size: 22px;
}

.auth-btn {
  width: 100%;
}

.bot-link {
  height: 46px;
  border: 1px solid #2f3648;
  border-radius: 8px;
  background: #101724;
  color: #e8edfe;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 600;
}

.bottom-nav {
  border-top: 1px solid var(--line);
  background: rgba(7, 9, 14, 0.96);
  backdrop-filter: blur(10px);
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  padding: 6px 8px max(10px, env(safe-area-inset-bottom));
  gap: 4px;
  position: sticky;
  bottom: 0;
  z-index: 14;
}

.nav-btn {
  min-height: 62px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #8f97ad;
  display: grid;
  place-items: center;
  gap: 5px;
  padding: 6px 4px;
  cursor: pointer;
}

.nav-btn span {
  font-size: 12px;
  line-height: 1;
}

.nav-btn.is-active {
  color: #fff;
  border-color: #2b3142;
  background: #121a29;
}

.nav-btn-center {
  border-color: #31374b;
  border-radius: 999px;
  width: 56px;
  height: 56px;
  margin: 0 auto;
}

.nav-btn-center span {
  display: none;
}

@media (max-width: 520px) {
  .tools-grid,
  .feed-grid,
  .history-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 390px) {
  .tools-grid,
  .feed-grid,
  .history-grid {
    grid-template-columns: 1fr;
  }

  .nav-btn span {
    font-size: 11px;
  }
}
