/* Prevent author display properties from overriding the HTML hidden attribute */
[hidden] { display: none !important; }

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

.btn-spinner {
  display: block;
  animation: btn-spin 0.75s linear infinite;
  transform-origin: center;
}


:root {
  --bg: #f4f7ff;
  --pattern-dot: rgba(0, 0, 0, 0.055);
  --surface: rgba(255, 255, 255, 0.75);
  --surface-strong: #ffffff;
  --text: #1d1b20;
  --muted: #6f6a77;
  --primary: #1c6e8c;
  --primary-strong: #0f4c5c;
  --outline: #d7d2dd;
  --grad1: rgba(28, 110, 140, 0.25);
  --grad2: rgba(89, 195, 195, 0.20);
  /* elevation tiers */
  --shadow-sm: 0 1px 3px rgba(22,36,71,0.06), 0 4px 14px rgba(22,36,71,0.09);
  --shadow-md: 0 2px 8px rgba(22,36,71,0.08), 0 10px 28px rgba(22,36,71,0.12);
  --shadow:    0 4px 12px rgba(22,36,71,0.10), 0 20px 50px rgba(22,36,71,0.18);
}

:root[data-theme="dark"] {
  --bg: #10131a;
  --pattern-dot: rgba(255, 255, 255, 0.04);
  --surface: rgba(20, 24, 32, 0.72);
  --surface-strong: #1b202b;
  --text: #ecedf2;
  --muted: #adb3c2;
  --primary: #59c3c3;
  --primary-strong: #7eddd7;
  --outline: #2f3644;
  --grad1: rgba(89, 195, 195, 0.10);
  --grad2: rgba(28, 110, 140, 0.08);
  /* elevation tiers — dark */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.18), 0 4px 14px rgba(0,0,0,0.28);
  --shadow-md: 0 2px 8px rgba(0,0,0,0.28), 0 10px 28px rgba(0,0,0,0.38);
  --shadow:    0 4px 12px rgba(0,0,0,0.35), 0 20px 50px rgba(0,0,0,0.55);
}

/* ── Day accent palettes ─────────────────────────────────────────────────────── */
:root[data-day-accent="ocean"] {
  --primary: #1c6e8c; --primary-strong: #0f4c5c;
  --bg: #f4f7ff;
  --grad1: rgba(28, 110, 140, 0.25); --grad2: rgba(89, 195, 195, 0.20);
}
:root[data-day-accent="forest"] {
  --primary: #2e7d52; --primary-strong: #1a5638;
  --bg: #f2f7f4;
  --grad1: rgba(46, 125, 82, 0.22); --grad2: rgba(100, 190, 140, 0.16);
}
:root[data-day-accent="violet"] {
  --primary: #6b4fa0; --primary-strong: #4d3578;
  --bg: #f5f3ff;
  --grad1: rgba(107, 79, 160, 0.20); --grad2: rgba(160, 120, 220, 0.15);
}
:root[data-day-accent="amber"] {
  --primary: #b06820; --primary-strong: #7d4a15;
  --bg: #fdf7ef;
  --grad1: rgba(176, 104, 32, 0.20); --grad2: rgba(220, 170, 80, 0.15);
}
:root[data-day-accent="rose"] {
  --primary: #b53060; --primary-strong: #8a1f47;
  --bg: #fff2f5;
  --grad1: rgba(181, 48, 96, 0.18); --grad2: rgba(220, 100, 140, 0.13);
}

/* ── Night accent palettes ───────────────────────────────────────────────────── */
:root[data-theme="dark"][data-night-accent="ocean"] {
  --primary: #59c3c3; --primary-strong: #7eddd7;
  --bg: #10131a; --surface-strong: #1b202b;
  --grad1: rgba(89, 195, 195, 0.10); --grad2: rgba(28, 110, 140, 0.08);
}
:root[data-theme="dark"][data-night-accent="forest"] {
  --primary: #52c48a; --primary-strong: #75d9a8;
  --bg: #0c1410; --surface-strong: #141e18;
  --grad1: rgba(82, 196, 138, 0.12); --grad2: rgba(46, 125, 82, 0.09);
}
:root[data-theme="dark"][data-night-accent="violet"] {
  --primary: #a87fdb; --primary-strong: #c4a0f0;
  --bg: #100f1a; --surface-strong: #1a1828;
  --grad1: rgba(168, 127, 219, 0.12); --grad2: rgba(107, 79, 160, 0.09);
}
:root[data-theme="dark"][data-night-accent="amber"] {
  --primary: #d4a843; --primary-strong: #e8c470;
  --bg: #14110a; --surface-strong: #1e1a0e;
  --grad1: rgba(212, 168, 67, 0.12); --grad2: rgba(176, 104, 32, 0.09);
}
:root[data-theme="dark"][data-night-accent="rose"] {
  --primary: #e07090; --primary-strong: #f0a0b8;
  --bg: #180e12; --surface-strong: #241520;
  --grad1: rgba(224, 112, 144, 0.12); --grad2: rgba(181, 48, 96, 0.09);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Manrope", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle, var(--pattern-dot) 1px, transparent 1px),
    radial-gradient(circle at 8% 15%, var(--grad1), transparent 38%),
    radial-gradient(circle at 92% 82%, var(--grad2), transparent 40%),
    var(--bg);
  background-size: 22px 22px, 100% 100%, 100% 100%, 100% 100%;
}

.signin-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.signin-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 48px 40px;
  border: 1px solid var(--outline);
  background: var(--surface);
  backdrop-filter: blur(12px);
  border-radius: 24px;
  box-shadow: var(--shadow);
  animation: rise 0.55s ease-out;
  width: min(420px, calc(100vw - 32px));
}

.signin-logo {
  width: 72px;
  height: 72px;
  border-radius: 20px;
  object-fit: cover;
  margin-bottom: 16px;
}

