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

:root {
  --bg: #faf9f6;
  --paper: #ffffff;
  --ink: #1a1a2e;
  --ink-light: #3d3d5c;
  --muted: #6b7280;
  --line: #e5e7eb;
  --line-light: #f3f4f6;
  --brand: #0d9488;
  --brand-dark: #0a7a70;
  --brand-soft: #ccfbf1;
  --brand-glow: rgba(13,148,136,0.12);
  --accent: #d97706;
  --accent-soft: #fef3c7;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --success: #059669;
  --success-soft: #ecfdf5;
  --shell: 1200px;
  --radius: 12px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow: 0 4px 16px rgba(0,0,0,0.06);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.08);
  --transition: 0.2s ease;
  /* Type scale */
  --text-xs: 0.75rem;
  --text-sm: 0.82rem;
  --text-base: 0.95rem;
  --text-md: 1.05rem;
  --text-lg: 1.15rem;
  --text-xl: 1.4rem;
  --text-2xl: clamp(1.8rem, 3.5vw, 2.4rem);
  --text-3xl: clamp(2.6rem, 5vw, 4.2rem);
}

[data-theme="dark"] {
  --bg: #0f0f1a;
  --paper: #1a1a2e;
  --ink: #e8e8f0;
  --ink-light: #c0c0d0;
  --muted: #8888a0;
  --line: #2a2a40;
  --line-light: #22223a;
  --brand-soft: rgba(13,148,136,0.15);
  --brand-glow: rgba(13,148,136,0.25);
  --accent-soft: rgba(217,119,6,0.15);
  --danger-soft: rgba(220,38,38,0.15);
  --success-soft: rgba(5,150,105,0.15);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow: 0 4px 16px rgba(0,0,0,0.3);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.4);
}

[data-theme="dark"] .site-header { background: rgba(15,15,26,0.92); }
[data-theme="dark"] input,
[data-theme="dark"] textarea,
[data-theme="dark"] select { background: var(--paper); color: var(--ink); border-color: var(--line); }
[data-theme="dark"] .cookie-banner { background: var(--paper); color: var(--ink); border-top: 1px solid var(--line); }
[data-theme="dark"] .hero { background: linear-gradient(170deg, #0a1a18 0%, var(--bg) 70%); }
[data-theme="dark"] .data-table tr:hover td { background: var(--line-light); }
[data-theme="dark"] img { opacity: 0.9; }

/* ---- Theme toggle ---- */
.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 8px;
  background: none; border: 1px solid var(--line); cursor: pointer;
  color: var(--muted); transition: all var(--transition);
}
.theme-toggle:hover { background: var(--line-light); color: var(--ink); }
[data-theme="dark"] .icon-sun { display: inline; }
[data-theme="dark"] .icon-moon { display: none; }
:root:not([data-theme="dark"]) .icon-sun { display: none; }
:root:not([data-theme="dark"]) .icon-moon { display: inline; }

/* ---- Skip link ---- */
.skip-link {
  position: absolute; left: -9999px; top: auto;
  z-index: 999; padding: 0.5rem 1rem;
  background: var(--brand); color: #fff; border-radius: 0 0 8px 0;
  font-weight: 600; font-size: 0.88rem; text-decoration: none;
}
.skip-link:focus { left: 0; top: 0; }

/* ---- Focus indicators ---- */
:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

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

body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--brand-dark); }

/* ---- Type scale ---- */
h1, h2, h3 { font-family: 'Playfair Display', Georgia, serif; margin: 0 0 0.75rem; line-height: 1.2; color: var(--ink); }
h1 { font-size: clamp(1.8rem, 3.5vw, 2.4rem); font-weight: 800; }
h2 { font-size: 1.4rem; font-weight: 700; }
h3 { font-size: 1.1rem; font-weight: 600; }
p { margin: 0 0 1rem; line-height: 1.7; color: var(--muted); font-size: 0.95rem; }
.text-xs { font-size: 0.75rem; }
.text-sm { font-size: 0.82rem; }
.text-base { font-size: 0.95rem; }
.text-lg { font-size: 1.1rem; }
.text-xl { font-size: 1.3rem; }

/* ---- Shell ---- */
.shell { width: min(var(--shell), calc(100% - 2.5rem)); margin: 0 auto; }

