/* ─── Design tokens — dark (default) ───────────────── */
:root {
  --bg:          #0d0d10;
  --surface:     #141418;
  --surface-2:   #1c1c22;
  --surface-3:   #222229;
  --border:      rgba(255, 255, 255, 0.07);
  --border-2:    rgba(255, 255, 255, 0.12);
  --text:        #eeeef0;
  --text-2:      #8e8e9c;
  --text-3:      #55556a;
  --header-bg:   rgba(13, 13, 16, 0.88);
  --reader-text: #d4d4da;
  --accent:      #c96442;
  --accent-dim:  rgba(201, 100, 66, 0.14);
  --a1:          #4ecba8;
  --a2:          #9c8df5;
  --b1:          #e8964d;
  --a1-dim:      rgba(78, 203, 168, 0.13);
  --a2-dim:      rgba(156, 141, 245, 0.13);
  --b1-dim:      rgba(232, 150, 77, 0.13);
  --radius:      13px;
  --radius-sm:   8px;
}

/* ─── Light mode ────────────────────────────────────── */
[data-theme="light"] {
  --bg:          #f7f6f3;
  --surface:     #ffffff;
  --surface-2:   #f0ede8;
  --surface-3:   #e8e4de;
  --border:      rgba(0, 0, 0, 0.07);
  --border-2:    rgba(0, 0, 0, 0.12);
  --text:        #1a1a1c;
  --text-2:      #6b6b78;
  --text-3:      #a0a0ad;
  --header-bg:   rgba(247, 246, 243, 0.88);
  --reader-text: #2e2e32;
  --accent:      #c96442;
  --accent-dim:  rgba(201, 100, 66, 0.10);
  --a1:          #1f9e7d;
  --a2:          #6b58e0;
  --b1:          #c4710e;
  --a1-dim:      rgba(31, 158, 125, 0.10);
  --a2-dim:      rgba(107, 88, 224, 0.10);
  --b1-dim:      rgba(196, 113, 14, 0.10);
}

/* ─── System preference fallback ───────────────────── */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg:          #f7f6f3;
    --surface:     #ffffff;
    --surface-2:   #f0ede8;
    --surface-3:   #e8e4de;
    --border:      rgba(0, 0, 0, 0.07);
    --border-2:    rgba(0, 0, 0, 0.12);
    --text:        #1a1a1c;
    --text-2:      #6b6b78;
    --text-3:      #a0a0ad;
    --header-bg:   rgba(247, 246, 243, 0.88);
    --reader-text: #2e2e32;
    --accent:      #c96442;
    --accent-dim:  rgba(201, 100, 66, 0.10);
    --a1:          #1f9e7d;
    --a2:          #6b58e0;
    --b1:          #c4710e;
    --a1-dim:      rgba(31, 158, 125, 0.10);
    --a2-dim:      rgba(107, 88, 224, 0.10);
    --b1-dim:      rgba(196, 113, 14, 0.10);
  }
}

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

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

/* ─── App main content wrapper ─────────────────────── */
.app-main {
  min-height: 100vh;
  transition: margin-left 0.2s ease;
}

/* ─── Site header ───────────────────────────────────── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 54px;
  padding: 0 2rem;
  background: var(--header-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
}

.logo {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  user-select: none;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text-2);
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
  flex-shrink: 0;
}
.icon-btn:hover,
.icon-btn[aria-expanded="true"] { color: var(--text); background: var(--surface-2); }

/* ─── Read progress bar ─────────────────────────────── */
#read-progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0%;
  background: var(--accent);
  z-index: 200;
  transition: width 0.15s linear;
  pointer-events: none;
  opacity: 0;
}
#read-progress-bar.visible { opacity: 1; }

/* ─── Sidebar settings button ───────────────────────── */
.sidebar-settings-btn {
  margin-top: auto;
}

.settings-email {
  font-size: 0.83rem;
  color: var(--text-2);
  padding: 0.6rem 0.85rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin: 0;
}

.settings-divider {
  height: 1px;
  background: var(--border);
  margin: 0.4rem 0;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 44px;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-sm);
  background: none;
  border: none;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s;
  text-align: left;
  gap: 0.75rem;
}
.settings-row:hover { background: var(--surface-3); }

.settings-row-label {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--text);
  white-space: nowrap;
  flex-shrink: 0;
}

.settings-row-danger .settings-row-label,
.settings-row-danger { color: var(--text-2); }
.settings-row-danger:hover { color: #f87171; background: rgba(248,113,113,0.08); }

.settings-level-row {
  cursor: default;
  pointer-events: none;
}
.settings-level-row .settings-row-label { pointer-events: none; }

.level-picker {
  display: flex;
  gap: 0.3rem;
  pointer-events: all;
  flex-shrink: 0;
}
.level-pick-btn {
  padding: 0.4rem 0.7rem;
  border-radius: 6px;
  border: 1.5px solid var(--border-2);
  background: none;
  color: var(--text-2);
  font-size: 0.82rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  min-height: 34px;
  min-width: 38px;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.level-pick-btn:hover { color: var(--text); border-color: var(--text-2); }
.level-pick-btn.active {
  background: #7c6af7;
  border-color: #7c6af7;
  color: #fff;
}

/* Toggle switch */
.toggle-switch {
  width: 40px;
  height: 24px;
  border-radius: 12px;
  background: var(--surface-3);
  border: 1px solid var(--border-2);
  position: relative;
  transition: background 0.2s;
  flex-shrink: 0;
}
.toggle-switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--text-2);
  transition: transform 0.2s, background 0.2s;
}
.toggle-switch.is-on {
  background: #7c6af7;
  border-color: #7c6af7;
}
.toggle-switch.is-on::after {
  transform: translateX(16px);
  background: #fff;
}