.signin-title {
  margin: 0 0 6px;
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.signin-subtitle {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 1rem;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px 1fr 280px;
  min-height: 100vh;
  gap: 16px;
  padding: 16px;
}

/* ── Fullscreen mode ─────────────────────────────────────────────────────────*/
.app-shell.app-fullscreen {
  grid-template-columns: 1fr;
}
.app-shell.app-fullscreen .sidebar-left,
.app-shell.app-fullscreen .sidebar-right {
  display: none;
}
.app-shell.app-fullscreen .content {
  zoom: 1.5;
}

/* Fullscreen toggle button */
.fullscreen-btn {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 200;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--outline);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.82rem;
  box-shadow: var(--shadow);
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.fullscreen-btn:hover {
  color: var(--primary);
  border-color: var(--primary);
  background: var(--surface-strong);
}

.sidebar,
.welcome-card,
.panel {
  border: 1px solid var(--outline);
  background: var(--surface);
  backdrop-filter: blur(12px);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.sidebar {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  top: 16px;
  height: calc(100vh - 32px);
  overflow-y: auto;
}

.welcome-card,
.panel {
  border: 1px solid var(--outline);
  background: var(--surface);
  backdrop-filter: blur(12px);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.brand {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.hint {
  margin-top: 8px;
  color: var(--muted);
}

.menu-card {
  margin-top: 18px;
  padding: 16px;
  border-radius: 18px;
  border: 1px solid var(--outline);
  background: var(--surface-strong);
  display: grid;
  gap: 8px;
  box-shadow: var(--shadow-sm);
}

.menu-title {
  margin: 0 0 6px;
  font-weight: 700;
  color: var(--text);
}

.menu-link {
  display: block;
  text-decoration: none;
  color: var(--text);
  border: 1px solid var(--outline);
  background: transparent;
  padding: 10px 12px;
  border-radius: 12px;
  font-weight: 600;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.menu-link:hover {
  background: rgba(28, 110, 140, 0.08);
  border-color: var(--primary);
}

.menu-link-active {
  background: rgba(28, 110, 140, 0.12);
  border-color: var(--primary);
}

.menu-link[aria-disabled="true"] {
  opacity: 0.55;
  pointer-events: none;
}

.sidebar-bottom-nav {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.settings-nav-btn {
  margin-top: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--text);
  border: 1px solid var(--outline);
  background: transparent;
  padding: 10px 14px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 0.95rem;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.settings-nav-btn:hover {
  background: rgba(28, 110, 140, 0.08);
  border-color: var(--primary);
}

.settings-nav-btn.menu-link-active {
  background: rgba(28, 110, 140, 0.12);
  border-color: var(--primary);
  color: var(--primary);
}

.theme-card {
  padding: 18px;
  border-radius: 18px;
  border: 1px solid var(--outline);
  background: var(--surface-strong);
  box-shadow: var(--shadow-sm);
}

.theme-title {
  margin: 0 0 12px;
  font-weight: 700;
}

.theme-mode {
  margin: 10px 0 0;
  font-size: 0.95rem;
  color: var(--muted);
}

.settings-card {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.settings-page-title {
  margin: 0 0 4px;
  font-size: 1.5rem;
  font-weight: 800;
}

.settings-section {
  padding: 18px;
  border-radius: 18px;
  border: 1px solid var(--outline);
  background: var(--surface-strong);
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--shadow-sm);
}

.settings-section-title {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0;
  border-top: 1px solid var(--outline);
}

.settings-row-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.settings-row-label {
  margin: 0;
  font-weight: 700;
  font-size: 0.95rem;
}

.settings-row-desc {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.settings-row-col {
  flex-direction: column;
  align-items: stretch;
}

.settings-select {
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--outline);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  min-width: 140px;
  transition: border-color 0.15s;
}

.settings-select:focus {
  outline: none;
  border-color: var(--primary);
}

.tts-range {
  accent-color: var(--primary);
  width: 120px;
  cursor: pointer;
}

.tts-range-label {
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--primary);
  min-width: 30px;
  text-align: right;
}

.profile-card {
  padding: 16px;
  border-radius: 18px;
  border: 1px solid var(--outline);
  background: var(--surface-strong);
  box-shadow: var(--shadow-sm);
}

.profile-filter-btn {
  display: block;
  width: 100%;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  text-align: left;
  border-radius: 10px;
  transition: opacity 0.15s ease;
}

.profile-filter-btn:hover {
  opacity: 0.75;
}

.profile-photo {
  display: block;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--outline);
  background: linear-gradient(120deg, #8abecf, #1c6e8c);
}

.profile-name {
  margin: 10px 0 4px;
  font-size: 1rem;
  font-weight: 800;
  color: var(--text);
}

.profile-email {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  word-break: break-word;
}

.guest-signin-hint {
  margin: 0 0 12px;
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.4;
}

.guest-signin-btn {
  display: inline-block;
  padding: 8px 20px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 700;
  text-decoration: none;
  transition: opacity 0.15s ease;
}

.guest-signin-btn:hover {
  opacity: 0.85;
}

.switch {
  position: relative;
  display: inline-block;
  width: 62px;
  height: 34px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  inset: 0;
  background: #c4cad7;
  border-radius: 999px;
  transition: 0.25s;
}

.slider::before {
  content: "";
  position: absolute;
  width: 26px;
  height: 26px;
  left: 4px;
  top: 4px;
  border-radius: 50%;
  background: #fff;
  transition: 0.25s;
}

input:checked + .slider {
  background: var(--primary);
}

input:checked + .slider::before {
  transform: translateX(28px);
}

/* ── Theme accent swatches ───────────────────────────────────────────────────── */
.theme-swatches {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  align-items: center;
}

.theme-swatch {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.15s;
  outline: 3px solid transparent;
  outline-offset: 3px;
}

.theme-swatch:hover {
  transform: scale(1.12);
}

.theme-swatch.active {
  outline-color: var(--primary);
}

.content {
  display: flex;
  align-items: center;
  justify-content: center;
}

.welcome-card {
  width: min(760px, 100%);
  padding: 48px 28px;
  text-align: center;
  animation: rise 0.55s ease-out;
}

/* ── Statistics view ──────────────────────────────────────────────────────── */
/* ── About view ───────────────────────────────────────────────────────────── */
.about-card {
  width: min(720px, 100%);
  padding: 48px 40px;
  border: 1px solid var(--outline);
  background: var(--surface);
  backdrop-filter: blur(12px);
  border-radius: 24px;
  box-shadow: var(--shadow);
  animation: rise 0.55s ease-out;
}
.about-content {
  color: var(--text);
  line-height: 1.75;
  font-size: 0.97rem;
}
.about-content h1 {
  font-size: 2rem;
  font-weight: 800;
  margin: 0 0 6px;
  color: var(--text);
}
.about-content h2 {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 36px 0 12px;
  color: var(--text);
  padding-bottom: 6px;
  border-bottom: 1px solid var(--outline);
}
.about-content h3 {
  font-size: 1rem;
  font-weight: 700;
  margin: 20px 0 8px;
  color: var(--text);
}
.about-content p {
  margin: 0 0 14px;
}
.about-content ul, .about-content ol {
  margin: 0 0 14px;
  padding-left: 22px;
}
.about-content li {
  margin-bottom: 6px;
}
.about-content strong {
  font-weight: 700;
  color: var(--text);
}
.about-content hr {
  border: none;
  border-top: 1px solid var(--outline);
  margin: 28px 0;
}
.about-content blockquote {
  border-left: 3px solid var(--primary);
  margin: 0 0 14px;
  padding: 8px 16px;
  color: var(--muted);
  font-style: italic;
  background: var(--surface-strong);
  border-radius: 0 8px 8px 0;
}
.about-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 20px;
  font-size: 0.9rem;
}
.about-content th, .about-content td {
  text-align: left;
  padding: 9px 14px;
  border-bottom: 1px solid var(--outline);
}
.about-content th {
  font-weight: 700;
  color: var(--primary);
  background: var(--surface-strong);
}
.about-content a {
  color: var(--primary);
  text-decoration: none;
}
.about-content a:hover {
  text-decoration: underline;
}
@media (max-width: 760px) {
  .about-card { padding: 28px 18px; }
}

.stats-card {
  width: min(860px, 100%);
  padding: 40px 28px;
  border: 1px solid var(--outline);
  background: var(--surface);
  backdrop-filter: blur(12px);
  border-radius: 24px;
  box-shadow: var(--shadow);
  animation: rise 0.55s ease-out;
}
.stats-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0 0 28px;
  color: var(--text);
}
.stats-loading, .stats-error {
  color: var(--text);
  opacity: 0.6;
  padding: 24px 0;
}
.stats-summary {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 36px;
}
.stats-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--surface-strong);
  border: 1px solid var(--outline);
  border-radius: 16px;
  padding: 18px 28px;
  min-width: 130px;
  flex: 1;
}
.stats-chip-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1;
}
.stats-chip-label {
  font-size: 0.78rem;
  color: var(--text);
  opacity: 0.65;
  margin-top: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.stats-chart-section {
  margin-bottom: 40px;
}
.stats-chart-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  opacity: 0.75;
  margin: 0 0 16px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.stats-chart {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.stats-bar-row {
  display: grid;
  grid-template-columns: 120px 1fr 70px;
  align-items: center;
  gap: 12px;
}
.stats-bar-lang {
  font-size: 0.88rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: right;
}
.stats-bar-track {
  height: 14px;
  background: var(--outline);
  border-radius: 8px;
  overflow: hidden;
}
.stats-bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 8px;
  transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}
.stats-bar-count {
  font-size: 0.8rem;
  color: var(--text);
  opacity: 0.6;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.stats-bar-row-clickable {
  cursor: pointer;
  border-radius: 6px;
  padding: 3px 6px;
  margin: -3px -6px;
  transition: background 0.15s;
}
.stats-bar-row-clickable:hover,
.stats-bar-row-clickable:focus-visible {
  background: var(--outline);
}
.stats-bar-row-clickable:hover .stats-bar-lang,
.stats-bar-row-clickable:focus-visible .stats-bar-lang {
  color: var(--primary);
}
.stats-bar-row-clickable:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
@media (max-width: 520px) {
  .stats-bar-row { grid-template-columns: 90px 1fr 52px; gap: 8px; }
  .stats-chip { padding: 14px 16px; min-width: 90px; }
  .stats-chip-value { font-size: 1.5rem; }
}

.library-card {
  width: min(920px, 100%);
  padding: 40px 28px;
  border: 1px solid var(--outline);
  background: var(--surface);
  backdrop-filter: blur(12px);
  border-radius: 24px;
  box-shadow: var(--shadow);
  animation: rise 0.55s ease-out;
}

.posts-card {
  width: min(980px, 100%);
  padding: 36px 24px;
  border: 1px solid var(--outline);
  background: var(--surface);
  backdrop-filter: blur(12px);
  border-radius: 24px;
  box-shadow: var(--shadow);
  animation: rise 0.55s ease-out;
}

.content-col {
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding-top: 16px;
  gap: 12px;
}

.posts-page-header {
  width: min(980px, 100%);
  padding: 16px 24px 14px;
  background: var(--surface);
  border: 1px solid var(--outline);
  border-radius: 18px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 20px;
}

.posts-page-logo-group {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.posts-page-logo {
  width: 40px;
  height: 40px;
  object-fit: contain;
  border-radius: 10px;
}

.posts-page-brand {
  display: flex;
  align-items: baseline;
  gap: 5px;
}

.posts-page-brand-name {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text);
}

.posts-page-brand-version {
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text);
  opacity: 0.45;
}

.posts-page-count-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.posts-page-title {
  margin: 0;
  font-size: clamp(1.4rem, 2.2vw, 2rem);
  white-space: nowrap;
}

.posts-total-count {
  display: inline-flex;
  align-items: center;
  padding: 4px 13px;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
  letter-spacing: 0.01em;
}

.publisher-banner {
  width: min(980px, 100%);
  padding: 14px 20px;
  background: var(--surface);
  border: 1px solid var(--outline);
  border-radius: 18px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 14px;
}

.publisher-banner-photo {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--outline);
  flex-shrink: 0;
}

.publisher-banner-name {
  flex: 1;
  font-size: 1.05rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.publisher-banner-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.publisher-sub-btn {
  padding: 7px 18px;
  border-radius: 8px;
  border: 1px solid var(--primary);
  background: var(--primary);
  color: #fff;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s;
}

.publisher-sub-btn:hover {
  opacity: 0.85;
}

.publisher-sub-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.publisher-sub-btn-unsub {
  background: transparent;
  color: var(--text);
  border-color: var(--outline);
}

.publisher-sub-btn-unsub:hover {
  border-color: #e05353;
  color: #e05353;
  opacity: 1;
}

.publisher-bell-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid var(--outline);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.publisher-bell-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.publisher-bell-btn.publisher-bell-on {
  border-color: var(--primary);
  color: var(--primary);
}

.publisher-bell-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.publisher-banner-close {
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--outline);
  background: transparent;
  color: var(--muted);
  font-size: 0.9rem;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.publisher-banner-close:hover {
  color: var(--text);
  border-color: var(--text);
}

.posts-card h1 {
  margin: 0 0 4px;
  font-size: clamp(1.7rem, 2.6vw, 2.4rem);
}

.posts-status {
  margin: 0;
  color: var(--muted);
}


.posts-list {
  margin-top: 16px;
  display: grid;
  gap: 12px;
}

.post-item {
  border: 1px solid var(--outline);
  border-radius: 16px;
  padding: 14px;
  background: var(--surface-strong);
  box-shadow: var(--shadow-sm);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.post-item:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.post-item h3 {
  margin: 0;
  font-size: 1.05rem;
}

.post-publisher {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  /* Always keep publisher photo + name at the top-left in both RTL and LTR */
  direction: ltr;
  justify-content: flex-start;
  text-align: left;
}

.post-publisher-photo {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
  background: linear-gradient(120deg, #8abecf, #1c6e8c);
  flex-shrink: 0;
}

.post-publisher-name {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
  border: none;
  background: none;
  font-family: inherit;
  padding: 0;
  cursor: pointer;
  text-align: left;
}

.post-publisher-name:hover {
  color: var(--primary);
}

.post-author {
  display: inline-block;
  margin: 0 0 4px;
  padding: 0;
  border: none;
  background: none;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--primary);
  cursor: pointer;
  text-align: left;
}

.post-author:hover {
  text-decoration: underline;
}

.post-title {
  margin: 0;
  font-size: 1.1rem;
  line-height: 1.3;
}

.post-summary {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.post-meta {
  margin: 8px 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.post-body {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.post-image {
  width: 100%;
  max-height: 220px;
  object-fit: cover;
  border-radius: 12px;
  margin-bottom: 10px;
}

.posts-loadmore {
  display: block;
  width: 100%;
  margin-top: 16px;
}

.post-item-rtl {
  text-align: right;
}

.post-item-rtl .post-meta {
  direction: ltr;
  text-align: right;
}

.post-item-rtl .post-details {
  justify-content: flex-end;
}

.post-details {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--outline);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.post-detail {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border: 1px solid var(--outline);
  border-radius: 999px;
  background: var(--surface-strong);
  font-size: 0.78rem;
}

.post-detail-label {
  color: var(--muted);
}

.post-detail-value {
  font-weight: 700;
  color: var(--text);
}

.post-detail-lang-active {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 12%, transparent);
}

.post-detail-lang-active .post-detail-value {
  color: var(--primary);
}

.post-detail-lang-btn {
  font: inherit;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.post-detail-lang-btn:not(.post-detail-lang-active):hover {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 8%, transparent);
}

.post-detail-lang-btn:not(.post-detail-lang-active):hover .post-detail-value {
  color: var(--primary);
}

.posts-sentinel {
  height: 1px;
  width: 100%;
}

.library-card h1 {
  margin: 0 0 10px;
  font-size: clamp(1.8rem, 2.8vw, 2.6rem);
}

.library-card p {
  margin: 0;
  color: var(--muted);
}

.library-grid {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.welcome-card h1 {
  margin: 0 0 12px;
  font-size: clamp(1.8rem, 2.8vw, 2.6rem);
  line-height: 1.1;
}

.welcome-card p {
  margin: 0 auto;
  max-width: 540px;
  color: var(--muted);
  font-size: 1.05rem;
}

.google-btn {
  margin-top: 28px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(120deg, var(--primary), var(--primary-strong));
  color: white;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 12px 22px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 10px 24px rgba(28, 110, 140, 0.35);
}

.google-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.google-btn:hover {
  transform: translateY(-2px);
}

.secondary-btn {
  margin-top: 12px;
  border: 1px solid var(--outline);
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--text);
  padding: 10px 18px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
}


.google-icon {
  display: inline-flex;
  width: 32px;
  height: 32px;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #fff;
}

.note {
  margin-top: 14px;
  font-size: 0.9rem;
}

.browse-guest-btn {
  display: block;
  margin-top: 14px;
  text-align: center;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
}

.browse-guest-btn:hover {
  text-decoration: underline;
}

.sidebar-right {
  gap: 16px;
  justify-content: flex-start;
}

/* Left sidebar nav wrapper — transparent to flex layout */
#left-sb-nav {
  display: contents;
}

/* AI panel fills left sidebar when placed there */
.sidebar-left > .filter-card {
  flex: 1;
  overflow-y: auto;
}

.filter-card {
  padding: 18px;
  border-radius: 18px;
  border: 1px solid var(--outline);
  background: var(--surface-strong);
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--shadow-sm);
}

.filter-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.filter-title {
  margin: 0;
  font-weight: 700;
  color: var(--text);
}

.filter-clear-all-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent, #6c63ff);
  padding: 2px 6px;
  border-radius: 6px;
  transition: opacity 0.15s;
}
.filter-clear-all-btn:hover { opacity: 0.7; }

.filter-active-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 20px;
  background: var(--chip-bg, rgba(108, 99, 255, 0.1));
  border: 1px solid var(--chip-border, rgba(108, 99, 255, 0.3));
  max-width: 100%;
}

