:root {
  --bg: #0a0a0f;
  --bg-2: #0f0e14;
  --bg-3: #16151e;
  --line: #1e1d2a;
  --text: #d8d0e8;
  --muted: #6e6880;
  --accent: #6e3aff;
  --accent-2: #9b6bff;
  --pink: #ff3a6e;
  --pink-dim: #a02048;
  --danger: #d86c6c;
  --ok: #74c58a;
  --ai-bubble: #14121e;
  --user-bubble: #1e1a2e;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
  --radius: 14px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  background:
    radial-gradient(900px 400px at 10% 0%, rgba(110, 58, 255, 0.08), transparent 60%),
    radial-gradient(700px 500px at 90% 100%, rgba(255, 58, 110, 0.05), transparent 60%),
    var(--bg);
  min-height: 100vh;
  display: flex;
  align-items: stretch;
  justify-content: center;
}

.app {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 0;
  width: 100%;
  max-width: 1200px;
  min-height: 100vh;
  background: var(--bg-2);
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
}

.sidebar {
  padding: 28px 24px;
  background: linear-gradient(180deg, #0d0b14 0%, #0a0910 100%);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  position: sticky;
  top: 0;
  max-height: 100vh;
}

.glyph {
  width: 160px;
  height: 208px;
  background: var(--bg-3);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}
.glyph svg { width: 100%; height: 100%; display: block; }

.brand {
  margin: 16px 0 2px;
  font-weight: 300;
  font-size: 42px;
  letter-spacing: 4px;
  color: var(--accent-2);
  text-shadow: 0 0 20px rgba(110, 58, 255, 0.4);
  font-style: italic;
}

.tagline {
  margin: 0 0 18px;
  color: var(--muted);
  font-style: italic;
  font-size: 13px;
  letter-spacing: 1px;
}

.traits {
  list-style: none;
  padding: 0;
  margin: 0 0 auto;
  color: var(--text);
  font-size: 12px;
  line-height: 2;
  letter-spacing: 0.5px;
}
.traits li::before {
  content: "~ ";
  color: var(--accent);
  opacity: 0.6;
}

.price-tag {
  margin: 16px 0 8px;
  padding: 6px 16px;
  border: 1px solid var(--accent);
  border-radius: 20px;
  font-size: 12px;
  color: var(--accent-2);
  letter-spacing: 1px;
  text-transform: uppercase;
}

.footer-note {
  margin: 12px 0 0;
  font-size: 10px;
  color: var(--muted);
}
.footer-note a { color: var(--accent); text-decoration: none; opacity: 0.7; }
.footer-note a:hover { opacity: 1; text-decoration: underline; }

.chat {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: var(--bg-2);
}
.chat > .messages { flex: 1 1 0; min-height: 0; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(0,0,0,0.3);
}

.status {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 11px;
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: 1px;
}
.dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 6px currentColor;
}
.dot.thinking { background: var(--accent); animation: pulse 1.6s ease-in-out infinite; }
.dot.error { background: var(--danger); }
.dot.ok { background: var(--ok); }

@keyframes pulse {
  0%, 100% { opacity: 0.5; transform: scale(0.85); }
  50% { opacity: 1; transform: scale(1.2); }
}

.auth-actions { display: flex; gap: 8px; align-items: center; }

.login-btn {
  background: transparent;
  color: var(--accent-2);
  border: 1px solid rgba(110, 58, 255, 0.3);
  padding: 7px 14px;
  border-radius: 8px;
  font-size: 11px;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: all 0.15s;
  text-transform: lowercase;
  font-family: inherit;
}
.login-btn:hover:not(:disabled) { background: rgba(110, 58, 255, 0.08); border-color: var(--accent); }
.login-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.ghost-btn { color: var(--muted); border-color: var(--line); }
.ghost-btn:hover { color: var(--text); border-color: rgba(110, 58, 255, 0.3); }

.notice {
  margin: 0;
  padding: 10px 18px;
  font-size: 12px;
  line-height: 1.4;
  background: rgba(110, 58, 255, 0.06);
  border-bottom: 1px solid var(--line);
  color: var(--muted);
}
.notice.ok { background: rgba(116, 197, 138, 0.08); color: var(--ok); }
.notice.warn { background: rgba(110, 58, 255, 0.08); color: var(--accent-2); }
.notice.error { background: rgba(216, 108, 108, 0.08); color: var(--danger); }