/* Show sun in dark mode, moon in light mode */
:root:not([data-theme="light"]) .icon-moon,
[data-theme="light"] .icon-sun { display: none; }

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .icon-sun { display: none; }
  :root:not([data-theme="dark"]) .icon-moon { display: block; }
}

/* ─── Buttons ───────────────────────────────────────── */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.48rem 0.95rem;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  font-family: inherit;
  font-size: 0.855rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.15s;
  line-height: 1;
}

.btn-primary:hover   { opacity: 0.85; transform: translateY(-1px); }
.btn-primary:active  { transform: none; opacity: 0.75; }
.btn-primary:disabled { opacity: 0.45; cursor: default; transform: none; }
.btn-primary.btn-full { width: 100%; justify-content: center; padding: 0.7rem 1rem; }

.btn-upgrade {
  display: inline-flex;
  align-items: center;
  padding: 0.42rem 0.85rem;
  border: 1.5px solid rgba(124, 106, 247, 0.55);
  border-radius: var(--radius-sm);
  background: rgba(124, 106, 247, 0.1);
  color: #a89ef7;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  white-space: nowrap;
}
.btn-upgrade:hover {
  background: rgba(124, 106, 247, 0.18);
  border-color: rgba(124, 106, 247, 0.8);
  color: #c4bbff;
}

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: none;
  border: none;
  color: var(--text-2);
  font-family: inherit;
  font-size: 0.855rem;
  font-weight: 500;
  cursor: pointer;
  padding: 0.38rem 0.6rem;
  border-radius: var(--radius-sm);
  transition: color 0.15s, background 0.15s;
  flex-shrink: 0;
}
.back-btn:hover { color: var(--text); background: var(--surface-2); }

/* ─── Views ─────────────────────────────────────────── */
.view          { animation: fadeUp 0.22s ease both; }
.view-hidden   { display: none !important; }

/* ─── Feed ──────────────────────────────────────────── */
#feed-view {
  max-width: 1160px;
  margin: 0 auto;
  padding: 2.8rem 2rem 6rem;
}

.feed-hero {
  margin-bottom: 2.2rem;
}

.feed-hero h1 {
  font-size: clamp(1.55rem, 2.8vw, 2.25rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin-bottom: 0.55rem;
}

.feed-hero p {
  color: var(--text-2);
  font-size: 0.93rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.level-pill {
  display: inline-flex;
  align-items: center;
  font-size: 0.73rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 0.15rem 0.5rem;
  border-radius: 100px;
}
.level-pill.a1 { background: var(--a1-dim); color: var(--a1); }
.level-pill.a2 { background: var(--a2-dim); color: var(--a2); }
.level-pill.b1 { background: var(--b1-dim); color: var(--b1); }

/* Grid — individual cards with gaps */
.article-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

/* ─── Article card ──────────────────────────────────── */
.article-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.4rem 1.5rem 1.3rem;
  cursor: pointer;
  transition: background 0.14s, box-shadow 0.14s, transform 0.14s;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  min-height: 200px;
  position: relative;
}
.article-card:hover {
  background: var(--surface-2);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.07);
  transform: translateY(-1px);
}

