/* ═══════════════════════════════════════════════════════════════
   DashAI — Main Stylesheet
   Dark theme matching the generated dashboards
════════════════════════════════════════════════════════════════ */

/* ── CSS Variables ─────────────────────────────────────────── */
:root {
  --bg:  #0d0f14;
  --sf:  #141720;
  --sf2: #1c2030;
  --sf3: #232840;
  --bd:  rgba(255,255,255,.07);
  --bd2: rgba(255,255,255,.12);
  --tx:  #e8eaf0;
  --mu:  #7a8099;
  --ac:  #4f8ef7;
  --ac2: #3a7be8;
  --gr:  #38d9a9;
  --wn:  #ffa94d;
  --dn:  #ff6b6b;
  --go:  #e8b84b;

  --radius:  12px;
  --radius-lg: 18px;
  --shadow: 0 4px 24px rgba(0,0,0,.4);
  --font: 'Inter', system-ui, -apple-system, sans-serif;

  --transition: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Base Reset ────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--tx);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; border: none; }
textarea, input { font-family: inherit; }
ul, ol { list-style: none; }
a { color: inherit; }
svg { display: block; flex-shrink: 0; }

/* ── Screen System ─────────────────────────────────────────── */
.screen {
  position: fixed;
  inset: 0;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity var(--transition), transform var(--transition);
  z-index: 1;
}

.screen.active {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
  z-index: 2;
}

/* Screens with fixed layouts (no outer scroll) */
#screen-consult,
#screen-result {
  overflow: hidden;
}

/* ── Utility ───────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ════════════════════════════════════════════════════════════
   APP-INIT OVERLAY
════════════════════════════════════════════════════════════ */
.app-init {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

.app-init-spin {
  width: 40px;
  height: 40px;
  border: 3px solid var(--bd2);
  border-top-color: var(--ac);
  border-radius: 50%;
  animation: spin-cw 0.8s linear infinite;
}

/* ════════════════════════════════════════════════════════════
   SCREEN 0 — PIN
════════════════════════════════════════════════════════════ */
.pin-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.pin-card {
  background: var(--sf);
  border: 1px solid var(--bd2);
  border-radius: var(--radius-lg);
  padding: 48px 40px;
  width: 100%;
  max-width: 400px;
  text-align: center;
  box-shadow: var(--shadow);
}

.pin-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 28px;
}

.pin-logo .brand-gem { font-size: 1.6rem; color: var(--ac); }
.pin-logo .brand-name { font-size: 1.25rem; font-weight: 700; letter-spacing: -0.02em; }

.pin-title {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 10px;
  letter-spacing: -0.02em;
}

.pin-sub {
  color: var(--mu);
  font-size: 0.875rem;
  line-height: 1.55;
  margin-bottom: 28px;
}

.pin-field-wrap {
  display: flex;
  gap: 10px;
}

.pin-input {
  flex: 1;
  background: var(--sf2);
  border: 1px solid var(--bd2);
  border-radius: var(--radius);
  color: var(--tx);
  font-size: 0.95rem;
  padding: 11px 14px;
  outline: none;
  transition: border-color 0.2s;
}
.pin-input:focus { border-color: var(--ac); }
.pin-input::placeholder { color: var(--mu); }

.pin-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 11px 18px;
  background: var(--ac);
  color: #fff;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
  transition: background 0.2s, opacity 0.2s;
}
.pin-btn svg { width: 16px; height: 16px; }
.pin-btn:hover { background: var(--ac2); }
.pin-btn:disabled { opacity: 0.55; cursor: not-allowed; }

.pin-error {
  margin-top: 14px;
  color: var(--dn);
  font-size: 0.85rem;
}

/* ════════════════════════════════════════════════════════════
   SCREEN 1 — UPLOAD
════════════════════════════════════════════════════════════ */

/* Top nav */
.top-nav {
  padding: 20px 32px;
  border-bottom: 1px solid var(--bd);
  flex-shrink: 0;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-gem {
  font-size: 1.4rem;
  color: var(--ac);
  line-height: 1;
}

.brand-name {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--tx);
}

