.app-body { height: 100dvh; overflow: hidden; }
.app { display: grid; grid-template-columns: 300px 1fr; height: 100dvh; }
.scrim { display: none; }

/* ---------- sidebar ---------- */
.side { background: var(--card); border-right: var(--b); display: flex; flex-direction: column; min-height: 0; padding: 16px 14px 14px; gap: 12px; z-index: 60; }
.side-top { display: flex; align-items: center; justify-content: space-between; padding: 0 4px; }
.side .logo { font-size: 23px; }
.side .logo .mark { width: 40px; height: 40px; }
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 5px; background: var(--bg); border-radius: 16px; border: 2px solid var(--line); }
.modes button { display: flex; align-items: center; justify-content: center; gap: 7px; border: 0; background: none; padding: 9px 6px; border-radius: 12px; font-weight: 700; font-size: 14px; color: var(--ink-2); cursor: pointer; }
.modes button svg { width: 18px; height: 18px; }
.modes button.on { background: var(--card); color: var(--ink); box-shadow: 0 2px 0 var(--ink); outline: 2px solid var(--ink); }
.new-chat { width: 100%; font-size: 16px; padding: 11px; }
.new-chat svg { width: 18px; height: 18px; }
.hist-head { display: flex; align-items: center; justify-content: space-between; margin-top: 4px; }
.seg { display: flex; gap: 2px; }
.seg button { border: 0; background: none; font-weight: 700; font-size: 13px; padding: 6px 12px; border-radius: 999px; color: var(--ink-3); cursor: pointer; text-transform: uppercase; letter-spacing: .06em; }
.seg button.on { background: var(--violet-soft); color: var(--violet); }
.hist { flex: 1; overflow-y: auto; min-height: 0; margin: 0 -6px; padding: 0 6px; }
.hist-empty { font-size: 14px; color: var(--ink-3); padding: 18px 8px; text-align: center; }
.hist-group { font-size: 11.5px; font-weight: 800; color: var(--ink-3); text-transform: uppercase; letter-spacing: .08em; padding: 12px 8px 6px; }
.hist-item { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 12px; cursor: pointer; position: relative; }
.hist-item:hover { background: var(--bg); }
.hist-item.on { background: var(--violet-soft); }
.hist-item .av { width: 30px; height: 30px; flex: none; }
.hist-item .tt { flex: 1; min-width: 0; font-size: 14.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hist-item .del { opacity: 0; border: 0; background: none; cursor: pointer; color: var(--ink-3); font-size: 15px; padding: 4px 6px; border-radius: 8px; }
.hist-item:hover .del, .hist-item.on .del { opacity: 1; }
.hist-item .del:hover { color: #d93f4f; background: #ffe4e4; }
.hist-imgs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 4px 2px; }
.hist-imgs img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; border: 2px solid var(--line); cursor: pointer; background: var(--bg); }
.hist-imgs img:hover { border-color: var(--violet); }