/* ---- Header ---- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(16px) saturate(180%);
  border-bottom: 1px solid var(--line);
}
.nav-shell {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  height: 64px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--ink);
  letter-spacing: -0.02em;
  flex-shrink: 0;
}
.brand:hover { color: var(--ink); text-decoration: none; }
.brand:hover .brand-mark { background: var(--brand-dark); }
.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 0.85rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  line-height: 1;
  transition: background var(--transition);
}
.brand-text { line-height: 1.1; }
.brand-accent { color: var(--brand); }

/* Nav body — flex row on desktop, hidden panel on mobile */
.nav-body {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  flex: 1;
  min-width: 0;
}

/* Nav links */
.site-nav { display: flex; align-items: center; gap: 0.25rem; flex-shrink: 0; }
.site-nav a {
  padding: 0.45rem 0.85rem;
  border-radius: 8px;
  color: var(--ink-light);
  font-size: 0.9rem;
  font-weight: 500;
  transition: all var(--transition);
}
.site-nav a:hover { background: var(--line-light); color: var(--ink); text-decoration: none; }

/* Resources dropdown */
.dropdown { position: relative; }
.dropdown-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.85rem;
  border-radius: 8px;
  color: var(--ink-light);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  background: none;
  border: none;
  font-family: inherit;
  transition: all var(--transition);
}
.dropdown-toggle:hover { background: var(--line-light); color: var(--ink); }
.dropdown-toggle::after {
  content: '';
  width: 0; height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid currentColor;
  transition: transform var(--transition);
}
.dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 180px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 0.4rem;
  padding-top: calc(0.4rem + 4px);
  z-index: 60;
}
.dropdown:hover .dropdown-menu,
.dropdown.open .dropdown-menu { display: block; }
.dropdown:hover .dropdown-toggle::after { transform: rotate(180deg); }
.dropdown-menu a {
  display: block;
  padding: 0.55rem 0.85rem;
  border-radius: 8px;
  color: var(--ink-light);
  font-size: 0.88rem;
  font-weight: 500;
}
.dropdown-menu a:hover { background: var(--line-light); color: var(--ink); text-decoration: none; }

/* Nav actions */
.nav-actions { display: flex; align-items: center; gap: 0.5rem; }
/* Language toggle */
.lang-toggle { gap: 0.3rem; font-size: 0.82rem; font-weight: 600; letter-spacing: 0.03em; }
.dropdown-menu a.active { color: var(--brand); font-weight: 600; }