/* Upload main layout */
.upload-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px 64px;
  gap: 36px;
}

/* Hero text */
.upload-hero { text-align: center; }

.hero-title {
  font-size: clamp(1.8rem, 4vw, 2.8rem);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.03em;
  margin-bottom: 16px;
}

.gradient-text {
  background: linear-gradient(135deg, var(--ac), var(--gr));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-sub {
  font-size: 1rem;
  color: var(--mu);
  line-height: 1.7;
  max-width: 520px;
  margin: 0 auto;
}

/* Drop zone */
.drop-zone {
  position: relative;
  width: 100%;
  max-width: 560px;
  background: var(--sf);
  border: 2px dashed var(--bd2);
  border-radius: var(--radius-lg);
  padding: 48px 32px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, transform 0.2s;
  overflow: hidden;
}

.drop-zone:hover,
.drop-zone:focus-visible {
  border-color: var(--ac);
  background: var(--sf2);
  outline: none;
}

.drop-zone:focus-visible {
  box-shadow: 0 0 0 3px rgba(79,142,247,.25);
}

/* Drag-over state */
.drop-zone.drag-over {
  border-color: var(--gr);
  background: rgba(56,217,169,.06);
  transform: scale(1.01);
}

.drop-zone.drag-over .dz-idle { opacity: 0; }
.drop-zone.drag-over .dz-hover { opacity: 1; }

/* Idle content */
.dz-idle {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  transition: opacity 0.2s;
}

.dz-icon {
  width: 64px;
  height: 64px;
  color: var(--ac);
  margin-bottom: 4px;
}

.dz-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--tx);
}

.dz-sub {
  font-size: 0.85rem;
  color: var(--mu);
  margin-bottom: 8px;
}

/* Browse button inside drop zone */
.btn-browse {
  background: var(--ac);
  color: #fff;
  border: none;
  padding: 8px 22px;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 600;
  transition: background 0.2s, transform 0.15s;
}

.btn-browse:hover { background: var(--ac2); }
.btn-browse:active { transform: scale(0.97); }

/* Drag-over overlay */
.dz-hover {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  opacity: 0;
  pointer-events: none;
  color: var(--gr);
  font-weight: 600;
  font-size: 1.05rem;
  transition: opacity 0.2s;
}

.dz-hover-arrow {
  font-size: 2.5rem;
  line-height: 1;
  animation: bounce-down 0.8s ease-in-out infinite;
}

@keyframes bounce-down {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(6px); }
}

/* Upload progress */
.upload-progress {
  width: 100%;
  max-width: 560px;
  background: var(--sf);
  border: 1px solid var(--bd);
  border-radius: var(--radius);
  padding: 20px 24px;
}

.prog-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.prog-meta span { font-size: 0.875rem; }
.progress-filename { font-weight: 500; color: var(--tx); }
.progress-pct { color: var(--ac); font-weight: 600; font-variant-numeric: tabular-nums; }

.prog-track {
  height: 6px;
  background: var(--sf2);
  border-radius: 3px;
  overflow: hidden;
}

.prog-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--ac), var(--gr));
  border-radius: 3px;
  width: 0%;
  transition: width 0.3s ease;
}

.prog-hint {
  margin-top: 10px;
  font-size: 0.8rem;
  color: var(--mu);
  text-align: center;
}

/* Example cards */
.example-section {
  width: 100%;
  max-width: 560px;
  text-align: center;
}

.example-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--mu);
  margin-bottom: 14px;
}

.example-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.example-card {
  background: var(--sf);
  border: 1px solid var(--bd);
  border-radius: var(--radius);
  padding: 18px 14px;
  text-align: center;
  transition: border-color 0.2s, transform 0.2s;
}

.example-card:hover {
  border-color: var(--bd2);
  transform: translateY(-2px);
}

