/* ============================================================
   Academic Researcher — assets/css/app.css  v4.0
   Design: premium minimal, black/white/grey only
   ============================================================ */

/* ── Google Fonts ─────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&family=Cairo:wght@400;500;600;700;800;900&family=IBM+Plex+Sans+Arabic:wght@400;500;600;700&display=swap');

/* ── Design Tokens ────────────────────────────────────────── */
:root {
  /* Dark mode (default) */
  --bg:       #000000;
  --bg2:      #0a0a0a;
  --bg3:      #111111;
  --panel:    #111111;
  --panel2:   #1a1a1a;
  --panel3:   #222222;
  --border:   #2a2a2a;
  --border2:  #333333;
  --text:     #ffffff;
  --text2:    #a0a0a0;
  --text3:    #666666;
  --accent:   #ffffff;
  --accent-bg:#1a1a1a;
  --danger:   #ff4444;
  --success:  #22c55e;
  --warn:     #f59e0b;

  /* Shadows */
  --shadow-sm:  0 1px 3px rgba(255,255,255,.04);
  --shadow-md:  0 4px 24px rgba(0,0,0,.6);
  --shadow-lg:  0 20px 60px rgba(0,0,0,.8);

  /* Radii */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 24px;

  /* Fonts */
  --font-en: 'Inter', system-ui, sans-serif;
  --font-ar: 'Cairo', 'IBM Plex Sans Arabic', system-ui, sans-serif;
}

[data-theme="light"] {
  --bg:       #ffffff;
  --bg2:      #f7f7f7;
  --bg3:      #f0f0f0;
  --panel:    #ffffff;
  --panel2:   #f7f7f7;
  --panel3:   #eeeeee;
  --border:   #e5e5e5;
  --border2:  #d4d4d4;
  --text:     #111111;
  --text2:    #555555;
  --text3:    #999999;
  --accent:   #000000;
  --accent-bg:#f0f0f0;
  --shadow-sm:  0 1px 3px rgba(0,0,0,.06);
  --shadow-md:  0 4px 24px rgba(0,0,0,.10);
  --shadow-lg:  0 20px 60px rgba(0,0,0,.14);
}

/* ── Reset ────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-en);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.6;
  transition: background .2s, color .2s;
  -webkit-font-smoothing: antialiased;
}
[dir="rtl"] body { font-family: var(--font-ar); }
[dir="rtl"] *   { font-family: var(--font-ar); }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; }
button, input, select, textarea { font-family: inherit; }

/* ── Typography ───────────────────────────────────────────── */
h1, h2, h3, h4, h5 { font-weight: 800; line-height: 1.1; }
h1 { font-size: clamp(36px, 5vw, 72px); letter-spacing: -.04em; }
h2 { font-size: clamp(24px, 3vw, 42px); letter-spacing: -.03em; }
h3 { font-size: clamp(18px, 2vw, 24px); letter-spacing: -.02em; }
[dir="rtl"] h1, [dir="rtl"] h2, [dir="rtl"] h3 { letter-spacing: 0; }
p   { color: var(--text2); line-height: 1.75; }