.side-foot { border-top: 2px solid var(--line); padding-top: 12px; display: grid; gap: 10px; }
.meters { display: grid; gap: 9px; }
.meter { font-size: 13px; font-weight: 700; }
.meter .ml { display: flex; justify-content: space-between; margin-bottom: 4px; color: var(--ink-2); }
.meter .bar { height: 9px; border-radius: 99px; background: var(--bg); border: 1.5px solid var(--line); overflow: hidden; }
.meter .bar i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--mint), #3fd8b0); transition: width .4s; }
.meter.full .bar i { background: linear-gradient(90deg, var(--coral), #ff9a8a); }
.tier-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; }
.tier-row a, .tier-row button { font-size: 13px; font-weight: 700; color: var(--violet); background: none; border: 0; cursor: pointer; padding: 0; text-decoration: none; }

/* ---------- main ---------- */
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative; background: var(--bg); background-image: radial-gradient(#e2dcff 1.1px, transparent 1.1px); background-size: 22px 22px; }
.top { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-bottom: 2px solid var(--line); background: rgba(246, 244, 255, .9); backdrop-filter: blur(10px); }
.picker { display: flex; align-items: center; gap: 10px; border: var(--b); background: var(--card); border-radius: 18px; padding: 5px 12px 5px 6px; cursor: pointer; box-shadow: var(--sh-sm); text-align: left; min-width: 0; transition: transform .12s; }
.picker:hover { transform: translateY(-1px); }
.picker .pa { width: 42px; height: 42px; flex: none; border-radius: 13px; display: grid; place-items: center; }
.picker .pa svg { width: 40px; height: 40px; }
.picker .pt { display: flex; flex-direction: column; min-width: 0; }
.picker b { font-family: var(--display); font-size: 18px; line-height: 1.1; }
.picker small { font-size: 12px; color: var(--ink-3); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.picker .chev { width: 18px; height: 18px; flex: none; color: var(--ink-3); }
.top-r { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.usage-pill { font-size: 13px; font-weight: 700; background: var(--card); border: 2px solid var(--line); border-radius: 999px; padding: 6px 12px; white-space: nowrap; color: var(--ink-2); }
.usage-pill:empty { display: none; }
.icon-btn { border: 0; background: none; cursor: pointer; padding: 6px; border-radius: 10px; font-size: 18px; }
.icon-btn svg { width: 26px; height: 26px; }
.only-m { display: none; }
.notice { margin: 12px 20px 0; padding: 11px 16px; border-radius: 14px; border: 2px solid #f5d27a; background: #fff8e1; font-size: 14px; font-weight: 600; color: #6f5200; display: flex; gap: 10px; align-items: center; }
.notice.err { border-color: #f3a7ae; background: #fff0f1; color: #a12a37; }

.view { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 0; }

/* ---------- chat ---------- */
.msgs { flex: 1; overflow-y: auto; padding: 26px 20px 10px; scroll-behavior: smooth; }
.msgs-in { max-width: 820px; margin: 0 auto; display: grid; gap: 22px; }
.msg { display: flex; gap: 12px; align-items: flex-start; animation: rise .25s ease; }
@keyframes rise { from { opacity: 0; transform: translateY(6px) } }
.msg .av { width: 40px; height: 40px; flex: none; border-radius: 13px; display: grid; place-items: center; border: 2px solid var(--ink); background: var(--card); }
.msg .av svg { width: 38px; height: 38px; }
.msg .bub { min-width: 0; max-width: 100%; }
.msg .name { font-size: 12.5px; font-weight: 800; color: var(--ink-3); margin-bottom: 4px; text-transform: uppercase; letter-spacing: .06em; }
.msg.bot .content { background: var(--card); border: 2px solid var(--ink); border-radius: 4px 18px 18px 18px; padding: 12px 16px; box-shadow: var(--sh-sm); }
.msg.me { flex-direction: row-reverse; }
.msg.me .bub { display: flex; flex-direction: column; align-items: flex-end; max-width: 85%; }
.msg.me .content { background: var(--violet); color: #fff; border: 2px solid var(--ink); border-radius: 18px 4px 18px 18px; padding: 11px 16px; white-space: pre-wrap; word-break: break-word; box-shadow: var(--sh-sm); }
.msg.me .av { background: var(--sun); font-family: var(--display); font-weight: 700; font-size: 15px; }
.msg.err .content { border-color: #d93f4f; background: #fff0f1; color: #a12a37; }
.content { font-size: 15.5px; line-height: 1.6; word-wrap: break-word; overflow-wrap: anywhere; }
.content > :first-child { margin-top: 0; }
.content > :last-child { margin-bottom: 0; }
.content p, .content ul, .content ol, .content pre, .content blockquote, .content h3, .content h4 { margin: 0 0 10px; }
.content ul, .content ol { padding-left: 22px; }
.content li { margin: 3px 0; }
.content h3, .content h4 { font-size: 18px; }
.content a { color: var(--violet); font-weight: 600; }
.content code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13.5px; background: var(--violet-soft); padding: 1px 6px; border-radius: 6px; }
.content blockquote { border-left: 4px solid var(--violet-2); padding-left: 12px; color: var(--ink-2); }
.content hr { border: 0; border-top: 2px solid var(--line); margin: 14px 0; }
.code { position: relative; margin: 0 0 10px; border-radius: 12px; background: #1d1b3a; color: #e9e7ff; overflow: hidden; }
.code .ch { display: flex; justify-content: space-between; align-items: center; padding: 6px 12px; font-size: 12px; font-weight: 700; color: #a9a4dc; background: rgba(255, 255, 255, .05); }
.code .ch button { border: 0; background: rgba(255, 255, 255, .1); color: #fff; font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 7px; cursor: pointer; }
.code pre { margin: 0; padding: 12px 14px; overflow-x: auto; }
.code code { background: none; padding: 0; color: inherit; font-size: 13.5px; }
.typing { display: inline-flex; gap: 5px; padding: 6px 2px; }
.typing i { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); animation: bop 1s infinite; }
.typing i:nth-child(2) { animation-delay: .15s; } .typing i:nth-child(3) { animation-delay: .3s; }
@keyframes bop { 0%, 100% { transform: translateY(0); opacity: .5 } 50% { transform: translateY(-5px); opacity: 1 } }
.msg-actions { display: flex; gap: 4px; margin-top: 6px; }
.msg-actions button { border: 0; background: none; font-size: 12.5px; font-weight: 700; color: var(--ink-3); cursor: pointer; padding: 3px 8px; border-radius: 8px; }
.msg-actions button:hover { background: var(--card); color: var(--ink); }

.welcome { text-align: center; padding: 30px 10px 10px; }
.welcome .big { width: 150px; height: 150px; margin: 0 auto 6px; animation: float 5s ease-in-out infinite; }
.welcome h2 { font-size: 32px; margin-bottom: 6px; }
.welcome .wm { color: var(--ink-2); margin-bottom: 4px; }
.welcome .tp { display: inline-flex; gap: 8px; align-items: center; margin-bottom: 22px; font-size: 13px; font-weight: 700; color: var(--ink-3); }
.sugg { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; max-width: 640px; margin: 0 auto; text-align: left; }
.sugg button { border: 2px solid var(--line); background: var(--card); border-radius: 16px; padding: 12px 14px; cursor: pointer; font-size: 14.5px; font-weight: 600; transition: border-color .15s, transform .15s; }
.sugg button:hover { border-color: var(--violet); transform: translateY(-2px); }
.sugg button small { display: block; color: var(--ink-3); font-weight: 500; font-size: 13px; }

.composer { padding: 10px 20px 14px; }
.comp-box { max-width: 820px; margin: 0 auto; display: flex; gap: 10px; align-items: flex-end; background: var(--card); border: var(--b); border-radius: 22px; padding: 8px 8px 8px 18px; box-shadow: var(--sh); }
.comp-box:focus-within { box-shadow: 0 5px 0 var(--violet); border-color: var(--violet); }
.comp-box textarea { flex: 1; border: 0; outline: 0; resize: none; background: none; font-size: 16px; line-height: 1.5; padding: 7px 0; max-height: 200px; }
.send { width: 44px; height: 44px; flex: none; border-radius: 15px; border: 2px solid var(--ink); background: var(--violet); color: #fff; cursor: pointer; display: grid; place-items: center; transition: transform .12s, opacity .15s; }
.send svg { width: 22px; height: 22px; }
.send:hover { transform: scale(1.05); }
.send:disabled { opacity: .4; cursor: not-allowed; transform: none; }
.comp-note { max-width: 820px; margin: 8px auto 0; text-align: center; font-size: 12.5px; color: var(--ink-3); }

/* ---------- studio ---------- */
.studio-view { overflow-y: auto; display: block; }
.studio-view.hide { display: none; }
.studio { display: grid; grid-template-columns: 380px 1fr; gap: 24px; padding: 24px; max-width: 1280px; width: 100%; margin: 0 auto; align-items: start; }
.studio-form { padding: 22px; position: sticky; top: 0; }
.studio-form h2 { font-size: 26px; margin-bottom: 8px; }
.lbl { display: block; font-size: 12.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-3); margin: 16px 0 8px; }
.artists { display: grid; gap: 8px; }
.artist { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 2px solid var(--line); border-radius: 14px; cursor: pointer; background: var(--card); text-align: left; position: relative; }
.artist.on { border-color: var(--ink); box-shadow: var(--sh-sm); background: var(--violet-soft); }
.artist.locked { opacity: .6; }
.artist svg.a { width: 40px; height: 40px; flex: none; }
.artist b { font-family: var(--display); font-size: 17px; display: block; line-height: 1.1; }
.artist small { font-size: 12px; color: var(--ink-3); font-weight: 600; }
.artist .chip { margin-left: auto; font-size: 10.5px; }
#prompt { width: 100%; border: 2px solid var(--line); border-radius: 14px; padding: 12px 14px; resize: vertical; background: var(--bg); outline: 0; font-size: 15px; min-height: 100px; }
#prompt:focus { border-color: var(--violet); background: var(--card); }
.ideas { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.ideas button { border: 1.5px dashed var(--ink-3); background: none; border-radius: 999px; font-size: 12.5px; font-weight: 600; padding: 4px 10px; cursor: pointer; color: var(--ink-2); }
.ideas button:hover { border-color: var(--violet); color: var(--violet); }
.styles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.styles button { border: 2px solid var(--line); background: var(--card); border-radius: 12px; padding: 8px 4px; font-size: 13px; font-weight: 700; cursor: pointer; }
.styles button.on { border-color: var(--ink); background: var(--sun); box-shadow: 0 2px 0 var(--ink); }
.gen { width: 100%; margin-top: 20px; }

.canvas { aspect-ratio: 1 / 1; max-height: 560px; width: 100%; padding: 0; overflow: hidden; display: grid; place-items: center; background: repeating-conic-gradient(#f3f0ff 0 25%, #fff 0 50%) 0 0 / 28px 28px; position: relative; }
.canvas img { width: 100%; height: 100%; object-fit: contain; background: #fff; cursor: zoom-in; }
.canvas .ph { text-align: center; padding: 30px; max-width: 360px; }
.canvas .ph svg { width: 130px; height: 130px; margin: 0 auto 10px; }
.canvas .ph h3 { font-size: 22px; margin-bottom: 6px; }
.canvas .ph p { color: var(--ink-2); font-size: 14.5px; }
.canvas.busy .ph svg { animation: paint 1.2s ease-in-out infinite; }
@keyframes paint { 0%, 100% { transform: rotate(-6deg) } 50% { transform: rotate(6deg) translateY(-6px) } }
.progress { width: 220px; height: 10px; border-radius: 99px; border: 2px solid var(--ink); margin: 14px auto 0; overflow: hidden; background: var(--card); }
.progress i { display: block; height: 100%; width: 40%; background: linear-gradient(90deg, var(--violet), var(--coral), var(--sun)); animation: load 1.4s ease-in-out infinite; border-radius: 99px; }
@keyframes load { 0% { transform: translateX(-100%) } 100% { transform: translateX(260%) } }
.gal-head { display: flex; justify-content: space-between; align-items: baseline; margin: 26px 0 12px; }
.gal-head h3 { font-size: 22px; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.gallery figure { margin: 0; border: 2px solid var(--ink); border-radius: 14px; overflow: hidden; background: var(--card); cursor: pointer; box-shadow: var(--sh-sm); transition: transform .15s; }
.gallery figure:hover { transform: translateY(-3px); }
.gallery img { width: 100%; aspect-ratio: 1; object-fit: cover; }
.gallery figcaption { font-size: 12.5px; padding: 7px 9px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink-2); font-weight: 600; }
.gal-empty { grid-column: 1 / -1; font-size: 14px; color: var(--ink-3); padding: 20px; text-align: center; border: 2px dashed var(--line); border-radius: 14px; }

/* ---------- gate ---------- */
.gate { position: absolute; inset: 0; z-index: 30; display: grid; place-items: center; padding: 20px; background: rgba(246, 244, 255, .7); backdrop-filter: blur(6px); }
.gate-card { max-width: 500px; text-align: center; padding: 34px 30px; }
.gate-mons { display: flex; justify-content: center; margin-bottom: 10px; }
.gate-mons svg { width: 96px; height: 96px; margin: 0 -10px; animation: float 5s ease-in-out infinite; }
.gate-mons svg:nth-child(2) { width: 120px; height: 120px; animation-delay: -1.5s; position: relative; z-index: 1; }
.gate-mons svg:nth-child(3) { animation-delay: -3s; }
.gate-card h2 { font-size: 30px; margin-bottom: 10px; }
.gate-perks { display: flex; gap: 8px 16px; justify-content: center; flex-wrap: wrap; margin: 18px 0 24px; font-size: 14px; font-weight: 600; color: var(--ink-2); }

/* ---------- modals ---------- */
.pick-card { width: min(860px, 100%) !important; max-height: 88dvh; overflow-y: auto; }
.pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.pick { border: 2px solid var(--line); border-radius: 18px; padding: 12px; cursor: pointer; background: var(--card); text-align: left; display: flex; flex-direction: column; gap: 6px; position: relative; transition: border-color .15s, transform .15s; }
.pick:hover { border-color: var(--violet); transform: translateY(-2px); }
.pick.on { border-color: var(--ink); box-shadow: var(--sh-sm); background: var(--violet-soft); }
.pick.locked { cursor: not-allowed; }
.pick.locked .pav { filter: grayscale(.7); opacity: .6; }
.pick .pav { height: 92px; border-radius: 12px; display: grid; place-items: center; }
.pick .pav svg { width: 84px; height: 84px; }
.pick b { font-family: var(--display); font-size: 19px; }
.pick small { font-size: 12px; color: var(--ink-3); font-weight: 600; }
.pick .chip { position: absolute; top: 18px; right: 18px; font-size: 10.5px; }
.pick .lock { font-size: 12px; font-weight: 700; color: #8a6200; }
.lb-card { width: min(980px, 100%) !important; padding: 0 !important; overflow: hidden; display: grid; grid-template-columns: 1.4fr 1fr; max-height: 90dvh; }
.lb-card img { width: 100%; height: 100%; object-fit: contain; background: #f3f0ff; max-height: 90dvh; }
.lb-info { padding: 26px 22px; display: flex; flex-direction: column; gap: 10px; overflow-y: auto; }
.lb-info #lbPrompt { font-size: 16px; font-weight: 600; }
.lb-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: auto; }
.wallet-pop { position: absolute; right: 20px; top: 66px; z-index: 70; width: 260px; padding: 14px; }
.wallet-pop .addr { font-family: ui-monospace, monospace; font-size: 13px; word-break: break-all; background: var(--bg); padding: 8px 10px; border-radius: 10px; margin: 8px 0 10px; }
.wallet-pop .btn { width: 100%; margin-top: 6px; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) { .studio { grid-template-columns: 1fr; } .studio-form { position: static; } .canvas { max-height: 480px; } }
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: min(310px, 86vw); transform: translateX(-102%); transition: transform .25s ease; }
  .side.open { transform: none; box-shadow: 10px 0 40px rgba(0, 0, 0, .2); }
  .scrim { position: fixed; inset: 0; background: rgba(29, 27, 58, .45); z-index: 55; display: none; }
  .scrim.on { display: block; }
  .only-m { display: inline-flex; }
  .top { padding: 10px 12px; gap: 8px; }
  .usage-pill { display: none; }
  .picker b { font-size: 16px; }
  .msgs { padding: 18px 12px 6px; }
  .composer { padding: 6px 10px calc(10px + env(safe-area-inset-bottom)); }
  .sugg { grid-template-columns: 1fr; }
  .studio { padding: 14px; }
  .lb-card { grid-template-columns: 1fr; overflow-y: auto; }
  .lb-card img { max-height: 60dvh; }
  .msg.me .bub { max-width: 92%; }
}
@media (max-width: 420px) { .picker small { display: none; } #walletBtn { padding: 8px 12px; font-size: 14px; } }
.md-t { border-collapse: collapse; margin: 0 0 10px; font-size: 14.5px; }
.md-t th, .md-t td { border: 1.5px solid var(--line); padding: 6px 10px; text-align: left; }
.md-t th { background: var(--bg); }

.drop { display: grid; place-items: center; min-height: 150px; border: 2px dashed var(--ink-3); border-radius: 14px; background: var(--bg); cursor: pointer; overflow: hidden; position: relative; transition: border-color .15s, background .15s; }
.drop:hover, .drop.over { border-color: var(--violet); background: var(--violet-soft); }
.drop-empty { display: grid; justify-items: center; gap: 4px; text-align: center; padding: 18px; color: var(--ink-2); }
.drop-empty svg { width: 30px; height: 30px; color: var(--violet); }
.drop-empty small { font-size: 12.5px; color: var(--ink-3); }
.drop img { width: 100%; max-height: 260px; object-fit: contain; background: #fff; }
.shapes { display: flex; gap: 6px; }
.shapes button { flex: 1; border: 2px solid var(--line); background: var(--card); border-radius: 12px; padding: 8px 4px 6px; cursor: pointer; display: grid; justify-items: center; gap: 4px; font-size: 12px; font-weight: 700; }
.shapes button i { display: block; border: 2px solid var(--ink-2); border-radius: 3px; }
.shapes button.on { border-color: var(--ink); background: var(--sun); box-shadow: 0 2px 0 var(--ink); }
.canvas.multi { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; place-items: stretch; }
.canvas.multi img { object-fit: cover; }