.ex-icon { font-size: 1.5rem; margin-bottom: 8px; }
.ex-title { font-size: 0.875rem; font-weight: 600; margin-bottom: 4px; }
.ex-desc  { font-size: 0.75rem; color: var(--mu); line-height: 1.5; }


/* ════════════════════════════════════════════════════════════
   SCREEN 2 — CONSULTATION
════════════════════════════════════════════════════════════ */

.consult-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Chat Panel (left 40%) ── */
.chat-panel {
  width: 40%;
  min-width: 320px;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--bd);
  background: var(--sf);
}

.chat-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--bd);
  flex-shrink: 0;
}

.chat-topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ai-avatar {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--ac), #7b5de8);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.chat-agent-name {
  font-size: 0.9rem;
  font-weight: 600;
}

.chat-agent-status {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
  font-size: 0.75rem;
  color: var(--mu);
}

.status-dot {
  width: 7px;
  height: 7px;
  background: var(--gr);
  border-radius: 50%;
  animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

/* Chat messages area */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--sf3); border-radius: 2px; }

/* Message bubbles */
.msg {
  display: flex;
  gap: 10px;
  max-width: 88%;
  animation: msg-in 0.25s ease;
}

@keyframes msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.msg-ai {
  align-self: flex-start;
  flex-direction: row;
}

.msg-user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.msg-mini-avatar {
  width: 28px;
  height: 28px;
  background: linear-gradient(135deg, var(--ac), #7b5de8);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  margin-top: 2px;
}

.msg-bubble {
  padding: 12px 14px;
  border-radius: 14px;
  font-size: 0.875rem;
  line-height: 1.6;
  word-break: break-word;
}

.msg-ai .msg-bubble {
  background: var(--sf2);
  border-bottom-left-radius: 4px;
  color: var(--tx);
}

.msg-user .msg-bubble {
  background: var(--ac);
  border-bottom-right-radius: 4px;
  color: #fff;
}

/* Markdown inside bubbles */
.msg-bubble strong { font-weight: 600; }
.msg-bubble em     { font-style: italic; }
.msg-bubble ul     { padding-left: 16px; list-style: disc; margin-top: 6px; }
.msg-bubble ol     { padding-left: 16px; list-style: decimal; margin-top: 6px; }
.msg-bubble li     { margin-bottom: 3px; }
.msg-bubble p      { margin-bottom: 6px; }
.msg-bubble p:last-child { margin-bottom: 0; }

/* Typing indicator */
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 14px 16px;
  background: var(--sf2);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  width: fit-content;
}

.typing-dot {
  width: 7px;
  height: 7px;
  background: var(--mu);
  border-radius: 50%;
  animation: typing-bounce 1.2s ease-in-out infinite;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.5; }
  40%            { transform: translateY(-6px); opacity: 1; }
}

/* Chat compose area */
.chat-compose {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 14px 16px;
  border-top: 1px solid var(--bd);
  flex-shrink: 0;
}

.chat-textarea {
  flex: 1;
  background: var(--sf2);
  border: 1px solid var(--bd);
  border-radius: 10px;
  padding: 10px 14px;
  color: var(--tx);
  font-size: 0.875rem;
  resize: none;
  max-height: 120px;
  overflow-y: auto;
  line-height: 1.5;
  transition: border-color 0.2s;
}

.chat-textarea:focus {
  outline: none;
  border-color: var(--ac);
}

.chat-textarea:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.chat-textarea::placeholder { color: var(--mu); }

.send-btn {
  width: 38px;
  height: 38px;
  background: var(--ac);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s, transform 0.15s;
}