/* Dropdown menu button (logout inside dropdown) */
.dropdown-menu-btn {
  display: block; width: 100%; text-align: left;
  padding: 0.55rem 0.85rem; border-radius: 8px;
  color: var(--danger); font-size: 0.88rem; font-weight: 500;
  background: none; border: none; cursor: pointer; font-family: inherit;
  transition: all var(--transition);
}
.dropdown-menu-btn:hover { background: var(--danger-soft); }
.ghost-link {
  padding: 0.4rem 0.75rem;
  border-radius: 8px;
  color: var(--ink-light);
  font-size: 0.88rem;
  font-weight: 500;
  transition: all var(--transition);
}
.ghost-link:hover { background: var(--line-light); color: var(--ink); text-decoration: none; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.7rem 1.4rem;
  border-radius: 10px;
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
  text-decoration: none;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn-primary { background: var(--brand); color: white; }
.btn-primary:hover { background: var(--brand-dark); color: white; box-shadow: 0 4px 12px var(--brand-glow); }
.btn-secondary { background: var(--paper); color: var(--ink); border-color: var(--line); }
.btn-secondary:hover { background: var(--line-light); }
.btn-danger { background: var(--danger-soft); color: var(--danger); border: 1px solid #fecaca; }
.btn-danger:hover { background: #fee2e2; }
.btn-link { padding: 0; background: transparent; border: 0; color: var(--muted); font: inherit; cursor: pointer; }
.btn-link:hover { color: var(--ink); }
.btn-sm { padding: 0.45rem 0.9rem; font-size: 0.82rem; }

/* ---- Hero ---- */
.hero {
  padding: 6rem 0 4rem;
  background: linear-gradient(175deg, #f0fdfa 0%, var(--bg) 60%);
}
.hero-grid {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 3rem;
  align-items: center;
}
.eyebrow {
  display: inline-flex;
  padding: 0.3rem 0.9rem;
  margin-bottom: 1.25rem;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--brand);
  background: var(--brand-soft);
  border-radius: 999px;
}
.hero h1 {
  font-size: clamp(2.6rem, 5vw, 4.2rem);
  line-height: 1.05;
  letter-spacing: -0.03em;
  margin-bottom: 1.25rem;
}
.hero-copy { font-size: 1.15rem; max-width: 56ch; color: var(--ink-light); line-height: 1.7; }
.hero-actions { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-top: 2rem; align-items: center; }
.hero-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: var(--shadow-lg);
}
.hero-card-label { color: var(--muted); font-size: 0.82rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; }
.clean-list { padding-left: 1rem; margin: 1rem 0 0; }
.clean-list li { margin-bottom: 0.7rem; color: var(--ink-light); font-size: 0.95rem; }

/* ---- Cards ---- */
.panel-card, .topic-card, .article-card, .plan-card, .empty-card, .admin-panel, .metric-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: all var(--transition);
}
.panel-card:hover, .topic-card:hover, .article-card:hover, .plan-card:hover {
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}
.panel-card, .topic-card, .article-card, .plan-card { padding: 1.5rem; }
.empty-card { padding: 2rem; text-align: center; color: var(--muted); }

/* Topic badge */
.topic-domain {
  display: inline-flex;
  margin-bottom: 0.75rem;
  padding: 0.25rem 0.7rem;
  background: var(--brand-soft);
  border-radius: 999px;
  color: var(--brand);
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: capitalize;
}

/* ---- Sections ---- */
.content-section { padding: 3.5rem 0; }
.content-section.muted {
  background: var(--paper);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.panel-section { padding: 3.5rem 0; }
.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.section-head h2 { margin-bottom: 0; }

/* Grids */
.three-up, .topic-grid, .article-grid, .plan-grid, .metric-grid, .prompt-grid { display: grid; gap: 1.25rem; }
.three-up, .topic-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.plan-grid { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.article-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.metric-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.prompt-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

/* Meta */
.meta { color: var(--muted); font-size: 0.82rem; font-weight: 500; margin-bottom: 0.4rem; }
.subtle-link { display: inline-flex; margin-top: 0.5rem; color: var(--brand); font-weight: 500; font-size: 0.9rem; }
.subtle-link:hover { text-decoration: underline; }

/* ---- Article detail ---- */
.article-detail, .form-shell {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  box-shadow: var(--shadow-sm);
}
.lede { font-size: 1.15rem; max-width: 70ch; color: var(--ink-light); line-height: 1.75; }
.breath-block { display: grid; gap: 0.75rem; margin: 2rem 0; }
.breath-block > div {
  padding: 1.1rem 1.4rem;
  border-left: 4px solid var(--accent);
  background: var(--accent-soft);
  border-radius: var(--radius);
  color: var(--ink-light);
  font-size: 0.95rem;
}

/* ---- Story body (article prose) ---- */
.story-body {
  max-width: 68ch;
  font-size: 1.08rem;
  line-height: 1.85;
  color: var(--ink-light);
  margin-top: 2rem;
}
.story-body p { color: var(--ink-light); margin-bottom: 1.5rem; }
.story-body p:first-of-type::first-letter {
  float: left;
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 3.6rem;
  font-weight: 800;
  line-height: 0.85;
  padding-right: 0.12em;
  padding-top: 0.06em;
  color: var(--brand);
}
.story-body blockquote,
.story-body .pull-quote {
  margin: 2rem 0;
  padding: 1.5rem 2rem;
  border-left: 4px solid var(--brand);
  background: var(--brand-soft);
  border-radius: var(--radius);
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.15rem;
  font-style: italic;
  line-height: 1.6;
  color: var(--ink);
}
.story-body blockquote cite,
.story-body .pull-quote cite {
  display: block;
  margin-top: 0.75rem;
  font-style: normal;
  font-family: 'Inter', sans-serif;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
}
.story-body h2 {
  font-size: 1.4rem;
  margin-top: 2.5rem;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--line);
}
.story-body h3 {
  font-size: 1.15rem;
  margin-top: 2rem;
  margin-bottom: 0.75rem;
}
.story-body ul, .story-body ol {
  padding-left: 1.5rem;
  margin-bottom: 1.5rem;
  color: var(--ink-light);
}
.story-body li { margin-bottom: 0.5rem; }
.story-body strong { color: var(--ink); }
.story-body a { text-decoration: underline; text-underline-offset: 2px; }
.story-body hr {
  border: none;
  border-top: 1px solid var(--line);
  margin: 2.5rem auto;
  max-width: 120px;
}

/* ---- Forms ---- */
.form-shell { display: grid; gap: 2rem; grid-template-columns: 1fr 1fr; }
.form-shell.narrow { max-width: 520px; grid-template-columns: 1fr; }
.stack-form { display: grid; gap: 1rem; }
.stack-form label { display: grid; gap: 0.35rem; font-size: 0.88rem; font-weight: 500; color: var(--ink); }
input, textarea, select {
  width: 100%;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  font-size: 0.95rem;
  transition: border-color var(--transition), box-shadow var(--transition);
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-glow);
}

.error-box, .success-box, .alert-band { border-radius: var(--radius); padding: 0.9rem 1.1rem; font-size: 0.92rem; }
.error-box { background: var(--danger-soft); color: var(--danger); border: 1px solid #fecaca; }
.success-box { background: var(--success-soft); color: var(--success); border: 1px solid #a7f3d0; }
.alert-band { background: var(--accent-soft); color: #92400e; border: 1px solid #fcd34d; margin: 1.5rem 0; }
.form-footer { margin-top: 0.75rem; font-size: 0.9rem; text-align: center; color: var(--muted); }

/* ---- Pricing ---- */
.plan-card h2 { font-size: 1.6rem; margin-bottom: 0.5rem; }
.price {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--ink);
  margin: 1rem 0 0.25rem;
}

/* ---- FAQ ---- */
.faq-grid, .split-layout { display: grid; gap: 2rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.faq-item, .howto-item {
  background: var(--paper);
  padding: 1.1rem 1.3rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 0.75rem;
  transition: all var(--transition);
}
.faq-item:hover, .howto-item:hover { box-shadow: var(--shadow-sm); }
.faq-item summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--ink);
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.faq-item summary::after { content: '+'; font-size: 1.2rem; color: var(--muted); transition: transform var(--transition); }
.faq-item[open] summary::after { content: '-'; }
.faq-item p { margin-top: 0.75rem; margin-bottom: 0; }
/* Steps */
.steps-grid { display: grid; gap: 1rem; }
.step-card {
  display: flex; gap: 1.25rem; align-items: flex-start;
  padding: 1.5rem; background: var(--paper);
  border: 1px solid var(--line); border-radius: var(--radius-lg);
  transition: all var(--transition);
}
.step-card:hover { box-shadow: var(--shadow-sm); }
.step-number {
  display: flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0;
  background: var(--brand); color: #fff;
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.1rem; font-weight: 700;
}
.step-card h3 { margin-bottom: 0.25rem; }
.step-card p { margin: 0; }

.faq-list { display: grid; gap: 0.75rem; margin: 1.5rem 0; }
.support-hub { margin: 2rem 0; }
.section-gap { margin-top: 2.5rem; }

/* ---- Confidence indicators ---- */
.confidence-indicator { display: inline-flex; gap: 3px; align-items: center; }
.ci-vertical { flex-direction: column; }
.ci-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
  transition: all var(--transition);
}
.ci-filled.confidence-high { background: var(--success); }
.ci-filled.confidence-med { background: var(--accent); }
.ci-filled.confidence-low { background: var(--danger); }
.ci-empty { background: var(--line); }

/* Card with confidence bar */
.article-card-row { display: flex; gap: 0.75rem; }
.article-card-row .confidence-indicator { padding-top: 0.25rem; }
.article-card-row .article-card-body { flex: 1; min-width: 0; }

/* ---- Account page ---- */
.account-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.5rem; margin-top: 2rem; }
.account-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: var(--shadow-sm);
}
.account-card h2 { font-size: 1.3rem; margin-bottom: 1rem; }
.account-card h3 { font-size: 1.1rem; margin-bottom: 0.5rem; }
.account-info-row { margin-bottom: 0.5rem; }
.badge {
  display: inline-flex;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
}
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--accent-soft); color: #92400e; }
.subscription-info { display: grid; gap: 0.5rem; }
.empty-state { text-align: center; padding: 1rem 0; }
.empty-state p { margin-bottom: 1rem; }
.session-info { margin-bottom: 0.5rem; }