.filter-chip-label {
  flex: 1;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.filter-chip-remove {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 0.8rem;
  padding: 1px 3px;
  border-radius: 4px;
  flex-shrink: 0;
  transition: color 0.15s;
}
.filter-chip-remove:hover { color: var(--text); }


.filter-publisher-tag {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 10px;
  border: 1px solid var(--outline);
  background: var(--bg);
}


.filter-publisher-name {
  flex: 1;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.filter-publisher-remove {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 0.85rem;
  padding: 2px 4px;
  border-radius: 4px;
  flex-shrink: 0;
  transition: color 0.15s ease;
}

.filter-publisher-remove:hover {
  color: var(--text);
}


.search-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.filter-search-input {
  width: 100%;
  padding: 9px 32px 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--outline);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.15s ease;
}

.filter-search-input::placeholder {
  color: var(--muted);
}

.filter-search-input:focus {
  border-color: var(--primary);
}

.search-clear-icon {
  position: absolute;
  right: 8px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 4px;
  transition: color 0.15s ease;
}

.search-clear-icon:hover {
  color: var(--text);
}

.filter-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.filter-section-disabled {
  opacity: 0.4;
  pointer-events: none;
  user-select: none;
}

.filter-section-label {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.filter-price-btns {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.filter-price-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 7px 4px;
  border-radius: 10px;
  border: 1px solid var(--outline);
  cursor: pointer;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text);
  transition: background 0.15s ease, border-color 0.15s ease;
  user-select: none;
  text-align: center;
}

.filter-price-btn input[type="radio"] {
  display: none;
}

.filter-price-btn:hover {
  background: rgba(28, 110, 140, 0.07);
  border-color: var(--primary);
}

.filter-price-btn:has(input:checked) {
  background: rgba(28, 110, 140, 0.12);
  border-color: var(--primary);
  color: var(--primary);
}

#paras-filter-panel .filter-price-btn {
  font-size: 0.68rem;
  padding: 6px 2px;
  white-space: nowrap;
}

#paras-font-panel .filter-price-btns {
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
}

#paras-font-panel .filter-price-btn {
  padding: 5px 2px;
}

.paras-go-pin-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 8px 12px;
  border: none;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
}

.paras-go-pin-btn i {
  flex-shrink: 0;
  font-size: 0.85rem;
}

.paras-go-pin-btn > span:first-of-type {
  flex: 1;
}

.go-pin-serial {
  font-size: 0.72rem;
  font-weight: 700;
  opacity: 0.85;
  background: rgba(255,255,255,0.2);
  border-radius: 4px;
  padding: 1px 5px;
  letter-spacing: 0.02em;
}

.paras-go-pin-btn:hover {
  opacity: 0.85;
}

.paras-go-serial-row {
  display: flex;
  gap: 6px;
  align-items: center;
}

.paras-go-serial-input {
  width: 64px;
  min-width: 0;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1.5px solid var(--outline);
  background: var(--surface);
  color: var(--text);
  font-size: 0.85rem;
  outline: none;
}
.paras-go-serial-input:focus {
  border-color: var(--primary);
}
.paras-go-serial-input::-webkit-inner-spin-button,
.paras-go-serial-input::-webkit-outer-spin-button {
  -webkit-appearance: none;
}
.paras-go-serial-input[type=number] {
  -moz-appearance: textfield;
}

.paras-go-serial-btn {
  flex: 1;
  padding: 8px 12px;
  border-radius: 6px;
  border: none;
  background: var(--primary);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  text-align: left;
}
.paras-go-serial-btn:hover {
  opacity: 0.85;
}

.lang-autocomplete {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.lang-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  min-height: 0;
}

.lang-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px 4px 10px;
  border-radius: 999px;
  background: rgba(28, 110, 140, 0.12);
  border: 1px solid var(--primary);
  color: var(--primary);
  font-size: 0.82rem;
  font-weight: 700;
}

.lang-tag-remove {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 1rem;
  line-height: 1;
  padding: 0;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.12s;
}

.lang-tag-remove:hover {
  opacity: 1;
}

.lang-input {
  width: 100%;
  padding: 8px 32px 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--outline);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 0.88rem;
  outline: none;
  transition: border-color 0.15s ease;
}

.lang-input::placeholder {
  color: var(--muted);
}

.lang-input:focus {
  border-color: var(--primary);
}

.lang-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--surface-strong);
  border: 1px solid var(--outline);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(22, 36, 71, 0.14);
  max-height: 180px;
  overflow-y: auto;
  list-style: none;
  margin: 0;
  padding: 4px;
}

.lang-suggestion {
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  transition: background 0.1s ease;
}

.lang-suggestion:hover {
  background: rgba(28, 110, 140, 0.1);
  color: var(--primary);
}

.filter-check-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 160px;
  overflow-y: auto;
}

.filter-check-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 9px;
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  transition: background 0.12s ease, border-color 0.12s ease;
  user-select: none;
}

.filter-check-option:hover {
  background: rgba(28, 110, 140, 0.07);
  border-color: var(--outline);
}

.filter-check-option:has(input:checked) {
  background: rgba(28, 110, 140, 0.1);
  border-color: var(--primary);
  color: var(--primary);
}

.filter-check-option input[type="checkbox"] {
  accent-color: var(--primary);
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  cursor: pointer;
}

.posts-empty {
  margin: 32px 0;
  text-align: center;
  color: var(--muted);
  font-size: 1rem;
}

.panel {
  padding: 18px;
  animation: fadeIn 0.6s ease both;
}

.panel h2 {
  margin: 0 0 8px;
  font-size: 1.1rem;
}

.panel p {
  margin: 0;
  color: var(--muted);
}

/* ── Load-more spinner ───────────────────────────────────────────────────── */

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

.posts-loading-row {
  display: flex;
  justify-content: center;
  padding: 24px 0 8px;
}

