@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

/* ─── Reset & Base ─────────────────────────────────────────────── */

*,* ::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-primary:     #0a0a0f;
  --bg-secondary:   #10101a;
  --bg-card:        rgba(255,255,255,0.04);
  --bg-card-hover:  rgba(255,255,255,0.07);
  --border:         rgba(255,255,255,0.08);
  --border-focus:   rgba(139,92,246,0.6);

  --accent-purple:  #8b5cf6;
  --accent-blue:    #3b82f6;
  --accent-cyan:    #06b6d4;
  --accent-green:   #10b981;
  --accent-amber:   #f59e0b;
  --accent-red:     #ef4444;

  --text-primary:   #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted:     #475569;

  --gradient-hero:  linear-gradient(135deg, #1e1b4b 0%, #0f172a 50%, #0a0a0f 100%);
  --gradient-card:  linear-gradient(135deg, rgba(139,92,246,0.15), rgba(59,130,246,0.05));
  --gradient-btn:   linear-gradient(135deg, #8b5cf6, #3b82f6);
  --gradient-score-high:   linear-gradient(135deg, #10b981, #06b6d4);
  --gradient-score-mid:    linear-gradient(135deg, #f59e0b, #f97316);
  --gradient-score-low:    linear-gradient(135deg, #ef4444, #ec4899);

  --radius-sm:  8px;
  --radius-md:  14px;
  --radius-lg:  20px;
  --radius-xl:  28px;

  --shadow-card: 0 4px 32px rgba(0,0,0,0.4), 0 1px 0 rgba(255,255,255,0.05) inset;
  --shadow-btn:  0 4px 20px rgba(139,92,246,0.4);
  --transition:  0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.6;
}

/* ─── Animated Background ───────────────────────────────────────── */
.bg-orbs {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  overflow: hidden;
}
.bg-orbs::before,
.bg-orbs::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.12;
  animation: drift 20s ease-in-out infinite alternate;
}
.bg-orbs::before {
  width: 600px; height: 600px;
  background: radial-gradient(circle, #8b5cf6, transparent);
  top: -200px; left: -200px;
}
.bg-orbs::after {
  width: 500px; height: 500px;
  background: radial-gradient(circle, #3b82f6, transparent);
  bottom: -150px; right: -150px;
  animation-delay: -10s;
}
@keyframes drift {
  0%   { transform: translate(0,0) scale(1); }
  100% { transform: translate(80px, 60px) scale(1.1); }
}

/* ─── Layout ────────────────────────────────────────────────────── */
.container {
  position: relative; z-index: 1;
  max-width: 860px;
  margin: 0 auto;
  padding: 2rem 1.5rem 6rem;
}

/* ─── Header ────────────────────────────────────────────────────── */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.75rem;
  background: rgba(10,10,15,0.8);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
}
.logo {
  display: flex; align-items: center; gap: 0.6rem;
  font-size: 1.1rem; font-weight: 700; letter-spacing: -0.02em;
}
.logo-icon {
  width: 32px; height: 32px;
  background: var(--gradient-btn);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  box-shadow: var(--shadow-btn);
}
.logo span { color: var(--text-secondary); font-weight: 400; margin-left: 2px; }

#settings-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.85rem;
  font-family: inherit;
  display: flex; align-items: center; gap: 0.4rem;
  transition: var(--transition);
}
#settings-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  border-color: var(--border-focus);
}

/* ─── Hero Section ──────────────────────────────────────────────── */
.hero {
  text-align: center;
  padding: 4rem 0 2.5rem;
}
.hero-badge {
  display: inline-flex; align-items: center; gap: 0.4rem;
  background: rgba(139,92,246,0.12);
  border: 1px solid rgba(139,92,246,0.3);
  color: var(--accent-purple);
  padding: 0.35rem 0.9rem;
  border-radius: 99px;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 1.25rem;
}
.hero h1 {
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.15;
  margin-bottom: 1rem;
  background: linear-gradient(135deg, #f1f5f9 30%, #8b5cf6 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.hero p {
  font-size: 1.05rem;
  color: var(--text-secondary);
  max-width: 520px;
  margin: 0 auto 2rem;
}

/* ─── Card ──────────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 2rem;
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(12px);
  margin-bottom: 1.5rem;
  transition: var(--transition);
}
.card:hover { border-color: rgba(255,255,255,0.12); }

.card-title {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-purple);
  margin-bottom: 1rem;
  display: flex; align-items: center; gap: 0.4rem;
}
.card-title::before {
  content: '';
  display: inline-block;
  width: 6px; height: 6px;
  background: var(--accent-purple);
  border-radius: 50%;
}

/* ─── Step Labels ───────────────────────────────────────────────── */
.step-label {
  display: inline-flex; align-items: center; gap: 0.5rem;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.6rem;
}
.step-num {
  width: 20px; height: 20px;
  background: var(--gradient-btn);
  border-radius: 50%;
  font-size: 0.65rem;
  font-weight: 800;
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

/* ─── Form Elements ─────────────────────────────────────────────── */
label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}
textarea, input[type="text"], input[type="password"], input[type="url"] {
  width: 100%;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.95rem;
  padding: 0.9rem 1rem;
  resize: vertical;
  outline: none;
  transition: var(--transition);
  line-height: 1.6;
}
textarea:focus, input:focus {
  border-color: var(--border-focus);
  background: rgba(139,92,246,0.04);
  box-shadow: 0 0 0 3px rgba(139,92,246,0.12);
}
textarea::placeholder, input::placeholder { color: var(--text-muted); }
textarea { min-height: 110px; }
#user_answer_1 { min-height: 150px; }

.char-count {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: right;
  margin-top: 0.35rem;
}

/* ─── Buttons ───────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  padding: 0.85rem 2rem;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: var(--transition);
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.btn-primary {
  background: var(--gradient-btn);
  color: #fff;
  box-shadow: var(--shadow-btn);
  width: 100%;
}
.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(139,92,246,0.5);
}
.btn-primary:active:not(:disabled) { transform: translateY(0); }
.btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.btn-secondary {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}
.btn-secondary:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  border-color: var(--border-focus);
}
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 0.5rem 1rem;
}
.btn-ghost:hover { color: var(--text-primary); }

/* ─── Loading Spinner ───────────────────────────────────────────── */
.spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,0.25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Score Ring ────────────────────────────────────────────────── */
.score-section {
  display: none;
  animation: fadeSlideUp 0.5s ease forwards;
}
.score-section.visible { display: block; }

@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(24px); }
  to   { opacity: 1; transform: translateY(0); }
}

.score-header {
  display: flex;
  align-items: center;
  gap: 2rem;
  margin-bottom: 1.75rem;
  flex-wrap: wrap;
}

.score-ring-wrap {
  position: relative;
  flex-shrink: 0;
}
.score-ring-wrap svg {
  transform: rotate(-90deg);
  display: block;
}
.score-ring-bg { fill: none; stroke: rgba(255,255,255,0.06); }
.score-ring-fill {
  fill: none;
  stroke-linecap: round;
  transition: stroke-dashoffset 1.2s cubic-bezier(0.4, 0, 0.2, 1),
              stroke 0.4s ease;
}
.score-label {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  pointer-events: none;
}
.score-number {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.03em;
}
.score-denom {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 500;
}

.score-meta { flex: 1; min-width: 200px; }
.score-grade {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 0.3rem;
}
.score-subtitle {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
  line-height: 1.5;
}

/* ─── Score Breakdown Pills ─────────────────────────────────────── */
.breakdown-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}
.breakdown-item {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}
.breakdown-name {
  font-size: 0.78rem;
  color: var(--text-secondary);
  font-weight: 500;
}
.breakdown-score {
  font-size: 0.88rem;
  font-weight: 700;
  background: var(--gradient-btn);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ─── Suggestions ───────────────────────────────────────────────── */
.suggestions-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 1rem;
  display: flex; align-items: center; gap: 0.5rem;
}
.suggestions-title .icon { 
  color: var(--accent-amber); 
  font-size: 1.35rem;
  filter: drop-shadow(0 0 8px rgba(245,158,11,0.4));
}