.send-btn svg { width: 16px; height: 16px; color: #fff; transform: rotate(0deg); }
.send-btn:hover:not(:disabled) { background: var(--ac2); }
.send-btn:active:not(:disabled) { transform: scale(0.93); }
.send-btn:disabled { opacity: 0.35; cursor: not-allowed; }

/* ── Info Panel (right 60%) ── */
.info-panel {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.info-panel::-webkit-scrollbar { width: 4px; }
.info-panel::-webkit-scrollbar-thumb { background: var(--sf3); border-radius: 2px; }

/* Skeleton loader */
.info-skeleton {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.sk-title {
  height: 22px;
  width: 55%;
  background: var(--sf2);
  border-radius: 6px;
  animation: shimmer 1.5s linear infinite;
}

.sk-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.sk-cell {
  height: 70px;
  background: var(--sf2);
  border-radius: var(--radius);
  animation: shimmer 1.5s linear infinite;
}

.sk-cell:nth-child(2) { animation-delay: 0.15s; }
.sk-cell:nth-child(3) { animation-delay: 0.3s; }
.sk-cell:nth-child(4) { animation-delay: 0.45s; }

.sk-line {
  height: 14px;
  background: var(--sf2);
  border-radius: 4px;
  animation: shimmer 1.5s linear infinite;
}

.sk-short { width: 65%; }

@keyframes shimmer {
  0%   { opacity: 0.6; }
  50%  { opacity: 1; }
  100% { opacity: 0.6; }
}

/* Data summary */
.data-summary {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.summary-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--bd);
}

.summary-file-icon {
  font-size: 1.8rem;
  line-height: 1;
}

.summary-file-name {
  font-size: 1rem;
  font-weight: 600;
  word-break: break-all;
}

.summary-file-sub {
  font-size: 0.8rem;
  color: var(--mu);
  margin-top: 3px;
}

.summary-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.stat-card {
  background: var(--sf);
  border: 1px solid var(--bd);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.stat-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--mu);
  margin-bottom: 6px;
}

.stat-value {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--tx);
  font-variant-numeric: tabular-nums;
}

.stat-unit {
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--mu);
  margin-left: 3px;
}

.summary-lang-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--sf2);
  border: 1px solid var(--bd);
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 0.78rem;
  color: var(--mu);
  width: fit-content;
}

/* Recommendation plan */
.reco-plan {
  display: flex;
  flex-direction: column;
  gap: 14px;
  animation: fade-up 0.4s ease;
  padding-bottom: 8px;
}

@keyframes fade-up {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.plan-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--bd);
}

.plan-main-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--tx);
}

.plan-badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.plan-badge {
  background: var(--sf3);
  color: var(--mu);
  border-radius: 20px;
  padding: 3px 10px;
  font-size: 0.72rem;
  font-weight: 500;
  white-space: nowrap;
}

.plan-section {
  background: var(--sf);
  border: 1px solid var(--bd);
  border-radius: var(--radius);
  overflow: hidden;
}

.plan-section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--mu);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--bd);
  background: var(--sf2);
}

.plan-section-body {
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.plan-finding {
  font-size: 0.83rem;
  color: var(--tx);
  padding-left: 16px;
  position: relative;
  line-height: 1.5;
}

.plan-finding::before {
  content: '•';
  position: absolute;
  left: 4px;
  color: var(--gr);
}

.plan-build-item {
  background: var(--sf2);
  border-radius: 8px;
  padding: 10px 12px;
}

.plan-build-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.plan-build-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--tx);
}

.plan-build-type {
  font-size: 0.72rem;
  background: rgba(79,142,247,.15);
  color: var(--ac);
  padding: 2px 8px;
  border-radius: 4px;
}

.plan-build-desc {
  font-size: 0.78rem;
  color: var(--mu);
  line-height: 1.5;
}

.plan-skip-item {
  font-size: 0.82rem;
  color: var(--mu);
  padding-left: 16px;
  position: relative;
  line-height: 1.5;
}

.plan-skip-item::before {
  content: '–';
  position: absolute;
  left: 4px;
}

.plan-skip-reason {
  color: var(--dn);
  font-size: 0.75rem;
  margin-top: 2px;
}

.plan-warning-item {
  font-size: 0.82rem;
  color: var(--wn);
  padding-left: 20px;
  position: relative;
  line-height: 1.5;
}

.plan-warning-item::before {
  content: '⚠';
  position: absolute;
  left: 2px;
  font-size: 0.75rem;
}

