:root {
  --bg: #0b0b12;
  --bg-2: #12121d;
  --panel: #171724;
  --panel-2: #1e1e2e;
  --border: #2a2a3d;
  --text: #ececf3;
  --muted: #9a9ab0;
  --accent: #7c5cff;
  --accent-2: #22d3ee;
  --danger: #ff5c7c;
  --ok: #34d399;
  --radius: 14px;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: radial-gradient(1200px 600px at 70% -10%, #1b1440 0%, transparent 60%),
    radial-gradient(900px 500px at 0% 10%, #0d2a33 0%, transparent 55%), var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-2); text-decoration: none; }
h1, h2, h3 { line-height: 1.15; }

.logo {
  width: 22px; height: 22px; border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #fff 0 18%, transparent 19%),
    linear-gradient(135deg, var(--accent), var(--accent-2));
  display: inline-block; box-shadow: 0 0 18px rgba(124, 92, 255, 0.6);
}
.logo.big { width: 46px; height: 46px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 18px; }
.brand.center { justify-content: center; margin-bottom: 6px; }
.brand b { color: var(--accent); font-weight: 700; }
.grad {
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

/* Buttons */
.btn {
  background: linear-gradient(135deg, var(--accent), #6a4bff);
  color: #fff; border: none; padding: 10px 18px; border-radius: 10px;
  font-weight: 600; cursor: pointer; font-size: 14px; transition: 0.15s;
}
.btn:hover { filter: brightness(1.08); transform: translateY(-1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn.ghost { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn.ghost:hover { border-color: var(--accent); }
.btn.lg { padding: 14px 24px; font-size: 16px; }
.btn.small { padding: 8px 12px; font-size: 13px; }
.btn.full { width: 100%; }

/* Nav */
.nav {
  display: flex; justify-content: space-between; align-items: center;
  padding: 20px 6vw; max-width: 1200px; margin: 0 auto;
}
.nav-links { display: flex; align-items: center; gap: 20px; }
.nav-links a { color: var(--muted); }
.nav-links a:hover { color: var(--text); }

/* Hero */
.hero { text-align: center; padding: 70px 6vw 40px; max-width: 860px; margin: 0 auto; }
.hero-badge {
  display: inline-block; padding: 6px 14px; border: 1px solid var(--border);
  border-radius: 999px; color: var(--muted); font-size: 13px; margin-bottom: 24px;
  background: rgba(255, 255, 255, 0.02);
}
.hero h1 { font-size: clamp(38px, 6vw, 66px); margin: 0 0 18px; letter-spacing: -1.5px; }
.sub { font-size: 18px; color: var(--muted); max-width: 640px; margin: 0 auto 32px; }
.hero-cta { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }
.hero-note { margin-top: 26px; color: var(--muted); font-size: 13px; display: flex; gap: 8px; justify-content: center; align-items: center; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); box-shadow: 0 0 8px currentColor; }
.dot.on { background: var(--ok); color: var(--ok); }
.dot.off { background: var(--danger); color: var(--danger); }

/* Features */
.features { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; max-width: 1100px; margin: 60px auto; padding: 0 6vw; }
.card { background: linear-gradient(180deg, var(--panel), var(--bg-2)); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; }
.feat h3 { margin: 0 0 8px; }
.feat p { color: var(--muted); margin: 0; }

/* Pricing */
.pricing { max-width: 900px; margin: 80px auto; padding: 0 6vw; text-align: center; }
.pricing h2 { font-size: 34px; margin-bottom: 36px; }
.plans { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.plan { text-align: left; position: relative; }
.plan.featured { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), var(--shadow); }
.plan .tag { position: absolute; top: -12px; right: 20px; background: var(--accent); padding: 4px 12px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.price { font-size: 44px; font-weight: 700; margin: 6px 0 18px; }
.price span { font-size: 16px; color: var(--muted); font-weight: 400; }
.plan ul { list-style: none; padding: 0; margin: 0 0 22px; }
.plan li { padding: 8px 0; color: var(--muted); border-bottom: 1px solid var(--border); }
.plan li::before { content: "✓ "; color: var(--ok); }

.foot { text-align: center; padding: 40px; color: var(--muted); border-top: 1px solid var(--border); }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(6px); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px; }
.modal { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 32px; width: 100%; max-width: 400px; position: relative; box-shadow: var(--shadow); }
.modal h2 { margin: 12px 0 4px; text-align: center; }
.modal-x { position: absolute; top: 14px; right: 16px; background: none; border: none; color: var(--muted); font-size: 24px; cursor: pointer; }
.muted { color: var(--muted); }
.muted.center, .modal .muted { text-align: center; }
form label { display: block; font-size: 13px; color: var(--muted); margin-top: 16px; }
form input, textarea {
  width: 100%; margin-top: 6px; padding: 12px 14px; background: var(--bg-2);
  border: 1px solid var(--border); border-radius: 10px; color: var(--text); font-size: 15px; font-family: inherit;
}
form input:focus, textarea:focus { outline: none; border-color: var(--accent); }
.form-error { color: var(--danger); font-size: 13px; min-height: 18px; margin-top: 10px; }
.switch { text-align: center; color: var(--muted); font-size: 14px; margin-top: 18px; }
.or { text-align: center; color: var(--muted); margin: 16px 0; font-size: 13px; }

/* Key box */
.key-box { background: var(--bg-2); border: 1px dashed var(--accent); border-radius: 12px; padding: 18px; text-align: center; margin: 18px 0; }
.key-label { color: var(--muted); font-size: 13px; }
.key { font-family: "SFMono-Regular", ui-monospace, monospace; font-size: 22px; letter-spacing: 2px; margin: 10px 0; color: var(--accent-2); }

/* Chat */
.chat-shell { display: grid; grid-template-columns: 280px 1fr; height: 100vh; }
.sidebar { background: var(--bg-2); border-right: 1px solid var(--border); padding: 18px; display: flex; flex-direction: column; gap: 16px; }
.host-row { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.chat-list {
  display: flex; flex-direction: column; gap: 4px;
  max-height: 42vh; overflow-y: auto; margin: 4px 0 8px;
  padding-right: 2px;
}
.chat-item {
  display: flex; align-items: center; gap: 6px;
  width: 100%; text-align: left; background: transparent;
  border: 1px solid transparent; color: var(--text);
  padding: 9px 10px; border-radius: 10px; cursor: pointer; font-size: 13px;
}
.chat-item:hover { background: var(--panel); }
.chat-item.active { background: var(--panel); border-color: var(--border); }
.chat-item .title {
  flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chat-item .del {
  opacity: 0; border: none; background: transparent; color: var(--muted);
  cursor: pointer; font-size: 15px; line-height: 1; padding: 0 4px;
}
.chat-item:hover .del, .chat-item.active .del { opacity: 1; }
.chat-item .del:hover { color: var(--danger); }
.chat-list-empty { color: var(--muted); font-size: 12px; padding: 8px 4px; }
.save-hint { font-size: 11px; color: var(--muted); margin-top: 4px; min-height: 14px; }
.spacer { flex: 1; }
.usage { padding: 16px; }
.usage-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.badge { background: var(--border); padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge.pro { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; }
.bar { height: 6px; background: var(--border); border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width 0.3s; }
.trial-line { font-size: 12px; color: var(--ok); margin-top: 10px; }
.trial-line.warn {
  color: var(--accent-2);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.trial-line.warn:hover { filter: brightness(1.15); }
.btn.trial {
  margin-top: 10px;
  background: transparent;
  border: 1px solid var(--accent-2);
  color: var(--accent-2);
}
.btn.trial:hover { background: rgba(34, 211, 238, 0.08); }
#upgrade-btn { margin-top: 14px; }
.account { display: flex; justify-content: space-between; align-items: center; font-size: 13px; }

.chat-main { display: flex; flex-direction: column; height: 100vh; }
.messages { flex: 1; overflow-y: auto; padding: 30px 8%; }
.empty { text-align: center; margin-top: 12vh; color: var(--muted); }
.empty h2 { color: var(--text); margin: 18px 0 24px; }
.chips { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.chip { background: var(--panel); border: 1px solid var(--border); color: var(--text); padding: 10px 16px; border-radius: 999px; cursor: pointer; font-size: 14px; }
.chip:hover { border-color: var(--accent); }

.msg { display: flex; gap: 14px; margin: 22px 0; max-width: 820px; margin-left: auto; margin-right: auto; }
.msg .avatar { width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; }
.msg.user .avatar { background: var(--panel-2); }
.msg.ai .avatar { background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.msg .body { padding-top: 3px; line-height: 1.6; overflow-x: auto; }
.msg .body p { margin: 0 0 12px; }
.msg .body pre { background: #0c0c14; border: 1px solid var(--border); border-radius: 10px; padding: 14px; overflow-x: auto; }
.msg .body code { font-family: ui-monospace, monospace; font-size: 13.5px; }
.msg .body :not(pre) > code { background: var(--panel-2); padding: 2px 6px; border-radius: 5px; }
.cursor-blink::after { content: "▍"; animation: blink 1s steps(2) infinite; color: var(--accent); }
@keyframes blink { 50% { opacity: 0; } }

.composer { padding: 16px 8% 22px; border-top: 1px solid var(--border); background: var(--bg-2); }
.composer form { display: flex; gap: 10px; align-items: flex-end; max-width: 820px; margin: 0 auto; background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 10px 12px; }
.composer textarea { border: none; background: transparent; resize: none; max-height: 200px; padding: 6px; margin: 0; }
.composer textarea:focus { border: none; outline: none; }

/* Model picker */
.model-picker { position: relative; flex-shrink: 0; }
.model-btn {
  display: flex; align-items: center; gap: 6px;
  background: var(--bg-2); border: 1px solid var(--border); color: var(--text);
  padding: 8px 12px; border-radius: 10px; cursor: pointer; font-size: 13px; font-weight: 600;
  white-space: nowrap; height: 38px;
}
.model-btn:hover { border-color: var(--accent); }
.model-btn .caret { color: var(--muted); font-size: 11px; }
.model-menu {
  position: absolute; bottom: calc(100% + 8px); right: 0;
  width: 280px; background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow); padding: 6px; z-index: 20;
}
.model-option {
  display: flex; flex-direction: column; gap: 2px; width: 100%; text-align: left;
  background: transparent; border: none; color: var(--text);
  padding: 10px 12px; border-radius: 8px; cursor: pointer;
}
.model-option:hover { background: var(--bg-2); }
.model-option.active { background: var(--bg-2); outline: 1px solid var(--accent); }
.mo-name { font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.mo-desc { font-size: 12px; color: var(--muted); }
.mo-tag {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff;
  padding: 2px 7px; border-radius: 999px;
}
.btn.send { width: 38px; height: 38px; border-radius: 10px; padding: 0; font-size: 18px; flex-shrink: 0; }
.composer-note { text-align: center; color: var(--muted); font-size: 12px; margin-top: 10px; }

.hidden { display: none !important; }

@media (max-width: 820px) {
  .features, .plans { grid-template-columns: 1fr; }
  .chat-shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
}