/* Right-aligned dropdown */
.dropdown-menu-right { right: 0; left: auto; }

/* ---- Admin ---- */
.admin-layout { display: grid; grid-template-columns: 240px 1fr; gap: 1.5rem; align-items: start; }
.admin-sidebar {
  position: sticky;
  top: 80px;
  padding: 1.5rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.admin-nav { display: grid; gap: 0.35rem; margin: 1rem 0 1.2rem; }
.admin-nav a {
  padding: 0.55rem 0.85rem;
  border-radius: 8px;
  color: var(--ink-light);
  font-size: 0.9rem;
  font-weight: 500;
}
.admin-nav a:hover { background: var(--line-light); color: var(--ink); text-decoration: none; }
.admin-main { display: grid; gap: 1.25rem; }
.admin-panel { padding: 1.5rem; box-shadow: var(--shadow-sm); }
.metric-card { padding: 1.5rem; display: grid; gap: 0.35rem; }
.metric-card strong { font-size: 2.2rem; font-family: 'Playfair Display', Georgia, serif; color: var(--ink); }
.metric-card span { font-size: 0.85rem; color: var(--muted); font-weight: 500; }

/* Data table */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th { font-size: 0.82rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.data-table[data-sortable] th { cursor: pointer; transition: color var(--transition); }
.data-table[data-sortable] th:hover { color: var(--ink); }
.data-table th, .data-table td { text-align: left; padding: 0.85rem 0.75rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.data-table tbody tr:hover { background: var(--line-light); }
.sort-arrow { font-size: 0.65rem; color: var(--brand); margin-left: 0.2rem; }
.table-toolbar {
  display: flex; justify-content: space-between; align-items: center;
  gap: 0.75rem; margin-bottom: 0.75rem; flex-wrap: wrap;
}
.table-filter {
  padding: 0.4rem 0.85rem; font-size: 0.82rem; border-radius: 8px;
  border: 1px solid var(--line); background: var(--paper); color: var(--ink);
  min-width: 200px; font-family: inherit;
}
.table-filter:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-glow); outline: none; }
.table-count { font-size: 0.78rem; color: var(--muted); font-weight: 500; }

.check-group { display: grid; gap: 0.55rem; margin: 0; padding: 1rem; border: 1px solid var(--line); border-radius: var(--radius); }
.check-group legend { padding: 0 0.4rem; color: var(--muted); font-weight: 500; font-size: 0.88rem; }
.check-row { display: flex; align-items: center; gap: 0.65rem; }
.check-row input { width: auto; }
.table-actions { display: flex; flex-wrap: wrap; gap: 0.65rem; align-items: center; }
.table-actions form { margin: 0; }

/* ---- Header search ---- */
.header-search { flex: 1 1 300px; margin: 0 0.75rem; max-width: 480px; }
.header-search input[type="search"] {
  width: 100%; padding: 0.4rem 0.85rem; font-size: 0.85rem;
  border-radius: 999px; border: 1px solid var(--line);
  background: var(--line-light); color: var(--ink);
  transition: all var(--transition); font-family: inherit;
}
.header-search input[type="search"]:focus {
  background: var(--paper); border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-glow); outline: none;
}
.header-search input[type="search"]::placeholder { color: var(--muted); }