/* ── Topbar ───────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 100;
  height: 64px;
  padding: 0 32px;
  display: flex; align-items: center; justify-content: space-between;
  background: rgba(0,0,0,.8);
  backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--border);
}
[data-theme="light"] .topbar { background: rgba(255,255,255,.85); }
.brand {
  display: flex; align-items: center; gap: 12px;
  font-weight: 900; font-size: 16px; letter-spacing: -.03em;
}

.site-logo {
  height: 48px;
  width: auto;
  display: block;
  object-fit: contain;
}
.logo-for-light { display: block; }
.logo-for-dark { display: none; }
[data-theme="dark"] .logo-for-light { display: none; }
[data-theme="dark"] .logo-for-dark { display: block; }
.logo-mark {
  width: 32px; height: 32px; border-radius: var(--r-sm);
  background: var(--text);
  display: grid; place-items: center;
  font-size: 13px; font-weight: 900; color: var(--bg);
  flex-shrink: 0;
}
.nav-links { display: flex; align-items: center; gap: 4px; }
.nav-links a {
  padding: 7px 14px; border-radius: var(--r-md);
  font-size: 14px; font-weight: 600; color: var(--text2);
  transition: color .15s, background .15s;
}
.nav-links a:hover { color: var(--text); background: var(--panel2); }
.nav-actions { display: flex; align-items: center; gap: 8px; }

/* ── Buttons ──────────────────────────────────────────────── */
.btn, .btn-ghost, .btn-sm {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font-weight: 700; cursor: pointer; border: 1px solid transparent;
  border-radius: var(--r-md); transition: all .15s; text-decoration: none;
  white-space: nowrap;
}
.btn {
  background: var(--text); color: var(--bg);
  border-color: var(--text);
  padding: 10px 20px; font-size: 14px;
}
.btn:hover { opacity: .88; }
.btn-ghost {
  background: transparent; color: var(--text);
  border-color: var(--border2);
  padding: 10px 20px; font-size: 14px;
}
.btn-ghost:hover { background: var(--panel2); border-color: var(--text3); }
.btn-sm { padding: 7px 14px; font-size: 13px; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { opacity: .85; }
.btn[disabled], .btn:disabled { opacity: .4; pointer-events: none; }

/* ── Cards ────────────────────────────────────────────────── */
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}
.card-body { padding: 28px; }
.card-sm   { border-radius: var(--r-md); }
.card-hover:hover { border-color: var(--border2); box-shadow: var(--shadow-md); transition: all .2s; }

/* ── Forms ────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 6px; }
.label { font-size: 13px; font-weight: 700; color: var(--text2); }
.input, select, textarea {
  width: 100%;
  background: var(--bg2); color: var(--text);
  border: 1px solid var(--border2);
  border-radius: var(--r-md);
  padding: 12px 16px;
  font-size: 14px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, select:focus, textarea:focus {
  border-color: var(--text3);
  box-shadow: 0 0 0 3px rgba(255,255,255,.06);
}
[data-theme="light"] .input:focus,
[data-theme="light"] select:focus,
[data-theme="light"] textarea:focus {
  box-shadow: 0 0 0 3px rgba(0,0,0,.06);
}
select { -webkit-appearance: none; appearance: none; cursor: pointer; }
textarea { resize: vertical; min-height: 200px; line-height: 1.75; }
.input-error { border-color: var(--danger) !important; }
.field-error { font-size: 12px; color: var(--danger); }

/* ── Alerts ───────────────────────────────────────────────── */
.alert {
  padding: 13px 16px; border-radius: var(--r-md);
  font-size: 14px; font-weight: 500;
  border: 1px solid;
}
.alert-error   { background: rgba(255,68,68,.08);   border-color: rgba(255,68,68,.25);   color: #ff6b6b; }
.alert-success { background: rgba(34,197,94,.08);   border-color: rgba(34,197,94,.25);   color: #4ade80; }
.alert-warn    { background: rgba(245,158,11,.08);  border-color: rgba(245,158,11,.25);  color: #fbbf24; }
.alert-info    { background: rgba(255,255,255,.04); border-color: var(--border2); color: var(--text2); }

/* ── Divider ──────────────────────────────────────────────── */
.divider {
  display: flex; align-items: center; gap: 16px;
  color: var(--text3); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em;
}
.divider::before, .divider::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}

/* ── Badge ────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  background: var(--panel2); border: 1px solid var(--border2); color: var(--text2);
}
.badge-active  { background: rgba(34,197,94,.12); border-color: rgba(34,197,94,.3); color: #4ade80; }
.badge-pending { background: rgba(245,158,11,.12); border-color: rgba(245,158,11,.3); color: #fbbf24; }
.badge-danger  { background: rgba(255,68,68,.12);  border-color: rgba(255,68,68,.3);  color: #ff6b6b; }

/* ── Table ────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--r-lg); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th {
  padding: 13px 16px; text-align: start;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text3); background: var(--panel2);
  border-bottom: 1px solid var(--border);
}
tbody td { padding: 14px 16px; border-bottom: 1px solid var(--border); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--panel2); transition: background .1s; }

/* ── Stats / Stat card ────────────────────────────────────── */
.stat-card { padding: 24px; }
.stat-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text3); margin-bottom: 10px; }
.stat-value { font-size: 36px; font-weight: 900; letter-spacing: -.04em; line-height: 1; }
.stat-sub   { font-size: 13px; color: var(--text3); margin-top: 6px; }

