:root {
  --bg: #fbfaf8;
  --panel: #ffffff;
  --panel-2: #f4f2ee;
  --line: #e7e3dc;
  --ink: #1b1a17;
  --ink-2: #57534b;
  --ink-3: #8c867b;
  --brand: #ff5a36;
  --brand-2: #ff8a3d;
  --brand-ink: #ffffff;
  --accent: #6b5cff;
  --ok: #1f9d55;
  --warn: #c07a00;
  --bad: #d23c3c;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 15, 5, .05), 0 8px 30px rgba(20, 15, 5, .07);
  --glow-1: #ffd7c2;
  --glow-2: #e6dcff;
  --glow-3: #ffe9b8;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121110;
    --panel: #1b1a18;
    --panel-2: #24221f;
    --line: #34312c;
    --ink: #f3f0ea;
    --ink-2: #bfb9ae;
    --ink-3: #8a847a;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 30px rgba(0,0,0,.35);
    --glow-1: #4a2215;
    --glow-2: #261f4d;
    --glow-3: #3d2e0d;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button, input, textarea, select { font: inherit; color: inherit; }
.hidden { display: none !important; }

/* ---------- buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 14px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--panel); cursor: pointer;
  font-weight: 550; font-size: 14px; white-space: nowrap; text-decoration: none;
  transition: background .15s, border-color .15s, transform .05s, opacity .15s;
}
.btn:hover { background: var(--panel-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn.primary:hover { opacity: .9; }
.btn.brand { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; border: 0; box-shadow: 0 6px 20px -6px rgba(255, 90, 54, .6); }
.btn.brand:hover { filter: brightness(1.05); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--panel-2); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn.icon { width: 38px; padding: 0; }
.btn.sm.icon { width: 30px; }
.btn.on { background: var(--panel-2); border-color: var(--ink-3); }
.btn svg { width: 16px; height: 16px; flex: none; }

.input, .textarea {
  width: 100%; border: 1px solid var(--line); background: var(--panel); border-radius: 10px;
  padding: 10px 12px; outline: none; transition: border-color .15s, box-shadow .15s;
}
.input:focus, .textarea:focus { border-color: var(--ink-3); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.textarea { resize: vertical; min-height: 80px; }
label.field { display: grid; gap: 6px; font-size: 13px; color: var(--ink-2); font-weight: 500; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line); background: var(--panel); border-radius: 999px;
  padding: 6px 12px; font-size: 13px; cursor: pointer; transition: all .15s; color: var(--ink-2);
}
.chip:hover { border-color: var(--ink-3); color: var(--ink); }
.chip.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--panel-2); color: var(--ink-2); font-weight: 550; }
.badge.live { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }
.badge.live::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.muted { color: var(--ink-3); }
.spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--brand); animation: spin .7s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- landing / dashboard ---------- */
.glow { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.glow::before, .glow::after, .glow i {
  content: ""; position: absolute; border-radius: 50%; filter: blur(80px); opacity: .9;
}
.glow::before { width: 60vw; height: 60vw; left: -10vw; top: -25vw; background: var(--glow-1); }
.glow::after { width: 55vw; height: 55vw; right: -15vw; top: -10vw; background: var(--glow-2); }
.glow i { width: 40vw; height: 40vw; left: 30vw; top: 10vw; background: var(--glow-3); opacity: .6; }

.topnav { display: flex; align-items: center; justify-content: space-between; padding: 14px 24px; }
.logo { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: -.01em; text-decoration: none; }
.logo-mark { width: 28px; height: 28px; border-radius: 8px; background: linear-gradient(135deg, var(--brand), var(--accent)); display: grid; place-items: center; color: #fff; }
.logo-mark svg { width: 16px; height: 16px; }

.hero { max-width: 760px; margin: 48px auto 0; padding: 0 16px; text-align: center; }
.hero h1 { font-size: clamp(32px, 5vw, 54px); line-height: 1.05; letter-spacing: -.035em; margin: 0 0 14px; font-weight: 750; }
.hero p { font-size: 17px; color: var(--ink-2); margin: 0 auto 28px; max-width: 560px; }

.composer-card {
  max-width: 760px; margin: 0 auto; background: var(--panel); border: 1px solid var(--line);
  border-radius: 22px; box-shadow: var(--shadow); padding: 16px; text-align: left;
}
.gbp-row { display: flex; gap: 8px; }
.gbp-row .input { height: 46px; font-size: 15px; padding-left: 40px; }
.gbp-wrap { position: relative; flex: 1; }
.gbp-wrap svg { position: absolute; left: 13px; top: 15px; width: 17px; height: 17px; color: var(--ink-3); }
.gbp-row .btn { height: 46px; }
.candidates { display: grid; gap: 8px; margin-top: 10px; }
.notice { padding: 12px 14px; border-radius: 12px; background: color-mix(in srgb, var(--warn) 10%, var(--panel)); border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent); font-size: 14px; color: var(--ink-2); line-height: 1.55; }
.notice b { color: var(--ink); }
.cand {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 12px; cursor: pointer; background: var(--panel); text-align: left; width: 100%;
}
.cand:hover { border-color: var(--ink-3); }
.cand.on { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent); }
.cand .pin { width: 36px; height: 36px; border-radius: 10px; background: var(--panel-2); display: grid; place-items: center; flex: none; }
.cand .pin svg { width: 18px; height: 18px; color: var(--brand); }
.cand b { display: block; font-weight: 600; }
.cand small { color: var(--ink-3); }
.stars { color: #f5a623; font-weight: 600; }

.prompt-box { margin-top: 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); }
.prompt-box textarea { border: 0; width: 100%; resize: none; min-height: 92px; padding: 14px; outline: none; background: transparent; font-size: 15px; }
.prompt-tools { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.opts { display: grid; gap: 14px; margin-top: 14px; }
.opts .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.opts h4 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); font-weight: 600; }
details.more summary { cursor: pointer; color: var(--ink-2); font-size: 14px; font-weight: 550; list-style: none; display: inline-flex; gap: 6px; align-items: center; }
details.more summary::-webkit-details-marker { display: none; }
details.more[open] summary { margin-bottom: 12px; }

