:root {
  --bg: #0b0709;
  --panel: #120b0f;
  --panel-2: #180e13;
  --line: #2c1a22;
  --line-soft: #211319;
  --ink: #f7ecef;
  --muted: #b9a4ac;
  --dim: #8d747d;
  --red: #ff2d55;
  --red-deep: #d9143d;
  --amber: #ffb86b;
  --green: #6ee7a8;
  --blue: #8bb8ff;
  --radius: 18px;
  --sans: "DM Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --serif: "DM Serif Display", "Iowan Old Style", Georgia, serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { min-height: 100%; }
body {
  margin: 0;
  background:
    radial-gradient(900px 460px at 82% -8%, rgb(255 45 85 / 0.16), transparent 62%),
    radial-gradient(700px 420px at -10% 110%, rgb(255 184 107 / 0.08), transparent 60%),
    var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
::selection { background: rgb(255 45 85 / 0.35); }

/* ---------- landing ---------- */
.landing { width: min(1120px, calc(100% - 40px)); margin: 0 auto; }
.nav { display: flex; align-items: center; justify-content: space-between; padding: 26px 0; }
.brand { display: inline-flex; align-items: baseline; gap: 2px; text-decoration: none; font-weight: 800; letter-spacing: -0.06em; font-size: 22px; }
.brand b { color: var(--red); font-weight: 800; }
.brand span { color: var(--dim); font-weight: 500; letter-spacing: 0; font-size: 12px; margin-left: 8px; text-transform: uppercase; }
.nav-links { display: flex; align-items: center; gap: 20px; color: var(--muted); font-size: 14px; }
.nav-links a { text-decoration: none; }
.nav-links a:hover { color: var(--ink); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 0 18px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--panel); color: var(--ink); text-decoration: none; font-weight: 600; font-size: 14px;
  transition: border-color .18s, transform .18s, background .18s;
}
.btn:hover { border-color: #5a2b3a; transform: translateY(-1px); }
.btn.primary { background: var(--red); border-color: var(--red); color: #1b040a; }
.btn.primary:hover { background: #ff4568; }
.btn.ghost { background: transparent; }
.btn.small { min-height: 34px; padding: 0 13px; font-size: 12px; }

.hero { display: grid; grid-template-columns: 1.05fr .95fr; gap: 56px; align-items: center; padding: 62px 0 48px; }
.kicker { display: inline-flex; align-items: center; gap: 9px; color: var(--amber); font-size: 12px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; }
.kicker i { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 16px var(--green); }
h1.hero-title { font-family: var(--serif); font-weight: 400; font-size: clamp(54px, 7.2vw, 96px); line-height: .92; letter-spacing: -0.035em; margin: 20px 0 22px; }
h1.hero-title em { color: var(--red); font-style: italic; }
.hero-copy { color: var(--muted); font-size: 18px; line-height: 1.65; max-width: 44ch; margin: 0 0 28px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.hero-note { color: var(--dim); font-size: 12px; margin-top: 18px; }
.hero-card {
  position: relative; padding: 18px; border: 1px solid var(--line); border-radius: 24px;
  background: linear-gradient(160deg, #1b0f14, #0e080b 72%);
  box-shadow: 0 30px 80px rgb(0 0 0 / .45), inset 0 1px 0 rgb(255 255 255 / .04);
}
.hero-card::before { content: ""; position: absolute; inset: 12px; border: 1px dashed rgb(255 255 255 / .07); border-radius: 16px; pointer-events: none; }
.mockbar { display: flex; gap: 6px; padding: 4px 4px 14px; }
.mockbar i { width: 8px; height: 8px; border-radius: 50%; background: #3a222b; }
.mockbar i:first-child { background: var(--red); }
.chat-mock { display: grid; gap: 12px; }
.mock-msg { padding: 13px 15px; border-radius: 14px; border: 1px solid var(--line-soft); background: #100a0d; font-size: 13.5px; line-height: 1.55; color: #d9c8ce; }
.mock-msg.user { margin-left: 34px; background: #251018; border-color: #40202b; }
.mock-msg.ai { margin-right: 22px; }
.mock-tag { display: inline-flex; align-items: center; gap: 6px; color: var(--green); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; margin-bottom: 8px; }
.mock-tag i { width: 5px; height: 5px; border-radius: 50%; background: var(--green); }
.mock-code { margin-top: 9px; padding: 10px; border-radius: 9px; background: #080506; border: 1px solid #24141a; font-family: var(--mono); font-size: 11px; color: #c7b2ba; overflow: hidden; }

.features { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; padding: 20px 0 70px; }
.feature { padding: 20px; border: 1px solid var(--line); border-radius: var(--radius); background: rgb(18 11 15 / .72); }
.feature b { display: block; font-size: 14px; margin-bottom: 6px; }
.feature p { margin: 0; color: var(--muted); font-size: 12.5px; line-height: 1.55; }
.feature .num { color: var(--red); font-family: var(--serif); font-size: 28px; line-height: 1; display: block; margin-bottom: 12px; }

/* ---------- app shell ---------- */
.app { display: grid; grid-template-columns: 286px minmax(0, 1fr); height: 100dvh; overflow: hidden; }
.sidebar { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); background: rgb(13 8 11 / .86); backdrop-filter: blur(18px); }
.side-head { padding: 20px 18px 14px; display: flex; align-items: center; justify-content: space-between; }
.side-user { margin: 0 12px 12px; padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); }
.side-user .who { display: flex; align-items: center; gap: 10px; }
.avatar { width: 30px; height: 30px; border-radius: 10px; display: grid; place-items: center; background: linear-gradient(140deg, #ff2d55, #8c1630); color: #25060e; font-weight: 800; font-size: 12px; }
.side-user strong { display: block; font-size: 13px; }
.side-user small { color: var(--dim); font-size: 11px; }
.side-user .user-actions { display: flex; gap: 8px; margin-top: 10px; }
.side-scroll { flex: 1; min-height: 0; overflow: auto; padding: 0 12px 16px; }
.side-label { display: flex; align-items: center; justify-content: space-between; padding: 16px 6px 8px; color: var(--dim); font-size: 10px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; }
.side-label button { width: 24px; height: 24px; border-radius: 8px; border: 1px solid var(--line); background: transparent; color: var(--muted); font-size: 16px; line-height: 1; }
.side-label button:hover { color: var(--ink); border-color: #5a2b3a; }
.project-list, .session-list { display: grid; gap: 3px; }
.project, .session {
  width: 100%; text-align: left; border: 1px solid transparent; background: transparent; color: var(--muted);
  border-radius: 10px; padding: 9px 10px; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.project:hover, .session:hover { color: var(--ink); background: #160d11; }
.project.active, .session.active { color: var(--ink); background: #201018; border-color: #3a1d27; }
.project small, .session small { display: block; color: var(--dim); font-size: 10px; margin-top: 2px; }
.side-foot { padding: 12px 18px 16px; border-top: 1px solid var(--line-soft); color: var(--dim); font-size: 11px; line-height: 1.5; }
.side-foot b { color: var(--green); }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar { display: flex; align-items: center; gap: 14px; padding: 14px 22px; border-bottom: 1px solid var(--line); background: rgb(11 7 9 / .75); backdrop-filter: blur(14px); }
.menu-btn { display: none; width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); }
.crumbs { min-width: 0; flex: 1; }
.crumbs strong { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumbs small { display: block; color: var(--dim); font-size: 11px; margin-top: 2px; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.model-picker { position: relative; min-width: 0; }
.model-trigger { display: flex; align-items: center; gap: 8px; min-height: 38px; max-width: 330px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); }
.model-trigger:hover, .model-trigger[aria-expanded="true"] { border-color: #5a2b3a; background: #1b0f14; }
.model-dot { width: 7px; height: 7px; border-radius: 50%; flex: 0 0 auto; background: var(--green); box-shadow: 0 0 10px rgb(110 231 168 / .6); }
.model-dot[data-provider="gemini"] { background: var(--blue); box-shadow: 0 0 10px rgb(139 184 255 / .6); }
.model-dot[data-provider="pollinations"] { background: var(--amber); box-shadow: 0 0 10px rgb(255 184 107 / .6); }
.model-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12.5px; font-weight: 600; }
.model-free { flex: 0 0 auto; padding: 2px 6px; border-radius: 999px; background: rgb(110 231 168 / .1); color: var(--green); font-size: 8px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.model-chevron { flex: 0 0 auto; color: var(--dim); font-size: 13px; line-height: 1; }
.model-menu { position: absolute; z-index: 35; right: 0; top: calc(100% + 8px); width: 370px; max-width: calc(100vw - 28px); border: 1px solid #3a1e28; border-radius: 15px; background: #120b0f; box-shadow: 0 24px 70px rgb(0 0 0 / .65); overflow: hidden; }
.model-search { padding: 9px; border-bottom: 1px solid var(--line-soft); }
.model-search input { width: 100%; border: 1px solid var(--line); border-radius: 9px; background: #0b0709; padding: 9px 10px; outline: 0; font-size: 12px; }
.model-search input:focus { border-color: #6a2c3d; }
.model-options { max-height: min(430px, 58vh); overflow: auto; padding: 6px; scrollbar-width: thin; scrollbar-color: #3a1e28 transparent; }
.model-options::-webkit-scrollbar { width: 8px; }
.model-options::-webkit-scrollbar-track { background: transparent; }
.model-options::-webkit-scrollbar-thumb { background: #3a1e28; border-radius: 999px; }
.model-group-label { display: flex; justify-content: space-between; padding: 9px 8px 5px; color: var(--dim); font-size: 9px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.model-group-label span { color: #6f5861; letter-spacing: 0; }
.model-option { display: flex; align-items: center; gap: 9px; width: 100%; padding: 9px 9px; border: 1px solid transparent; border-radius: 9px; background: transparent; text-align: left; }
.model-option:hover, .model-option:focus-visible { background: #1b0f14; border-color: #321a24; outline: 0; }
.model-option[aria-selected="true"] { background: #251018; border-color: #40202b; }
.model-option-main { min-width: 0; flex: 1; }
.model-option-main b { display: block; font-size: 12px; font-weight: 600; color: #eadce1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.model-option-main small { display: block; margin-top: 2px; color: var(--dim); font-size: 9.5px; }
.model-check { flex: 0 0 auto; color: var(--green); font-size: 12px; opacity: 0; }
.model-option[aria-selected="true"] .model-check { opacity: 1; }
.model-empty { padding: 18px; color: var(--dim); font-size: 12px; text-align: center; }
.model-foot { display: flex; justify-content: space-between; gap: 10px; padding: 9px 12px 10px; border-top: 1px solid var(--line-soft); color: var(--dim); font-size: 9.5px; }
.status { display: inline-flex; align-items: center; gap: 6px; color: var(--green); font-size: 11px; white-space: nowrap; }
.status i { width: 6px; height: 6px; border-radius: 50%; background: var(--green); }

.chat { flex: 1; min-height: 0; overflow: auto; padding: 34px 22px 20px; scroll-behavior: smooth; }
.chat-inner { width: min(820px, 100%); margin: 0 auto; display: grid; gap: 20px; }
.empty { padding: 8vh 0 4vh; text-align: center; }
.empty .glyph { font-family: var(--serif); font-size: 56px; line-height: 1; color: var(--red); margin-bottom: 18px; }
.empty h2 { font-family: var(--serif); font-weight: 400; font-size: 34px; margin: 0 0 8px; }
.empty p { color: var(--muted); margin: 0 auto 22px; max-width: 46ch; line-height: 1.6; font-size: 14px; }
.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.chip { padding: 9px 13px; border-radius: 999px; border: 1px solid var(--line); background: #140c10; color: #d8c4ca; font-size: 12px; }
.chip:hover { border-color: #5a2b3a; color: var(--ink); }

.msg { display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 12px; align-items: start; }
.msg .who { width: 30px; height: 30px; border-radius: 10px; display: grid; place-items: center; font-size: 11px; font-weight: 800; border: 1px solid var(--line); background: #160d11; color: var(--muted); }
.msg.user .who { background: #251018; color: #ffb3c2; border-color: #40202b; }
.msg.assistant .who { background: linear-gradient(140deg, #ff2d55, #8c1630); color: #25060e; border-color: #ff2d55; }
.bubble { min-width: 0; padding-top: 3px; }
.bubble .text { font-size: 14.5px; line-height: 1.72; color: #eadce1; overflow-wrap: anywhere; }
.bubble .text p { margin: 0 0 10px; }
.bubble .text p:last-child { margin-bottom: 0; }
.bubble .text h1, .bubble .text h2, .bubble .text h3 { font-family: var(--serif); font-weight: 400; letter-spacing: -0.01em; margin: 18px 0 8px; }
.bubble .text h1 { font-size: 26px; } .bubble .text h2 { font-size: 22px; } .bubble .text h3 { font-size: 18px; }
.bubble .text ul, .bubble .text ol { margin: 0 0 10px; padding-left: 22px; }
.bubble .text li { margin: 3px 0; }
.bubble .text a { color: var(--blue); }
.bubble .text blockquote { margin: 12px 0; padding: 8px 14px; border-left: 2px solid var(--red); color: var(--muted); background: #130b0f; }
.bubble .text pre { margin: 12px 0; padding: 13px 14px; overflow: auto; border: 1px solid #26151c; border-radius: 11px; background: #080506; font-family: var(--mono); font-size: 12px; line-height: 1.55; color: #d6c1c9; }
.bubble .text code { font-family: var(--mono); font-size: .92em; padding: 1px 5px; border-radius: 5px; background: #1b0f14; color: #ffc0cd; }
.bubble .text pre code { padding: 0; background: none; color: inherit; }
.meta { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; color: var(--dim); font-size: 10px; }
.meta b { color: var(--muted); font-weight: 500; }
.typing { display: inline-flex; gap: 4px; padding: 12px 0 2px; }
.typing i { width: 5px; height: 5px; border-radius: 50%; background: var(--dim); animation: blink 1.1s infinite; }
.typing i:nth-child(2) { animation-delay: .15s; } .typing i:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%, 70%, 100% { opacity: .25; transform: translateY(0); } 35% { opacity: 1; transform: translateY(-2px); } }

.composer-wrap { padding: 10px 22px 20px; }
.composer { width: min(820px, 100%); margin: 0 auto; border: 1px solid #38202a; border-radius: 18px; background: #140c10; box-shadow: 0 18px 50px rgb(0 0 0 / .35); overflow: hidden; }
.composer textarea { display: block; width: 100%; min-height: 54px; max-height: 190px; resize: none; border: 0; outline: 0; background: transparent; padding: 16px 16px 8px; color: var(--ink); font-size: 14.5px; line-height: 1.5; }
.composer-foot { display: flex; align-items: center; gap: 10px; padding: 8px 10px 10px 16px; }
.composer-foot .hint { color: var(--dim); font-size: 10.5px; }
.send { margin-left: auto; width: 36px; height: 36px; border-radius: 11px; border: 0; background: var(--red); color: #22050c; font-weight: 800; display: grid; place-items: center; }
.send:disabled { opacity: .45; cursor: not-allowed; }
.send svg { width: 17px; height: 17px; }
.disclaimer { text-align: center; color: var(--dim); font-size: 10px; padding: 9px 0 0; }

/* ---------- modal / toast ---------- */
.modal { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 20px; background: rgb(5 3 4 / .74); backdrop-filter: blur(7px); }
.modal[hidden] { display: none; }
.sheet { width: min(440px, 100%); border: 1px solid #3a1e28; border-radius: 20px; background: #140c10; box-shadow: 0 30px 90px #000; padding: 22px; }
.sheet .eyebrow { color: var(--red); font-size: 10px; letter-spacing: .16em; text-transform: uppercase; font-weight: 700; }
.sheet h3 { font-family: var(--serif); font-weight: 400; font-size: 28px; margin: 8px 0 6px; }
.sheet p { color: var(--muted); font-size: 12.5px; line-height: 1.55; margin: 0 0 16px; }
.tabs { display: flex; gap: 4px; padding: 4px; border: 1px solid var(--line); border-radius: 10px; background: #0d080a; margin-bottom: 14px; }
.tabs button { flex: 1; border: 0; background: transparent; color: var(--muted); border-radius: 7px; padding: 8px; font-size: 12px; }
.tabs button.active { background: #2a111a; color: var(--ink); }
.field { display: grid; gap: 6px; margin-bottom: 12px; }
.field label { color: var(--dim); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; }
.field input { width: 100%; border: 1px solid var(--line); border-radius: 10px; background: #0d080a; padding: 11px 12px; outline: 0; font-size: 13px; }
.field input:focus { border-color: #6a2c3d; }
.form-error { color: #ff8fa3; font-size: 12px; margin: 2px 0 10px; }
.sheet-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.toast { position: fixed; z-index: 60; left: 50%; bottom: 26px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; padding: 10px 15px; border-radius: 999px; border: 1px solid #4a2330; background: #1d1015; color: var(--ink); font-size: 12px; transition: .2s; max-width: min(520px, calc(100% - 30px)); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 980px) {
  .hero { grid-template-columns: 1fr; gap: 34px; padding-top: 36px; }
  .hero-card { max-width: 560px; }
  .features { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 30; inset: 0 auto 0 0; width: min(290px, 86vw); transform: translateX(-102%); transition: transform .22s ease; box-shadow: 30px 0 80px #000; }
  .sidebar.open { transform: translateX(0); }
  .menu-btn { display: grid; place-items: center; }
  .topbar { padding: 11px 14px; gap: 10px; flex-wrap: wrap; row-gap: 8px; }
  .top-actions { width: 100%; margin-left: 0; justify-content: space-between; }
  .model-picker { flex: 1; }
  .model-trigger { width: 100%; max-width: none; }
  .model-menu { left: 0; right: auto; width: 100%; max-width: none; }
  .chat { padding: 22px 14px 12px; }
  .composer-wrap { padding: 8px 12px 14px; }
  .status { display: none; }
  .landing { width: min(100% - 28px, 1120px); }
  .nav-links a:not(.btn) { display: none; }
  .features { grid-template-columns: 1fr; }
  .hero-title { font-size: clamp(48px, 14vw, 76px); }
}