.posts-spinner {
  display: inline-block;
  width: 28px;
  height: 28px;
  border: 3px solid rgba(28, 110, 140, 0.2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

[data-theme="dark"] .posts-spinner {
  border-color: rgba(89, 195, 195, 0.15);
  border-top-color: var(--primary);
}

/* ── Skeleton loading ──────────────────────────────────────────────────────── */

@keyframes shimmer {
  0%   { background-position: -600px 0; }
  100% { background-position: 600px 0; }
}

.post-skeleton {
  border: 1px solid var(--outline);
  border-radius: 16px;
  padding: 14px;
  background: var(--surface-strong);
}

.skel-pub {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.skel-circle,
.skel-line,
.skel-chip {
  background: linear-gradient(
    90deg,
    var(--outline) 25%,
    var(--surface) 50%,
    var(--outline) 75%
  );
  background-size: 1200px 100%;
  animation: shimmer 1.5s infinite linear;
  border-radius: 6px;
}

.skel-circle {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  flex-shrink: 0;
}

.skel-line       { height: 12px; }
.skel-line-xs    { width: 28%; height: 10px; margin-bottom: 6px; }
.skel-line-sm    { width: 38%; }
.skel-line-md    { width: 88%; height: 12px; margin-bottom: 6px; }
.skel-line-lg    { width: 65%; height: 16px; margin-bottom: 8px; }
.skel-line-short { width: 72%; }
.skel-line-date  { width: 22%; height: 10px; margin-top: 2px; margin-bottom: 8px; }

.skel-chips {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--outline);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.skel-chip {
  width: 70px;
  height: 26px;
  border-radius: 999px;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateX(10px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* ── Drawer overlay (shared) ─────────────────────────────────────────────── */
.drawer-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 299;
}
.drawer-overlay.active { display: block; }

/* ── FAB bar: always hidden on desktop (> 1080px) ───────────────────────── */
.mobile-fab-bar {
  display: none;
}
#mob-left-btn { display: none; }

/* ── Tablet (≤ 1080px): right sidebar becomes a drawer, right FAB appears ── */
@media (max-width: 1080px) {
  .app-shell {
    grid-template-columns: 250px 1fr;
  }

  /* Right sidebar: off-screen drawer instead of display:none */
  .sidebar-right {
    display: flex;
    position: fixed;
    top: 0;
    right: 0;
    height: 100dvh;
    width: 280px;
    z-index: 300;
    border-radius: 20px 0 0 20px;
    border: none;
    transform: translateX(100%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
  }
  .sidebar-right.drawer-open {
    transform: translateX(0);
  }

  /* Show FAB bar with right button only */
  .mobile-fab-bar {
    display: flex;
    position: fixed;
    bottom: 20px;
    left: 0;
    right: 0;
    justify-content: flex-end;
    padding: 0 20px;
    z-index: 200;
    pointer-events: none;
  }
  .mob-fab {
    pointer-events: all;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    background: var(--surface);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.18);
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
  }
  .mob-fab:active { opacity: 0.75; }
}

/* ── Mobile (≤ 760px): left sidebar also becomes a drawer, both FABs show ── */
@media (max-width: 760px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  /* Left sidebar: off-screen drawer */
  .sidebar-left {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    height: 100dvh;
    width: 280px;
    z-index: 300;
    border-radius: 0 20px 20px 0;
    border: none;
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
  }
  .sidebar-left.drawer-open {
    transform: translateX(0);
  }

  /* Both FABs visible, spread to corners */
  .mobile-fab-bar {
    justify-content: space-between;
  }
  #mob-left-btn {
    display: flex;
  }

  .welcome-card { padding: 32px 18px; }
  .library-card { padding: 28px 18px; }
  .posts-card   { padding: 26px 18px; }
  .library-grid { grid-template-columns: 1fr; }
}

.scroll-top-btn {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--outline);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.scroll-top-btn:hover {
  transform: translateX(-50%) translateY(-2px);
  background: var(--surface-strong);
}

/* ── Post owner actions (edit / delete) ─────────────────────────────────── */

.post-owner-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--outline);
  direction: ltr;
}

.post-action-btn {
  padding: 5px 12px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid transparent;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.post-action-btn:hover {
  opacity: 0.85;
  transform: translateY(-1px);
}

.post-edit-btn {
  background: rgba(28, 110, 140, 0.12);
  color: var(--primary);
  border-color: var(--primary);
}

.post-delete-btn {
  background: rgba(220, 53, 69, 0.08);
  color: #dc3545;
  border-color: #dc3545;
}

[data-theme="dark"] .post-delete-btn {
  background: rgba(220, 53, 69, 0.14);
  color: #f07882;
  border-color: #f07882;
}

/* ── Add to My Library button (on post cards) ────────────────────────────── */
.post-card-btn-row {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 10px;
}

.post-add-lib-btn {
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid #28a745;
  background: transparent;
  color: #28a745;
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.post-add-lib-btn:hover {
  background: #28a745;
  color: #fff;
}

[data-theme="dark"] .post-add-lib-btn {
  border-color: #4cae60;
  color: #4cae60;
}

[data-theme="dark"] .post-add-lib-btn:hover {
  background: #4cae60;
  color: #111;
}

.post-cover-btn {
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid var(--primary);
  background: transparent;
  color: var(--primary);
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.post-cover-btn:hover {
  background: var(--primary);
  color: #fff;
}

[data-theme="dark"] .post-cover-btn:hover {
  color: #0f1a1f;
}

/* ── Block background scroll whenever any dialog is open ────────────────── */
body:has(dialog[open]) {
  overflow: hidden;
}

/* ── IRANNastaliq ────────────────────────────────────────────────────────── */
@font-face {
  font-family: "IRANNastaliq";
  src: url("https://cdn.fontcdn.ir/Font/Persian/Nastaliq/Nastaliq.woff2") format("woff2"),
       url("https://cdn.fontcdn.ir/Font/Persian/Nastaliq/Nastaliq.woff")  format("woff");
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

/* ── Cover poster dialog ─────────────────────────────────────────────────── */
.cover-dialog {
  position: fixed;
  inset: 0;
  margin: auto;
  width: 95%;
  max-width: 860px;
  height: 90vh;
  max-height: 90vh;
  border: 1px solid var(--outline);
  border-radius: 20px;
  background: var(--surface-strong);
  color: var(--text);
  padding: 0;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.cover-dialog::backdrop {
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(3px);
}

.cover-dialog-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.cover-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--outline);
  flex-shrink: 0;
}

.cover-dialog-title {
  font-weight: 700;
  font-size: 1rem;
  color: var(--text);
}

.cover-dialog-body {
  display: flex;
  flex-direction: row;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.cover-canvas-wrap {
  flex: 1;
  min-width: 0;
  min-height: 0;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.cover-canvas-wrap canvas {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  border-radius: 10px;
  display: block;
  box-shadow: 0 4px 24px rgba(0,0,0,0.18);
}

.cover-palette-panel {
  width: 200px;
  flex-shrink: 0;
  border-left: 1px solid var(--outline);
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: hidden;
}

.cover-color-label-text {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 2px;
}

.cover-swatches {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  flex: 1;
}

.cover-swatch-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cover-swatch-label {
  font-size: 0.64rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.cover-swatch-row {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 3px;
  justify-items: center;
  align-items: center;
}

.cover-swatch {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
  outline: none;
  transition: transform 0.1s, box-shadow 0.1s;
}

.cover-swatch:hover {
  transform: scale(1.2);
  box-shadow: 0 0 0 2px var(--outline);
}

.cover-swatch--active {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 30%, transparent);
  transform: scale(1.15);
}

.cover-controls {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 10px;
  border-top: 1px solid var(--outline);
  flex-shrink: 0;
}

.cover-btn {
  padding: 7px 12px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s;
  border: none;
  width: 100%;
}

.cover-btn:hover { opacity: 0.85; }

.cover-btn-save {
  background: var(--primary);
  color: #fff;
}

.cover-btn-share {
  background: #28a745;
  color: #fff;
}


/* ── Batch Cover ─────────────────────────────────────────────────────────── */
.filter-batch-section {
  padding-top: 10px;
  border-top: 1px solid var(--outline);
  margin-top: 4px;
}

.batch-cover-trigger-btn {
  width: 100%;
  padding: 7px 12px;
  border-radius: 8px;
  border: 1px solid var(--primary);
  background: transparent;
  color: var(--primary);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.batch-cover-trigger-btn:hover {
  background: var(--primary);
  color: #fff;
}

.batch-cover-dialog {
  position: fixed;
  inset: 0;
  margin: auto;
  width: 92%;
  max-width: 420px;
  border: 1px solid var(--outline);
  border-radius: 16px;
  background: var(--surface-strong);
  color: var(--text);
  padding: 0;
  box-shadow: var(--shadow);
}
.batch-cover-dialog::backdrop {
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(3px);
}
.batch-cover-inner {
  display: flex;
  flex-direction: column;
}
.batch-cover-header {
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--outline);
}
.batch-cover-title {
  font-weight: 700;
  font-size: 1rem;
}
.batch-archive-row {
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--outline);
}
.batch-archive-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  white-space: nowrap;
}
.batch-archive-input {
  flex: 1;
  padding: 6px 10px;
  border: 1px solid var(--outline);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.875rem;
  font-family: inherit;
}
.batch-archive-input:focus {
  outline: none;
  border-color: var(--primary);
}
.batch-resume-bar {
  padding: 8px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: color-mix(in srgb, var(--primary) 10%, transparent);
  border-bottom: 1px solid var(--outline);
}
.batch-resume-text {
  flex: 1;
  font-size: 0.8rem;
  color: var(--text-secondary);
}
.batch-reset-btn {
  font-size: 0.78rem;
  color: var(--primary);
  background: none;
  border: none;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
}
.batch-cancel-btn {
  align-self: center;
  margin-top: 6px;
  padding: 6px 18px;
  border-radius: 6px;
  border: 1px solid var(--outline);
  background: none;
  color: var(--text-secondary);
  font-size: 0.82rem;
  cursor: pointer;
}
.batch-cancel-btn:hover { background: var(--surface-hover, #f0f0f0); }
.batch-form-actions {
  padding: 14px 20px;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}
.batch-start-btn {
  padding: 8px 24px;
  border-radius: 8px;
  border: none;
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
}
.batch-start-btn:hover { opacity: 0.88; }
.batch-cover-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.batch-progress-bar-wrap {
  height: 6px;
  border-radius: 3px;
  background: var(--outline);
  overflow: hidden;
}
.batch-progress-bar {
  height: 100%;
  background: var(--primary);
  border-radius: 3px;
  transition: width 0.3s ease;
}
.batch-progress-current {
  font-size: 0.88rem;
  color: var(--text);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.batch-progress-count {
  font-size: 0.78rem;
  color: var(--muted);
  margin: 0;
}
.batch-cover-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--outline);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.batch-summary-text {
  font-size: 0.88rem;
  color: var(--text);
  margin: 0;
  line-height: 1.5;
}
.batch-cover-close-btn {
  padding: 7px 16px;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  border: none;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  align-self: flex-end;
}
.batch-cover-close-btn:hover { opacity: 0.85; }

/* ── Add-to-Library dialog ───────────────────────────────────────────────── */
.lib-add-dialog {
  position: fixed;
  inset: 0;
  margin: auto;
  width: 90%;
  max-width: 460px;
  max-height: 85vh;
  overflow-y: auto;
  border: 1px solid var(--outline);
  border-radius: 20px;
  background: var(--surface-strong);
  color: var(--text);
  padding: 24px;
  box-shadow: var(--shadow);
}

.lib-add-dialog[open] {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.lib-add-dialog::backdrop {
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(3px);
}

.lib-add-meta {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.lib-add-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  font-size: 0.875rem;
  padding: 4px 0;
  border-bottom: 1px solid var(--outline);
}

.lib-add-row:last-child {
  border-bottom: none;
}

.lib-add-label {
  font-weight: 700;
  color: var(--muted);
  flex-shrink: 0;
  font-size: 0.8rem;
}

.lib-add-value {
  color: var(--text);
  text-align: right;
}

.lib-add-summary-row {
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

.lib-add-summary {
  margin: 0;
  font-size: 0.85rem;
  line-height: 1.45;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.lib-add-status {
  font-size: 0.85rem;
  color: var(--primary);
  font-weight: 600;
  text-align: center;
  padding: 4px 0;
}

.btn-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: btn-spin 0.65s linear infinite;
  vertical-align: middle;
}

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

/* ── Edit post modal ─────────────────────────────────────────────────────── */

.edit-modal {
  position: fixed;
  inset: 0;
  margin: auto;
  width: 90%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  border: 1px solid var(--outline);
  border-radius: 20px;
  background: var(--surface-strong);
  color: var(--text);
  padding: 28px;
  box-shadow: var(--shadow);
}

.edit-modal::backdrop {
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(3px);
}

.edit-modal-title {
  margin: 0 0 20px;
  font-size: 1.2rem;
  font-weight: 800;
}

.edit-modal-fields {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.edit-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.edit-field-label {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.edit-input {
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--outline);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  transition: border-color 0.15s;
}

.edit-input:focus {
  outline: none;
  border-color: var(--primary);
}

.edit-textarea {
  resize: vertical;
  min-height: 90px;
  line-height: 1.5;
}

.edit-save-status {
  margin: 12px 0 0;
  font-size: 0.85rem;
  color: var(--muted);
  min-height: 1.2em;
}

.edit-modal-footer {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.edit-cancel-btn {
  flex: 1;
  padding: 10px 0;
  border-radius: 10px;
  border: 1px solid var(--outline);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
}

.edit-cancel-btn:hover {
  background: var(--surface-strong);
}

.edit-save-btn {
  flex: 2;
  padding: 10px 0;
  border-radius: 10px;
  border: none;
  background: var(--primary);
  color: #fff;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s;
}

.edit-save-btn:hover {
  opacity: 0.88;
}

.edit-save-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* ── Text Editor ─────────────────────────────────────────────────────────── */

.text-editor-card {
  width: min(980px, 100%);
  padding: 24px;
  border: 1px solid var(--outline);
  background: var(--surface);
  backdrop-filter: blur(12px);
  border-radius: 24px;
  box-shadow: var(--shadow);
  animation: rise 0.55s ease-out;
  display: flex;
  flex-direction: column;
  gap: 0;
  min-height: calc(100vh - 80px);
}

/* Header: title + filename + dirty dot */
.te-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 4px;
}

.te-title {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 800;
  flex-shrink: 0;
}

.te-filename {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 300px;
  min-width: 80px;
  padding: 3px 9px;
  border-radius: 6px;
  border: 1px solid var(--outline);
  background: var(--surface-strong);
  cursor: text;
  outline: none;
  transition: border-color 0.15s, color 0.15s;
}
.te-filename:focus {
  overflow: visible;
  text-overflow: clip;
  border-color: var(--primary, #1c6e8c);
  color: var(--text);
}

.te-dirty {
  color: var(--primary);
  font-size: 1rem;
  flex-shrink: 0;
}

/* Menu bar */
.te-menubar {
  display: flex;
  gap: 2px;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--outline);
}

.te-menu-item {
  position: relative;
}

.te-menu-btn {
  background: none;
  border: none;
  color: var(--text);
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  padding: 5px 11px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
}

.te-menu-btn:hover {
  background: rgba(28, 110, 140, 0.09);
}

.te-ai-menu-btn {
  color: var(--primary);
}

/* Dropdown panel */
.te-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 200px;
  background: var(--surface-strong);
  border: 1px solid var(--outline);
  border-radius: 12px;
  box-shadow: 0 8px 28px rgba(22, 36, 71, 0.15);
  z-index: 200;
  padding: 4px;
}

.te-dd-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 7px 12px;
  border: none;
  background: none;
  color: var(--text);
  font-family: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  transition: background 0.12s;
  white-space: nowrap;
}

.te-dd-item:hover {
  background: rgba(28, 110, 140, 0.09);
}

.te-kbd {
  font-size: 0.74rem;
  color: var(--muted);
  font-weight: 500;
}

.te-dd-sep {
  height: 1px;
  background: var(--outline);
  margin: 4px 0;
}

/* Submenu groups */
.te-dd-group {
  position: relative;
}

.te-dd-group-btn {
  width: 100%;
}

.te-dd-arrow {
  margin-left: auto;
  font-size: 0.7rem;
  color: var(--muted);
  transition: transform 0.15s;
}

.te-dd-group-btn.open .te-dd-arrow {
  transform: rotate(90deg);
}

.te-submenu {
  position: absolute;
  left: calc(100% + 4px);
  top: 0;
  min-width: 240px;
  background: var(--surface-strong);
  border: 1px solid var(--outline);
  border-radius: 12px;
  box-shadow: 0 8px 28px rgba(22, 36, 71, 0.15);
  z-index: 201;
  padding: 4px;
}

/* Find & Replace panel */
.te-find-panel {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 14px;
  margin-bottom: 10px;
  border-radius: 12px;
  border: 1px solid var(--outline);
  background: var(--surface-strong);
}

.te-find-row,
.te-replace-row {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.te-find-lbl {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  width: 52px;
  flex-shrink: 0;
}

.te-find-input {
  flex: 1;
  min-width: 140px;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--outline);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 0.88rem;
  outline: none;
  transition: border-color 0.15s;
}

.te-find-input:focus {
  border-color: var(--primary);
}

.te-opt {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 7px;
  border: 1px solid var(--outline);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted);
  user-select: none;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.te-opt input { display: none; }

.te-opt:has(input:checked) {
  background: rgba(28, 110, 140, 0.1);
  border-color: var(--primary);
  color: var(--primary);
}

.te-match-count {
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 600;
  min-width: 40px;
  text-align: center;
}

.te-nav-btn,
.te-close-btn {
  padding: 4px 9px;
  border-radius: 7px;
  border: 1px solid var(--outline);
  background: var(--surface);
  color: var(--text);
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}

.te-nav-btn:hover:not(:disabled),
.te-close-btn:hover {
  background: rgba(28, 110, 140, 0.08);
  border-color: var(--primary);
}

.te-nav-btn:disabled { opacity: 0.35; cursor: not-allowed; }

.te-close-btn {
  margin-left: auto;
  border-color: transparent;
  background: none;
  color: var(--muted);
}

.te-rep-btn {
  padding: 5px 11px;
  border-radius: 8px;
  border: 1px solid var(--outline);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s, border-color 0.12s;
}

.te-rep-btn:hover:not(:disabled) {
  background: rgba(28, 110, 140, 0.08);
  border-color: var(--primary);
}

.te-rep-btn:disabled { opacity: 0.35; cursor: not-allowed; }

/* ── AI panel (in right sidebar, visible when Text Editor is active) ─────── */
/* AI toggle button in text editor menubar */
.te-ai-toggle-btn {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  background: none;
  border: 1px solid var(--outline);
  border-radius: 6px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.13s, border-color 0.13s, color 0.13s;
}
.te-ai-toggle-btn:hover {
  background: rgba(28, 110, 140, 0.09);
  border-color: var(--primary);
  color: var(--primary);
}

/* AI button on paragraph cards */
.para-ai-btn {
  color: var(--primary) !important;
}

.te-ai-panel-status {
  font-size: 0.78rem;
  color: var(--muted);
  min-height: 1.1em;
  margin: 0;
}

.te-ai-action-row {
  display: flex;
  gap: 6px;
  align-items: center;
}

.te-ai-action-select {
  flex: 1;
  min-width: 0;
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid var(--outline);
  background: var(--surface-strong);
  color: var(--text);
  font-family: inherit;
  font-size: 0.84rem;
  cursor: pointer;
  appearance: auto;
}

.te-ai-action-select:focus {
  outline: none;
  border-color: var(--primary);
}

.te-ai-action-select:disabled { opacity: 0.45; cursor: not-allowed; }

.te-ai-sb-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 10px;
  border-top: 1px solid var(--outline);
}

.te-ai-sb-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.te-ai-sb-prompt {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--outline);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 0.84rem;
  resize: vertical;
  min-height: 72px;
}

.te-ai-sb-prompt:focus {
  outline: none;
  border-color: var(--primary);
}

.te-ai-sb-run {
  align-self: flex-end;
  padding: 7px 18px;
  border-radius: 8px;
  border: none;
  background: var(--primary);
  color: #fff;
  font-family: inherit;
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s;
}

.te-ai-sb-run:hover { opacity: 0.88; }
.te-ai-sb-run:disabled { opacity: 0.45; cursor: not-allowed; }

/* Circular progress on Run button while loading */
.te-ai-sb-run.te-ai-loading {
  color: transparent !important;
  pointer-events: none;
  position: relative;
}
.te-ai-sb-run.te-ai-loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 15px;
  height: 15px;
  margin: -7.5px 0 0 -7.5px;
  border: 2px solid rgba(255,255,255,0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: te-ai-spin 0.65s linear infinite;
}
@keyframes te-ai-spin {
  to { transform: rotate(360deg); }
}

/* Paragraph result action buttons */
.te-ai-para-actions {
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.te-ai-para-btn {
  width: 100%;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--outline);
  background: var(--surface-strong);
  color: var(--text);
  font-family: inherit;
  font-size: 0.84rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: background 0.13s, border-color 0.13s;
}
.te-ai-para-btn:hover { background: rgba(28,110,140,0.09); border-color: var(--primary); }
.te-ai-para-add,
.te-ai-para-replace { border-color: var(--primary); color: var(--primary); }
.te-ai-para-cancel { color: var(--muted); }

.te-ai-result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.te-ai-tts-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 6px;
  border: 1px solid var(--outline);
  background: var(--surface-strong);
  color: var(--text);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.te-ai-tts-btn:hover {
  background: rgba(28, 110, 140, 0.09);
  border-color: var(--primary);
  color: var(--primary);
}

.te-ai-tts-btn.te-ai-tts-speaking {
  background: rgba(220, 60, 60, 0.09);
  border-color: #c0392b;
  color: #c0392b;
}

.te-ai-sb-result {
  width: 100%;
  box-sizing: border-box;
  min-height: 240px;
  max-height: 600px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--outline);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 0.84rem;
  line-height: 1.6;
  resize: vertical;
}

.te-ai-sb-use {
  align-self: stretch;
  padding: 8px;
  border-radius: 8px;
  border: none;
  background: var(--primary);
  color: #fff;
  font-family: inherit;
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s;
}

.te-ai-sb-use:hover { opacity: 0.88; }


/* Textarea */
.te-textarea {
  flex: 1;
  width: 100%;
  min-height: 400px;
  padding: 16px 18px;
  border-radius: 14px;
  border: 1px solid var(--outline);
  background: var(--surface-strong);
  color: var(--text);
  font-family: "Menlo", "Consolas", "Monaco", "Courier New", monospace;
  font-size: 0.92rem;
  line-height: 1.7;
  resize: none;
  outline: none;
  transition: border-color 0.15s;
  tab-size: 4;
}

.te-textarea:focus { border-color: var(--primary); }

.te-textarea::placeholder {
  color: var(--muted);
  font-style: italic;
}

/* Status bar */
.te-statusbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--outline);
  gap: 12px;
  min-height: 22px;
}

.te-status {
  font-size: 0.8rem;
  color: var(--primary);
  font-weight: 700;
}

.te-stats {
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}

/* ── Text Editor: Open dialog ────────────────────────────────────────────── */

.te-open-dialog {
  position: fixed;
  inset: 0;
  margin: auto;
  width: 90%;
  max-width: 400px;
  border: 1px solid var(--outline);
  border-radius: 24px;
  background: var(--surface-strong);
  color: var(--text);
  padding: 24px;
  box-shadow: var(--shadow-md);
}

.te-open-dialog[open] {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.te-open-dialog::backdrop {
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(8px);
}

.te-open-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 4px;
}

.te-open-title {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text);
}

.te-open-x-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  color: var(--muted);
  padding: 5px 9px;
  border-radius: 10px;
  font-family: inherit;
  transition: background 0.15s, color 0.15s;
}