.projects { max-width: 1120px; margin: 64px auto 80px; padding: 0 16px; }
.projects h2 { font-size: 18px; margin: 0 0 16px; letter-spacing: -.01em; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.pcard { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; text-decoration: none; transition: transform .15s, box-shadow .15s; display: block; }
.pcard:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.pthumb { aspect-ratio: 16/10; background: var(--panel-2); position: relative; overflow: hidden; }
.pthumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pthumb .initial { position: absolute; inset: 0; display: grid; place-items: center; font-size: 42px; font-weight: 750; color: #fff; }
.pmeta { padding: 12px 14px; display: grid; gap: 4px; }
.pmeta b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pmeta .row { display: flex; gap: 8px; align-items: center; justify-content: space-between; font-size: 12px; color: var(--ink-3); }
.empty { color: var(--ink-3); padding: 40px; text-align: center; border: 1px dashed var(--line); border-radius: var(--radius); }

/* ---------- editor ---------- */
.editor { display: grid; grid-template-rows: 56px 1fr; height: 100vh; }
.ebar { display: flex; align-items: center; gap: 8px; padding: 0 12px; border-bottom: 1px solid var(--line); background: var(--panel); }
.ebar .name { font-weight: 600; border: 1px solid transparent; background: transparent; border-radius: 8px; padding: 4px 8px; min-width: 60px; max-width: 280px; }
.ebar .name:hover, .ebar .name:focus { border-color: var(--line); outline: none; }
.ebar .spacer { flex: 1; }
.seg { display: inline-flex; background: var(--panel-2); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; height: 30px; padding: 0 10px; border-radius: 8px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); font-size: 13px; font-weight: 550; }
.seg button svg { width: 16px; height: 16px; }
.seg button.on { background: var(--panel); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.08); }

