:root {
  --ink: #171717;
  --paper: #f4f0e6;
  --card: #fffdf8;
  --paper-strong: #fffaf0;
  --muted: #777168;
  --line: #aaa398;
  --violet: #8b5cf6;
  --blue: #66a9ff;
  --mint: #66d7af;
  --coral: #ff876f;
  --nav-base: #fffdf8;
  --nav-wave: #ebe3ff;
  --dot-color: #8b5cf6;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --app-height: 100vh;
  color-scheme: light;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

@supports (height: 100dvh) {
  :root { --app-height: 100dvh; }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { min-height: 100%; }
body {
  min-width: 280px;
  margin: 0;
  overflow: hidden;
  background: radial-gradient(circle at 10% 0, rgba(244,216,77,.28), transparent 28rem), #d8d5ce;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button, textarea, input { color: inherit; font: inherit; }
button { touch-action: manipulation; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }

.app-shell {
  position: relative;
  width: min(100%, 560px);
  height: min(var(--app-height), 932px);
  min-height: min(var(--app-height), 480px);
  overflow: hidden;
  margin: auto;
  border: 2px solid var(--ink);
  border-radius: 35px 35px 46px 46px;
  background: var(--paper);
  box-shadow: 9px 11px 0 var(--ink);
  isolation: isolate;
}

.app-head {
  position: absolute;
  z-index: 20;
  top: 0;
  right: 0;
  left: 0;
  display: flex;
  height: calc(62px + var(--safe-top));
  align-items: center;
  padding: var(--safe-top) 16px 0;
  pointer-events: none;
}
.brand, .header-back { pointer-events: auto; }
.brand {
  display: flex;
  align-items: center;
  opacity: 1;
  filter: blur(0);
  transform: scale(1);
  transform-origin: left center;
  transition: opacity .28s ease, filter .34s ease, transform .46s cubic-bezier(.16,1,.3,1);
}
.brand i {
  display: grid;
  width: 31px;
  height: 31px;
  place-items: center;
  border-radius: 50%;
  background: var(--ink);
  color: white;
  font-style: normal;
  font-weight: 850;
}
.header-back {
  position: absolute;
  top: calc(10px + var(--safe-top));
  bottom: auto;
  left: 12px;
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 1px solid rgba(255,255,255,.26);
  border-radius: 50%;
  background: var(--ink);
  box-shadow: 0 4px 12px rgba(0,0,0,.16);
  color: white;
  font-size: 14px;
  opacity: 0;
  filter: blur(4px);
  pointer-events: none;
  transform: scale(.72);
  transition: opacity .28s ease, filter .34s ease, transform .46s cubic-bezier(.16,1,.3,1);
}
.app-shell.tool-mode .brand { opacity: 0; filter: blur(4px); transform: scale(.72); }
.app-shell.tool-mode .header-back { opacity: 1; filter: blur(0); pointer-events: auto; transform: scale(1); }

.scene { position: absolute; z-index: 1; inset: 0; overflow: hidden; background: var(--paper); }
#dots {
  position: absolute;
  z-index: 0;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: .72;
  filter: drop-shadow(0 0 4px var(--dot-glow, rgba(139,92,246,.32)));
  pointer-events: none;
}
.screen-stack { position: absolute; z-index: 2; inset: 0 0 calc(48px + var(--safe-bottom)); overflow: hidden; }
.screen {
  position: absolute;
  inset: 0;
  display: none;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  contain: layout paint style;
  background: transparent;
}
.screen.scene-transitioning { will-change: clip-path, mask-image, -webkit-mask-image; }
.screen::-webkit-scrollbar { display: none; }
.screen.active { display: block; }

.home-screen { place-items: center; overflow: hidden; }
.home-screen.active { display: grid; }
.home-center {
  display: grid;
  width: min(86%, 340px);
  place-items: center;
  margin-top: -20px;
  padding: calc(82px + var(--safe-top)) 0 20px;
  text-align: center;
}
.crosshair { position: relative; width: 112px; aspect-ratio: 1; margin-bottom: 0; border: 1px solid #9d968b; border-radius: 50%; background: rgba(255,253,248,.55); }
.crosshair::before, .crosshair::after { position: absolute; background: var(--ink); content: ""; }
.crosshair::before { top: 50%; right: -25px; left: -25px; height: 1px; background:#9d968b; }
.crosshair::after { top: -25px; bottom: -25px; left: 50%; width: 1px; background:#9d968b; }
.crosshair i { position: absolute; top:50%; left:50%; width:11px; height:11px; border:2px solid var(--ink); border-radius:50%; background:var(--paper); transform:translate(-50%,-50%); }
.crosshair.compact { width: 72px; margin-bottom: 8px; }
.home-center h1 { margin: 26px 0 0; font-size: 25px; line-height: 1; letter-spacing: -.045em; }
.home-copy { max-width: 235px; margin: 7px 0 0; color: var(--muted); font-size: 11px; line-height: 1.45; }
.home-hint { margin-top:12px; padding: 6px 9px; border: 1px solid #aaa398; border-radius: 999px; background: rgba(255,253,248,.62); font-size: 9px; font-weight: 800; }

.ideas-screen, .works-screen, .profile-screen { padding: calc(70px + var(--safe-top)) clamp(12px, 4vw, 18px) 20px; }
.screen-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.screen-head small { display: block; margin-bottom: 3px; color: var(--muted); font-size: 8px; font-weight: 900; letter-spacing: .12em; text-transform: uppercase; }
.screen-head h1 { margin: 0; font-size: clamp(28px, 8vw, 38px); line-height: .95; letter-spacing: -.055em; }
.screen-count { flex: 0 0 auto; padding: 6px 9px; border: 1px solid #aaa398; border-radius: 999px; background: rgba(255,253,248,.78); font-size: 8px; font-weight: 850; }
.screen-intro { max-width: 300px; margin: -4px 0 14px; color: var(--muted); font-size: 10px; line-height: 1.45; }

.idea-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; padding-bottom: 10px; }
.idea-card {
  position: relative;
  display: flex;
  min-height: 160px;
  overflow: hidden;
  flex-direction: column;
  justify-content: flex-end;
  padding: 13px;
  border: 1px solid rgba(23,23,23,.72);
  border-radius: 22px;
  background: rgba(255,253,248,.78);
  box-shadow: 0 10px 28px rgba(42,36,28,.08);
  text-align: left;
  cursor: pointer;
}
.idea-card:first-child { grid-column: 1 / -1; min-height: 190px; }
.idea-card::before { position: absolute; width: 130px; height: 130px; border-radius: 50%; content: ""; filter: blur(3px); transform: translate(45px,-28px); }
.idea-card.cobalt::before { background: rgba(102,169,255,.58); }
.idea-card.ember::before { background: rgba(255,135,111,.55); }
.idea-card.mint::before { background: rgba(102,215,175,.55); }
.idea-card > * { position: relative; z-index: 1; }
.idea-card small { margin-bottom: auto; color: var(--muted); font-size: 7px; font-weight: 900; letter-spacing: .1em; }
.idea-card strong { font-size: clamp(13px, 4vw, 18px); line-height: 1.05; }
.idea-card p { margin: 5px 0 0; color: var(--muted); font-size: 9px; line-height: 1.35; }
.idea-card.selected { outline: 2px solid var(--violet); outline-offset: -4px; }

.empty-state { display: grid; min-height: 55%; place-items: center; align-content: center; padding: 26px 10px; text-align: center; }
.empty-state h2 { margin: 8px 0 4px; font-size: 24px; }
.empty-state p { max-width: 280px; margin: 0 0 14px; color: var(--muted); font-size: 10px; line-height: 1.5; }
.text-action { min-height: 44px; padding: 0 10px; border: 0; background: transparent; color: var(--violet); font-size: 10px; font-weight: 900; cursor: pointer; }
.works-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; padding-bottom: 10px; }
.work-card { position: relative; overflow: hidden; min-height: 170px; border: 1px solid rgba(23,23,23,.72); border-radius: 22px; background: rgba(255,253,248,.84); box-shadow: 0 10px 28px rgba(42,36,28,.08); }
.work-card.wide { grid-column: 1 / -1; }
.work-card img { display: block; width: 100%; aspect-ratio: 4 / 5; object-fit: cover; cursor: pointer; }
.work-card.wide img { aspect-ratio: 16 / 9; }
.work-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 11px 11px; }
.work-meta strong, .work-meta small { display: block; }
.work-meta strong { overflow: hidden; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.work-meta small { margin-top: 2px; color: var(--muted); font-size: 7px; }
.work-save { display: grid; width: 34px; height: 34px; flex: 0 0 34px; place-items: center; border: 1px solid var(--ink); border-radius: 50%; background: var(--ink); color: white; cursor: pointer; }
.work-placeholder { display: grid; min-height: 145px; place-items: center; padding: 20px; color: var(--muted); font-size: 9px; text-align: center; }

.profile-card { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 13px; margin-bottom: 10px; padding: 15px; border: 1px solid rgba(23,23,23,.72); border-radius: 22px; background: rgba(255,253,248,.82); }
.profile-avatar { display: grid; width: 58px; height: 58px; place-items: center; border-radius: 50%; background: var(--coral); color: white; font-size: 20px; font-weight: 900; }
.profile-card strong, .profile-card small { display: block; }
.profile-card strong { font-size: 14px; }
.profile-card small { margin-top: 3px; color: var(--muted); font-size: 9px; }
.balance-card { margin-bottom: 10px; padding: 17px; border: 1px solid rgba(23,23,23,.72); border-radius: 22px; background: #ffe9e4; }
.balance-card > small { color: var(--muted); font-size: 8px; font-weight: 900; letter-spacing: .1em; text-transform: uppercase; }
.balance-card div { display: flex; align-items: flex-end; gap: 7px; margin-top: 16px; }
.balance-card div strong { font-size: clamp(42px, 14vw, 60px); line-height: .8; letter-spacing: -.065em; }
.balance-card div span { font-size: 10px; font-weight: 850; text-transform: uppercase; }
.balance-card p { margin: 14px 0 12px; color: var(--muted); font-size: 9px; }
.balance-card button { display: flex; width: 100%; min-height: 44px; align-items: center; justify-content: space-between; padding: 0 13px; border: 1px solid var(--ink); border-radius: 13px; background: var(--ink); color: white; font-size: 10px; font-weight: 850; cursor: pointer; }
.settings-list { overflow: hidden; border: 1px solid rgba(23,23,23,.72); border-radius: 22px; background: rgba(255,253,248,.82); }
.setting-row { display: flex; min-height: 58px; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 14px; border-bottom: 1px solid #c9c2b7; font-size: 10px; font-weight: 800; }
.setting-row:last-child { border-bottom: 0; }
.setting-row span small { display: block; margin-top: 3px; color: var(--muted); font-size: 8px; font-weight: 650; }
.setting-row > strong { color: var(--muted); font-size: 9px; }

.tool-screen { overflow: hidden; padding: calc(7px + var(--safe-top)) clamp(10px,3.5vw,14px) 0; background: transparent; }
.workspace { display: flex; min-height: 0; height: 100%; flex-direction: column; gap: 9px; }
.canvas-stage {
  position: relative;
  display: grid;
  min-height: 315px;
  flex: 1 1 auto;
  place-items: stretch;
  overflow: hidden;
  border: 1.5px solid var(--ink);
  border-radius: clamp(18px, 6vw, 26px);
  background: rgba(255,253,248,.87);
  box-shadow: 0 12px 34px rgba(42,36,28,.1);
}
.canvas-stage::before { position: absolute; z-index: 1; inset: 12px; border: 1px dashed #999287; border-radius: 17px; content: ""; pointer-events: none; }
.canvas-stage.has-photo::before, .canvas-stage.has-result::before { opacity: .45; }
.upload-zone { position: relative; z-index: 2; display: grid; min-width: 0; min-height: 0; place-items: center; overflow: hidden; cursor: pointer; }
.upload-zone input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.upload-empty { display: grid; gap: 9px; place-items: center; padding: 22px; text-align: center; }
.upload-empty i { display: grid; width: 58px; height: 58px; place-items: center; border-radius: 50%; background: var(--violet); color: white; font-style: normal; font-size: 26px; }
.upload-empty strong { font-size: 13px; }
.upload-empty small { color: var(--muted); font-size: 9px; }
.upload-preview { position: absolute; inset: 0; display: none; width: 100%; height: 100%; object-fit: contain; background: rgba(23,23,23,.96); }
.canvas-stage.has-photo .upload-preview { display: block; }
.canvas-stage.has-photo .upload-empty { display: none; }
.change-photo { position: absolute; z-index: 3; right: 18px; bottom: 18px; display: none; padding: 7px 10px; border: 1px solid rgba(255,255,255,.45); border-radius: 999px; background: rgba(23,23,23,.74); color: white; font-size: 8px; font-weight: 850; backdrop-filter: blur(8px); }
.canvas-stage.has-photo .change-photo { display: block; }
.result-layer { position: absolute; z-index: 5; inset: 0; display: grid; place-items: center; overflow: hidden; background: rgba(23,23,23,.9); }
.result-layer > img { display: none; width: 100%; height: 100%; object-fit: contain; }
.result-layer.has-result > img { display: block; }
.result-layer.has-result .result-progress { display: none; }
.result-progress { position: relative; z-index: 2; display: grid; max-width: 240px; place-items: center; padding: 20px; color: white; text-align: center; }
.result-progress strong { margin-top: 10px; font-size: 12px; }
.result-progress p { margin: 5px 0 0; color: rgba(255,255,255,.7); font-size: 9px; line-height: 1.4; }
.progress-orbit { width: 38px; height: 38px; border: 2px solid rgba(255,255,255,.25); border-top-color: var(--violet); border-radius: 50%; animation: orbit .9s linear infinite; }

.prompt-card { position: relative; min-height: 116px; flex: 0 0 116px; padding: 14px 15px 23px; }
.prompt-surface { position: absolute; z-index: 0; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.prompt-surface path { fill: rgba(255,253,248,.93); stroke: #aaa398; stroke-width: 1; vector-effect: non-scaling-stroke; }
.prompt-card label, .prompt-card textarea, .char-count { position: relative; z-index: 1; }
.prompt-card label { display: block; margin-bottom: 5px; font-size: 9px; font-weight: 900; text-transform: uppercase; }
.prompt-card textarea { display: block; width: 100%; height: 61px; overflow-y: auto; resize: none; border: 0; outline: 0; background: transparent; scrollbar-width: none; font-size: 16px; line-height: 1.35; }
.prompt-card textarea::-webkit-scrollbar { display: none; }
.prompt-card textarea::placeholder { color: #8d867c; opacity: 1; }
.char-count { position: absolute; right: 16px; bottom: 17px; color: var(--muted); font-size: 7px; }
.result-actions { display: grid; flex: 0 0 44px; grid-template-columns: 1fr 1fr; gap: 8px; }
.result-actions button { border: 1px solid var(--ink); border-radius: 13px; background: var(--paper); font-size: 10px; font-weight: 850; cursor: pointer; }
.result-actions button:first-child { background: var(--ink); color: white; }

.bottom-nav { position: absolute; z-index: 15; right: 0; bottom: 0; left: 0; display: grid; height: calc(48px + var(--safe-bottom)); grid-template-columns: 1fr 1fr minmax(70px,78px) 1fr 1fr; padding: 2px 6px var(--safe-bottom); background: transparent; }
.nav-surface { position: absolute; z-index: 0; inset: 0 0 var(--safe-bottom); width: 100%; height: 48px; overflow: visible; pointer-events: none; }
.nav-surface-base { fill: var(--nav-base); }
.nav-surface-wave { fill: var(--nav-wave); clip-path: url(#nav-wave-clip); }
.nav-divider-line { fill: none; stroke: #aaa49a; stroke-width: 1; vector-effect: non-scaling-stroke; }
.nav-item { position: relative; z-index: 2; display: grid; min-width: 0; place-items: center; align-content:center; gap:1px; padding:1px 2px; border: 0; background: transparent; color: #888178; cursor: pointer; transition:opacity .38s cubic-bezier(.16,1,.3,1),filter .38s ease; }
.nav-item i { display: grid; width:auto; height:17px; place-items: center; border-radius:0; color:inherit; font-style: normal; font-size: 13px; font-weight:900; transform:none; transition:none; }
.nav-item span { font-size: 6.5px; font-weight: 800; white-space: nowrap; }
.nav-item.active, .nav-item.active i { color:var(--ink); background:transparent; }
.create-slot { position: relative; z-index: 2; display: grid; min-width: 0; place-items: end center; }
.create-main { position: absolute; top: -41px; display: grid; width: 66px; height: 66px; overflow: hidden; place-items: center; border: 1.25px solid var(--ink); border-radius: 50%; background: var(--ink); box-shadow: 0 7px 18px rgba(0,0,0,.18); color: white; cursor: pointer; line-height: 1; transition: transform .58s cubic-bezier(.16,1,.3,1), box-shadow .48s ease; will-change:transform; }
.create-main::before { position: absolute; z-index: 0; inset: 0; margin: auto; width: 100%; height: 100%; border-radius: 50%; background: var(--violet); content: ""; transform: scale(0); transition: transform .46s cubic-bezier(.45,0,.2,1); }
.create-main.generate-mode::before { transform: scale(1); }
.create-main.is-returning::before { transition-duration:.18s; transition-delay:.76s; }
.create-main.needs-input { box-shadow: 0 5px 12px rgba(0,0,0,.14); }
.button-face { position: absolute; z-index: 1; display: flex; align-items: center; justify-content: center; white-space: nowrap; opacity: 0; filter: blur(4px); transform: translateY(8px) scale(.86); transition: opacity .28s ease, filter .34s ease, transform .48s cubic-bezier(.16,1,.3,1); pointer-events: none; }
.face-plus { opacity: 1; filter: blur(0); font-size: 31px; transform: translateY(0) scale(1); }
.face-generate, .face-done { font-size: 22px; }
.face-loading { font-size: 14px; font-weight: 950; letter-spacing: 3px; }
.create-main.generate-mode .face-plus { opacity: 0; filter: blur(4px); transform: translateY(-8px) scale(.82); }
.create-main.generate-mode .face-generate { opacity: 1; filter: blur(0); transform: translateY(0) scale(1); transition-delay: .12s; }
.create-main.generating .face-generate, .create-main.complete .face-generate { opacity: 0; filter: blur(4px); transform: translateY(-7px) scale(.88); transition-delay: 0ms; }
.create-main.generating .face-loading, .create-main.complete .face-done { opacity: 1; filter: blur(0); transform: translateY(0) scale(1); }
.create-main.generating { animation: generate-pulse 1.15s cubic-bezier(.45,0,.55,1) infinite alternate; }
.create-label { position: relative; display: block; width: 80px; height: 10px; font-size: 7px; font-weight: 850; text-align: center; }
.label-state { position: absolute; top: 0; left: 50%; white-space: nowrap; opacity: 0; filter: blur(3px); transform: translate(-50%,5px); transition: opacity .3s ease, filter .34s ease, transform .46s cubic-bezier(.16,1,.3,1); }
.label-create { opacity: 1; filter: blur(0); transform: translate(-50%,0); }
.create-main.generate-mode + .create-label .label-create { opacity: 0; filter: blur(3px); transform: translate(-50%,-5px); }
.create-main.generate-mode + .create-label .label-generate { opacity: 1; filter: blur(0); transform: translate(-50%,0); transition-delay: .12s; }
.create-main.is-returning .button-face, .create-main.is-returning + .create-label .label-state { transition-delay:.76s; }
.toast { position: absolute; z-index: 30; right: 15px; bottom: calc(60px + var(--safe-bottom)); left: 15px; padding: 10px; border: 1px solid var(--ink); border-radius: 14px; background: var(--card); box-shadow: 0 8px 22px rgba(0,0,0,.12); font-size: 10px; font-weight: 850; text-align: center; }

@keyframes orbit { to { transform: rotate(1turn); } }
@keyframes generate-pulse { from { transform: scale(1); box-shadow: 0 8px 22px rgba(139,92,246,.3); } to { transform: scale(.965); box-shadow: 0 5px 13px rgba(139,92,246,.2); } }

@media (max-width: 720px) {
  body { display: block; background: var(--paper); }
  .app-shell { width: 100%; height: var(--app-height); max-height: none; border: 0; border-radius: 0; box-shadow: none; }
}

@media (min-width: 721px) {
  body { display: grid; min-height: 100vh; place-items: center; padding: 20px; }
  .app-shell { height: min(calc(var(--app-height) - 40px), 932px); min-height: min(calc(var(--app-height) - 40px), 480px); }
}

@media (max-width: 350px) {
  .ideas-screen, .works-screen, .profile-screen { padding-right: 10px; padding-left: 10px; }
  .screen-intro { font-size: 9px; }
  .idea-grid, .works-grid { gap: 7px; }
  .idea-card { min-height: 145px; padding: 10px; border-radius: 18px; }
  .idea-card:first-child { min-height: 170px; }
  .idea-card p { display: none; }
  .nav-item span { font-size: 6.5px; }
  .bottom-nav { grid-template-columns: 1fr 1fr 70px 1fr 1fr; }
  .prompt-card { padding-right: 12px; padding-left: 12px; }
}

@media (max-height: 680px) {
  .home-center { padding-top: calc(28px + var(--safe-top)); transform: scale(.9); }
  .crosshair { width: 82px; margin-bottom: 12px; }
  .tool-screen { padding-top: calc(7px + var(--safe-top)); }
  .workspace { gap: 6px; }
  .canvas-stage { min-height: 150px; }
  .prompt-card { min-height: 100px; flex-basis: 100px; padding-top: 11px; }
  .prompt-card textarea { height: 48px; }
  .char-count { bottom: 12px; }
}

@media (max-height: 540px) {
  .home-copy { display: none; }
  .home-hint { margin-top: 12px; }
  .canvas-stage { min-height: 125px; }
  .prompt-card { min-height: 92px; flex-basis: 92px; }
  .prompt-card textarea { height: 42px; }
  .change-photo { right: 14px; bottom: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; transition-delay: 0ms !important; }
  #dots { filter: none; }
}

@media (prefers-contrast: more) {
  :root { --line: #625d56; --muted: #514d47; }
  .screen { background: rgba(255,253,248,.45); }
}