/* ─── Card action button (remove / add) ─────────────── */
.card-action-btn {
  position: absolute;
  top: 0.8rem;
  right: 0.8rem;
  width: 1.65rem;
  height: 1.65rem;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
  transition: background 0.14s, color 0.14s;
  background: var(--surface-2);
  color: var(--text-3);
  z-index: 1;
  flex-shrink: 0;
}
.card-action-btn:hover { background: var(--border); color: var(--text); }
.card-remove-btn:hover { background: #fee2e2; color: #dc2626; }
.card-add-btn:hover    { background: #dcfce7; color: #16a34a; }

/* Reserve space so title doesn't slide under the action button */
.article-card.has-action .card-title { padding-right: 1.8rem; }

.card-badges {
  display: flex;
  gap: 0.35rem;
}

.badge {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 0.18rem 0.48rem;
  border-radius: 100px;
}
.badge.a1 { background: var(--a1-dim); color: var(--a1); }
.badge.a2 { background: var(--a2-dim); color: var(--a2); }
.badge.b1 { background: var(--b1-dim); color: var(--b1); }

.card-title {
  font-size: 0.97rem;
  font-weight: 600;
  line-height: 1.42;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-snippet {
  font-size: 0.845rem;
  color: var(--text-2);
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex: 1;
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
}

.card-date   { font-size: 0.77rem; color: var(--text-3); }
.card-source { font-size: 0.77rem; color: var(--text-3); }

.card-arrow {
  font-size: 0.82rem;
  color: var(--text-3);
  transition: transform 0.14s, color 0.14s;
}
.article-card:hover .card-arrow { transform: translateX(3px); color: var(--text-2); }

/* ─── Empty & loading states ────────────────────────── */
.empty-state {
  grid-column: 1 / -1;
  background: var(--surface);
  text-align: center;
  padding: 5rem 2rem;
}

.empty-icon { font-size: 2.2rem; margin-bottom: 1rem; opacity: 0.35; }

.empty-state h3 {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 0.45rem;
}

.empty-state p {
  color: var(--text-2);
  font-size: 0.875rem;
  max-width: 30ch;
  margin: 0 auto 1.5rem;
  line-height: 1.6;
}

.skeleton-card {
  background: var(--surface);
  padding: 1.4rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-height: 200px;
}

.skel {
  border-radius: 5px;
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}
.skel-xs  { height: 13px; }
.skel-sm  { height: 14px; }
.skel-lg  { height: 16px; }

@keyframes shimmer {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}

/* ─── Reader header ─────────────────────────────────── */
.reader-header {
  position: sticky;
  top: 54px;
  z-index: 90;
  display: flex;
  align-items: center;
  gap: 1rem;
  height: 54px;
  padding: 0 1.25rem;
  background: var(--header-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
}

.level-tabs {
  display: flex;
  flex: 1;
  gap: 0.25rem;
  padding: 0.22rem;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
}

.level-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  flex: 1;
  padding: 0.5rem 0.5rem;
  border: none;
  border-radius: 6px;
  background: none;
  color: var(--text-2);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.14s, color 0.14s, box-shadow 0.14s;
  line-height: 1;
  white-space: nowrap;
}
.level-tab:hover { color: var(--text); }
.level-tab.active {
  background: #7c6af7;
  color: #fff;
  box-shadow: 0 1px 6px rgba(124,106,247,0.4);
}

.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot-a1 { background: var(--a1); }
.dot-a2 { background: var(--a2); }
.dot-b1 { background: var(--b1); }
.level-tab.active .dot { background: rgba(255,255,255,0.7); }

.source-link {
  margin-left: auto;
  font-size: 0.8rem;
  color: var(--text-2);
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.14s;
  flex-shrink: 0;
}
.source-link:hover { color: var(--text); }

/* ─── Reader body ───────────────────────────────────── */
.reader-container {
  max-width: 672px;
  margin: 0 auto;
  padding: 3.2rem 2rem 7rem;
}

.reader-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 1.1rem;
}

.reader-wordcount {
  font-size: 0.78rem;
  color: var(--text-3);
}

.reader-level-label {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  margin-bottom: 0;
}
.reader-level-label.a1 { color: var(--a1); }
.reader-level-label.a2 { color: var(--a2); }
.reader-level-label.b1 { color: var(--b1); }

.reader-title {
  font-family: 'Lora', Georgia, serif;
  font-size: clamp(1.65rem, 3.5vw, 2.3rem);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.01em;
  color: var(--text);
  margin-bottom: 2rem;
}

.reader-body {
  font-family: 'Lora', Georgia, serif;
  font-size: 1.06rem;
  line-height: 1.82;
  color: var(--reader-text);
}
.reader-body p + p { margin-top: 1.25em; }

.reader-word {
  cursor: pointer;
  border-radius: 0.3rem;
  transition: background-color 0.14s ease, color 0.14s ease;
}
.reader-word:hover {
  background: var(--accent-dim);
  color: var(--text);
}
.reader-word:focus-visible {
  outline: 2px solid rgba(124, 106, 247, 0.7);
  outline-offset: 1px;
}

/* ─── Dictionary popup ───────────────────────────────── */
.dict-popup-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0.75rem;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.dict-popup-overlay.modal-hidden { display: none; }

.dict-popup {
  width: min(100%, 34rem);
  border-radius: 14px;
  border: 1px solid var(--border-2);
  background: var(--surface);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.34);
  padding: 0.95rem 0.95rem 1rem;
}

.dict-popup-head {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  justify-content: space-between;
  margin-bottom: 0.2rem;
}

.dict-popup-word {
  font-size: 1.08rem;
  color: var(--text);
  letter-spacing: -0.01em;
  word-break: break-word;
}

.dict-popup-close {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border: none;
  border-radius: 9px;
  color: var(--text-2);
  background: var(--surface-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color 0.14s ease, background 0.14s ease;
}
.dict-popup-close:hover {
  color: var(--text);
  background: var(--surface-3);
}

.dict-popup-pos {
  color: var(--text-2);
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 0.55rem;
}

.dict-popup-status {
  color: var(--text-2);
  font-size: 0.88rem;
  min-height: 1.4em;
  margin-bottom: 0.2rem;
}

.dict-popup-definition {
  color: var(--text);
  font-size: 0.95rem;
  line-height: 1.52;
}

.dict-popup-example {
  margin-top: 0.55rem;
  color: var(--reader-text);
  font-size: 0.92rem;
  line-height: 1.5;
  font-style: italic;
}

@media (min-width: 768px) {
  .dict-popup-overlay {
    align-items: center;
    padding: 1.25rem;
  }
}

/* ─── Modal ─────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.58);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: fadeIn 0.14s ease;
}
.modal-overlay.modal-hidden { display: none; }

.modal {
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  padding: 0.5rem;
  width: 100%;
  max-width: 460px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
  animation: slideUp 0.18s ease;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.3rem 0.55rem 0.3rem 0.85rem;
  min-height: 44px;
}

.modal-head h2 {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
}

/* ─── Modal pickers (mode / language) ──────────────── */
.modal-picker {
  display: flex;
  gap: 0.3rem;
  pointer-events: all;
}

.modal-pick-opt { margin: 0; }

.modal-pick-opt input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.modal-pick-opt span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.4rem 0.7rem;
  border-radius: 6px;
  border: 1.5px solid var(--border-2);
  background: none;
  color: var(--text-2);
  font-size: 0.82rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  min-height: 34px;
  min-width: 38px;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
  user-select: none;
}

.modal-pick-opt:hover span { color: var(--text); border-color: var(--text-2); }

.modal-pick-opt input:checked + span {
  background: #7c6af7;
  border-color: #7c6af7;
  color: #fff;
}

/* ─── Modal input + submit areas ────────────────────── */
.modal-input-area {
  padding: 0.6rem 0.85rem 0.5rem;
}

.modal-submit-row {
  padding: 0.35rem 0.85rem 0.5rem;
}

.modal-close-btn {
  background: none;
  border: none;
  color: var(--text-2);
  cursor: pointer;
  padding: 0.3rem;
  border-radius: 6px;
  line-height: 0;
  transition: color 0.14s, background 0.14s;
}
.modal-close-btn:hover { color: var(--text); background: var(--surface-2); }

/* ─── Form ──────────────────────────────────────────── */
.toggle-row {
  display: inline-flex;
  gap: 0;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  padding: 0.18rem;
  margin-bottom: 1.1rem;
}

.toggle-option { margin: 0; }

.toggle-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.toggle-option span {
  display: inline-block;
  padding: 0.36rem 0.82rem;
  border-radius: 6px;
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
  transition: background 0.14s, color 0.14s;
  user-select: none;
}
.toggle-option input:checked + span {
  background: var(--surface-2);
  color: var(--text);
}


input[type="url"],
textarea {
  width: 100%;
  background: var(--surface-3);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 0.93rem;
  padding: 0.72rem 0.95rem;
  outline: none;
  transition: border-color 0.14s;
  margin-bottom: 0;
  display: block;
}
textarea { margin-bottom: 0; }
input[type="url"]:focus,
textarea:focus { border-color: rgba(201, 100, 66, 0.55); }

textarea {
  resize: vertical;
  min-height: 150px;
  line-height: 1.55;
}

.modal-status {
  font-size: 0.835rem;
  color: var(--text-2);
  text-align: center;
  padding: 0.4rem 0.85rem 0.25rem;
  min-height: 1.2em;
  line-height: 1.5;
}
.modal-status.error { color: #f08080; }

/* ─── Field hint (paywall link) ─────────────────────── */
.field-hint {
  font-size: 0.8rem;
  color: var(--text-2);
  margin: 0.45rem 0 0;
}
.hint-link {
  background: none;
  border: none;
  padding: 0;
  color: var(--text-2);
  font-size: inherit;
  text-decoration: underline;
  cursor: pointer;
  font-family: inherit;
}
.hint-link:hover { color: var(--text); }

/* ─── Progress steps ────────────────────────────────── */
.modal-progress {
  margin-top: 0.75rem;
  padding: 0 0.85rem;
}
.modal-progress.hidden { display: none; }

.progress-steps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
}

.progress-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
}