.ebody { display: grid; grid-template-columns: 420px 1fr; min-height: 0; }
.chat { display: grid; grid-template-rows: 1fr auto; border-right: 1px solid var(--line); background: var(--panel); min-height: 0; }
.thread { overflow-y: auto; padding: 18px 16px 8px; display: flex; flex-direction: column; gap: 14px; }
.msg { max-width: 100%; white-space: pre-wrap; word-wrap: break-word; }
.msg.user { align-self: flex-end; background: var(--panel-2); padding: 10px 14px; border-radius: 16px 16px 4px 16px; max-width: 85%; }
.msg.user .sel { display: block; font-size: 11px; color: var(--accent); margin-bottom: 4px; font-family: ui-monospace, monospace; }
.msg.ai { display: grid; grid-template-columns: 26px 1fr; gap: 10px; }
.msg.ai .av { width: 26px; height: 26px; border-radius: 8px; background: linear-gradient(135deg, var(--brand), var(--accent)); display: grid; place-items: center; color: #fff; }
.msg.ai .av svg { width: 14px; height: 14px; }
.msg.ai .body { padding-top: 2px; }
.msg .vtag { display: inline-flex; margin-top: 8px; font-size: 12px; color: var(--ink-3); gap: 6px; align-items: center; cursor: pointer; border: 1px solid var(--line); border-radius: 8px; padding: 3px 8px; white-space: nowrap; }
.msg .vtag:hover { color: var(--ink); }

.steps { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; display: grid; gap: 8px; background: var(--bg); font-size: 14px; }
.step { display: flex; align-items: center; gap: 10px; color: var(--ink-2); }
.step.done { color: var(--ink); }
.step .tick { width: 14px; height: 14px; color: var(--ok); flex: none; }
.thinking { font-size: 13px; color: var(--ink-3); }
.thinking summary { cursor: pointer; }
.thinking div { white-space: pre-wrap; max-height: 160px; overflow: auto; margin-top: 6px; padding-left: 10px; border-left: 2px solid var(--line); }

.brief { border: 1px solid var(--line); border-radius: 12px; padding: 12px; display: grid; gap: 10px; font-size: 13px; }
.swatches { display: flex; gap: 6px; }
.swatches span { width: 26px; height: 26px; border-radius: 8px; border: 1px solid rgba(0,0,0,.08); }
.brief .tags { display: flex; flex-wrap: wrap; gap: 6px; }
.brief .tags span { background: var(--panel-2); border-radius: 6px; padding: 2px 8px; color: var(--ink-2); }

.compose { padding: 12px; border-top: 1px solid var(--line); display: grid; gap: 8px; }
.suggest { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.suggest .chip { white-space: nowrap; font-size: 12px; padding: 5px 10px; }
.cbox { border: 1px solid var(--line); border-radius: 16px; background: var(--panel); transition: border-color .15s, box-shadow .15s; }
.cbox:focus-within { border-color: var(--ink-3); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent); }
.cbox textarea { width: 100%; border: 0; outline: none; resize: none; background: transparent; padding: 12px 14px 4px; min-height: 52px; max-height: 200px; }
.cbox .tools { display: flex; align-items: center; gap: 6px; padding: 6px 8px 8px; }
.cbox .tools .spacer { flex: 1; }
.selchip { display: flex; align-items: center; gap: 8px; margin: 8px 8px 0; padding: 6px 10px; border-radius: 10px; background: color-mix(in srgb, var(--accent) 10%, transparent); color: var(--accent); font-size: 12px; font-family: ui-monospace, monospace; }
.selchip span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.selchip button { border: 0; background: none; cursor: pointer; color: inherit; font-size: 16px; line-height: 1; }
.attach { display: flex; gap: 6px; padding: 8px 8px 0; flex-wrap: wrap; }
.attach img { width: 44px; height: 44px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.send { width: 34px; height: 34px; border-radius: 10px; border: 0; background: var(--ink); color: var(--bg); display: grid; place-items: center; cursor: pointer; }
.send:disabled { opacity: .35; cursor: not-allowed; }
.send svg { width: 16px; height: 16px; }

.stage { position: relative; background: var(--panel-2); display: grid; place-items: stretch; min-height: 0; overflow: hidden; }
.frame-wrap { position: relative; margin: 0 auto; width: 100%; height: 100%; transition: width .25s ease, margin .25s, border-radius .25s; background: #fff; }
.frame-wrap.tablet { width: 820px; max-width: calc(100% - 32px); margin: 16px auto; height: calc(100% - 32px); border-radius: 18px; overflow: hidden; box-shadow: var(--shadow); }
.frame-wrap.mobile { width: 390px; margin: 16px auto; height: calc(100% - 32px); border-radius: 28px; overflow: hidden; box-shadow: var(--shadow); border: 8px solid #111; }
.frame-wrap iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #fff; }
.frame-wrap iframe.back { visibility: hidden; }
.placeholder { position: absolute; inset: 0; display: grid; place-items: center; background: var(--bg); z-index: 2; }
.placeholder .inner { text-align: center; color: var(--ink-2); display: grid; gap: 14px; justify-items: center; max-width: 340px; }
.orb { width: 64px; height: 64px; border-radius: 50%; background: conic-gradient(from 0deg, var(--brand), var(--accent), var(--brand-2), var(--brand)); animation: spin 2.4s linear infinite; filter: blur(.5px); box-shadow: 0 0 60px -10px var(--brand); }
.building-pill { position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 3; background: var(--ink); color: var(--bg); border-radius: 999px; padding: 8px 14px; font-size: 13px; display: flex; gap: 8px; align-items: center; box-shadow: var(--shadow); }
.code { position: absolute; inset: 0; display: grid; grid-template-rows: 1fr auto; background: #0f0f10; }
.code textarea { width: 100%; height: 100%; border: 0; outline: none; resize: none; background: #0f0f10; color: #e7e3da; font: 12.5px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; padding: 16px; tab-size: 2; }
.code .bar { display: flex; gap: 8px; justify-content: flex-end; padding: 8px 12px; background: #18181a; border-top: 1px solid #2a2a2d; }
.viewing { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 4; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 6px 6px 6px 12px; display: flex; gap: 8px; align-items: center; box-shadow: var(--shadow); font-size: 13px; }

.pop { position: absolute; right: 12px; top: 52px; z-index: 50; width: 360px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); padding: 16px; display: grid; gap: 12px; }
.pop h3 { margin: 0; font-size: 15px; }
.pop .url { display: flex; gap: 6px; }
.pop .url .input { font-size: 13px; }
.menu { position: absolute; z-index: 50; top: 52px; width: 320px; max-height: 60vh; overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 6px; }
.menu button { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; text-align: left; width: 100%; border: 0; background: none; border-radius: 10px; padding: 8px 10px; cursor: pointer; }
.menu button:hover { background: var(--panel-2); }
.menu button small { color: var(--ink-3); grid-column: 1 / -1; }
.menu .cur { color: var(--brand); font-size: 12px; font-weight: 600; }

.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 100; display: grid; place-items: center; padding: 16px; }
.modal { background: var(--panel); border-radius: 18px; width: min(720px, 100%); max-height: 80vh; overflow: auto; padding: 20px; box-shadow: var(--shadow); }
.modal table { width: 100%; border-collapse: collapse; font-size: 13px; }
.modal td, .modal th { text-align: left; padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px; z-index: 200; box-shadow: var(--shadow); animation: up .2s ease; }
@keyframes up { from { opacity: 0; transform: translate(-50%, 8px); } }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login form { width: min(360px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 28px; box-shadow: var(--shadow); display: grid; gap: 14px; }
.login h1 { margin: 0; font-size: 22px; letter-spacing: -.02em; }

.mobile-tabs { display: none; }
@media (max-width: 900px) {
  .ebody { grid-template-columns: 1fr; }
  .ebody.show-preview .chat, .ebody:not(.show-preview) .stage { display: none; }
  .mobile-tabs { display: inline-flex; }
  .desk-only { display: none !important; }
  .opts .row2 { grid-template-columns: 1fr; }
  .gbp-row { flex-direction: column; }
  .pop { width: calc(100vw - 24px); }
}