.suggestion-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}
.suggestion-item {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  background: linear-gradient(135deg, rgba(139,92,246,0.10), rgba(59,130,246,0.05));
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent-purple);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  padding: 0.9rem 1.15rem;
  font-size: 0.92rem;
  color: var(--text-primary);
  line-height: 1.65;
  animation: fadeSlideUp 0.4s ease both;
  transition: all 0.3s ease;
}
.suggestion-item:hover {
  background: linear-gradient(135deg, rgba(139,92,246,0.15), rgba(59,130,246,0.08));
  border-left-width: 5px;
  transform: translateX(2px);
}
.suggestion-item:nth-child(2) { animation-delay: 0.08s; border-left-color: var(--accent-blue); }
.suggestion-item:nth-child(3) { animation-delay: 0.16s; border-left-color: var(--accent-cyan); }
.suggestion-item:nth-child(4) { animation-delay: 0.24s; border-left-color: var(--accent-green); }
.suggestion-item:nth-child(5) { animation-delay: 0.32s; border-left-color: var(--accent-amber); }
.suggestion-bullet {
  color: var(--accent-purple);
  font-size: 0.85rem;
  font-weight: 700;
  margin-top: 2px;
  flex-shrink: 0;
}
.suggestion-item:nth-child(2) .suggestion-bullet { color: var(--accent-blue); }
.suggestion-item:nth-child(3) .suggestion-bullet { color: var(--accent-cyan); }
.suggestion-item:nth-child(4) .suggestion-bullet { color: var(--accent-green); }
.suggestion-item:nth-child(5) .suggestion-bullet { color: var(--accent-amber); }