.step-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--surface-3);
  border: 2px solid var(--border-2);
  transition: background 0.3s, border-color 0.3s, box-shadow 0.3s;
}

.progress-step.active .step-dot {
  background: #e8622a;
  border-color: #e8622a;
  box-shadow: 0 0 0 4px rgba(232, 98, 42, 0.3), 0 0 12px rgba(232, 98, 42, 0.4);
  animation: pulse-dot 1.2s ease-in-out infinite;
}

.progress-step.done .step-dot {
  background: #7c6af7;
  border-color: #7c6af7;
  box-shadow: 0 0 6px rgba(124, 106, 247, 0.4);
}

.step-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-3);
  transition: color 0.3s;
  white-space: nowrap;
  letter-spacing: 0.01em;
}
.progress-step.active .step-label { color: #e8622a; }
.progress-step.done  .step-label  { color: #7c6af7; }

.progress-connector {
  flex: 1;
  height: 2px;
  background: var(--border-2);
  min-width: 40px;
  max-width: 80px;
  margin-bottom: 1.2rem;
  transition: background 0.4s;
  position: relative;
  overflow: hidden;
  border-radius: 2px;
}
.progress-connector.done { background: #7c6af7; }
.progress-connector.active::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, #e8622a, #7c6af7, transparent);
  animation: shimmer 1.2s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 0 4px rgba(232,98,42,0.3), 0 0 12px rgba(232,98,42,0.4); }
  50%       { box-shadow: 0 0 0 7px rgba(232,98,42,0.15), 0 0 18px rgba(232,98,42,0.25); }
}
@keyframes shimmer {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* ─── Landing page ──────────────────────────────────── */
.login-view {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  animation: fadeUp 0.28s ease both;
  overflow-x: hidden;
}

/* Nav */
.lp-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 54px;
  padding: 0 2rem;
  background: var(--header-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
}

.lp-nav-logo {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--text);
}

.btn-sm {
  padding: 0.4rem 0.85rem;
  font-size: 0.82rem;
}

/* Hero */
.lp-hero {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 6rem 2rem 5rem;
  overflow: hidden;
}

.lp-hero-glow {
  position: absolute;
  top: -120px;
  left: 50%;
  transform: translateX(-50%);
  width: 900px;
  height: 600px;
  background: radial-gradient(ellipse at 50% 30%, rgba(201, 100, 66, 0.13) 0%, transparent 65%);
  pointer-events: none;
}

.lp-hero-inner {
  position: relative;
  max-width: 680px;
  width: 100%;
}

.lp-level-pills {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  margin-bottom: 1.5rem;
}

.lp-headline {
  font-family: 'Lora', Georgia, serif;
  font-size: clamp(2.4rem, 6vw, 4rem);
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--text);
  margin-bottom: 1.25rem;
}