/* ---- Search bar ---- */
.search-bar {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}
.search-bar input {
  width: 240px;
  padding: 0.5rem 0.85rem;
  font-size: 0.88rem;
}

/* ---- Confidence badges ---- */
.confidence-badge {
  display: inline-flex;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.confidence-high { background: var(--success-soft); color: var(--success); }
.confidence-med { background: var(--accent-soft); color: #92400e; }
.confidence-low { background: var(--danger-soft); color: var(--danger); }

/* ---- Article detail extras ---- */
.article-meta-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.breath-connector {
  padding: 0.5rem 1.4rem;
  font-weight: 700;
  font-size: 0.82rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  border-left: 4px solid var(--accent);
  background: transparent;
}
.article-footer-actions {
  display: flex;
  gap: 0.65rem;
  flex-wrap: wrap;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
}

/* ---- Pager + Footer ---- */
.pager { display: flex; justify-content: space-between; align-items: center; margin-top: 1.5rem; color: var(--muted); font-size: 0.9rem; }
.inline-form { display: flex; gap: 0.5rem; align-items: center; }

.site-footer {
  padding: 2.5rem 0 3rem;
  border-top: 1px solid var(--line);
  background: var(--paper);
}
.footer-grid { display: flex; justify-content: space-between; gap: 2rem; }
.footer-grid strong { font-family: 'Playfair Display', Georgia, serif; font-size: 1.1rem; }
.footer-grid p { font-size: 0.88rem; }

/* ---- Hamburger ---- */
.hamburger {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  z-index: 55;
}
.hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--ink);
  border-radius: 2px;
  transition: transform 0.25s, opacity 0.25s;
}
.hamburger.active span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.active span:nth-child(2) { opacity: 0; }
.hamburger.active span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ---- Floating Action Button Group ---- */
.fab-group {
  position: fixed !important; bottom: 1.5rem; right: 1.5rem; z-index: 9999;
  display: flex !important; flex-direction: column-reverse; align-items: flex-end; gap: 0.65rem;
}
.fab-main {
  display: flex; align-items: center; justify-content: center;
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--brand); color: #fff; border: none; cursor: pointer;
  box-shadow: 0 4px 20px rgba(13,148,136,0.4);
  transition: all 0.25s ease;
}
.fab-main:hover { background: var(--brand-dark); transform: scale(1.08); }
.fab-main:active { transform: scale(0.95); }
.fab-main.open { background: var(--ink); }
.fab-main.open:hover { background: var(--ink-light); }
.fab-main.open .fab-icon-open { transform: rotate(45deg); transition: transform 0.25s ease; }
.fab-main .fab-icon-open { transition: transform 0.25s ease; }

