:root {
  --bg: #0c0a1a;
  --bg-card: #14102a;
  --bg-elevated: #1c1638;
  --border: rgba(139, 92, 246, 0.22);
  --text: #f4f4f5;
  --muted: #a1a1aa;
  --primary: #8b5cf6;
  --primary2: #6366f1;
  --accent: #a78bfa;
  --danger: #f87171;
  --success: #4ade80;
  --radius: 14px;
  --font: 'Plus Jakarta Sans', system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font); background: var(--bg); color: var(--text); line-height: 1.55; min-height: 100vh; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: 10px; font-weight: 600; font-size: 14px;
  border: none; cursor: pointer; text-decoration: none; transition: 0.2s;
}
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary2)); color: #fff; }
.btn-primary:hover { opacity: 0.92; text-decoration: none; }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { background: rgba(139, 92, 246, 0.12); text-decoration: none; }
.btn-lg { padding: 14px 24px; font-size: 15px; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; }

.logo { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; color: var(--text); text-decoration: none; }
.logo__icon { font-size: 1.4rem; }
.logo--sm { font-size: 15px; }

.site-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 32px; max-width: 1100px; margin: 0 auto;
}
.site-nav { display: flex; align-items: center; gap: 12px; }
.lang-link { font-size: 13px; color: var(--muted); }

.hero {
  position: relative; text-align: center; padding: 60px 24px 80px;
  max-width: 800px; margin: 0 auto;
}
.hero__glow {
  position: absolute; inset: -40% 10% auto; height: 400px;
  background: radial-gradient(circle, rgba(139, 92, 246, 0.35), transparent 70%);
  pointer-events: none; z-index: 0;
}
.hero__content { position: relative; z-index: 1; }
.hero__badge {
  display: inline-block; padding: 6px 14px; border-radius: 999px;
  background: rgba(139, 92, 246, 0.15); border: 1px solid var(--border);
  font-size: 13px; color: var(--accent); margin-bottom: 20px;
}
.hero h1 {
  font-size: clamp(2rem, 5vw, 2.75rem); font-weight: 800; line-height: 1.15;
  background: linear-gradient(135deg, #fff, var(--accent));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  margin-bottom: 16px;
}
.hero__sub { color: var(--muted); font-size: 1.1rem; margin-bottom: 32px; }
.hero__actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }

.features {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px; max-width: 1000px; margin: 0 auto 60px; padding: 0 24px;
}
.feature-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 28px;
}
.feature-card__icon { font-size: 2rem; margin-bottom: 12px; }
.feature-card h3 { font-size: 1.1rem; margin-bottom: 8px; }
.feature-card p { color: var(--muted); font-size: 14px; }

.site-footer { text-align: center; padding: 24px; color: var(--muted); font-size: 13px; }