/* ── Progress bar ─────────────────────────────────────────── */
.progress { height: 4px; background: var(--panel3); border-radius: 999px; overflow: hidden; }
.progress-bar { height: 100%; background: var(--text); border-radius: 999px; transition: width .4s ease; }

/* ── Layout Utilities ─────────────────────────────────────── */
.container   { max-width: 1200px; margin: 0 auto; padding: 0 24px; }
.container-sm{ max-width: 480px;  margin: 0 auto; padding: 0 24px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.flex   { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-center  { display: flex; justify-content: center; align-items: center; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.gap-24 { gap: 24px; }
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mt-32 { margin-top: 32px; }
.mb-8  { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.mb-32 { margin-bottom: 32px; }
.p-16  { padding: 16px; }
.p-24  { padding: 24px; }
.p-32  { padding: 32px; }
.w-full { width: 100%; }
.text-sm    { font-size: 13px; }
.text-xs    { font-size: 11px; }
.text-muted { color: var(--text2); }
.text-dim   { color: var(--text3); }
.text-right { text-align: end; }
.text-center{ text-align: center; }
.fw-700 { font-weight: 700; }
.fw-800 { font-weight: 800; }

/* ── Home: Hero ───────────────────────────────────────────── */
.hero {
  padding: 120px 24px 80px;
  text-align: center;
  max-width: 860px; margin: 0 auto;
}
.hero-eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 16px; border-radius: 999px;
  border: 1px solid var(--border2);
  font-size: 13px; font-weight: 700; color: var(--text2);
  margin-bottom: 32px;
  background: var(--panel2);
}
.hero h1 { margin-bottom: 24px; }
.hero p   { font-size: 20px; max-width: 640px; margin: 0 auto 40px; }
.hero-cta { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

/* Home: Feature section */
.section { padding: 80px 24px; }
.section-header { text-align: center; margin-bottom: 56px; }
.section-header p { max-width: 540px; margin: 16px auto 0; font-size: 18px; }
.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}
.feature-card { padding: 28px; transition: border-color .2s; }
.feature-card:hover { border-color: var(--border2); }
.feature-icon {
  width: 40px; height: 40px;
  background: var(--panel2); border: 1px solid var(--border2);
  border-radius: var(--r-md);
  display: grid; place-items: center;
  font-size: 18px; margin-bottom: 18px;
}
.feature-card h3 { margin-bottom: 10px; font-size: 18px; }
.feature-card p  { font-size: 14px; }

/* Home: AI Modes */
.modes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}
.mode-card {
  padding: 22px;
  display: flex; align-items: flex-start; gap: 16px;
  cursor: default; transition: border-color .2s;
}
.mode-card:hover { border-color: var(--border2); }
.mode-num {
  font-size: 12px; font-weight: 900; letter-spacing: .06em;
  color: var(--text3); flex-shrink: 0; margin-top: 2px;
}
.mode-card h4  { font-size: 15px; margin-bottom: 6px; }
.mode-card p   { font-size: 13px; }

/* Home: Pricing */
.pricing-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 16px; align-items: start;
}
.price-card {
  padding: 16px;
  position: relative;
  overflow: hidden;
  transition: transform .22s ease, box-shadow .22s ease, border-color .22s ease, background .22s ease;
}
.price-card:hover {
  transform: translateY(-8px);
  border-color: var(--border2);
  box-shadow: var(--shadow-md);
  background: var(--panel2);
}
.price-card:hover .btn {
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}
.price-card .btn { transition: transform .18s ease, box-shadow .18s ease, background .18s ease, border-color .18s ease; }
.price-card.popular {
  border-color: var(--text3);
  background: var(--panel2);
  transform: scale(1.02);
}
.price-card.popular:hover {
  transform: translateY(-8px) scale(1.02);
}

.plan-label { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--text3); margin-bottom: 12px; }
.plan-price {
  font-size: 30px; font-weight: 900; letter-spacing: -.035em; line-height: 1;
  margin-bottom: 6px;
}
.plan-price sup { font-size: 18px; vertical-align: top; margin-top: 10px; font-weight: 700; }
.plan-period { font-size: 12px; color: var(--text3); margin-bottom: 14px; }
.plan-features { list-style: none; display: grid; gap: 6px; margin-bottom: 16px; }
.plan-features li {
  font-size: 11.8px; color: var(--text2);
  display: flex; align-items: flex-start; gap: 10px;
  line-height: 1.55;
}
.plan-features li::before {
  content: '✓'; color: var(--text); font-weight: 900; flex-shrink: 0;
  width: 18px; height: 18px; border: 1px solid var(--border2); border-radius: 999px;
  display: inline-grid; place-items: center; font-size: 11px; margin-top: 1px;
}
.plan-words { font-size: 13px; font-weight: 800; color: var(--text); margin-bottom: 6px; }


