/* ===== RESET ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg:       #f8f9fa;
  --white:    #ffffff;
  --text:     #1f1f1f;
  --muted:    #6b7280;
  --border:   #e5e7eb;
  --blue:     #4285f4;
  --blue-light: #e8f0fe;
  --gem:      linear-gradient(135deg, #4285f4, #9b59b6, #e74c3c);
  --radius:   14px;
}
html, body { height: 100%; font-family: 'Google Sans', 'Segoe UI', system-ui, sans-serif; background: var(--bg); color: var(--text); }
button { cursor: pointer; font-family: inherit; }
input, textarea { font-family: inherit; }
.hidden { display: none !important; }

/* ===== AUTH ===== */
.auth-screen {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #f0f4ff 0%, #faf0ff 50%, #f0f8ff 100%);
}
.auth-card {
  background: var(--white);
  border-radius: 24px;
  padding: 2.5rem 2rem;
  width: 100%; max-width: 380px;
  box-shadow: 0 4px 40px rgba(0,0,0,0.08);
  text-align: center;
  display: flex; flex-direction: column; gap: 1rem;
}
.auth-gem {
  font-size: 2.5rem;
  background: var(--gem);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  font-weight: 900;
}
.auth-card h1 { font-size: 1.5rem; font-weight: 700; }
.auth-card p  { color: var(--muted); font-size: 0.9rem; }
.auth-card input {
  width: 100%; border: 1.5px solid var(--border); border-radius: 10px;
  padding: 0.75rem 1rem; font-size: 0.95rem; outline: none;
  transition: border-color 0.2s;
}
.auth-card input:focus { border-color: var(--blue); }
.auth-card button {
  background: var(--blue); color: #fff; border: none;
  border-radius: 10px; padding: 0.8rem; font-size: 1rem; font-weight: 600;
  transition: background 0.2s;
}
.auth-card button:hover { background: #3367d6; }
.auth-hint { font-size: 0.75rem; color: #aaa; }

/* ===== APP LAYOUT ===== */
.app { display: flex; height: 100vh; overflow: hidden; }

/* ===== SIDEBAR ===== */
.sidebar {
  width: 56px;
  background: var(--white);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  align-items: center;
  padding: 1rem 0;
  flex-shrink: 0;
  position: relative;
  z-index: 10;
}
.sidebar-top  { display: flex; flex-direction: column; align-items: center; gap: 0.5rem; flex: 1; }
.sidebar-bottom { display: flex; flex-direction: column; align-items: center; gap: 0.5rem; position: relative; }

.gem-logo {
  font-size: 1.4rem; font-weight: 900; margin-bottom: 0.5rem;
  background: var(--gem);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%;
  background: none; border: none; color: var(--muted);
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.icon-btn:hover { background: var(--blue-light); color: var(--blue); }

.user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, #4285f4, #9b59b6);
  color: #fff; font-weight: 700; font-size: 0.85rem;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; margin-top: 0.3rem;
}

.user-menu {
  position: absolute; bottom: 50px; left: 60px;
  background: var(--white); border: 1px solid var(--border);
  border-radius: 12px; padding: 0.8rem;
  min-width: 200px; box-shadow: 0 4px 20px rgba(0,0,0,0.1);
  z-index: 100;
}
.user-menu-email { font-size: 0.82rem; font-weight: 600; color: var(--text); }
.user-menu-plan  { font-size: 0.75rem; color: var(--muted); margin-bottom: 0.5rem; }
.user-menu hr    { border: none; border-top: 1px solid var(--border); margin: 0.5rem 0; }
.user-menu button {
  width: 100%; background: none; border: none; text-align: left;
  padding: 0.4rem 0; font-size: 0.85rem; color: var(--muted);
  transition: color 0.15s;
}
.user-menu button:hover { color: var(--text); }

/* ===== MAIN ===== */
.main { flex: 1; display: flex; flex-direction: column; position: relative; overflow: hidden; }

.topbar {
  position: absolute; top: 1rem; right: 1.2rem; z-index: 10;
}
.upgrade-pill {
  background: var(--blue-light); color: var(--blue);
  border: 1px solid #c5d8fd; border-radius: 20px;
  padding: 0.45rem 1rem; font-size: 0.85rem; font-weight: 600;
  transition: background 0.15s;
}
.upgrade-pill:hover { background: #d2e3fc; }

/* ===== HOME VIEW ===== */
.home-view {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  position: relative; padding: 2rem;
}
.glow-bg {
  position: absolute;
  width: 500px; height: 300px;
  background: radial-gradient(ellipse, rgba(66,133,244,0.12) 0%, transparent 70%);
  top: 50%; left: 50%; transform: translate(-50%, -60%);
  pointer-events: none;
}
.greeting {
  font-size: clamp(1.4rem, 3vw, 2rem);
  font-weight: 400; color: var(--text);
  margin-bottom: 1.8rem; text-align: center;
  position: relative; z-index: 1;
}

.home-input-wrap { width: 100%; max-width: 580px; position: relative; z-index: 2; }
.home-input-box {
  display: flex; align-items: center; gap: 0.5rem;
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: 30px;
  padding: 0.6rem 0.8rem 0.6rem 1rem;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.home-input-box:focus-within {
  border-color: #c5d8fd;
  box-shadow: 0 2px 20px rgba(66,133,244,0.12);
}
.home-input-box input {
  flex: 1; border: none; outline: none; background: none;
  font-size: 0.95rem; color: var(--text);
}
.plus-btn {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--bg); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; color: var(--muted); cursor: pointer; flex-shrink: 0;
  transition: background 0.15s;
}
.plus-btn:hover { background: var(--blue-light); color: var(--blue); }

.model-pill {
  display: flex; align-items: center; gap: 0.3rem;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 20px; padding: 0.3rem 0.7rem;
  font-size: 0.8rem; font-weight: 600; color: var(--text);
  cursor: pointer; flex-shrink: 0; transition: background 0.15s;
  user-select: none;
}
.model-pill:hover { background: var(--blue-light); }
.model-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--blue); display: inline-block; }
.model-dot.pro { background: #9b59b6; }

.mic-btn {
  width: 32px; height: 32px; border-radius: 50%;
  background: none; border: none; color: var(--muted);
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s; flex-shrink: 0;
}
.mic-btn:hover { background: var(--blue-light); color: var(--blue); }

.model-dropdown {
  position: absolute; top: calc(100% + 8px); left: 50%;
  transform: translateX(-50%);
  background: var(--white); border: 1px solid var(--border);
  border-radius: 12px; padding: 0.5rem;
  min-width: 180px; box-shadow: 0 4px 20px rgba(0,0,0,0.1);
  z-index: 100;
}
.model-option {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.6rem 0.8rem; border-radius: 8px;
  font-size: 0.88rem; cursor: pointer; transition: background 0.15s;
}
.model-option:hover { background: var(--bg); }
.model-tag { margin-left: auto; font-size: 0.72rem; color: var(--muted); }
.pro-tag   { color: #9b59b6; font-weight: 600; }

/* ===== CHAT VIEW ===== */
.chat-view {
  flex: 1; display: flex; flex-direction: column; overflow: hidden;
}
.messages {
  flex: 1; overflow-y: auto; padding: 2rem 1rem 1rem;
  display: flex; flex-direction: column; gap: 1.5rem;
  max-width: 720px; width: 100%; margin: 0 auto;
}
.msg { display: flex; gap: 0.8rem; align-items: flex-start; }
.msg.user { flex-direction: row-reverse; }

.msg-avatar {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.85rem; font-weight: 700;
}
.msg.ai   .msg-avatar { background: var(--gem); color: #fff; font-size: 1rem; }
.msg.user .msg-avatar { background: linear-gradient(135deg,#4285f4,#9b59b6); color:#fff; }

.msg-bubble {
  max-width: 80%; padding: 0.75rem 1rem;
  border-radius: 18px; font-size: 0.92rem; line-height: 1.6;
}
.msg.ai   .msg-bubble { background: var(--white); border: 1px solid var(--border); border-top-left-radius: 4px; }
.msg.user .msg-bubble { background: var(--blue); color: #fff; border-top-right-radius: 4px; }

.msg-bubble pre {
  background: #1e1e2e; color: #cdd6f4; border-radius: 8px;
  padding: 0.8rem 1rem; overflow-x: auto; font-size: 0.82rem;
  margin: 0.5rem 0; white-space: pre-wrap;
}
.msg-bubble code { font-family: 'Fira Code', monospace; }

.typing-dots { display: flex; gap: 4px; padding: 0.3rem 0; }
.typing-dots span {
  width: 7px; height: 7px; border-radius: 50%; background: var(--muted);
  animation: bounce 1.2s infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes bounce { 0%,60%,100%{transform:translateY(0)} 30%{transform:translateY(-6px)} }

.chat-input-area {
  padding: 0.8rem 1rem 1rem;
  max-width: 720px; width: 100%; margin: 0 auto;
}
.chat-input-box {
  display: flex; align-items: flex-end; gap: 0.5rem;
  background: var(--white); border: 1.5px solid var(--border);
  border-radius: 20px; padding: 0.6rem 0.8rem;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
  transition: border-color 0.2s;
}
.chat-input-box:focus-within { border-color: #c5d8fd; }
.chat-input-box textarea {
  flex: 1; border: none; outline: none; background: none;
  font-size: 0.92rem; resize: none; max-height: 160px;
  line-height: 1.5; color: var(--text);
}
.send-btn {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--blue); color: #fff; border: none;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: background 0.15s;
}
.send-btn:hover { background: #3367d6; }
.send-btn:disabled { background: var(--border); }
.chat-hint { font-size: 0.72rem; color: #aaa; text-align: center; margin-top: 0.5rem; }

/* ===== UPGRADE MODAL ===== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.3);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; padding: 1rem;
}
.modal {
  background: var(--white); border-radius: 20px;
  padding: 2rem; width: 100%; max-width: 520px;
  position: relative; text-align: center;
  box-shadow: 0 8px 40px rgba(0,0,0,0.15);
}
.modal-close {
  position: absolute; top: 1rem; right: 1rem;
  background: none; border: none; font-size: 1.1rem; color: var(--muted);
}
.modal-gem {
  font-size: 2rem; font-weight: 900; margin-bottom: 0.5rem;
  background: var(--gem); -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.modal h2 { font-size: 1.4rem; font-weight: 700; margin-bottom: 0.4rem; }
.modal > p { color: var(--muted); font-size: 0.9rem; margin-bottom: 1.5rem; }

.plan-cards { display: flex; gap: 1rem; }
.plan-card {
  flex: 1; border: 1.5px solid var(--border); border-radius: 14px;
  padding: 1.2rem; text-align: left; position: relative;
}
.plan-card.pro { border-color: var(--blue); background: #f8fbff; }
.plan-badge {
  position: absolute; top: -10px; left: 50%; transform: translateX(-50%);
  background: var(--blue); color: #fff; font-size: 0.7rem; font-weight: 700;
  padding: 2px 10px; border-radius: 10px;
}
.plan-label { font-size: 0.8rem; font-weight: 700; color: var(--muted); text-transform: uppercase; margin-bottom: 0.3rem; }
.plan-price { font-size: 1.6rem; font-weight: 800; margin-bottom: 0.8rem; }
.plan-price span { font-size: 0.85rem; font-weight: 400; color: var(--muted); }
.plan-card ul { list-style: none; display: flex; flex-direction: column; gap: 0.4rem; margin-bottom: 1rem; }
.plan-card li { font-size: 0.82rem; color: var(--muted); }
.plan-btn {
  width: 100%; padding: 0.65rem; border-radius: 10px;
  font-size: 0.88rem; font-weight: 600; border: none;
  background: var(--blue); color: #fff; transition: background 0.15s;
}
.plan-btn:hover { background: #3367d6; }
.plan-btn.current { background: var(--bg); color: var(--muted); cursor: default; }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ===== RESPONSIVE ===== */
@media (max-width: 600px) {
  .plan-cards { flex-direction: column; }
  .messages { padding: 1rem 0.5rem; }
}

/* ===== EMAIL VALIDATION ===== */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-8px); }
  40%       { transform: translateX(8px); }
  60%       { transform: translateX(-5px); }
  80%       { transform: translateX(5px); }
}

/* ===== AUTH NEW ELEMENTS ===== */
.auth-logo { display: flex; justify-content: center; margin-bottom: 0.3rem; }
.google-btn {
  display: flex; align-items: center; justify-content: center; gap: 0.6rem;
  width: 100%; padding: 0.75rem; border-radius: 10px;
  border: 1.5px solid var(--border); background: var(--white);
  font-size: 0.95rem; font-weight: 600; color: var(--text);
  cursor: pointer; transition: background 0.15s, border-color 0.15s;
}
.google-btn:hover { background: #f8f9fa; border-color: #aaa; }
.auth-divider { display: flex; align-items: center; gap: 0.8rem; color: var(--muted); font-size: 0.8rem; }
.auth-divider::before, .auth-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.auth-continue-btn { background: var(--blue); color: #fff; border: none; border-radius: 10px; padding: 0.8rem; font-size: 1rem; font-weight: 600; width: 100%; transition: background 0.2s; }
.auth-continue-btn:hover { background: #3367d6; }

/* ===== HISTORY PANEL ===== */
.history-panel { width: 260px; background: var(--white); border-right: 1px solid var(--border); display: flex; flex-direction: column; height: 100vh; flex-shrink: 0; z-index: 50; }
.history-header { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1rem 0.5rem; font-weight: 700; font-size: 0.95rem; border-bottom: 1px solid var(--border); }
.history-header button { background: none; border: none; color: var(--muted); font-size: 1rem; cursor: pointer; }
.history-header button:hover { color: var(--text); }
.history-search { padding: 0.6rem 0.8rem; }
.history-search input { width: 100%; border: 1px solid var(--border); border-radius: 8px; padding: 0.5rem 0.7rem; font-size: 0.85rem; outline: none; background: var(--bg); }
.history-search input:focus { border-color: var(--blue); }
.history-list { flex: 1; overflow-y: auto; padding: 0.4rem 0.5rem; display: flex; flex-direction: column; gap: 0.2rem; }
.history-empty { color: var(--muted); font-size: 0.85rem; text-align: center; padding: 1rem; }
.history-item { display: flex; flex-direction: column; gap: 0.15rem; padding: 0.6rem 0.7rem; border-radius: 8px; cursor: pointer; position: relative; transition: background 0.15s; }
.history-item:hover { background: var(--bg); }
.history-item.active { background: var(--blue-light); }
.history-item-title { font-size: 0.83rem; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 1.5rem; }
.history-item-date { font-size: 0.72rem; color: var(--muted); }
.history-item-del { position: absolute; right: 0.5rem; top: 50%; transform: translateY(-50%); background: none; border: none; font-size: 0.8rem; opacity: 0; cursor: pointer; transition: opacity 0.15s; }
.history-item:hover .history-item-del { opacity: 0.6; }
.history-clear-btn { margin: 0.5rem; padding: 0.5rem; border-radius: 8px; background: none; border: 1px solid var(--border); color: var(--muted); font-size: 0.8rem; cursor: pointer; }
.history-clear-btn:hover { border-color: #e53e3e; color: #e53e3e; }
.user-menu-name { font-size: 0.88rem; font-weight: 700; color: var(--text); }
.modal-star { display: flex; justify-content: center; margin-bottom: 0.5rem; }

/* ===== OTP VERIFICATION ===== */
.otp-info { color: var(--muted); font-size: 0.88rem; text-align: center; margin-bottom: 1.2rem; }
.otp-inputs { display: flex; gap: 0.5rem; justify-content: center; margin-bottom: 1.2rem; }
.otp-box { width: 44px; height: 52px; border: 2px solid var(--border); border-radius: 10px; text-align: center; font-size: 1.4rem; font-weight: 700; outline: none; transition: border-color 0.2s; background: var(--bg); }
.otp-box:focus { border-color: var(--blue); background: #fff; }
.auth-error { color: #e53e3e; font-size: 0.82rem; text-align: center; margin-top: 0.3rem; }
.auth-resend-btn { background: none; border: none; color: var(--blue); font-size: 0.85rem; cursor: pointer; text-decoration: underline; display: block; margin: 0.5rem auto 0; }
.auth-back-btn { background: none; border: none; color: var(--muted); font-size: 0.82rem; cursor: pointer; display: block; margin: 0.3rem auto 0; }
.auth-back-btn:hover { color: var(--text); }


/* ===== DARK MODE ===== */
[data-theme='dark'] {
  --bg: #0f0f0f;
  --white: #1a1a1a;
  --text: #f0f0f0;
  --muted: #9ca3af;
  --border: #2a2a2a;
  --blue-light: #1e2a3a;
  --bg2: #111111;
}
[data-theme='dark'] body { background: var(--bg); color: var(--text); }
[data-theme='dark'] .sidebar { background: #111; border-color: #222; }
[data-theme='dark'] .main { background: #0f0f0f; }
[data-theme='dark'] .home-input-box { background: #1a1a1a; border-color: #333; }
[data-theme='dark'] .home-input-box input { color: #f0f0f0; }
[data-theme='dark'] .chat-input-box { background: #1a1a1a; border-color: #333; }
[data-theme='dark'] .chat-input-box textarea { color: #f0f0f0; }
[data-theme='dark'] .msg.ai .msg-bubble { background: #1e1e1e; border-color: #333; color: #f0f0f0; }
[data-theme='dark'] .auth-card { background: #1a1a1a; color: #f0f0f0; }
[data-theme='dark'] .auth-card input { background: #111; border-color: #333; color: #f0f0f0; }
[data-theme='dark'] .history-panel { background: #111; border-color: #222; }
[data-theme='dark'] .history-item:hover { background: #1e1e1e; }
[data-theme='dark'] .user-menu { background: #1a1a1a; border-color: #333; }
[data-theme='dark'] .model-pill { background: #1a1a1a; border-color: #333; color: #f0f0f0; }
[data-theme='dark'] .upgrade-pill { background: #1e2a3a; }
[data-theme='dark'] .glow-bg { background: radial-gradient(ellipse, rgba(124,92,252,0.15) 0%, transparent 70%); }
[data-theme='dark'] .greeting { color: #f0f0f0; }