.lp-sub {
  font-size: clamp(0.95rem, 2vw, 1.1rem);
  color: var(--text-2);
  line-height: 1.7;
  margin-bottom: 2.5rem;
  max-width: 520px;
  margin-left: auto;
  margin-right: auto;
}
.lp-br { display: none; }

/* Signup form */
.lp-signup {
  max-width: 460px;
  margin: 0 auto;
}

.lp-form-row {
  display: flex;
  gap: 0.6rem;
  align-items: stretch;
}

#login-btn {
  justify-content: center;
}

.lp-email-input {
  flex: 1;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  padding: 0.7rem 0.95rem;
  outline: none;
  transition: border-color 0.14s, box-shadow 0.14s;
}
.lp-email-input:focus {
  border-color: rgba(201, 100, 66, 0.55);
  box-shadow: 0 0 0 3px rgba(201, 100, 66, 0.1);
}
.lp-email-input::placeholder { color: var(--text-3); }

.lp-form-note {
  margin-top: 0.85rem;
  font-size: 0.78rem;
  color: var(--text-3);
}

.login-status {
  font-size: 0.84rem;
  color: var(--text-2);
  margin-top: 0.6rem;
  min-height: 1.2em;
  line-height: 1.5;
  text-align: center;
}
.login-status.success { color: var(--a1); }
.login-status.error   { color: #f08080; }

/* "Check your inbox" success state — replaces form content */
.login-sub {
  color: var(--text-2);
  font-size: 0.92rem;
  line-height: 1.6;
}

/* Demo cards */
.lp-demo {
  padding: 0 2rem 5rem;
}

.lp-demo-label {
  text-align: center;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 1.5rem;
}

.lp-demo-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  max-width: 1060px;
  margin: 0 auto;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.lp-demo-card {
  background: var(--surface);
  padding: 1.5rem 1.6rem 1.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  transition: background 0.14s;
}

.lp-demo-card-featured {
  background: var(--surface-2);
}

.lp-demo-card-head {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.lp-demo-level {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.lp-demo-level.a1 { color: var(--a1); }
.lp-demo-level.a2 { color: var(--a2); }
.lp-demo-level.b1 { color: var(--b1); }

.lp-demo-title {
  font-family: 'Lora', Georgia, serif;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.38;
  color: var(--text);
}

.lp-demo-body {
  font-size: 0.875rem;
  color: var(--text-2);
  line-height: 1.65;
  flex: 1;
}

.lp-demo-words {
  font-size: 0.72rem;
  color: var(--text-3);
  margin-top: auto;
}

/* How it works */
.lp-steps {
  padding: 0 2rem 5rem;
}

.lp-steps-inner {
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  align-items: flex-start;
  gap: 0;
}

.lp-step {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 1rem;
  padding: 0 1.5rem;
}

.lp-step-num {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1.5px solid var(--border-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--accent);
  flex-shrink: 0;
}

.lp-step-text h3 {
  font-size: 0.97rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.4rem;
  letter-spacing: -0.01em;
}

.lp-step-text p {
  font-size: 0.875rem;
  color: var(--text-2);
  line-height: 1.65;
}

.lp-step-connector {
  width: 60px;
  height: 1.5px;
  background: var(--border-2);
  flex-shrink: 0;
  margin-top: 22px; /* vertically align with circle center */
}


/* Benefits */
.lp-benefits {
  padding: 0 2rem 3rem;
}

.lp-benefits-inner {
  max-width: 980px;
  margin: 0 auto;
}

.lp-benefits-label {
  text-align: center;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
}

.lp-benefits-title {
  margin-top: 0.35rem;
  text-align: center;
  font-family: 'Lora', Georgia, serif;
  font-size: clamp(1.35rem, 2.6vw, 1.9rem);
  color: var(--text);
}

.lp-benefits-grid {
  margin-top: 1.2rem;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.85rem;
}

.lp-benefit-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1.1rem;
}

.lp-benefit-card h3 {
  font-size: 0.95rem;
  color: var(--text);
  margin-bottom: 0.45rem;
}

.lp-benefit-card p {
  font-size: 0.86rem;
  color: var(--text-2);
  line-height: 1.6;
}

/* Pricing */
.lp-pricing {
  padding: 0 2rem 4rem;
}

.lp-pricing-inner {
  max-width: 980px;
  margin: 0 auto;
  padding: 1.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--surface) 0%, var(--bg) 100%);
}