/* Plan action buttons */
.plan-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 16px;
  border-top: 1px solid var(--bd);
  margin-top: auto;
  flex-shrink: 0;
  background: var(--bg);
  padding-bottom: 4px;
  position: sticky;
  bottom: 0;
}

.btn-approve {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 13px;
  background: var(--ac);
  color: #fff;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 600;
  transition: background 0.2s, transform 0.15s;
}

.btn-approve svg { width: 18px; height: 18px; }
.btn-approve:hover { background: var(--ac2); }
.btn-approve:active { transform: scale(0.98); }

.btn-changes {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 11px;
  background: transparent;
  color: var(--mu);
  border: 1px solid var(--bd);
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  transition: border-color 0.2s, color 0.2s;
}

.btn-changes svg { width: 16px; height: 16px; }
.btn-changes:hover { border-color: var(--bd2); color: var(--tx); }


/* ════════════════════════════════════════════════════════════
   SCREEN 3 — GENERATING
════════════════════════════════════════════════════════════ */

.gen-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 48px 24px;
}

/* Orb spinner */
.gen-orb {
  position: relative;
  width: 100px;
  height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
}

.orb-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid transparent;
}

.orb-ring-1 {
  border-top-color: var(--ac);
  animation: spin-cw 1.4s linear infinite;
}

.orb-ring-2 {
  inset: 12px;
  border-right-color: var(--gr);
  animation: spin-ccw 2s linear infinite;
}

.orb-ring-3 {
  inset: 24px;
  border-bottom-color: var(--go);
  animation: spin-cw 2.6s linear infinite;
}

.orb-core {
  font-size: 1.2rem;
  color: var(--ac);
  z-index: 1;
}

@keyframes spin-cw  { to { transform: rotate(360deg);  } }
@keyframes spin-ccw { to { transform: rotate(-360deg); } }

/* Gen text */
.gen-title {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  text-align: center;
}

.gen-sub {
  font-size: 0.9rem;
  color: var(--mu);
  text-align: center;
  max-width: 380px;
}

/* Steps */
.gen-steps {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 340px;
  background: var(--sf);
  border: 1px solid var(--bd);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
}

.gen-step {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.875rem;
  color: var(--mu);
  transition: color 0.3s;
}

.gen-step.done   { color: var(--gr); }
.gen-step.active { color: var(--tx); }

.step-bullet {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--sf3);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6rem;
  transition: all 0.3s;
}

.gen-step.done .step-bullet {
  background: var(--gr);
  border-color: var(--gr);
  color: var(--bg);
}

.gen-step.done .step-bullet::after { content: '✓'; }

.gen-step.active .step-bullet {
  border-color: var(--ac);
  animation: pulse-ring 1s ease-in-out infinite;
}

@keyframes pulse-ring {
  0%, 100% { box-shadow: 0 0 0 0 rgba(79,142,247,.4); }
  50%       { box-shadow: 0 0 0 5px rgba(79,142,247,0); }
}

.gen-elapsed {
  font-size: 0.8rem;
  color: var(--mu);
  font-variant-numeric: tabular-nums;
}


/* ════════════════════════════════════════════════════════════
   SCREEN 4 — RESULT
════════════════════════════════════════════════════════════ */

.result-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* Left panel */
.result-left {
  width: 35%;
  min-width: 280px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 24px;
  overflow-y: auto;
  border-right: 1px solid var(--bd);
  background: var(--sf);
}

.result-left::-webkit-scrollbar { width: 4px; }
.result-left::-webkit-scrollbar-thumb { background: var(--sf3); border-radius: 2px; }

.result-header { padding-bottom: 16px; border-bottom: 1px solid var(--bd); }
.result-title  { font-size: 1.1rem; font-weight: 700; margin-bottom: 4px; }
.result-date   { font-size: 0.78rem; color: var(--mu); }