.auth-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
}
.auth-card {
  width: 100%; max-width: 420px; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: 20px; padding: 36px;
}
.auth-logo { display: block; margin-bottom: 24px; font-weight: 800; color: var(--text); }
.auth-card h1 { font-size: 1.5rem; margin-bottom: 6px; }
.auth-sub { color: var(--muted); font-size: 14px; margin-bottom: 24px; }
.auth-form label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; margin-top: 14px; }
.auth-form input {
  width: 100%; padding: 12px 14px; background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.1); border-radius: 10px; color: var(--text); font: inherit;
}
.auth-form input:focus { outline: none; border-color: var(--primary); }
.auth-footer { margin-top: 20px; font-size: 14px; color: var(--muted); text-align: center; }
.alert { padding: 12px; border-radius: 10px; font-size: 14px; margin-bottom: 16px; }
.alert-error { background: rgba(248,113,113,0.12); border: 1px solid rgba(248,113,113,0.3); color: #fca5a5; }

.app-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px; border-bottom: 1px solid var(--border); background: var(--bg-card);
}
.app-bar__meta { display: flex; align-items: center; gap: 12px; font-size: 13px; }
.usage-pill {
  padding: 4px 10px; border-radius: 999px; background: rgba(139,92,246,0.15);
  color: var(--accent); font-size: 12px;
}
.user-name { color: var(--muted); }
.banner { padding: 10px 20px; font-size: 13px; text-align: center; }
.banner-warn { background: rgba(251,191,36,0.12); color: #fcd34d; }

.workspace {
  display: grid; grid-template-columns: 280px 1fr;
  height: calc(100vh - 53px); max-height: calc(100dvh - 53px);
}
.workspace-sidebar {
  border-right: 1px solid var(--border); padding: 16px; overflow-y: auto;
  background: var(--bg-card);
}
.sidebar-title { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 16px 0 8px; }
.sidebar-sub { font-size: 12px; color: var(--muted); margin: 12px 0 6px; }
.sidebar-divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
.session-list { list-style: none; }
.session-list li { margin-bottom: 4px; }
.session-link {
  display: block; padding: 8px 10px; border-radius: 8px; font-size: 13px;
  color: var(--muted); text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.session-link:hover, .session-link.is-active { background: rgba(139,92,246,0.15); color: var(--text); text-decoration: none; }
.pdf-input { display: none; }
.pdf-summary-box { margin-top: 12px; font-size: 13px; }
.pdf-summary-content { max-height: 200px; overflow-y: auto; color: var(--muted); white-space: pre-wrap; margin-top: 8px; }
.doc-list { list-style: none; }
.doc-link {
  width: 100%; text-align: left; background: none; border: none; color: var(--accent);
  font-size: 12px; padding: 6px 0; cursor: pointer; overflow: hidden; text-overflow: ellipsis;
}

.workspace-main { display: flex; flex-direction: column; min-height: 0; }
.mode-tabs { display: flex; gap: 6px; padding: 12px 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.mode-tab {
  padding: 6px 14px; border-radius: 999px; border: 1px solid var(--border);
  background: transparent; color: var(--muted); font-size: 13px; cursor: pointer; font-family: inherit;
}
.mode-tab.is-active { background: rgba(139,92,246,0.2); color: var(--accent); border-color: var(--primary); }

.chat-messages { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.msg { display: flex; }
.msg--user { justify-content: flex-end; }
.msg--assistant { justify-content: flex-start; }
.msg__bubble {
  max-width: min(720px, 90%); padding: 12px 16px; border-radius: 16px; font-size: 14px;
  white-space: pre-wrap; word-break: break-word;
}
.msg--user .msg__bubble { background: linear-gradient(135deg, var(--primary), var(--primary2)); color: #fff; border-bottom-right-radius: 4px; }
.msg--assistant .msg__bubble { background: var(--bg-elevated); border: 1px solid var(--border); border-bottom-left-radius: 4px; }

.chat-composer {
  display: flex; gap: 10px; padding: 16px; border-top: 1px solid var(--border); background: var(--bg-card);
}
.chat-composer textarea {
  flex: 1; resize: none; padding: 12px 14px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text); font: inherit;
}
.chat-composer textarea:focus { outline: none; border-color: var(--primary); }

.label-row { display: flex; justify-content: space-between; align-items: center; }
.label-row a { font-size: 13px; font-weight: 500; }
.alert-success { background: rgba(74,222,128,0.12); border: 1px solid rgba(74,222,128,0.3); color: #86efac; }

.billing-page { max-width: 960px; margin: 0 auto; padding: 32px 24px; }
.billing-page h1 { font-size: 1.75rem; margin-bottom: 8px; }
.billing-sub { color: var(--muted); margin-bottom: 28px; }
.plan-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 20px; }
.plan-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px; position: relative;
}
.plan-card.is-current { border-color: var(--primary); box-shadow: 0 0 0 1px rgba(139,92,246,0.3); }
.plan-price { font-size: 1.75rem; font-weight: 800; margin: 12px 0; }
.plan-price span { font-size: 14px; font-weight: 500; color: var(--muted); }
.plan-features { list-style: none; margin: 16px 0 20px; font-size: 14px; color: var(--muted); }
.plan-features li { padding: 4px 0; }
.plan-badge {
  display: inline-block; padding: 8px 12px; background: rgba(139,92,246,0.15);
  color: var(--accent); border-radius: 8px; font-size: 13px; font-weight: 600;
}
.auth-debug { font-size: 12px; word-break: break-all; margin: 12px 0; color: var(--muted); }

/* Landing pricing */
.pricing { max-width: 1000px; margin: 0 auto 80px; padding: 0 24px; text-align: center; }
.pricing__title { font-size: 2rem; font-weight: 800; margin-bottom: 10px; }
.pricing__sub { color: var(--muted); margin-bottom: 36px; }
.plan-grid--landing { text-align: left; }
.plan-card--landing { position: relative; }
.plan-card--landing.is-featured {
  border-color: var(--primary);
  transform: scale(1.02);
  box-shadow: 0 12px 40px rgba(139, 92, 246, 0.25);
}
.plan-card__badge {
  position: absolute; top: -10px; left: 50%; transform: translateX(-50%);
  background: linear-gradient(135deg, var(--primary), var(--primary2));
  color: #fff; font-size: 11px; font-weight: 700; padding: 4px 12px; border-radius: 999px;
}

/* Admin */
.layout-admin { display: flex; min-height: 100vh; }
.admin-sidebar {
  width: 220px; flex-shrink: 0; background: var(--bg-card);
  border-right: 1px solid var(--border); padding: 20px 16px; display: flex; flex-direction: column;
}
.admin-nav { display: flex; flex-direction: column; gap: 4px; margin-top: 24px; flex: 1; }
.admin-nav a {
  padding: 10px 12px; border-radius: 8px; color: var(--muted); text-decoration: none; font-size: 14px; font-weight: 500;
}
.admin-nav a:hover, .admin-nav a.is-active { background: rgba(139,92,246,0.15); color: var(--text); text-decoration: none; }
.admin-sidebar__foot { display: flex; flex-direction: column; gap: 8px; font-size: 13px; padding-top: 16px; border-top: 1px solid var(--border); }
.admin-main { flex: 1; padding: 28px 32px; overflow-y: auto; }
.admin-title { font-size: 1.5rem; font-weight: 800; margin-bottom: 24px; }
.admin-stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 16px; margin-bottom: 28px; }
.stat-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; display: flex; flex-direction: column; gap: 6px;
}
.stat-card--accent { border-color: var(--primary); background: rgba(139,92,246,0.08); }
.stat-card__label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.stat-card__value { font-size: 1.5rem; font-weight: 800; }
.admin-two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 24px; }
.admin-panel {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; margin-bottom: 24px;
}
.admin-panel h2 { font-size: 15px; margin-bottom: 16px; }
.bar-row { margin-bottom: 14px; font-size: 13px; }
.bar-row span { color: var(--muted); }
.bar-row strong { float: right; }
.bar-track { height: 8px; background: rgba(255,255,255,0.06); border-radius: 4px; margin-top: 8px; clear: both; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--primary), var(--primary2)); border-radius: 4px; }
.admin-kv { list-style: none; }
.admin-kv li { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.admin-kv li:last-child { border-bottom: none; }
.table-wrap { overflow-x: auto; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.admin-table th, .admin-table td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border); }
.admin-table th { color: var(--muted); font-size: 12px; text-transform: uppercase; }
.admin-table small { color: var(--muted); }
.tag { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: rgba(139,92,246,0.15); color: var(--accent); }
.tag--free { background: rgba(161,161,170,0.15); color: var(--muted); }
.tag--student { background: rgba(99,102,241,0.2); color: #a5b4fc; }
.tag--pro { background: rgba(139,92,246,0.25); color: #c4b5fd; }
.admin-filters { margin-bottom: 16px; }
.admin-filters select, .inline-form select {
  padding: 6px 10px; background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font: inherit;
}
.inline-form { display: inline; }
.muted { color: var(--muted); font-size: 14px; }

@media (max-width: 900px) {
  .layout-admin { flex-direction: column; }
  .admin-sidebar { width: 100%; }
  .admin-two-col { grid-template-columns: 1fr; }
  .plan-card--landing.is-featured { transform: none; }
}

@media (max-width: 768px) {
  .workspace { grid-template-columns: 1fr; }
  .workspace-sidebar { display: none; }
}