.fab-options {
  display: flex; flex-direction: column; align-items: flex-end; gap: 0.5rem;
  opacity: 0; pointer-events: none; transform: translateY(10px);
  transition: all 0.25s ease;
}
.fab-options.open { opacity: 1; pointer-events: auto; transform: none; }

.fab-option {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.55rem 1rem 0.55rem 0.75rem;
  background: var(--paper); color: var(--ink);
  border: 1px solid var(--line); border-radius: 999px;
  box-shadow: var(--shadow); cursor: pointer;
  font-size: 0.85rem; font-weight: 600; font-family: inherit;
  text-decoration: none; white-space: nowrap;
  transition: all 0.2s ease;
}
.fab-option:hover { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); text-decoration: none; transform: translateX(-4px); }
.fab-option svg { flex-shrink: 0; color: var(--brand); }

/* ---- AI Chat Widget ---- */
.chat-panel {
  position: fixed; bottom: 6rem; right: 1.5rem; z-index: 205;
  width: 400px; max-height: 520px;
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
  animation: chatSlideUp 0.25s ease;
  overflow: hidden;
  transition: all 0.3s ease;
}
.chat-panel.chat-maximized {
  bottom: 0; right: 0; top: 0;
  width: 33.33vw; max-height: none;
  border-radius: 0; border-right: none;
}
@keyframes chatSlideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: none; } }

.chat-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.85rem 1.25rem; border-bottom: 1px solid var(--line);
  background: var(--brand); color: #fff; flex-shrink: 0;
}
.chat-header strong { display: block; font-size: 0.95rem; }
.chat-header .meta { color: rgba(255,255,255,0.7); font-size: 0.75rem; }
.chat-header-actions { display: flex; align-items: center; gap: 0.35rem; }
.chat-header-btn {
  background: none; border: none; color: rgba(255,255,255,0.7); cursor: pointer;
  font-size: 1.1rem; line-height: 1; padding: 0.15rem; transition: color 0.15s;
}
.chat-header-btn:hover { color: #fff; }
.chat-close { background: none; border: none; color: rgba(255,255,255,0.7); font-size: 1.4rem; cursor: pointer; line-height: 1; }
.chat-close:hover { color: #fff; }

.chat-messages {
  flex: 1; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: 0.75rem;
  max-height: 350px; min-height: 200px;
}
.chat-maximized .chat-messages { max-height: none; }
.chat-msg { max-width: 88%; animation: fadeInUp 0.2s ease; }
.chat-msg p { margin: 0; font-size: 0.88rem; line-height: 1.55; white-space: pre-wrap; }
.chat-msg-user {
  align-self: flex-end;
  background: var(--brand); color: #fff;
  padding: 0.65rem 1rem; border-radius: 16px 16px 4px 16px;
}
.chat-msg-ai {
  align-self: flex-start;
  background: var(--bg); color: var(--ink);
  padding: 0.65rem 1rem; border-radius: 16px 16px 16px 4px;
  border: 1px solid var(--line);
}
.chat-msg-ai p { color: var(--ink-light); }
.chat-typing {
  align-self: flex-start;
  padding: 0.65rem 1rem; border-radius: 16px 16px 16px 4px;
  background: var(--bg); border: 1px solid var(--line);
  font-size: 0.82rem; color: var(--muted);
}

.chat-input {
  display: flex; gap: 0.5rem; padding: 0.75rem 1rem;
  border-top: 1px solid var(--line); background: var(--paper);
}
.chat-input input {
  flex: 1; padding: 0.55rem 0.85rem; font-size: 0.88rem;
  border-radius: 999px; border: 1px solid var(--line);
  background: var(--bg); color: var(--ink); font-family: inherit;
}
.chat-input input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-glow); outline: none; }
.chat-input button {
  display: flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--brand); color: #fff; border: none; cursor: pointer;
  transition: all var(--transition); flex-shrink: 0;
}
.chat-input button:hover { background: var(--brand-dark); }
.chat-input button:disabled { opacity: 0.5; cursor: not-allowed; }