/* Quality badge */
.quality-block {
  background: var(--sf2);
  border: 1px solid var(--bd);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.quality-label {
  font-size: 0.8rem;
  color: var(--mu);
}

.quality-score {
  font-size: 1.3rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.quality-score.high   { color: var(--gr); }
.quality-score.medium { color: var(--go); }
.quality-score.low    { color: var(--dn); }

.quality-bar-wrap {
  height: 4px;
  background: var(--sf3);
  border-radius: 2px;
  margin-top: 8px;
  overflow: hidden;
}

.quality-bar {
  height: 100%;
  border-radius: 2px;
  transition: width 1s ease;
}

/* Review notes */
.review-notes {
  background: var(--sf2);
  border: 1px solid var(--bd);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 0.8rem;
  color: var(--mu);
  line-height: 1.6;
}

.review-notes-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--mu);
  margin-bottom: 6px;
}

/* Improvement cards */
.improvements-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.improvements-heading {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--mu);
  margin-bottom: 4px;
}

.improve-card {
  background: var(--sf2);
  border: 1px solid var(--bd);
  border-radius: var(--radius);
  padding: 12px 14px;
  transition: border-color 0.2s;
}

.improve-card:hover { border-color: var(--bd2); }

.improve-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.improve-card-title {
  font-size: 0.85rem;
  font-weight: 600;
}

.effort-badge {
  font-size: 0.68rem;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 500;
}

.effort-quick  { background: rgba(56,217,169,.15); color: var(--gr); }
.effort-medium { background: rgba(255,169,77,.15);  color: var(--wn); }

.improve-card-desc {
  font-size: 0.78rem;
  color: var(--mu);
  line-height: 1.5;
  margin-bottom: 10px;
}

.btn-apply {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--sf3);
  color: var(--tx);
  border: 1px solid var(--bd);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 0.78rem;
  font-weight: 500;
  transition: background 0.2s, border-color 0.2s;
}

.btn-apply:hover { background: var(--sf2); border-color: var(--ac); color: var(--ac); }
.btn-apply:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-apply-spinner {
  width: 12px;
  height: 12px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: var(--tx);
  border-radius: 50%;
  animation: spin-cw 0.7s linear infinite;
}

/* Result action buttons */
.result-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: auto;
  padding-top: 8px;
}

.ra-btn {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 11px 14px;
  background: var(--sf2);
  color: var(--tx);
  border: 1px solid var(--bd);
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  text-align: left;
  transition: background 0.2s, border-color 0.2s;
}

.ra-btn svg { width: 18px; height: 18px; flex-shrink: 0; }
.ra-btn:hover { background: var(--sf3); border-color: var(--bd2); }

.ra-danger:hover { border-color: var(--dn); color: var(--dn); }
.ra-ghost { color: var(--mu); }
.ra-ghost:hover { color: var(--tx); }

/* Right panel: Preview */
.result-right {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.preview-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--bd);
  flex-shrink: 0;
  background: var(--sf);
}

.preview-modes {
  display: flex;
  background: var(--sf2);
  border: 1px solid var(--bd);
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
}

.mode-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  background: transparent;
  color: var(--mu);
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 500;
  transition: background 0.2s, color 0.2s;
}

.mode-btn svg { width: 16px; height: 16px; }
.mode-btn.active { background: var(--sf3); color: var(--tx); }
.mode-btn:hover:not(.active) { color: var(--tx); }

/* iframe wrapper */
.iframe-wrap {
  flex: 1;
  overflow: hidden;
  background: var(--sf2);
  position: relative;
  transition: all 0.3s ease;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.iframe-wrap.mobile-mode {
  overflow: auto;
  padding: 20px;
}

.preview-frame {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

.iframe-wrap.mobile-mode .preview-frame {
  width: 390px;
  height: 844px;
  border-radius: 16px;
  flex-shrink: 0;
  box-shadow: 0 0 0 1px var(--bd), 0 20px 60px rgba(0,0,0,.5);
}


/* ════════════════════════════════════════════════════════════
   COMMON COMPONENTS
════════════════════════════════════════════════════════════ */

/* Icon button (ghost) */
.icon-btn {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--bd);
  border-radius: 8px;
  color: var(--mu);
  flex-shrink: 0;
  transition: border-color 0.2s, color 0.2s;
}

.icon-btn svg   { width: 16px; height: 16px; }
.icon-btn:hover { border-color: var(--bd2); color: var(--tx); }

/* "AI is thinking…" gap indicator shown when tokens pause mid-stream */
.thinking-label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--mu);
  font-size: 0.78rem;
  font-style: italic;
  margin-top: 6px;
  animation: fade-in 0.3s ease;
}