.payment-method-card, .payment-choice {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--panel2);
}
.payment-method-card { padding: 16px; }
.payment-method-card b { display:block; margin-bottom:8px; }
.payment-choice-grid { display:grid; grid-template-columns:1fr 1fr; gap:10px; }
.payment-choice { padding: 12px 14px; display:flex; align-items:center; gap:10px; cursor:pointer; }
.payment-choice input { accent-color: currentColor; }
@media (max-width: 1180px) {
  .pricing-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .pricing-grid { grid-template-columns: 1fr; }
  .payment-choice-grid { grid-template-columns: 1fr; }
}

/* Home: FAQ */
.faq-list { max-width: 720px; margin: 0 auto; display: grid; gap: 12px; }
.faq-item {
  border: 1px solid var(--border); border-radius: var(--r-lg);
  overflow: hidden;
}
.faq-q {
  padding: 18px 22px; font-weight: 700; font-size: 15px;
  cursor: pointer; display: flex; justify-content: space-between; align-items: center;
  user-select: none;
}
.faq-q span { transition: transform .2s; font-size: 18px; color: var(--text3); }
.faq-item.open .faq-q span { transform: rotate(45deg); }
.faq-a {
  padding: 0 22px; max-height: 0; overflow: hidden;
  transition: max-height .3s ease, padding .3s;
  font-size: 14px; line-height: 1.8; color: var(--text2);
}
.faq-item.open .faq-a { max-height: 300px; padding: 0 22px 18px; }

/* ── Auth pages ───────────────────────────────────────────── */
.auth-wrap {
  min-height: calc(100vh - 64px);
  display: grid; place-items: center;
  padding: 40px 24px;
}
.auth-card { width: min(440px, 100%); }
.auth-card .card-body { padding: 36px; }
.auth-card h1 { font-size: 28px; margin-bottom: 6px; }
.auth-card .sub { font-size: 14px; color: var(--text2); margin-bottom: 28px; }
.auth-form { display: grid; gap: 18px; }
.auth-footer-link { text-align: center; font-size: 13px; color: var(--text3); margin-top: 20px; }
.auth-footer-link a { color: var(--text2); font-weight: 700; }
.auth-footer-link a:hover { color: var(--text); }