.te-open-x-btn:hover {
  background: var(--outline);
  color: var(--text);
}

.te-open-dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 40px 24px;
  border: 2px dashed var(--outline);
  border-radius: 16px;
  color: var(--muted);
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.te-open-dropzone.te-drag-over {
  border-color: var(--primary);
  background: rgba(28, 110, 140, 0.07);
  color: var(--primary);
}

.te-open-drop-icon {
  font-size: 2.2rem;
}

.te-open-drop-label {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 600;
}

.te-open-check-icon {
  font-size: 1.6rem;
  color: var(--primary);
}

.te-open-preview {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  border-radius: 14px;
  border: 1px solid var(--outline);
  background: var(--surface);
  color: var(--primary);
}

.te-open-preview-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.te-open-preview-name {
  font-size: 1rem;
  font-weight: 700;
  word-break: break-all;
  line-height: 1.4;
}

.te-open-preview-size {
  font-size: 0.8rem;
  color: var(--muted);
}

.te-open-action-row {
  display: flex;
  gap: 12px;
}

.te-open-browse-btn {
  flex: 1;
  padding: 12px 0;
  border-radius: 12px;
  border: none;
  background: var(--outline);
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s;
}

.te-open-confirm-btn {
  flex: 1;
  padding: 12px 0;
  border-radius: 12px;
  border: none;
  background: var(--primary);
  color: #fff;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s;
}

.te-open-browse-btn:hover,
.te-open-confirm-btn:hover,
.primary-btn:hover {
  opacity: 0.88;
}

.primary-btn {
  padding: 12px 16px;
  border-radius: 12px;
  border: none;
  background: var(--primary);
  color: #fff;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s;
}

.te-open-cancel-btn {
  padding: 12px 0;
  border-radius: 12px;
  border: 1px solid var(--outline);
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
}