.thinking-spin {
  width: 12px;
  height: 12px;
  border: 1.5px solid var(--mu);
  border-top-color: var(--ac);
  border-radius: 50%;
  display: inline-block;
  animation: spin-cw 0.9s linear infinite;
  flex-shrink: 0;
}

@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(0);
  background: var(--sf2);
  border: 1px solid var(--bd2);
  border-radius: var(--radius);
  padding: 12px 20px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--tx);
  z-index: 999;
  box-shadow: var(--shadow);
  transition: opacity 0.3s, transform 0.3s;
  white-space: nowrap;
  max-width: calc(100vw - 48px);
  text-overflow: ellipsis;
  overflow: hidden;
}

.toast.hidden {
  display: block !important; /* override .hidden so we can animate */
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(10px);
}

.toast.toast-success { border-color: var(--gr); color: var(--gr); }
.toast.toast-error   { border-color: var(--dn); color: var(--dn); }
.toast.toast-info    { border-color: var(--ac); color: var(--ac); }


/* ════════════════════════════════════════════════════════════
   MOBILE RESPONSIVE  (≤ 768 px)
════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  .top-nav { padding: 16px 20px; }

  .upload-main { padding: 32px 16px 48px; }

  .hero-title { font-size: 1.7rem; }
  .hero-sub br { display: none; }

  .drop-zone { padding: 36px 20px; }

  .example-cards { grid-template-columns: 1fr; }

  /* Consultation: stack vertically */
  .consult-layout { flex-direction: column; height: auto; overflow: auto; }

  .chat-panel {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--bd);
    height: 55vh;
  }

  .info-panel {
    height: auto;
    min-height: 320px;
    padding: 16px;
  }

  .plan-actions { position: static; }

  /* Generating */
  .gen-center { padding: 48px 20px; }

  /* Result: stack vertically */
  .result-layout { flex-direction: column; height: auto; overflow: auto; }

  .result-left {
    width: 100%;
    min-width: 0;
    border-right: none;
    border-bottom: 1px solid var(--bd);
    max-height: none;
  }

  .result-right { height: 60vh; }

  .result-actions { margin-top: 16px; }

  .iframe-wrap.mobile-mode { padding: 12px; }
}


/* ════════════════════════════════════════════════════════════
   RTL (Arabic)  — toggled by JS on <html dir="rtl">
════════════════════════════════════════════════════════════ */
[dir="rtl"] .msg-ai  { flex-direction: row-reverse; }
[dir="rtl"] .msg-user { flex-direction: row; }

[dir="rtl"] .msg-ai .msg-bubble {
  border-radius: 14px;
  border-bottom-right-radius: 4px;
  border-bottom-left-radius: 14px;
}

[dir="rtl"] .msg-user .msg-bubble {
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  border-bottom-right-radius: 14px;
}

[dir="rtl"] .chat-topbar-left { flex-direction: row-reverse; }
[dir="rtl"] .summary-header   { flex-direction: row-reverse; text-align: right; }
[dir="rtl"] .plan-finding,
[dir="rtl"] .plan-skip-item,
[dir="rtl"] .plan-warning-item { padding-left: 0; padding-right: 16px; }
[dir="rtl"] .plan-finding::before,
[dir="rtl"] .plan-skip-item::before,
[dir="rtl"] .plan-warning-item::before { left: auto; right: 4px; }
[dir="rtl"] .ra-btn { text-align: right; }