/* paywall */
.paywall {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
}

.paywall-inner {
  text-align: center;
  max-width: 420px;
}

.paywall-icon {
  font-size: 48px;
  margin-bottom: 16px;
  filter: hue-rotate(20deg);
}

.paywall-inner h2 {
  font-weight: 300;
  font-size: 26px;
  color: var(--accent-2);
  margin: 0 0 14px;
  letter-spacing: 2px;
  text-transform: lowercase;
}

.paywall-inner > p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
  margin: 0 0 10px;
}

.paywall-price {
  font-size: 20px;
  color: var(--text);
  font-weight: 600;
  margin: 16px 0 20px;
  letter-spacing: 1px;
}

.pay-btn {
  width: 100%;
  max-width: 280px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--pink) 100%);
  color: #fff;
  border: none;
  padding: 14px 28px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  letter-spacing: 0.5px;
  transition: filter 0.15s, transform 0.1s;
  text-transform: lowercase;
  font-family: inherit;
}
.pay-btn:hover:not(:disabled) { filter: brightness(1.1); transform: translateY(-1px); }
.pay-btn:active:not(:disabled) { transform: translateY(0); }
.pay-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.paywall-note {
  margin-top: 16px;
  font-size: 11px;
  color: var(--muted);
}
.paywall-note a { color: var(--accent); text-decoration: none; }
.paywall-note a:hover { text-decoration: underline; }

/* messages */
.messages {
  overflow-y: auto;
  padding: 24px 22px 12px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}
.messages::-webkit-scrollbar { width: 6px; }
.messages::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }

.msg {
  display: flex;
  gap: 10px;
  max-width: 85%;
  align-items: flex-end;
}
.msg .avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--bg-3);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  border: 1px solid var(--line);
  flex-shrink: 0;
  color: var(--accent-2);
}
.msg .bubble {
  padding: 12px 16px;
  border-radius: var(--radius);
  line-height: 1.6;
  font-size: 14px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.25);
}
.msg .bubble p { margin: 0; white-space: pre-wrap; word-wrap: break-word; }

.ai-msg { align-self: flex-start; }
.ai-msg .bubble {
  background: var(--ai-bubble);
  border: 1px solid var(--line);
  border-bottom-left-radius: 4px;
  color: var(--text);
}
.user-msg { align-self: flex-end; flex-direction: row-reverse; }
.user-msg .bubble {
  background: var(--user-bubble);
  border: 1px solid rgba(110, 58, 255, 0.15);
  border-bottom-right-radius: 4px;
}
.user-msg .avatar { color: var(--muted); }

/* composer */
.composer {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 18px 18px;
  border-top: 1px solid var(--line);
  background: rgba(0,0,0,0.25);
}
.composer textarea {
  width: 100%;
  background: var(--bg-3);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  font-family: inherit;
  font-size: 14px;
  resize: none;
  outline: none;
  transition: border-color 0.15s;
  min-height: 44px;
  max-height: 160px;
}
.composer textarea::placeholder { color: var(--muted); }
.composer textarea:focus { border-color: rgba(110, 58, 255, 0.4); }

.composer button {
  width: 100%;
  background: linear-gradient(135deg, var(--accent) 0%, var(--pink) 100%);
  color: #fff;
  border: none;
  padding: 12px 22px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  letter-spacing: 0.5px;
  transition: filter 0.15s;
  text-transform: lowercase;
  font-family: inherit;
}
.composer button:hover:not(:disabled) { filter: brightness(1.08); }
.composer button:disabled { opacity: 0.5; cursor: not-allowed; }

@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    padding: 16px 16px 12px;
    position: static;
    max-height: none;
    flex-direction: row;
    gap: 14px;
    text-align: left;
    border-right: none;
    border-bottom: 1px solid var(--line);
  }
  .glyph { width: 80px; height: 104px; flex-shrink: 0; }
  .brand { font-size: 28px; margin: 0; }
  .tagline { margin: 2px 0 0; font-size: 11px; }
  .traits { display: none; }
  .price-tag { display: none; }
  .footer-note { display: none; }
  .chat { height: auto; min-height: calc(100vh - 130px); }
}