.te-open-cancel-btn:hover {
  background: var(--outline);
}

/* ── My Subscriptions ────────────────────────────────────────────────────── */
.subs-card {
  width: min(980px, 100%);
  padding: 36px 24px;
  border: 1px solid var(--outline);
  background: var(--surface);
  backdrop-filter: blur(12px);
  border-radius: 24px;
  box-shadow: var(--shadow);
  animation: rise 0.55s ease-out;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.subs-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.subs-title {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 800;
}

.subs-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.subs-count {
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 600;
}

.subs-refresh-btn {
  background: none;
  border: 1px solid var(--outline);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--primary);
  transition: background 0.15s, border-color 0.15s;
  flex-shrink: 0;
}

.subs-refresh-btn:hover {
  background: rgba(28, 110, 140, 0.08);
  border-color: var(--primary);
}

.subs-search-wrap {
  position: relative;
}

.subs-search-input {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 36px 10px 14px;
  border: 1px solid var(--outline);
  border-radius: 12px;
  background: var(--surface-strong);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  transition: border-color 0.15s;
}

.subs-search-input:focus {
  outline: none;
  border-color: var(--primary);
}

.subs-search-wrap .search-clear-icon {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
}

.subs-content {
  display: flex;
  flex-direction: column;
}

.subs-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.subs-user-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border: 1px solid var(--outline);
  border-radius: 14px;
  background: var(--surface-strong);
  transition: border-color 0.15s;
  cursor: pointer;
}

.subs-user-card:hover {
  border-color: var(--primary);
}

.subs-user-photo {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--outline);
  flex-shrink: 0;
}

.subs-user-info {
  flex: 1;
  min-width: 0;
}

.subs-user-name {
  margin: 0 0 2px;
  font-weight: 700;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.subs-user-email {
  margin: 0 0 2px;
  font-size: 0.82rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.subs-user-since {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
}

.subs-unsub-btn {
  padding: 7px 14px;
  border-radius: 8px;
  border: 1px solid var(--outline);
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.subs-unsub-btn:hover {
  border-color: #e05353;
  color: #e05353;
}

.subs-highlight {
  background: var(--primary, #5b8dee);
  color: #fff;
  border-radius: 3px;
  padding: 0 2px;
}

.lib-highlight {
  background: var(--primary, #5b8dee);
  color: #fff;
  border-radius: 3px;
  padding: 0 2px;
}

.search-hl {
  background: rgba(255, 204, 0, 0.45);
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
  font-style: inherit;
  font-weight: inherit;
}

[data-theme="dark"] .search-hl {
  background: rgba(255, 204, 0, 0.28);
}

.subs-btn-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

.subs-view-posts-btn {
  padding: 7px 14px;
  border-radius: 8px;
  border: 1px solid var(--outline);
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.subs-view-posts-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.subs-bell-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid var(--outline);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.subs-bell-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.subs-bell-btn.subs-bell-on {
  color: var(--primary);
  border-color: var(--primary);
}

.subs-bell-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.subs-loading,
.subs-error,
.subs-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 48px 24px;
  text-align: center;
  color: var(--muted);
}

.subs-loading .posts-spinner {
  width: 28px;
  height: 28px;
}

.subs-empty h3 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}

.subs-empty p {
  margin: 0;
  font-size: 0.9rem;
}

.subs-undo-toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  background: #323232;
  color: #fff;
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
  z-index: 1000;
  font-size: 0.9rem;
  white-space: nowrap;
}

.subs-undo-btn {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  transition: opacity 0.15s;
}

.subs-undo-btn:hover {
  opacity: 0.85;
}

/* ── My Library ──────────────────────────────────────────────────────────── */
.library-card {
  width: min(980px, 100%);
  padding: 36px 24px;
  border: 1px solid var(--outline);
  background: var(--surface);
  backdrop-filter: blur(12px);
  border-radius: 24px;
  box-shadow: var(--shadow);
  animation: rise 0.55s ease-out;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.library-header {
  display: flex;
  align-items: baseline;
  justify-content: flex-start;
  gap: 12px;
}

.library-title {
  margin: 0;
  font-size: 2rem;
  font-weight: 800;
}

.library-count {
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 600;
}

.library-content {
  display: flex;
  flex-direction: column;
}

.lib-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 18px;
}

.lib-card-item {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px 18px 14px;
  border: 1px solid var(--outline);
  border-radius: 16px;
  background: var(--surface-strong);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.18s, box-shadow 0.18s, transform 0.18s;
}

.lib-card-item:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.lib-item-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.lib-item-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.35;
  color: var(--text);
  flex: 1;
  min-width: 0;
}

.lib-delete-btn {
  flex-shrink: 0;
  background: none;
  border: none;
  font-size: 0.85rem;
  color: var(--muted);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 6px;
  line-height: 1;
  transition: background 0.15s, color 0.15s;
  margin-top: 1px;
}

.lib-delete-btn:hover {
  background: rgba(224, 83, 83, 0.12);
  color: #e05353;
}

.lib-item-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.lib-item-author {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 600;
}

.lib-item-lang {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.lib-item-summary {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.lib-item-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.lib-tag {
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--outline);
  color: var(--muted);
  font-weight: 600;
}

.lib-loading,
.lib-error,
.lib-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 56px 24px;
  text-align: center;
  color: var(--muted);
}

.lib-loading .posts-spinner {
  width: 28px;
  height: 28px;
}

.lib-empty h3 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}

.lib-empty p {
  margin: 0;
  font-size: 0.9rem;
  max-width: 320px;
}

/* ── Library card: action row ───────────────────────────────────────────────── */
.lib-card-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
}

.lib-open-btn {
  flex: 1;
  min-width: 0;
  padding: 9px 0;
  border-radius: 10px;
  border: 1.5px solid var(--primary);
  background: transparent;
  color: var(--primary);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.lib-open-btn:hover {
  background: var(--primary);
  color: #fff;
}

.lib-action-btn {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid var(--outline);
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-size: 0.82rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.lib-action-btn:hover {
  background: var(--outline);
  color: var(--text);
  border-color: var(--text);
}

.lib-action-btn--delete:hover {
  background: rgba(220, 20, 60, 0.08);
  border-color: #dc143c;
  color: #dc143c;
}

/* ── Library edit dialog ────────────────────────────────────────────────────── */
.lib-edit-dialog {
  width: min(460px, 92vw);
}

.lib-edit-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.lib-edit-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.lib-edit-label {
  font-size: 0.73rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.lib-edit-input,
.lib-edit-textarea {
  width: 100%;
  padding: 8px 11px;
  border: 1.5px solid var(--outline);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  box-sizing: border-box;
  transition: border-color 0.15s;
  resize: vertical;
}

.lib-edit-input:focus,
.lib-edit-textarea:focus {
  outline: none;
  border-color: var(--primary);
}

/* ── Library export dialog ──────────────────────────────────────────────────── */
.lib-export-options {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 6px 0 8px;
}

.lib-export-check {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text);
  user-select: none;
}

.lib-export-check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
  flex-shrink: 0;
}

/* ── Paragraphs view ────────────────────────────────────────────────────────── */
.paragraphs-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 24px;
  max-width: 720px;
  margin: 0 auto;
  width: 100%;
  box-sizing: border-box;
}

.paras-header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.paras-title-group {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: row;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.paras-section-label {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted);
}

.paras-back-btn {
  background: none;
  border: none;
  color: var(--text);
  font-family: inherit;
  font-size: 2rem;
  font-weight: 800;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: opacity 0.15s;
}

.paras-back-btn:hover {
  opacity: 0.7;
}

.paras-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.3;
  word-break: break-word;
  color: var(--muted);
}

.paras-count {
  font-size: 0.65rem;
  color: var(--muted);
  flex-shrink: 0;
}

.para-raw-btn--active {
  color: var(--primary) !important;
}

.para-tts-btn--active {
  color: #c0392b !important;
}

.paras-raw-all-btn {
  width: 100%;
  padding: 7px 12px;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  text-align: center;
}
.paras-raw-all-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.paras-raw-all-btn--active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.paras-raw-all-btn--active:hover {
  opacity: 0.88;
  color: #fff;
}
.para-raw-pre {
  margin: 0;
  font-family: ui-monospace, "Cascadia Code", "Fira Code", monospace;
  font-size: 0.82em;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
  line-height: 1.6;
}

.paras-merge-label {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--primary);
}

.paras-merge-hint {
  margin: 0;
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.45;
}

.paras-bm-actions-inner {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 12px;
  margin-top: 4px;
  border-top: 1px solid var(--outline);
}

.paras-merge-btn {
  width: 100%;
  padding: 9px 0;
  border-radius: 10px;
  border: none;
  background: var(--primary);
  color: #fff;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s;
}

.paras-merge-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.paras-merge-btn:not(:disabled):hover {
  opacity: 0.85;
}

.paras-merge-cancel {
  width: 100%;
  padding: 9px 0;
  border-radius: 10px;
  border: 1px solid var(--outline);
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.12s;
}

.paras-merge-cancel:hover {
  background: var(--outline);
}

.para-clip-dot {
  background: none;
  border: none;
  border-right: 1px solid var(--outline);
  padding: 14px 8px;
  flex-shrink: 0;
  cursor: pointer;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  color: var(--muted);
  font-size: 0.8rem;
  opacity: 0.25;
  transition: opacity 0.15s, color 0.15s, background 0.15s;
  width: 32px;
}

.para-clip-dot--active {
  opacity: 1;
  background: color-mix(in srgb, currentColor 8%, transparent);
}

.para-clip-dot:hover {
  opacity: 0.6;
  background: var(--outline);
}

.para-clip-dot--active:hover {
  opacity: 0.85;
}

.para-merge-check {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1.5px solid var(--outline);
  flex-shrink: 0;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  display: none;
  align-items: center;
  justify-content: center;
}

#paras-content.selection-mode .para-merge-check {
  display: flex;
}

/* ── Paragraph card context menu ─────────────────────────────────────────── */
.para-ctx-menu {
  position: fixed;
  z-index: 9999;
  background: var(--surface-strong);
  border: 1px solid var(--outline);
  border-radius: 10px;
  box-shadow: var(--shadow-md);
  padding: 4px;
  min-width: 130px;
}

.para-ctx-item {
  display: block;
  width: 100%;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px 14px;
  text-align: left;
  font-size: 0.875rem;
  color: var(--text);
  border-radius: 7px;
  transition: background 0.12s;
}

.para-ctx-item:hover {
  background: var(--outline);
}

.para-merge-check:hover {
  border-color: var(--primary);
}

.para-merge-check.checked {
  border-color: var(--primary);
  background: var(--primary);
}

.para-merge-check.checked::after {
  content: "✓";
  color: #fff;
  font-size: 0.65rem;
  font-weight: 900;
  line-height: 1;
}

.paras-content {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.para-card-item {
  background: var(--surface);
  border: 1px solid var(--outline);
  border-radius: 14px;
  padding: 0;
  display: flex;
  flex-direction: row;
  align-items: stretch;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
  overflow: hidden;
}

.para-card-body {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 18px 14px 14px;
}

.para-card-item:hover {
  border-color: var(--primary);
}

.para-card-item.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 20%, transparent);
}