.lp-pricing-label {
  text-align: center;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
}

.lp-pricing-title {
  margin-top: 0.35rem;
  text-align: center;
  font-family: 'Lora', Georgia, serif;
  font-size: clamp(1.4rem, 2.8vw, 2rem);
  color: var(--text);
}

.lp-pricing-cards {
  margin-top: 1.4rem;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
}

.lp-price-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1.2rem;
}

.lp-price-card-pro {
  border-color: rgba(124, 106, 247, 0.48);
  background: linear-gradient(180deg, rgba(124, 106, 247, 0.12) 0%, var(--surface) 100%);
}

.lp-price-badge {
  position: absolute;
  top: 1rem;
  right: 1rem;
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.lp-price-tier {
  font-size: 0.82rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-3);
  font-weight: 700;
}

.lp-price-value {
  margin-top: 0.35rem;
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--text);
}

.lp-price-value span {
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--text-3);
}

.lp-price-list {
  margin-top: 0.9rem;
  list-style: none;
  display: grid;
  gap: 0.45rem;
  color: var(--text-2);
  font-size: 0.9rem;
}

.lp-price-list li {
  position: relative;
  padding-left: 1rem;
}

.lp-price-list li::before {
  content: '•';
  position: absolute;
  left: 0;
  color: var(--accent);
}

/* Footer */
.lp-footer {
  padding: 0.85rem 1.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  border-top: 1px solid var(--border);
}

.lp-footer-logo {
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-3);
}

.lp-footer p {
  font-size: 0.78rem;
  color: var(--text-3);
  margin: 0;
}

/* Landing responsive */
@media (max-width: 800px) {
  .lp-demo-cards { grid-template-columns: 1fr; }
  .lp-demo-card-featured { background: var(--surface); }
  .lp-benefits-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .lp-hero { padding: 4rem 1.25rem 3.5rem; }
  .lp-demo { padding: 0 1.25rem 3.5rem; }
  .lp-steps { padding: 0 1.25rem 3.5rem; }
  .lp-benefits { padding: 0 1.25rem 2.5rem; }
  .lp-pricing { padding: 0 1.25rem 3rem; }
  .lp-pricing-inner { padding: 1.2rem; }
  .lp-pricing-cards { grid-template-columns: 1fr; }
  .lp-steps-inner { flex-direction: column; align-items: center; gap: 2rem; }
  .lp-step-connector { width: 1.5px; height: 24px; margin-top: 0; }
  .lp-form-row { flex-direction: column; }
  .lp-email-input { text-align: center; }
  .lp-nav { padding: 0 1.25rem; }
  .lp-headline { font-size: 2.2rem; }
  .lp-br { display: inline; }
}