/* ── App layout ───────────────────────────────────────────── */
.app-wrap {
  max-width: 1440px; margin: 0 auto;
  padding: 24px;
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 20px;
  min-height: calc(100vh - 64px);
}
.sidebar {
  position: sticky; top: 84px;
  height: fit-content; max-height: calc(100vh - 104px);
  overflow-y: auto;
  padding: 20px;
  display: flex; flex-direction: column; gap: 8px;
}
.sidebar-section { margin-bottom: 8px; }
.sidebar-label {
  font-size: 10px; font-weight: 800; text-transform: uppercase;
  letter-spacing: .1em; color: var(--text3);
  padding: 0 12px; margin-bottom: 4px;
}
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar-nav a, .sidebar-nav button {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: var(--r-md);
  font-size: 14px; font-weight: 600; color: var(--text2);
  transition: all .12s; border: none; background: none;
  cursor: pointer; text-decoration: none; width: 100%; text-align: start;
}
.sidebar-nav a:hover, .sidebar-nav button:hover { color: var(--text); background: var(--panel2); }
.sidebar-nav a.active, .sidebar-nav a[aria-current] { color: var(--text); background: var(--panel2); }
.sidebar-icon { width: 18px; text-align: center; flex-shrink: 0; font-size: 15px; }

/* Plan badge in sidebar */
.plan-pill {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; border-radius: var(--r-md);
  background: var(--panel2); border: 1px solid var(--border);
  font-size: 13px;
}
.plan-pill b { font-weight: 800; }
.word-bar-wrap { margin-top: 6px; }
.word-bar-label {
  display: flex; justify-content: space-between;
  font-size: 11px; color: var(--text3); margin-bottom: 6px;
}

/* Main editor */
.editor-wrap { display: flex; flex-direction: column; gap: 16px; }
.editor-toolbar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.editor-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
}
.editor-panel {
  display: flex; flex-direction: column;
}
.editor-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
}
.editor-head h3 { font-size: 14px; font-weight: 700; }
.editor-body { flex: 1; }
.editor-body textarea {
  border: none; border-radius: 0 0 var(--r-lg) var(--r-lg);
  min-height: 500px; background: transparent;
  padding: 18px;
  resize: none;
}
.editor-body textarea:focus { box-shadow: none; border-color: transparent; }
.result-area {
  min-height: 500px; padding: 18px;
  font-size: 15px; line-height: 1.85;
  white-space: pre-wrap; overflow-y: auto;
  color: var(--text); border-radius: 0 0 var(--r-lg) var(--r-lg);
}
.result-placeholder { color: var(--text3); font-size: 14px; }

/* Spinner */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border2);
  border-top-color: var(--text);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: none;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading .spinner { display: block; }

/* Word counter */
.word-counter {
  font-size: 12px; color: var(--text3);
  padding: 8px 18px; border-top: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
}

/* Dashboard */
.dash-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.dash-card { padding: 24px; }
.history-table { font-size: 13px; }
.text-truncate {
  max-width: 280px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}

/* ── Admin ────────────────────────────────────────────────── */
.admin-wrap {
  max-width: 1400px; margin: 0 auto;
  padding: 24px;
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 20px;
}

/* ── Footer ───────────────────────────────────────────────── */
.footer {
  margin-top: auto;
  border-top: 1px solid var(--border);
  padding: 32px 40px;
  display: flex; align-items: center; justify-content: space-between;
  font-size: 13px; color: var(--text3);
}
.footer-links { display: flex; gap: 20px; }
.footer-links a:hover { color: var(--text2); }

/* ── Scroll thin ──────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--bg2); }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }

/* ── Skeleton loader ──────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--panel2) 25%, var(--panel3) 50%, var(--panel2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--r-sm);
  color: transparent !important;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ── Toast ────────────────────────────────────────────────── */