.para-card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.para-serial {
  font-size: 0.6rem;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.para-indicators {
  display: flex;
  gap: 4px;
  margin-left: auto;
}

.para-indicator-icon {
  font-size: 0.7rem;
  line-height: 1;
}

.para-bookmark-dot {
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
  border: none;
  padding: 0;
  background: transparent;
  font-size: 13px;
  transition: transform 0.15s, opacity 0.15s;
}

.para-bookmark-dot:hover {
  transform: scale(1.25);
  opacity: 0.85;
}

/* ── Bookmark settings ── */
.bm-radio-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bm-radio-opt {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text);
  user-select: none;
}

.bm-radio-opt input[type="radio"] {
  accent-color: var(--primary);
  width: 16px;
  height: 16px;
  cursor: pointer;
  flex-shrink: 0;
}

/* ── Paragraph card — bookmark left bar (full-card mode) ── */
.para-bm-bar {
  width: 7px;
  align-self: stretch;
  flex-shrink: 0;
}

/* ── Bookmark picker style row ── */
.bm-card-style-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 0 4px;
  border-top: 1px solid var(--outline);
  margin-top: 8px;
}

/* ── Paragraph move confirmation dialog ── */
.para-move-dialog-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.para-move-serials {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
}

.para-move-serial {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--primary);
}

.para-move-swap-icon {
  color: var(--muted);
  font-size: 1.1rem;
}

.para-undo-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1.5px dashed var(--primary);
  background: transparent;
  color: var(--primary);
  font-size: 0.88rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
}

.para-undo-btn:hover {
  background: color-mix(in srgb, var(--primary) 10%, transparent);
}

/* ── Swap highlight (2 s glow on both cards after switch) ── */
@keyframes para-swap-glow {
  0%   {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 30%, transparent);
    background: color-mix(in srgb, var(--primary) 12%, var(--surface));
  }
  100% {
    border-color: var(--outline);
    box-shadow: none;
    background: var(--surface);
  }
}

.para-swap-highlight {
  animation: para-swap-glow 2s ease-out forwards;
}

.font-opt-1 { font-size: 0.72rem; font-weight: 700; }
.font-opt-2 { font-size: 0.85rem; font-weight: 700; }
.font-opt-3 { font-size: 1rem;    font-weight: 700; }
.font-opt-4 { font-size: 1.15rem; font-weight: 700; }
.font-opt-5 { font-size: 1.3rem;  font-weight: 700; }

.para-content {
  margin: 0;
  font-size: var(--para-font-size, 0.95rem);
  line-height: 1.65;
  color: var(--text);
}

/* Markdown elements inside paragraph cards */
.para-content > *:first-child { margin-top: 0; }
.para-content > *:last-child  { margin-bottom: 0; }
.para-content p  { margin: 0.35em 0; }
.para-content h1, .para-content h2, .para-content h3,
.para-content h4, .para-content h5, .para-content h6 {
  margin: 0.6em 0 0.25em;
  font-weight: 700;
  line-height: 1.3;
  color: var(--text);
}
.para-content h1 { font-size: 1.15em; }
.para-content h2 { font-size: 1.05em; }
.para-content h3, .para-content h4,
.para-content h5, .para-content h6 { font-size: 0.97em; }
.para-content ul, .para-content ol { margin: 0.4em 0; padding-left: 1.4em; }
.para-content li { margin: 0.15em 0; }
.para-content blockquote {
  margin: 0.5em 0;
  padding: 3px 12px;
  border-left: 3px solid var(--primary);
  color: var(--muted);
}
.para-content code {
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.85em;
  background: var(--surface-strong);
  padding: 1px 5px;
  border-radius: 4px;
}
.para-content pre {
  background: var(--surface-strong);
  padding: 10px 14px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 0.5em 0;
}
.para-content pre code { background: none; padding: 0; font-size: 0.82em; }
.para-content a { color: var(--primary); }
.para-content hr { border: none; border-top: 1px solid var(--outline); margin: 0.5em 0; }
.para-content table { border-collapse: collapse; width: 100%; margin: 0.5em 0; font-size: 0.88em; }
.para-content th, .para-content td { border: 1px solid var(--outline); padding: 4px 8px; text-align: left; }
.para-content th { background: var(--surface-strong); font-weight: 700; }

.para-note-preview {
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.4;
  color: var(--muted);
  font-style: italic;
  padding: 6px 10px;
  background: color-mix(in srgb, var(--primary) 8%, transparent);
  border-left: 2px solid var(--primary);
  border-radius: 4px;
}
.para-note-preview > *:first-child { margin-top: 0; }
.para-note-preview > *:last-child  { margin-bottom: 0; }
.para-note-preview p  { margin: 0.3em 0; }
.para-note-preview code {
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.85em;
  background: color-mix(in srgb, var(--primary) 12%, transparent);
  padding: 1px 4px;
  border-radius: 3px;
}
.para-note-preview strong { color: var(--text); }
.para-note-preview ul, .para-note-preview ol { margin: 0.3em 0; padding-left: 1.3em; }
.para-note-preview li { margin: 0.1em 0; }

.para-meta {
  display: flex;
  gap: 12px;
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 600;
}

/* ── Paragraph Inspector Panel ───────────────────────────────────────────── */
.inspector-close-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 0.85rem;
  padding: 2px 6px;
  border-radius: 6px;
  line-height: 1;
  margin-left: auto;
}

.inspector-close-btn:hover {
  background: var(--outline);
}

.inspector-actions {
  display: flex;
  gap: 8px;
}

.inspector-action-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 8px;
  border: 1px solid var(--outline);
  border-radius: 10px;
  background: var(--bg);
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.15s, background 0.15s;
}

.inspector-action-btn:hover {
  border-color: var(--primary);
}

.inspector-action-btn.inspector-action-active {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 12%, transparent);
}

.inspector-icon {
  font-size: 1.1rem;
  line-height: 1;
}

.inspector-action-label {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.inspector-edit-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.inspector-edit-input {
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid var(--outline);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 0.875rem;
  resize: vertical;
  box-sizing: border-box;
}

.inspector-edit-input:focus {
  outline: none;
  border-color: var(--primary);
}

.inspector-note-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.inspector-note-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.inspector-note-input {
  width: 100%;
  resize: vertical;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--outline);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 0.875rem;
  line-height: 1.5;
  box-sizing: border-box;
}

.inspector-note-input:focus {
  outline: none;
  border-color: var(--primary);
}

.inspector-edit-actions {
  display: flex;
  gap: 8px;
  align-self: flex-end;
}