/* ─── Billing row (settings dropdown) ──────────────── */
.settings-billing-row {
  cursor: default;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.billing-action-btn {
  background: var(--accent);
  border: none;
  border-radius: 6px;
  color: #fff;
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.3rem 0.65rem;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.14s;
  flex-shrink: 0;
}
.billing-action-btn:hover { opacity: 0.82; }
.billing-action-btn.billing-btn-manage {
  background: var(--surface-3);
  color: var(--text-2);
}
.billing-action-btn.billing-btn-manage:hover { color: var(--text); }

/* Usage bar inside settings row */
.billing-usage-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  flex: 1;
  min-width: 0;
}
.billing-usage-bar-bg {
  height: 4px;
  border-radius: 2px;
  background: var(--surface-3);
  overflow: hidden;
}
.billing-usage-bar-fill {
  height: 100%;
  border-radius: 2px;
  background: var(--accent);
  transition: width 0.3s ease;
}
.billing-usage-bar-fill.full { background: #f87171; }
.billing-usage-text {
  font-size: 0.72rem;
  color: var(--text-3);
}

/* ─── Paywall modal ─────────────────────────────────── */
.paywall-modal {
  text-align: center;
  padding: 2rem 1.75rem 1.5rem;
}

.paywall-icon {
  font-size: 2.5rem;
  margin-bottom: 1rem;
  line-height: 1;
}

.paywall-title {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 0.6rem;
}

.paywall-sub {
  font-size: 0.875rem;
  color: var(--text-2);
  line-height: 1.65;
  margin-bottom: 1.4rem;
  max-width: 34ch;
  margin-left: auto;
  margin-right: auto;
}

.paywall-perks {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  text-align: left;
  margin: 0 auto 1.6rem;
  max-width: 280px;
}

.paywall-perks li {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.875rem;
  color: var(--text);
}

.paywall-perks svg { color: var(--a1); flex-shrink: 0; }

.paywall-cta {
  font-size: 0.92rem;
  padding: 0.75rem 1rem;
  margin-bottom: 0.65rem;
}

.paywall-error {
  font-size: 0.82rem;
  color: #f08080;
  min-height: 1em;
  margin-bottom: 0.25rem;
}

/* ─── Toast notification ──────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(0);
  background: #2a2a35;
  color: #e8e8f0;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 0.5rem;
  padding: 0.65rem 1.1rem;
  font-size: 0.85rem;
  max-width: min(90vw, 360px);
  text-align: center;
  z-index: 9999;
  transition: opacity 0.25s, transform 0.25s;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}
.toast.toast-hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(0.5rem);
}

.paywall-dismiss {
  display: block;
  width: 100%;
  background: none;
  border: none;
  color: var(--text-3);
  font-family: inherit;
  font-size: 0.82rem;
  cursor: pointer;
  padding: 0.4rem;
  transition: color 0.14s;
}
.paywall-dismiss:hover { color: var(--text-2); }

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

/* ─── Animations ────────────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

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

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

/* ─── Stats strip ───────────────────────────────────── */
.stats-strip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  max-width: 700px;
  margin: 0 auto 2.5rem;
  padding: 0.9rem 1.5rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  animation: fadeUp 0.4s ease both;
  transition: opacity 0.3s ease;
}
.stats-hidden { display: none; }
.stat-item {
  display: flex;
  align-items: baseline;
  gap: 0.35rem;
  flex: 1;
  justify-content: center;
}
.stat-icon { font-size: 1rem; line-height: 1; }
.stat-value {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.stat-label {
  font-size: 0.75rem;
  color: var(--text-2);
  font-weight: 500;
  white-space: nowrap;
}
.stat-divider {
  width: 1px;
  height: 1.8rem;
  background: var(--border);
  flex-shrink: 0;
  margin: 0 0.25rem;
}

/* ─── TTS listen button (reader header) ────────────── */
.tts-listen-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1.5px solid var(--border-2);
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text-2);
  cursor: pointer;
  flex-shrink: 0;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.tts-listen-btn:hover { color: var(--text); background: var(--surface-2); }
.tts-listen-btn:disabled { opacity: 0.5; cursor: default; }
.tts-listen-btn[data-state="playing"],
.tts-listen-btn[data-state="paused"] {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-dim);
}

.tts-icon-spinner { display: none; animation: tts-spin 0.8s linear infinite; }
.tts-listen-btn[data-state="loading"] .tts-icon-headphone { display: none; }
.tts-listen-btn[data-state="loading"] .tts-icon-spinner  { display: block; }

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

/* ─── TTS player bar (fixed bottom) ────────────────── */
.tts-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 150;
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0.75rem 1.5rem;
  background: var(--surface-2);
  border-top: 1px solid var(--border-2);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  animation: slideBarUp 0.2s ease both;
}
.tts-bar-hidden { display: none !important; }

@keyframes slideBarUp {
  from { transform: translateY(100%); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.tts-play-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity 0.15s, transform 0.15s;
}
.tts-play-btn:hover  { opacity: 0.85; transform: scale(1.05); }
.tts-play-btn:active { transform: scale(0.95); }

/* Show pause icon by default (playing); show play icon when paused */
.tts-icon-pause { display: block; }
.tts-icon-play  { display: none; }
.tts-bar[data-paused="true"] .tts-icon-pause { display: none; }
.tts-bar[data-paused="true"] .tts-icon-play  { display: block; }

.tts-track {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.tts-progress-bg {
  height: 4px;
  border-radius: 2px;
  background: var(--surface-3);
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.tts-progress-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.25s linear;
  pointer-events: none;
}

.tts-times {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.tts-speed-group {
  display: flex;
  gap: 0.2rem;
  flex-shrink: 0;
}

.tts-speed-btn {
  padding: 0.3rem 0.5rem;
  border-radius: 5px;
  border: 1px solid var(--border-2);
  background: none;
  color: var(--text-3);
  font-size: 0.72rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  min-height: 28px;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
  white-space: nowrap;
}
.tts-speed-btn:hover { color: var(--text); border-color: var(--text-3); }
.tts-speed-btn.tts-speed-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

@media (max-width: 580px) {
  .tts-bar { padding: 0.65rem 1rem; gap: 0.65rem; }
  .tts-speed-group { display: none; }
  .source-link { display: none; }
}

/* ─── Sidebar (desktop) ─────────────────────────────── */
.app-sidebar {
  position: fixed;
  top: 54px;
  left: 0;
  bottom: 0;
  width: 200px;
  background: var(--bg);
  border-right: 1px solid var(--border);
  z-index: 50;
  padding: 1rem 0.6rem;
  display: flex;
  flex-direction: column;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  padding: 0.6rem 0.85rem;
  border: none;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text-2);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: background 0.12s, color 0.12s;
}
.sidebar-nav-item:hover {
  background: var(--surface-2);
  color: var(--text);
}
.sidebar-nav-item.active {
  background: var(--surface-2);
  color: var(--text);
  font-weight: 600;
}
.sidebar-nav-item.active svg {
  color: #7c6af7;
}

/* Shift app content to account for sidebar on desktop */
.with-sidebar .app-main {
  margin-left: 200px;
}

/* ─── Mobile bottom nav ─────────────────────────────── */
.mobile-nav {
  display: none; /* shown only on mobile via media query */
  flex-direction: row;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 120;
  background: var(--header-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  padding: 0;
  padding-bottom: env(safe-area-inset-bottom);
}

.mobile-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  flex: 1;
  height: 56px;
  border: none;
  background: none;
  color: var(--text-3);
  font-family: inherit;
  font-size: 0.68rem;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.14s;
}
.mobile-nav-item.active {
  color: #7c6af7;
}
.mobile-nav-item svg {
  flex-shrink: 0;
}

/* ─── Feed panels ───────────────────────────────────── */
.feed-panel-hidden { display: none !important; }

/* ─── Explore header ────────────────────────────────── */
.explore-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}

.explore-desc {
  font-size: 0.845rem;
  color: var(--text-2);
  line-height: 1.5;
  max-width: 36ch;
  margin: 0;
}

.topic-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.75rem;
}

