:root {
  --ink: #f7f4ff;
  --muted: #a7a0b7;
  --surface: rgba(31, 27, 42, 0.78);
  --surface-strong: #262132;
  --line: rgba(255, 255, 255, 0.09);
  --violet: #a970ff;
  --violet-hot: #d3b2ff;
  --cyan: #57e5d4;
  --black: #0b0910;
  --danger: #ff7b95;
}

* { box-sizing: border-box; }

html { background: var(--black); }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% -10%, rgba(169, 112, 255, 0.22), transparent 38%),
    radial-gradient(circle at 90% 35%, rgba(87, 229, 212, 0.09), transparent 32%),
    #0b0910;
  font-family: "Manrope", "Avenir Next", "Montserrat", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; }

.ambient {
  position: fixed;
  z-index: 0;
  border-radius: 50%;
  filter: blur(90px);
  pointer-events: none;
}

.ambient-one { width: 180px; height: 180px; top: 20%; left: -110px; background: #783bd8; opacity: .22; }
.ambient-two { width: 150px; height: 150px; right: -100px; bottom: 15%; background: #4ce4cf; opacity: .11; }

.shell {
  position: relative;
  z-index: 1;
  width: min(100%, 620px);
  margin: 0 auto;
  padding: max(22px, env(safe-area-inset-top)) 18px calc(36px + env(safe-area-inset-bottom));
}

.topbar, .section-head, .job-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.topbar { margin-bottom: 28px; animation: rise .45s ease both; }
.eyebrow, .section-kicker { margin: 0 0 7px; color: var(--violet-hot); font-size: 10px; font-weight: 800; letter-spacing: .19em; }
.topbar h1 { max-width: 330px; margin: 0; font-size: clamp(22px, 6vw, 31px); line-height: 1.08; letter-spacing: -.045em; }
.avatar { display: grid; width: 48px; height: 48px; flex: 0 0 auto; place-items: center; border: 1px solid rgba(211,178,255,.45); border-radius: 17px; background: linear-gradient(145deg, #6a35a8, #251b3c); box-shadow: 0 10px 35px rgba(169,112,255,.22); font-weight: 800; }

.view { display: none; }
.view.active { display: block; animation: rise .35s ease both; }
.balance-grid { display: grid; grid-template-columns: 1.2fr .8fr; gap: 10px; }
.metric, .plan-card, .panel, .project-card { border: 1px solid var(--line); background: var(--surface); backdrop-filter: blur(18px); }
.metric { min-height: 130px; padding: 18px; border-radius: 23px; }
.metric-primary { background: linear-gradient(145deg, rgba(116,66,185,.8), rgba(45,33,65,.9)); }
.metric span, .metric small { display: block; color: #c7bfd2; font-size: 12px; }
.metric strong { display: block; margin: 13px 0 8px; font-size: 34px; letter-spacing: -.05em; }
.metric-primary strong { color: white; }

.plan-card { display: flex; align-items: center; justify-content: space-between; margin: 12px 0 32px; padding: 20px; border-radius: 23px; }
.plan-card h2, .section-head h2, .project-hero h2 { margin: 0; letter-spacing: -.035em; }
.plan-card p, .project-hero p { margin: 7px 0 0; color: var(--muted); font-size: 13px; }
.plan-mark { display: grid; width: 46px; height: 46px; place-items: center; border-radius: 50%; color: var(--cyan); background: rgba(87,229,212,.09); font-size: 24px; }
.section-head { margin: 0 2px 14px; }
.section-head.compact { margin: 0 0 14px; }
.section-head h2 { font-size: 24px; }
.section-head h3 { margin: 0; font-size: 17px; }
.text-button, .back-button { border: 0; color: var(--violet-hot); background: transparent; cursor: pointer; }
.back-button { margin: 0 0 22px; padding: 0; }

.project-list { display: grid; gap: 10px; }
.creation-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 32px; }
.creation-card, .tool-card { border: 1px solid var(--line); color: var(--ink); background: var(--surface); cursor: pointer; text-align: left; }
.creation-card { min-height: 145px; padding: 17px; border-radius: 22px; }
.creation-card:first-child { grid-column: 1 / -1; min-height: 125px; background: linear-gradient(120deg, rgba(124,70,199,.75), rgba(34,27,49,.92)); }
.creation-card strong, .creation-card small { display: block; }
.creation-card strong { margin: 20px 0 5px; font-size: 17px; }
.creation-card:first-child strong { margin-top: 14px; font-size: 21px; }
.creation-card small { color: #bcb4c9; }
.creation-icon { display: grid; width: 38px; height: 38px; place-items: center; border: 1px solid rgba(255,255,255,.13); border-radius: 13px; color: var(--violet-hot); background: rgba(255,255,255,.06); font-weight: 800; }
.creation-text .creation-icon { color: var(--cyan); }
.tools-head { margin-top: 4px; }
.tool-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-bottom: 34px; }
.tool-card { display: flex; align-items: center; min-height: 60px; padding: 12px 14px; border-radius: 17px; }
.tool-card span { display: grid; width: 31px; height: 31px; margin-right: 10px; place-items: center; border-radius: 10px; color: var(--violet-hot); background: rgba(169,112,255,.1); font-weight: 800; }
.tool-card strong { font-size: 13px; }
.project-card { position: relative; width: 100%; padding: 18px; overflow: hidden; border-radius: 21px; color: var(--ink); text-align: left; cursor: pointer; animation: rise .35s ease both; }
.project-card::after { content: "↗"; position: absolute; right: 18px; top: 18px; color: var(--violet-hot); }
.project-card strong { display: block; max-width: 80%; margin: 7px 0; font-size: 17px; }
.project-card small, .muted { color: var(--muted); font-size: 12px; }
.project-card .favorite { color: #ffd76a; }
.empty { padding: 30px 20px; border: 1px dashed var(--line); border-radius: 21px; color: var(--muted); text-align: center; }
.pager { display: flex; justify-content: center; align-items: center; gap: 18px; margin-top: 18px; color: var(--muted); font-size: 12px; letter-spacing: .15em; }
.icon-button { display: grid; width: 42px; height: 42px; place-items: center; border: 1px solid var(--line); border-radius: 15px; color: var(--ink); background: var(--surface); cursor: pointer; }
.icon-button:disabled { opacity: .28; }

.project-hero { margin-bottom: 18px; padding: 4px 2px 10px; }
.project-hero h2 { margin-top: 13px; font-size: clamp(28px, 8vw, 40px); line-height: 1.05; }
.pill { display: inline-flex; padding: 7px 10px; border: 1px solid rgba(169,112,255,.32); border-radius: 999px; color: var(--violet-hot); background: rgba(169,112,255,.08); font-size: 9px; font-weight: 800; letter-spacing: .14em; }
.panel { margin-bottom: 11px; padding: 19px; border-radius: 22px; }
.settings-list { display: grid; gap: 0; }
.setting, .result-item { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 0; border-top: 1px solid var(--line); }
.setting:first-child, .result-item:first-child { border-top: 0; }
.setting span { color: var(--muted); font-size: 13px; }
.setting strong { font-size: 13px; text-align: right; }
.action-stack { display: grid; gap: 9px; margin: 18px 0 11px; }
.studio-hero { margin-bottom: 10px; }
.studio-form { display: grid; gap: 11px; }
.studio-form .panel { margin-bottom: 0; }
.form-panel { display: grid; gap: 14px; }
.field-grid, .effects-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field { display: grid; gap: 7px; }
.field > span, .upload-field > span { color: #d8d1e2; font-size: 12px; font-weight: 700; }
.field input, .field select, .field textarea {
  width: 100%; min-width: 0; border: 1px solid var(--line); border-radius: 13px;
  outline: 0; color: var(--ink); background: rgba(10, 8, 14, .58); font: inherit;
}
.field input, .field select { min-height: 47px; padding: 0 12px; }
.field textarea { padding: 12px; resize: vertical; line-height: 1.45; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: rgba(169,112,255,.7); box-shadow: 0 0 0 3px rgba(169,112,255,.1); }
.upload-field { position: relative; display: grid; gap: 6px; min-height: 84px; padding: 15px; border: 1px dashed rgba(211,178,255,.28); border-radius: 16px; background: rgba(169,112,255,.05); overflow: hidden; }
.upload-field input { width: 100%; color: var(--muted); font-size: 11px; }
.upload-field small { color: var(--muted); font-size: 10px; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; min-height: 48px; padding: 0 4px; color: #d8d1e2; font-size: 13px; }
.toggle-row input { width: 22px; height: 22px; accent-color: var(--violet); }
.studio-submit { width: 100%; margin-top: 5px; }
.studio-submit:disabled { opacity: .55; }
.form-note { margin: 0 12px 8px; color: var(--muted); font-size: 11px; line-height: 1.5; text-align: center; }
.primary-button, .secondary-button, .send-button { min-height: 52px; border: 0; border-radius: 17px; font-weight: 800; cursor: pointer; }
.primary-button { color: #130b1e; background: linear-gradient(110deg, var(--violet-hot), #8e60ec); box-shadow: 0 12px 35px rgba(169,112,255,.2); }
.secondary-button { border: 1px solid var(--line); color: var(--ink); background: var(--surface-strong); }
.send-button { min-height: 38px; padding: 0 13px; border-radius: 12px; color: #0b1917; background: var(--cyan); font-size: 12px; }
.error-text { margin: 12px 0 0; color: var(--danger); font-size: 13px; }

.error-view { padding: 60px 12px; text-align: center; }
.error-view.active { display: grid; justify-items: center; gap: 14px; }
.error-view h2, .error-view p { margin: 0; }
.error-view p { color: var(--muted); line-height: 1.5; }
.error-view .primary-button { width: 100%; margin-top: 12px; }
.error-orbit { display: grid; width: 72px; height: 72px; place-items: center; border: 1px solid rgba(255,123,149,.35); border-radius: 50%; color: var(--danger); background: rgba(255,123,149,.08); font-size: 30px; }
.hidden { display: none !important; }

.toast { position: fixed; z-index: 10; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); width: calc(100% - 36px); max-width: 520px; padding: 14px 16px; transform: translate(-50%, 120px); border: 1px solid var(--line); border-radius: 16px; color: var(--ink); background: #292333; opacity: 0; transition: .25s ease; }
.toast.visible { transform: translate(-50%, 0); opacity: 1; }
.loader { position: fixed; z-index: 20; inset: 0; display: flex; align-items: center; justify-content: center; gap: 7px; background: rgba(11,9,16,.78); backdrop-filter: blur(8px); }
.loader.hidden { display: none; }
.loader span { width: 8px; height: 8px; border-radius: 50%; background: var(--violet-hot); animation: pulse .8s ease-in-out infinite alternate; }
.loader span:nth-child(2) { animation-delay: .18s; }
.loader span:nth-child(3) { animation-delay: .36s; }

@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes pulse { to { transform: translateY(-9px); opacity: .35; } }

@media (max-width: 360px) {
  .balance-grid { grid-template-columns: 1fr; }
  .metric { min-height: 108px; }
  .tool-grid { grid-template-columns: 1fr; }
  .field-grid, .effects-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