@media (max-width: 960px) {
  .chat-panel { width: calc(100% - 2rem); right: 1rem; bottom: 5rem; max-height: 60vh; }
  .chat-panel.chat-maximized { width: 100vw; height: 100vh; max-height: 100vh; right: 0; bottom: 0; border-radius: 0; }
  .fab-group { bottom: 1rem; right: 1rem; }
  .fab-main { width: 48px; height: 48px; }
}

/* ---- Cookie banner ---- */
.cookie-banner {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--ink);
  padding: 1rem 0;
}
.cookie-inner {
  width: min(var(--shell), calc(100% - 2.5rem));
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 1.5rem;
}
.cookie-inner p { color: rgba(255,255,255,0.8); margin: 0; font-size: 0.88rem; }

/* ---- Card differentiation ---- */
.article-card { border-left: 3px solid var(--brand); }
.topic-card { border-left: 3px solid var(--accent); }
.plan-card { border-top: 3px solid var(--brand); }

/* ---- Stagger-in animation ---- */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}
.article-card, .topic-card, .plan-card, .faq-item {
  animation: fadeInUp 0.35s ease both;
}
.article-grid > :nth-child(1) { animation-delay: 0s; }
.article-grid > :nth-child(2) { animation-delay: 0.06s; }
.article-grid > :nth-child(3) { animation-delay: 0.12s; }
.article-grid > :nth-child(4) { animation-delay: 0.18s; }
.article-grid > :nth-child(5) { animation-delay: 0.24s; }
.article-grid > :nth-child(6) { animation-delay: 0.30s; }
.topic-grid > :nth-child(1) { animation-delay: 0s; }
.topic-grid > :nth-child(2) { animation-delay: 0.06s; }
.topic-grid > :nth-child(3) { animation-delay: 0.12s; }

/* Scroll-reveal for sections */
@keyframes slideInLeft { from { opacity: 0; transform: translateX(-20px); } to { opacity: 1; transform: none; } }
@keyframes scaleIn { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: none; } }

.content-section { animation: fadeInUp 0.4s ease both; }
.hero-card { animation: scaleIn 0.5s ease 0.2s both; }
.admin-panel { animation: fadeInUp 0.3s ease both; }
.breath-block > div { animation: slideInLeft 0.3s ease both; }
.breath-block > div:nth-child(2) { animation-delay: 0.1s; }
.breath-block > div:nth-child(3) { animation-delay: 0.2s; }
.breath-block > div:nth-child(4) { animation-delay: 0.3s; }

/* Microinteractions */
.btn { transition: all 0.2s ease; }
.btn:active { transform: translateY(0) scale(0.98); }
.lens-card:active { transform: scale(0.98); }
a.subtle-link { transition: all 0.2s ease; }
a.subtle-link:hover { transform: translateX(3px); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ---- Trending strip ---- */
.trending-strip { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.trending-chip {
  display: inline-flex; align-items: center; gap: 0.5rem;
  padding: 0.5rem 1rem; border-radius: 999px;
  background: var(--paper); border: 1px solid var(--line);
  color: var(--ink); font-size: 0.88rem; font-weight: 500;
  text-decoration: none; transition: all var(--transition);
}
.trending-chip:hover { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); text-decoration: none; }
.trending-count {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--brand); color: #fff;
  font-size: 0.72rem; font-weight: 700;
}