/* ─── Key Points Missing ─────────────────────────────────────────── */
.missing-section {
  margin-top: 1.25rem;
}
.missing-title {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 0.6rem;
}
.missing-tags {
  display: flex; flex-wrap: wrap; gap: 0.4rem;
}
.missing-tag {
  background: rgba(239,68,68,0.08);
  border: 1px solid rgba(239,68,68,0.25);
  color: #fca5a5;
  padding: 0.25rem 0.7rem;
  border-radius: 99px;
  font-size: 0.78rem;
  font-weight: 500;
}

/* ─── Reset Button Row ───────────────────────────────────────────── */
.action-row {
  display: flex; gap: 0.75rem;
  margin-top: 1.25rem;
  flex-wrap: wrap;
}
.action-row .btn { flex: 1; min-width: 140px; }

/* ─── Settings Modal ─────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(8px);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal-overlay.open { display: flex; }

.modal {
  background: #13131f;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 2rem;
  width: 100%;
  max-width: 480px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.6);
  animation: modalIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.94) translateY(16px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 0.3rem;
}
.modal-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
  line-height: 1.5;
}
.modal-field { margin-bottom: 1rem; }
.modal-footer {
  display: flex; gap: 0.75rem; margin-top: 1.5rem;
  flex-wrap: wrap;
}
.modal-footer .btn { flex: 1; }

.api-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.4rem;
}
.api-hint a { color: var(--accent-purple); text-decoration: none; }
.api-hint a:hover { text-decoration: underline; }

/* ─── Alert Banner ───────────────────────────────────────────────── */
.alert {
  padding: 0.85rem 1.1rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  margin-bottom: 1.25rem;
  border: 1px solid;
}
.alert-error {
  background: rgba(239,68,68,0.08);
  border-color: rgba(239,68,68,0.25);
  color: #fca5a5;
}
.alert-warning {
  background: rgba(245,158,11,0.08);
  border-color: rgba(245,158,11,0.25);
  color: #fcd34d;
}
.alert-icon { flex-shrink: 0; font-size: 1rem; margin-top: 1px; }
.alert-text { line-height: 1.5; }

/* ─── Session History ────────────────────────────────────────────── */
.history-section {
  margin-top: 2rem;
}
.history-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 0.9rem;
}
.history-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.history-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  font-size: 0.85rem;
  cursor: pointer;
  transition: var(--transition);
}
.history-item:hover {
  background: var(--bg-card-hover);
  border-color: rgba(255,255,255,0.12);
}
.history-score {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
  color: #fff;
}
.history-q {
  flex: 1;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.history-time {
  font-size: 0.7rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* ─── Utility ────────────────────────────────────────────────────── */
.hidden { display: none !important; }
.divider {
  height: 1px;
  background: var(--border);
  margin: 1.5rem 0;
}
.text-muted { color: var(--text-muted); }
.mt-1 { margin-top: 0.75rem; }

/* ─── Chatbot ────────────────────────────────────────────────────── */
.chat-section { margin-top: 1.25rem; }
.chat-messages {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  max-height: 420px;
  overflow-y: auto;
  padding: 0.5rem 0 1rem;
  margin-bottom: 1rem;
}
.chat-msg {
  display: flex;
  gap: 0.65rem;
  align-items: flex-start;
  animation: fadeSlideUp 0.35s ease both;
}
.chat-msg-user { flex-direction: row-reverse; }
.chat-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.65rem;
  font-weight: 700;
  flex-shrink: 0;
  background: var(--gradient-btn);
  color: #fff;
}
.chat-msg-user .chat-avatar {
  background: rgba(255,255,255,0.08);
  color: var(--text-secondary);
  font-size: 0.55rem;
}
.chat-bubble {
  max-width: 85%;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--text-secondary);
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
}
.chat-msg-user .chat-bubble {
  background: rgba(139,92,246,0.12);
  border-color: rgba(139,92,246,0.25);
  color: var(--text-primary);
}
.chat-msg-bot.typing .chat-bubble {
  opacity: 0.7;
  font-style: italic;
}
.chat-form {
  display: flex;
  gap: 0.65rem;
  align-items: flex-end;
}
.chat-form textarea {
  flex: 1;
  min-height: 48px;
  resize: vertical;
}
.chat-form .btn { flex-shrink: 0; padding: 0.75rem 1.25rem; }
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* ─── Responsive ─────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .container { padding: 1.5rem 1rem 5rem; }
  header { padding: 1rem 1.25rem; }
  .card { padding: 1.5rem; }
  .hero { padding: 2.5rem 0 1.5rem; }
  .score-header { flex-direction: column; align-items: flex-start; }
}