.topic-pill {
  font-size: 0.78rem;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.topic-pill:hover {
  border-color: var(--text-1);
  color: var(--text-1);
}

.topic-pill.active {
  background: var(--text-1);
  color: var(--bg);
  border-color: var(--text-1);
}

.explore-lang-row {
  display: flex;
  gap: 0.3rem;
  flex-shrink: 0;
}

.explore-lang-btn {
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  border: 1.5px solid var(--border-2);
  background: none;
  color: var(--text-2);
  font-size: 0.82rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  min-height: 34px;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.explore-lang-btn:hover { color: var(--text); border-color: var(--text-2); }
.explore-lang-btn.active {
  background: #7c6af7;
  border-color: #7c6af7;
  color: #fff;
}

/* ─── Responsive ────────────────────────────────────── */
@media (max-width: 960px) {
  .article-grid { grid-template-columns: repeat(2, 1fr); }
}

/* Hide sidebar on mobile, show bottom nav instead */
@media (max-width: 640px) {
  .app-sidebar { display: none !important; }
  .with-sidebar .app-main {
    margin-left: 0;
  }
  .mobile-nav { display: flex; }
  /* Add bottom padding so content clears the mobile nav */
  #feed-view { padding-bottom: calc(56px + env(safe-area-inset-bottom) + 1rem); }
  #article-view { padding-bottom: calc(56px + env(safe-area-inset-bottom)); }
  /* TTS bar sits above mobile nav */
  .tts-bar { bottom: calc(56px + env(safe-area-inset-bottom)); }
  /* Add article lives in the mobile nav — hide from header */
  #add-btn { display: none !important; }
}

@media (max-width: 580px) {
  .article-grid { grid-template-columns: 1fr; }
  #feed-view { padding: 2rem 1rem calc(56px + env(safe-area-inset-bottom) + 1rem); }
  .site-header { padding: 0 1rem; }
  .reader-header { padding: 0 1rem; gap: 0.6rem; }
  .reader-container { padding: 2rem 1.25rem 5rem; }
  .source-link { display: none; }
  .reader-title { font-size: 1.55rem; }
  .stats-strip { flex-wrap: wrap; gap: 0.75rem; padding: 0.9rem 1rem; }
  .stat-divider { display: none; }
  .stat-item { flex: none; min-width: 40%; }
  .explore-header { flex-direction: column; align-items: flex-start; gap: 0.75rem; }
}

/* ─── Language onboarding overlay ─────────────────────────────────────── */
.lang-onboarding {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}
.lang-onboarding.view-hidden { display: none; }
.lang-onboarding-inner {
  text-align: center;
  max-width: 480px;
  width: 100%;
}
.lang-onboarding-title {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: var(--text);
}
.lang-onboarding-sub {
  color: var(--text-muted);
  margin-bottom: 2.5rem;
  font-size: 0.95rem;
}
.lang-onboarding-btns {
  display: flex;
  gap: 1rem;
  justify-content: center;
}
.lang-onboarding-btn {
  flex: 1;
  max-width: 180px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 2rem 1.5rem;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  background: var(--card-bg);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
  font-family: inherit;
}
.lang-onboarding-btn:hover {
  border-color: var(--accent);
  background: var(--card-bg-hover, var(--card-bg));
  transform: translateY(-2px);
}
.lang-flag {
  font-size: 2.5rem;
  line-height: 1;
}
.lang-name {
  font-size: 1rem;
  font-weight: 600;
}
@media (max-width: 420px) {
  .lang-onboarding-btns { flex-direction: column; align-items: center; }
  .lang-onboarding-btn { max-width: 260px; width: 100%; flex-direction: row; padding: 1.25rem 1.5rem; gap: 1rem; }
  .lang-flag { font-size: 2rem; }
}