/* ---- Newsletter banner ---- */
.newsletter-banner {
  background: var(--brand);
  padding: 3rem 0;
  margin-top: 4rem;
}
.newsletter-banner-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2.5rem;
  flex-wrap: wrap;
}
.newsletter-banner-text { flex: 1; min-width: 280px; }
.newsletter-banner-text h2 {
  color: #fff;
  font-size: 1.6rem;
  margin-bottom: 0.5rem;
}
.newsletter-banner-text p {
  color: rgba(255,255,255,0.85);
  font-size: 1.05rem;
  line-height: 1.6;
  margin: 0;
  max-width: 52ch;
}
.newsletter-banner-form {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}
.newsletter-banner-form input[type="email"] {
  padding: 0.75rem 1.25rem;
  font-size: 1rem;
  border-radius: 999px;
  border: 2px solid rgba(255,255,255,0.3);
  background: rgba(255,255,255,0.12);
  color: #fff;
  min-width: 260px;
  font-family: inherit;
  transition: all var(--transition);
}
.newsletter-banner-form input[type="email"]::placeholder { color: rgba(255,255,255,0.5); }
.newsletter-banner-form input[type="email"]:focus {
  outline: none;
  border-color: #fff;
  background: rgba(255,255,255,0.2);
}
.newsletter-freq {
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
  border-radius: 999px;
  border: 2px solid rgba(255,255,255,0.3);
  background: rgba(255,255,255,0.12);
  color: #fff;
  font-family: inherit;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  min-width: 110px;
}
.newsletter-freq option { color: #1a1a2e; background: #fff; }
.newsletter-freq:focus { outline: none; border-color: #fff; }
.newsletter-banner-form .btn {
  border-radius: 999px;
  background: #fff;
  color: var(--brand);
  font-weight: 700;
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  white-space: nowrap;
  border: none;
}
.newsletter-banner-form .btn:hover {
  background: var(--bg);
  color: var(--brand-dark);
  box-shadow: none;
}
.newsletter-success {
  color: #fff;
  font-weight: 600;
  font-size: 1rem;
  margin-top: 0.75rem;
  width: 100%;
}
@media (max-width: 960px) {
  .newsletter-banner-inner { flex-direction: column; text-align: center; }
  .newsletter-banner-form { width: 100%; }
  .newsletter-banner-form input[type="email"] { flex: 1; min-width: 0; }
}

/* ---- Admin active nav ---- */
.admin-nav a[aria-current="page"],
.admin-nav a.active {
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 600;
}

/* ---- Responsive ---- */
@media (max-width: 960px) {
  .hero-grid, .three-up, .topic-grid, .plan-grid, .metric-grid, .prompt-grid, .faq-grid, .split-layout, .form-shell, .admin-layout, .account-grid {
    grid-template-columns: 1fr;
  }
  .article-grid { grid-template-columns: 1fr; }
  .footer-grid { flex-direction: column; }

  .hamburger { display: flex; }
  .nav-body {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    background: var(--paper);
    border-bottom: 1px solid var(--line);
    padding: 1rem 1.25rem 1.5rem;
    box-shadow: var(--shadow-lg);
    z-index: 51;
  }
  .nav-body.nav-open { display: flex; }
  .nav-body .site-nav { flex-direction: column; align-items: stretch; gap: 0.15rem; }
  .nav-body .site-nav a { display: block; }
  .nav-body .dropdown-menu {
    position: static;
    box-shadow: none;
    border: none;
    padding: 0 0 0 0.75rem;
  }
  .nav-body .dropdown:hover .dropdown-menu,
  .nav-body .dropdown.open .dropdown-menu { display: block; }
  .nav-body .nav-actions {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--line);
    gap: 0.15rem;
  }
  /* fab group handled above */
  .nav-body .ghost-link { display: block; }
  .header-search { flex: 1 1 100%; margin: 0.5rem 0; order: -1; }
  .theme-toggle { align-self: flex-start; }

  .hero { padding: 3rem 0 2rem; }
  .hero h1 { font-size: 2.2rem; }
  .section-head { flex-direction: column; align-items: stretch; gap: 0.75rem; }
  .search-bar { width: 100%; }
  .search-bar input { width: 100%; }
  .cookie-inner { flex-direction: column; text-align: center; }

  /* ---- Mobile card fixes ---- */
  /* Disable hover float on touch devices — causes sticky transforms */
  .panel-card:hover, .topic-card:hover, .article-card:hover, .plan-card:hover {
    transform: none;
  }

  /* Give all sections a solid background so cards don't float over page bg */
  .content-section {
    background: var(--bg);
  }
  .content-section.muted {
    background: var(--paper);
  }

  /* Reduce card padding on small screens */
  .panel-card, .topic-card, .article-card, .plan-card { padding: 1.15rem; }

  /* Reduce section padding */
  .content-section { padding: 2rem 0; }
  .panel-section { padding: 2rem 0; }

  /* Tighten grids */
  .article-grid, .topic-grid, .plan-grid { gap: 0.75rem; }

  /* Disable stagger animations — confusing during scroll on mobile */
  .article-card, .topic-card, .plan-card, .faq-item,
  .content-section, .hero-card, .admin-panel, .breath-block > div {
    animation: none;
  }

  /* Newsletter banner — stack vertically */
  .newsletter-banner-inner { flex-direction: column; gap: 1rem; }
  .newsletter-banner-form { flex-direction: column; gap: 0.5rem; }
  .newsletter-banner-form input,
  .newsletter-banner-form select,
  .newsletter-banner-form button { width: 100%; }

  /* Shell narrower gutters on mobile */
  .shell { width: calc(100% - 1.5rem); }
}