#toast-container {
  position: fixed; bottom: 24px; inset-inline-end: 24px;
  z-index: 9999; display: flex; flex-direction: column; gap: 10px;
}
.toast {
  padding: 13px 18px; border-radius: var(--r-md);
  background: var(--panel); border: 1px solid var(--border2);
  font-size: 14px; font-weight: 600;
  box-shadow: var(--shadow-md);
  animation: slide-in .2s ease;
  max-width: 320px;
}
.toast-success { border-color: rgba(34,197,94,.4); color: #4ade80; }
.toast-error   { border-color: rgba(255,68,68,.4);  color: #ff6b6b; }
@keyframes slide-in { from { opacity:0; transform: translateY(12px); } }

/* ── Modal ────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,.7); backdrop-filter: blur(4px);
  display: grid; place-items: center; padding: 24px;
}
.modal {
  width: min(520px, 100%);
  background: var(--panel); border: 1px solid var(--border2);
  border-radius: var(--r-xl); padding: 32px;
  box-shadow: var(--shadow-lg);
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.modal-close  { background: none; border: none; cursor: pointer; color: var(--text3); font-size: 20px; padding: 4px; }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 900px) {
  .app-wrap     { grid-template-columns: 1fr; }
  .admin-wrap   { grid-template-columns: 1fr; }
  .editor-grid  { grid-template-columns: 1fr; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .sidebar      { position: static; max-height: none; }
  .nav-links    { display: none; }
  .topbar       { padding: 0 18px; }
  .hero         { padding: 80px 24px 60px; }
  .price-card.popular { transform: none; }
  .footer       { flex-direction: column; gap: 16px; text-align: center; }
  .plan-price   { font-size: 36px; }
}
@media (max-width: 600px) {
  .hero p     { font-size: 17px; }
  .hero-cta   { flex-direction: column; align-items: center; }
  .pricing-grid { grid-template-columns: 1fr; }
  .dash-grid  { grid-template-columns: 1fr 1fr; }
}

/* ── Legal Pages: Privacy / Terms ─────────────────────────── */
.legal-page {
  flex: 1 0 auto;
  min-height: calc(100vh - 64px);
  background: var(--bg);
}
.legal-hero {
  padding: 54px 0 30px;
  border-bottom: 1px solid var(--border);
  background:
    radial-gradient(circle at 50% 0%, rgba(255,255,255,.08), transparent 34%),
    linear-gradient(180deg, var(--bg2), var(--bg));
  text-align: center;
}
[data-theme="light"] .legal-hero {
  background:
    radial-gradient(circle at 50% 0%, rgba(0,0,0,.045), transparent 34%),
    linear-gradient(180deg, var(--bg2), var(--bg));
}
.legal-badge {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 6px 14px; margin-bottom: 14px;
  border: 1px solid var(--border2); border-radius: 999px;
  color: var(--text2); background: var(--panel);
  font-size: 12px; font-weight: 800;
}
.legal-hero h1 {
  margin: 0 0 12px;
  font-size: clamp(34px, 4.2vw, 52px);
  line-height: 1.15;
  letter-spacing: 0;
}
.legal-hero p {
  max-width: 820px;
  margin: 0 auto;
  font-size: 15px;
  line-height: 1.9;
  color: var(--text2);
}
.legal-content { padding: 32px 0 64px; }
.legal-grid {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}
.legal-sidebar {
  position: sticky; top: 88px;
  padding: 12px;
  display: grid; gap: 6px;
}
.legal-sidebar a {
  display: block;
  padding: 10px 12px;
  border-radius: var(--r-md);
  color: var(--text2);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.5;
  transition: background .15s, color .15s, transform .15s;
}
.legal-sidebar a:hover { background: var(--panel2); color: var(--text); transform: translateX(-2px); }
[dir="ltr"] .legal-sidebar a:hover { transform: translateX(2px); }
.legal-card {
  padding: clamp(22px, 3vw, 34px);
  overflow: hidden;
}
.legal-card section {
  padding: 0 0 22px;
  margin: 0 0 22px;
  border-bottom: 1px solid var(--border);
  scroll-margin-top: 92px;
}
.legal-card section:last-of-type { margin-bottom: 0; }
.legal-card h2 {
  margin: 0 0 10px;
  font-size: clamp(20px, 2vw, 25px);
  line-height: 1.35;
  letter-spacing: 0;
  font-weight: 800;
}
.legal-card p {
  margin: 0;
  font-size: 15px;
  line-height: 2.05;
  color: var(--text2);
}
.legal-updated {
  margin-top: 22px;
  padding: 12px 14px;
  border-radius: var(--r-md);
  background: var(--panel2);
  border: 1px solid var(--border);
  color: var(--text2);
  font-size: 13px;
  font-weight: 700;
}
@media (max-width: 900px) {
  .legal-grid { grid-template-columns: 1fr; }
  .legal-sidebar { position: static; grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .legal-hero { padding: 42px 18px 26px; }
  .legal-hero h1 { font-size: 34px; }
  .legal-content { padding: 24px 0 48px; }
  .legal-sidebar { grid-template-columns: 1fr; }
  .legal-card { padding: 20px; }
  .legal-card h2 { font-size: 20px; }
  .legal-card p { font-size: 14px; line-height: 1.95; }
}

/* Professional discount badges for long-term subscriptions */
.plan-discount-badge {
  position: absolute;
  top: 18px;
  inset-inline-end: 18px;
  padding: 7px 11px;
  border-radius: 999px;
  border: 1px solid var(--border2);
  background: var(--panel2);
  color: var(--text);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .04em;
  box-shadow: var(--shadow-sm);
}
.price-card .plan-discount-badge + .plan-label { padding-inline-end: 86px; }
@media (max-width: 640px) {
  .plan-discount-badge { top: 14px; inset-inline-end: 14px; }
  .price-card .plan-discount-badge + .plan-label { padding-inline-end: 78px; }
}

/* Billing cycle switcher: monthly / semi-annual / annual */
.billing-switch {
  grid-column: 1 / -1;
  width: fit-content;
  max-width: 100%;
  margin: 0 auto 12px;
  padding: 5px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel2);
  display: flex;
  gap: 4px;
  box-shadow: var(--shadow-sm);
}
.billing-tab {
  border: 0;
  background: transparent;
  color: var(--text2);
  border-radius: 999px;
  padding: 9px 16px;
  cursor: pointer;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: background .18s ease, color .18s ease, box-shadow .18s ease, transform .18s ease;
}
.billing-tab:hover { color: var(--text); transform: translateY(-1px); }
.billing-tab.active {
  color: var(--text);
  background: var(--panel);
  box-shadow: var(--shadow-sm);
}
.billing-tab small {
  font-size: 10px;
  font-weight: 900;
  color: var(--text3);
  white-space: nowrap;
}
.billing-note {
  grid-column: 1 / -1;
  margin: 0 auto 30px;
  text-align: center;
  color: var(--text3);
  font-size: 13px;
}
.plan-topline {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}
.plan-desc {
  color: var(--text3);
  font-size: 12px;
  line-height: 1.45;
  margin-top: -4px;
}
.plan-mini-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 5px 8px;
  border-radius: 999px;
  background: var(--text);
  color: var(--bg);
  font-size: 10px;
  font-weight: 900;
  white-space: nowrap;
}
.plan-price-wrap {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  margin-bottom: 10px;
}
.plan-price-wrap .plan-price,
.plan-price-wrap .plan-period { margin-bottom: 0; }
.plan-cycle-saving {
  width: fit-content;
  margin-bottom: 14px;
  padding: 5px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel2);
  color: var(--text2);
  font-size: 12px;
  font-weight: 800;
}
@media (max-width: 640px) {
  .billing-switch { width: 100%; border-radius: 20px; justify-content: center; flex-wrap: wrap; }
  .billing-tab { flex: 1 1 auto; justify-content: center; padding: 9px 10px; }
  .plan-topline { flex-direction: column; }
  .plan-price-wrap { align-items: flex-start; flex-direction: column; gap: 4px; }
}