.inspector-note-save-btn {
  padding: 7px 14px;
  border-radius: 8px;
  border: none;
  background: var(--primary);
  color: #fff;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}

.inspector-note-save-btn:hover {
  opacity: 0.85;
}

.inspector-split-btn {
  padding: 7px 14px;
  border-radius: 8px;
  border: 1.5px solid var(--primary);
  background: transparent;
  color: var(--primary);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.inspector-split-btn:hover {
  background: var(--primary);
  color: #fff;
}

.inspector-delete-section {
  margin-top: 4px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.inspector-duplicate-btn {
  width: 100%;
  padding: 7px 14px;
  border-radius: 8px;
  border: 1.5px solid var(--primary);
  background: transparent;
  color: var(--primary);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.inspector-duplicate-btn:hover {
  background: var(--primary);
  color: #fff;
}

.inspector-bookmark-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-bottom: 4px;
}

.bookmark-swatches {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 4px 0 8px;
}

.bookmark-swatch {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 2.5px solid transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 800;
  color: #fff;
  transition: transform 0.1s, border-color 0.15s, box-shadow 0.15s;
  outline: none;
  flex-shrink: 0;
}
.bookmark-swatch-clear { background: #AAAAAA; }
.bookmark-swatch[data-value="1"] { background: #dc143c; }
.bookmark-swatch[data-value="2"] { background: #008080; }
.bookmark-swatch[data-value="3"] { background: #4169e1; }
.bookmark-swatch[data-value="4"] { background: #FFa500; }
.bookmark-swatch:hover { transform: scale(1.12); }
.bookmark-swatch.active {
  border-color: var(--text);
  box-shadow: 0 0 0 2px var(--text);
  transform: scale(1.15);
}

.bookmark-filter-swatches {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

.bookmark-filter-btn {
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 6px;
  border: 2px solid transparent;
  cursor: pointer;
  position: relative;
  transition: opacity 0.15s, border-color 0.15s, box-shadow 0.15s;
  flex-shrink: 0;
}
.bookmark-filter-color[data-value="0"] { background: #AAAAAA; }
.bookmark-filter-color[data-value="1"] { background: #dc143c; }
.bookmark-filter-color[data-value="2"] { background: #008080; }
.bookmark-filter-color[data-value="3"] { background: #4169e1; }
.bookmark-filter-color[data-value="4"] { background: #FFa500; }

.bookmark-filter-btn:not(.active) { opacity: 0.5; }
.bookmark-filter-btn:hover { opacity: 0.85; }
.bookmark-filter-btn.active {
  opacity: 1;
  border-color: var(--text);
  box-shadow: 0 0 0 2px var(--text);
}
.bookmark-filter-color.active::after {
  content: "✓";
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  color: rgba(255, 255, 255, 0.95);
  font-size: 0.75rem;
  font-weight: 900;
  line-height: 1;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  pointer-events: none;
}

.inspector-delete-btn {
  width: 100%;
  padding: 7px 14px;
  border-radius: 8px;
  border: none;
  background: #e53e3e;
  color: #fff;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}

.inspector-delete-btn:hover {
  opacity: 0.85;
}

.para-delete-msg {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--muted);
}

.para-card-actions {
  display: flex;
  gap: 4px;
  padding-top: 6px;
  border-top: 1px solid var(--outline);
  margin-top: 6px;
}

.para-quick-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 3px 8px;
  font-size: 0.9rem;
  color: var(--muted);
  border-radius: 6px;
  line-height: 1;
  transition: color 0.12s, background 0.12s;
  flex-shrink: 0;
}

.para-quick-btn:hover {
  color: var(--primary);
  background: var(--outline);
}

.para-quick-btn--delete:hover {
  color: #dc143c;
  background: rgba(220, 20, 60, 0.08);
}

.para-move-group {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin-left: 6px;
}

.para-move-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 6px;
  font-size: 0.75rem;
  color: var(--muted);
  border-radius: 4px;
  line-height: 1;
  transition: color 0.12s, background 0.12s;
}

.para-move-btn:hover {
  color: var(--primary);
  background: var(--outline);
}

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

@keyframes para-slide-down {
  from { transform: translateY(-10px); opacity: 0.5; }
  to   { transform: translateY(0);     opacity: 1; }
}

.para-moved-up   { animation: para-slide-up   0.22s ease-out; }
.para-moved-down { animation: para-slide-down 0.22s ease-out; }

.paras-load-sentinel {
  height: 1px;
  pointer-events: none;
}

.paras-empty {
  padding: 56px 24px;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}

.paras-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 56px 24px;
  color: var(--muted);
  font-size: 0.9rem;
}

.paras-loading .posts-spinner {
  width: 28px;
  height: 28px;
}

/* ── Post Modal ──────────────────────────────────────────────────────────── */
.post-modal {
  position: fixed;
  inset: 0;
  margin: auto;
  width: min(440px, calc(100vw - 32px));
  max-height: 90vh;
  overflow-y: auto;
  border: 1px solid var(--outline);
  border-radius: 20px;
  background: var(--surface-strong);
  color: var(--text);
  padding: 0;
  box-shadow: var(--shadow);
}

.post-modal::backdrop {
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
}

.post-modal-inner {
  display: flex;
  flex-direction: column;
}

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

.post-modal-title-wrap {
  flex: 1;
  min-width: 0;
}

.post-modal-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.4;
}

.post-modal-author {
  margin: 4px 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.post-modal-close-btn {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}

.post-modal-close-btn:hover {
  background: var(--outline);
  color: var(--text);
}

.post-modal-body {
  padding: 16px 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.post-modal-summary {
  margin: 0;
  font-size: 0.875rem;
  color: var(--muted);
  line-height: 1.6;
}

.post-modal-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.post-modal-tag {
  font-size: 0.75rem;
  padding: 2px 10px;
  border-radius: 999px;
  border: 1px solid var(--outline);
  background: var(--bg);
  color: var(--muted);
}

.post-modal-tag-blue {
  border-color: #bfdbfe;
  background: #eff6ff;
  color: #1d4ed8;
}

[data-theme="dark"] .post-modal-tag-blue {
  border-color: #1e3a5f;
  background: #0f1f3d;
  color: #60a5fa;
}

.post-modal-cta {
  padding-top: 4px;
}

.post-modal-qr-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.post-modal-qr-label {
  font-size: 0.75rem;
  color: var(--muted);
  text-align: center;
  margin: 0;
}

.post-modal-qr-canvas-wrap {
  padding: 10px;
  background: #ffffff;
  border-radius: 12px;
  box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.08);
  display: inline-flex;
}

.post-modal-deep-link {
  font-size: 0.65rem;
  color: var(--muted);
  font-family: monospace;
  word-break: break-all;
  text-align: center;
  margin: 0;
  opacity: 0.7;
}

.post-modal-open-btn {
  display: block;
  width: 100%;
  text-align: center;
  padding: 12px;
  border-radius: 12px;
  background: var(--primary);
  color: #fff;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.875rem;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: opacity 0.15s;
}

.post-modal-open-btn:hover {
  opacity: 0.85;
}

.post-modal-ios-msg {
  text-align: center;
  padding: 12px;
  border-radius: 12px;
  background: var(--bg);
  color: var(--muted);
  font-size: 0.875rem;
}

.post-item {
  cursor: default;
}

/* ── Landing page ────────────────────────────────────────────────────────── */

.landing-body {
  min-height: 100vh;
  display: flex;
  align-items: stretch;
}

.landing-wrap {
  display: flex;
  flex: 1;
  min-height: 100vh;
}

/* Left panel — branding & features */
.landing-left {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 64px 56px;
  max-width: 560px;
}

.landing-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 40px;
}

.landing-logo {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  object-fit: cover;
}

.landing-brand-name {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
}

.landing-headline {
  margin: 0 0 16px;
  font-size: clamp(1.8rem, 3.5vw, 2.6rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.15;
  color: var(--text);
}

.landing-tagline {
  margin: 0 0 40px;
  font-size: 1.05rem;
  line-height: 1.65;
  color: var(--muted);
  max-width: 420px;
}

.landing-features {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.landing-feature {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.landing-feature-icon {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: rgba(28, 110, 140, 0.12);
  color: var(--primary);
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

[data-theme="dark"] .landing-feature-icon {
  background: rgba(89, 195, 195, 0.12);
}

.landing-feature div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.landing-feature strong {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
}

.landing-feature span {
  font-size: 0.875rem;
  color: var(--muted);
  line-height: 1.5;
}

/* Right panel — sign-in card */
.landing-right {
  flex-shrink: 0;
  width: min(420px, 45vw);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 32px;
  background: var(--surface);
  backdrop-filter: blur(14px);
  border-left: 1px solid var(--outline);
}

.landing-card {
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  gap: 0;
  animation: rise 0.55s ease-out;
}

.landing-card-title {
  margin: 0 0 6px;
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.landing-card-sub {
  margin: 0 0 28px;
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.5;
}

.landing-card-footer {
  margin: 16px 0 0;
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.5;
  text-align: center;
}

/* Responsive: stack vertically on narrow screens */
@media (max-width: 720px) {
  .landing-wrap {
    flex-direction: column;
  }
  .landing-left {
    max-width: 100%;
    padding: 48px 24px 32px;
  }
  .landing-right {
    width: 100%;
    border-left: none;
    border-top: 1px solid var(--outline);
    padding: 32px 24px 48px;
  }
}

/* ── AdSense ad containers ───────────────────────────────────────────────── */

.landing-ad-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px 0;
  min-width: 160px;
  max-width: 300px;
  align-self: center;
}

.posts-ad-wrap {
  width: min(980px, 100%);
  overflow: hidden;
}

.view-ad-wrap {
  width: 100%;
  overflow: hidden;
  margin-bottom: 12px;
}

.post-in-feed-ad {
  width: 100%;
  overflow: hidden;
  margin: 4px 0;
}

@media (max-width: 860px) {
  .landing-ad-wrap {
    display: none;
  }
}

/* ── AI Settings ─────────────────────────────────────────────────────────── */
.ai-key-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.ai-key-input {
  flex: 1;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--outline);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  transition: border-color 0.15s;
}

.ai-key-input:focus {
  outline: none;
  border-color: var(--primary);
}

.ai-key-status {
  margin: 4px 0 0;
  font-size: 0.8rem;
  font-weight: 600;
  min-height: 1.2em;
}

.ai-key-ok  { color: #2e7d52; }
.ai-key-err { color: #b53060; }

/* ── New library card highlight ──────────────────────────────────────────── */
@keyframes lib-card-new-fade {
  0%   { box-shadow: 0 0 0 3px var(--primary), var(--shadow); background: color-mix(in srgb, var(--primary) 14%, var(--surface)); }
  70%  { box-shadow: 0 0 0 3px var(--primary), var(--shadow); background: color-mix(in srgb, var(--primary) 14%, var(--surface)); }
  100% { box-shadow: var(--shadow); background: var(--surface); }
}

.lib-card-new {
  animation: lib-card-new-fade 5s ease-out forwards;
}

/* ── QR Scanner dialog ───────────────────────────────────────────────────── */
.qr-scan-dialog {
  width: min(420px, 96vw);
}

.qr-scan-drop {
  border: 2px dashed var(--outline);
  border-radius: 14px;
  padding: 32px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.18s, background 0.18s;
  margin: 4px 0 8px;
}

.qr-scan-drop.drag-over {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 8%, transparent);
}

.qr-scan-drop-icon {
  font-size: 2.2rem;
  color: var(--primary);
  display: block;
  margin-bottom: 10px;
}

.qr-scan-drop-label {
  margin: 0 0 4px;
  font-weight: 600;
  font-size: 0.95rem;
}

.qr-scan-drop-sub {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.qr-scan-preview {
  margin: 6px 0;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--outline);
  max-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-strong);
}

.qr-scan-img {
  max-width: 100%;
  max-height: 200px;
  display: block;
  object-fit: contain;
}

.qr-scan-status {
  min-height: 1.4em;
  font-size: 0.86rem;
  font-weight: 600;
  text-align: center;
  margin: 4px 0;
}

.qr-scan-status.ok  { color: #2e7d52; }
.qr-scan-status.err { color: #b53060; }

/* ── Library FAB (floating add button + speed-dial) ─────────────────────── */
.lib-fab-wrap {
  position: fixed;
  bottom: 28px;
  right: calc(280px + 28px);
  z-index: 150;
  width: 56px;
  height: 56px;
}

.lib-fab-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: var(--primary);
  color: #fff;
  font-size: 1.35rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(0,0,0,0.28);
  transition: transform 0.22s ease, box-shadow 0.2s;
  position: relative;
  z-index: 1;
}

.lib-fab-btn:hover {
  transform: scale(1.09);
  box-shadow: 0 6px 28px rgba(0,0,0,0.34);
}

.lib-fab-plus-icon {
  transition: transform 0.25s ease;
  display: block;
}

.lib-fab-btn[aria-expanded="true"] .lib-fab-plus-icon {
  transform: rotate(45deg);
}

.lib-fab-menu {
  position: absolute;
  bottom: calc(100% + 12px);
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  pointer-events: none;
  opacity: 0;
  transform: translateY(10px) scale(0.95);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.lib-fab-menu.open {
  pointer-events: all;
  opacity: 1;
  transform: translateY(0) scale(1);
}

.lib-fab-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--outline);
  border-radius: 28px;
  padding: 7px 16px 7px 10px;
  cursor: pointer;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text);
  box-shadow: 0 2px 10px rgba(0,0,0,0.13);
  white-space: nowrap;
  transition: background 0.15s, transform 0.15s;
  opacity: 0;
  transform: translateY(8px);
}

.lib-fab-menu.open .lib-fab-item {
  opacity: 1;
  transform: translateY(0);
}

.lib-fab-menu.open .lib-fab-item:nth-child(1) { transition: opacity 0.18s 0.04s ease, transform 0.18s 0.04s ease, background 0.15s; }
.lib-fab-menu.open .lib-fab-item:nth-child(2) { transition: opacity 0.18s 0.08s ease, transform 0.18s 0.08s ease, background 0.15s; }
.lib-fab-menu.open .lib-fab-item:nth-child(3) { transition: opacity 0.18s 0.12s ease, transform 0.18s 0.12s ease, background 0.15s; }
.lib-fab-menu.open .lib-fab-item:nth-child(4) { transition: opacity 0.18s 0.16s ease, transform 0.18s 0.16s ease, background 0.15s; }
.lib-fab-menu.open .lib-fab-item:nth-child(5) { transition: opacity 0.18s 0.20s ease, transform 0.18s 0.20s ease, background 0.15s; }

.lib-fab-item:hover {
  background: var(--surface-strong);
  transform: translateX(-3px);
}

.lib-fab-item-icon {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  flex-shrink: 0;
}

.lib-fab-item-label {
  flex: 1;
}

.lib-fab-overlay {
  position: fixed;
  inset: 0;
  z-index: 149;
}

.lib-fab-toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: var(--text);
  color: var(--surface);
  padding: 10px 22px;
  border-radius: 24px;
  font-size: 0.86rem;
  font-weight: 600;
  opacity: 0;
  transition: opacity 0.22s, transform 0.22s;
  z-index: 600;
  pointer-events: none;
  white-space: nowrap;
}

.lib-fab-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 1080px) {
  .lib-fab-wrap {
    right: 20px;
    bottom: 84px;
  }
}

@media (max-width: 680px) {
  .lib-fab-wrap {
    right: 14px;
    bottom: 84px;
  }
  .lib-fab-btn {
    width: 50px;
    height: 50px;
    font-size: 1.2rem;
  }
}


