/* ── 白天模式（默认）──────────────────────────────── */
:root {
  --bg: #f8f9fa;
  --panel: #ffffff;
  --panel-soft: #f1f4f5;
  --line: #dee3e6;
  --text: #2d3335;
  --muted: #7b8488;
  --accent: #006b62;
  --danger: #ff7b7b;
  --scrollbar-track: #e5e9eb;
  --scrollbar-thumb: #bcc4c7;
  --font-family-base: 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Noto Sans SC', sans-serif;
  --topbar-height: calc(70px + env(safe-area-inset-top, 0px));
}

/* ── 护眼模式 ─────────────────────────────────────── */
body.theme-warm {
  --bg: #f5ecd7;
  --panel: rgba(255, 255, 255, 0.6);
  --panel-soft: rgba(255, 255, 255, 0.8);
  --line: rgba(60, 60, 60, 0.18);
  --text: #1a1a1a;
  --muted: #888888;
  --accent: #88d6b5;
  --scrollbar-track: rgba(255, 255, 255, 0.65);
  --scrollbar-thumb: #cbb892;
}

/* ── 深色模式 ─────────────────────────────────────── */
body.theme-dark {
  --bg: #1a1a1a;
  --panel: #181c23;
  --panel-soft: #202733;
  --line: #2a3242;
  --text: #c8c8c8;
  --muted: #666666;
  --accent: #88d6b5;
  --scrollbar-track: #11151d;
  --scrollbar-thumb: #3a4354;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-family-base);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

body.font-serif {
  --font-family-base: 'Noto Serif SC', 'Songti SC', 'SimSun', serif;
}

body.font-sans {
  --font-family-base: 'PingFang SC', 'Microsoft YaHei', 'Noto Sans SC', sans-serif;
}

body.font-system {
  --font-family-base: system-ui, -apple-system, 'Segoe UI', sans-serif;
}

.splash-screen {
  position: fixed;
  inset: 0;
  z-index: 150;
  background: #f6f5f2;
  display: flex;
  align-items: stretch;
  justify-content: center;
  opacity: 1;
  visibility: visible;
  transition: opacity 260ms ease, visibility 260ms ease;
}

.splash-screen.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.splash-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

html:not(.reading-mode),
body:not(.reading-mode) {
  scrollbar-width: none;
}

html:not(.reading-mode)::-webkit-scrollbar,
body:not(.reading-mode)::-webkit-scrollbar {
  width: 0;
  height: 0;
}

html.reading-mode,
body.reading-mode {
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

body.reading-mode {
  overflow: hidden;
}

html.reading-mode::-webkit-scrollbar,
body.reading-mode::-webkit-scrollbar {
  width: 6px;
}

html.reading-mode::-webkit-scrollbar-track,
body.reading-mode::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
}

html.reading-mode::-webkit-scrollbar-thumb,
body.reading-mode::-webkit-scrollbar-thumb {
  background-color: var(--scrollbar-thumb);
  border-radius: 999px;
  border: 2px solid var(--scrollbar-track);
}

.app-shell {
  width: 100%;
  max-width: 620px;
  margin: 0 auto;
  padding: var(--topbar-height) 16px 88px;
  height: 100vh;
  position: relative;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
}

.login-overlay {
  position: fixed;
  inset: 0;
  background: rgba(12, 12, 12, 0.55);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 120;
}

.login-card {
  width: min(360px, 88vw);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 24px 22px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
}

.login-card h2 {
  margin: 0 0 6px;
  font-size: 20px;
}

.login-card p {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 14px;
}

.login-card input {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--line);
  padding: 10px 12px;
  font-size: 14px;
  background: #fff;
}

.login-card input + input {
  margin-top: 8px;
}

.login-card button {
  width: 100%;
  margin-top: 12px;
  border: none;
  border-radius: 12px;
  padding: 10px 12px;
  background: var(--text);
  color: var(--bg);
  font-size: 14px;
  cursor: pointer;
}

.login-error {
  margin-top: 10px;
  color: var(--danger);
  font-size: 13px;
  min-height: 18px;
}

.login-error:empty {
  display: none;
}

.me-section {
  margin-top: 12px;
  background: var(--panel);
  border: 1px solid rgba(173, 179, 181, 0.18);
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.me-section h2 {
  margin: 0 0 10px;
  font-size: 16px;
}

.me-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.me-section-head h2 {
  margin: 0;
}

.me-ghost-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 999px;
  cursor: pointer;
}

#tab-notes {
  max-width: 780px;
  margin: 0 auto;
  padding-bottom: 14px;
}

.me-profile-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  padding: 8px 0 2px;
}

.me-profile-avatar-wrap {
  position: relative;
}

.me-profile-avatar {
  width: 64px;
  height: 64px;
  border-radius: 999px;
  background: linear-gradient(145deg, #006b62, #005e56);
  color: #e2fff9;
  display: grid;
  place-items: center;
  font-size: 24px;
  font-weight: 800;
}

.me-profile-verified {
  position: absolute;
  right: -4px;
  bottom: -2px;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: #fff;
  color: #006b62;
  font-size: 10px;
  display: grid;
  place-items: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.16);
}

.me-profile-name {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.me-profile-invite-row {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: -2px;
}

.me-profile-invite-label {
  color: rgba(90, 96, 98, 0.85);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.me-profile-invite-row code {
  border-radius: 8px;
  background: #e5e9eb;
  color: #006b62;
  font-weight: 700;
  font-size: 11px;
  padding: 3px 7px;
}

.me-profile-logout {
  border: none;
  background: transparent;
  color: #a83836;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.me-card-head h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 800;
  border-left: 4px solid #006b62;
  padding-left: 10px;
}

.me-appearance-title {
  font-size: 10px;
  color: var(--muted);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-weight: 700;
}

.theme-choice,
.font-choice {
  border: 1px solid rgba(173, 179, 181, 0.2);
  background: #f1f4f5;
  color: #5a6062;
  border-radius: 10px;
  padding: 9px 8px;
  font-size: 12px;
  width: 100%;
  white-space: nowrap;
  cursor: pointer;
  font-weight: 600;
}

.theme-choice.is-active,
.font-choice.is-active {
  background: rgba(13, 148, 136, 0.12);
  color: #0f766e;
  border-color: rgba(0, 107, 98, 0.25);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.me-menu-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.me-menu-item {
  background: var(--panel);
  border: 1px solid rgba(173, 179, 181, 0.18);
  border-radius: 14px;
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: background-color 0.15s ease, transform 0.15s ease;
}

.me-menu-item:active {
  transform: scale(0.99);
}

.me-menu-item:hover {
  background: rgba(13, 148, 136, 0.06);
}

.me-menu-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-size: 19px;
}

.me-menu-icon.export {
  background: #b6e7fe;
  color: #235669;
}

.me-menu-icon.feedback {
  background: #cce8e3;
  color: #3d5653;
}

.me-menu-icon.admin {
  background: #e5e9eb;
  color: #006b62;
}

.me-menu-text {
  flex: 1;
  min-width: 0;
}

.me-menu-text h4 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
}

.me-menu-text p {
  margin: 3px 0 0;
  font-size: 11px;
  color: #5a6062;
  line-height: 1.2;
}

.me-menu-arrow {
  font-size: 22px;
  color: #9ca3af;
}

.me-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
  cursor: pointer;
}

.me-item:first-of-type {
  border-top: none;
  padding-top: 0;
}

.me-item span {
  color: var(--muted);
}

.me-value {
  font-weight: 600;
  color: var(--text);
}

.me-panel {
  display: flex;
  flex-direction: column;
  height: 85vh;
  background: var(--panel);
  border-radius: 16px 16px 0 0;
  padding: 16px;
  overflow: hidden;
}

.me-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.me-panel-body {
  flex: 1;
  overflow-y: auto;
  display: grid;
  gap: 12px;
}

.me-stat-block {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  background: var(--panel-soft);
  display: grid;
  gap: 8px;
}

.me-stat-block h3 {
  margin: 0;
  font-size: 14px;
}

.me-stat-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
}

.me-stat-line span {
  color: var(--muted);
}

.app-version {
  margin: 16px 0 8px;
  text-align: center;
  font-size: 10px;
  color: rgba(118, 124, 126, 0.75);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 700;
}

.admin-console {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.admin-console-head {
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0 6px;
}

.admin-console-head h2 {
  margin: 0;
  font-size: 18px;
}

.admin-console-body {
  display: grid;
  gap: 18px;
}

.admin-block {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
}

.admin-block h3 {
  margin: 0 0 12px;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
}

.admin-block h3::after {
  content: '▾';
  font-size: 12px;
  color: var(--muted);
  transition: transform 0.18s ease;
}

.admin-block.is-collapsed h3 {
  margin-bottom: 0;
}

.admin-block.is-collapsed h3::after {
  transform: rotate(-90deg);
}

.admin-block.is-collapsed > :not(h3) {
  display: none;
}

.admin-list {
  display: grid;
  gap: 10px;
}

.admin-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  background: var(--panel-soft);
}

.admin-item-actions {
  margin-top: 8px;
  display: flex;
  justify-content: flex-end;
}

.admin-item-actions button {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
}

.admin-item-actions button.danger {
  border-color: rgba(255, 123, 123, 0.5);
  color: var(--danger);
}

.admin-item-meta {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.admin-invite-form {
  margin-top: 12px;
  display: grid;
  gap: 8px;
}

.admin-invite-form input {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 14px;
}

.admin-invite-form button {
  border: none;
  border-radius: 12px;
  padding: 10px 12px;
  background: var(--text);
  color: var(--bg);
  cursor: pointer;
}

.me-feedback-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  background: var(--panel-soft);
}

.me-feedback-meta {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

.feedback-input {
  flex: 1;
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--line);
  padding: 10px 12px;
  font-size: 14px;
  resize: none;
  background: #fff;
  min-height: 140px;
}

.feedback-submit {
  margin-top: 12px;
  border: none;
  border-radius: 12px;
  padding: 10px 12px;
  background: var(--text);
  color: var(--bg);
  font-size: 14px;
  cursor: pointer;
}

.ingest-input {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--line);
  padding: 10px 12px;
  font-size: 14px;
  background: #fff;
}

.ingest-note {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}

.ingest-submit {
  margin-top: 12px;
  border: none;
  border-radius: 12px;
  padding: 10px 12px;
  background: var(--text);
  color: var(--bg);
  font-size: 14px;
  cursor: pointer;
}

.ingest-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.topbar {
  position: fixed;
  left: 0;
  right: 0;
  top: 0;
  z-index: 30;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background: var(--bg);
  box-shadow: 0 1px 6px rgba(22, 41, 47, 0.08);
  padding: calc(10px + env(safe-area-inset-top, 0px)) 18px 10px;
  transform: translateZ(0);
  will-change: transform;
}

.topbar-title {
  display: flex;
  flex-direction: column;
}

.topbar h1 {
  margin: 0;
  color: #0f766e;
  font-size: 22px;
  line-height: 1;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.topbar p {
  margin: 5px 0 0;
  color: rgba(13, 148, 136, 0.62);
  font-size: 9px;
  letter-spacing: 0.11em;
  font-weight: 700;
}

.icon-btn {
  border: 1px solid transparent;
  background: transparent;
  color: #64748b;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background-color 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.icon-btn:active {
  transform: scale(0.96);
}

#ingestToggle.icon-btn {
  color: #0d9488;
}

.icon-btn:hover {
  background: rgba(100, 116, 139, 0.12);
}

body.theme-dark .topbar {
  background: var(--bg);
  box-shadow: none;
}

body.theme-dark .topbar h1 {
  color: #a7f3d0;
}

body.theme-dark .topbar p {
  color: rgba(167, 243, 208, 0.62);
}

.me-theme-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.me-appearance-group + .me-appearance-group {
  margin-top: 12px;
}

.icon-btn svg {
  width: 20px;
  height: 20px;
}

.filter-panel {
  position: absolute;
  right: 14px;
  top: 78px;
  width: min(320px, calc(100vw - 28px));
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  display: grid;
  gap: 12px;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.35);
  z-index: 20;
}

.filter-panel label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

.filter-panel select {
  width: 100%;
  padding: 8px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel-soft);
  color: var(--text);
}

.state-text {
  color: var(--muted);
  margin: 8px 4px 10px;
  font-size: 13px;
}

.articles-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 10px;
  max-width: 100%;
}

.article-card {
  background: var(--panel);
  border: 1px solid rgba(222, 227, 230, 0.75);
  border-radius: 14px;
  padding: 14px;
  cursor: pointer;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.03);
  max-width: 100%;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

.article-card-top {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: space-between;
  margin-bottom: 8px;
}

.article-author {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.article-avatar {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  object-fit: cover;
}

.article-author-text {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  min-width: 0;
}

.article-author-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.article-reading-time {
  color: rgba(90, 96, 98, 0.75);
  font-size: 12px;
  white-space: nowrap;
}

.article-badge {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(13, 148, 136, 0.12);
  color: #0f766e;
  border: 1px solid rgba(13, 148, 136, 0.25);
  white-space: nowrap;
}

.article-card-status {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-shrink: 0;
}

.article-progress {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.article-progress.is-read {
  color: rgba(118, 124, 126, 0.55);
}

.article-progress.is-unread {
  color: #0d9488;
}

.article-progress.is-translating {
  color: rgba(118, 124, 126, 0.85);
}

.article-body {
  margin-bottom: 8px;
}

.article-title {
  margin: 0 0 6px;
  line-height: 1.25;
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  font-synthesis: weight;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.article-summary {
  font-size: 14px;
  line-height: 1.6;
  color: rgba(90, 96, 98, 0.92);
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}

.article-summary.summary-long {
  -webkit-line-clamp: 4;
}

.article-bottom {
  display: none;
}

.article-topic {
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.article-dot {
  width: 3px;
  height: 3px;
  border-radius: 999px;
  background: rgba(118, 124, 126, 0.55);
}

.article-date {
  color: rgba(90, 96, 98, 0.75);
  font-size: 11px;
  font-weight: 500;
}

.article-card.is-disabled {
  cursor: default;
  opacity: 0.78;
}

.article-card.is-recommend {
  background: #f6f8f9;
}

.article-card.is-recommend .article-title,
.article-card.is-recommend .article-summary,
.article-card.is-recommend .article-progress,
.article-card.is-recommend .article-reading-time,
.article-card.is-recommend .article-date {
  color: var(--muted);
}

.notes-placeholder {
  border: 1px dashed var(--line);
  border-radius: 14px;
  padding: 22px;
  background: var(--panel);
}

.reader {
  margin-top: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
}

.reader-loading {
  color: var(--muted);
  font-size: 14px;
}

.reader-skeleton {
  display: grid;
  gap: 10px;
}

.skeleton-line {
  height: 12px;
  border-radius: 8px;
  background: var(--panel-soft);
  position: relative;
  overflow: hidden;
}

.skeleton-line::after {
  content: '';
  position: absolute;
  top: 0;
  left: -40%;
  width: 40%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.45), transparent);
  animation: skeleton-shimmer 1.2s ease-in-out infinite;
}

.skeleton-line.w-70 { width: 70%; }
.skeleton-line.w-90 { width: 90%; }
.skeleton-line.w-60 { width: 60%; }

@keyframes skeleton-shimmer {
  0% { left: -40%; }
  100% { left: 100%; }
}

.reader-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  position: sticky;
  top: 0;
  background: var(--bg);
  padding: 6px 0;
  z-index: 5;
}

/* Right-side button group (highlights + appearance) */
.reader-header-right {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

.reader-header button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--text);
  padding: 7px 11px;
  cursor: pointer;
}

.back-btn {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  padding: 0;
  font-size: 18px;
  display: grid;
  place-items: center;
}

/* Icon-only buttons in the header right group */
.header-icon-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 999px;
  display: grid;
  place-items: center;
}

#shareArticleBtn {
  color: #6f7f9b;
}

#backBtn,
#shareArticleBtn,
#readerAppearanceBtn,
#articleNotesBtn {
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}

#backBtn {
  color: #119f92;
}

#readerAppearanceBtn {
  color: #6f7f9b;
}

#articleNotesBtn {
  color: #6f7f9b;
}

.reference-banner {
  margin: 8px 0 16px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.reference-banner-text {
  font-size: 14px;
  color: var(--text);
}

.reference-banner-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.reference-banner-actions button {
  border: 1px solid var(--line);
  background: var(--panel-soft);
  color: var(--text);
  padding: 6px 10px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 12px;
}

.reader-content {
  line-height: 2;
  font-size: 18px;
  word-break: break-word;
  user-select: text;
  -webkit-user-select: text;
  -webkit-touch-callout: none;
  touch-action: pan-y;
  padding: 0 8px;
}


/* Divider between Chinese translation and English original */
.reader-original-label {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 32px 0 20px;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.05em;
}

.reader-original-label::before,
.reader-original-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line);
}

.reader-content p {
  margin: 0 0 1.5em;
}

.reader-content h1,
.reader-content h2,
.reader-content h3,
.reader-content h4 {
  margin: 1.6em 0 0.7em;
  line-height: 1.35;
  font-weight: 700;
}

.reader-content h1 { font-size: 1.45em; }
.reader-content h2 { font-size: 1.32em; }
.reader-content h3 { font-size: 1.2em; }
.reader-content h4 { font-size: 1.1em; }

.reader-content ul,
.reader-content ol {
  margin: 0.5em 0 1.3em 1.25em;
  padding: 0;
}

.reader-content li {
  margin: 0.3em 0;
}

.reader-content blockquote {
  margin: 0.8em 0 1.3em;
  padding: 0.2em 0 0.2em 0.9em;
  border-left: 3px solid var(--line);
  color: var(--muted);
}

.reader-content blockquote p {
  margin: 0.5em 0;
}

.reader-content pre,
.reader-content code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.reader-content pre {
  margin: 0.8em 0 1.3em;
  padding: 0.75em 0.9em;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel-soft);
  overflow-x: auto;
  line-height: 1.7;
}

.reader-content p code,
.reader-content li code,
.reader-content blockquote code {
  padding: 0.05em 0.35em;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--panel-soft);
  font-size: 0.92em;
}

.reader-content hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 1.6em 0;
}

.reader-content a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.reader-content img,
.reader-content .md-image {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  margin: 0.8em 0 1.4em;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel-soft);
}

.notes-section {
  margin-bottom: 20px;
}

.notes-section h2 {
  margin: 0 0 12px;
  font-size: 18px;
}

.notes-list,
.reading-list {
  display: grid;
  gap: 12px;
}

.notes-article {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  padding: 12px;
}

.notes-article h3 {
  margin: 0 0 8px;
  font-size: 16px;
}

.note-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--panel-soft);
  cursor: pointer;
  font-size: 14px;
  line-height: 1.6;
}

.note-item:last-child {
  margin-bottom: 0;
}

/* Icon bubble on the left of each highlight card */
.note-item-icon {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: rgba(255, 193, 80, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(160, 110, 10, 0.85);
}

/* Text content — max 3 lines then ellipsis */
.note-item-text {
  flex: 1;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
}

.reading-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  padding: 10px 12px;
}

.reading-item h4 {
  margin: 0 0 6px;
  font-size: 15px;
}

.reading-item p {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

.notes-panel {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg);
  z-index: 65;
  display: flex;
  flex-direction: column;
}

.notes-panel-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  flex-shrink: 0;
}

.notes-panel-head strong {
  flex: 1;
  font-size: 16px;
}

.notes-panel-head .back-btn {
  border: 1px solid var(--line);
  background: var(--panel-soft);
  color: var(--text);
}

.notes-panel-body {
  padding: 16px;
  overflow: auto;
  flex: 1;
  display: grid;
  gap: 10px;
  align-content: start;
}

.translated-paragraph {
  position: relative;
  padding-right: 36px;
  margin: 0 0 16px;
}

.origin-btn {
  position: absolute;
  right: 0;
  top: 2px;
  border: 1px solid var(--line);
  background: var(--panel-soft);
  color: var(--muted);
  border-radius: 99px;
  width: 26px;
  height: 26px;
  font-size: 12px;
  cursor: pointer;
}

.origin-btn:hover {
  color: var(--text);
  border-color: var(--accent);
}

.long-press-menu {
  position: fixed;
  z-index: 30;
  min-width: 150px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}

.long-press-menu button {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  padding: 10px 12px;
  cursor: pointer;
}

.long-press-menu button:hover {
  background: var(--panel-soft);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 86px;
  transform: translateX(-50%);
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
}

.origin-snippet {
  position: fixed;
  z-index: 40;
  left: 50%;
  transform: translateX(-50%);
  bottom: 68px;
  width: min(90vw, 760px);
  max-height: 46vh;
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
}

.origin-snippet-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.origin-snippet-head button {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  border-radius: 8px;
  padding: 4px 8px;
  cursor: pointer;
}

.origin-snippet pre {
  margin: 0;
  white-space: pre-wrap;
  line-height: 1.7;
  color: var(--text);
}

.qa-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.15);
  display: grid;
  align-items: end;
  z-index: 60;
}

#feedbackModal,
#adminFeedbackModal,
#hideArticleModal {
  background: var(--bg);
}

#ingestModal {
  background: var(--bg);
}

#appearanceModal {
  background: var(--bg);
}

.appearance-panel .me-panel-head button {
  border: 0;
  background: transparent;
  color: var(--text);
  border-radius: 10px;
  width: 34px;
  height: 34px;
  cursor: pointer;
}

.appearance-panel .me-panel-body {
  align-content: start;
}

.appearance-panel .me-section {
  margin-top: 0;
}

.qa-sheet {
  width: 100%;
  max-width: 840px;
  margin: 0 auto;
  background: #ffffff;
  border: 1px solid #e7e7e7;
  border-radius: 18px 18px 0 0;
  padding: 14px 14px 12px;
  height: 85vh;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 -20px 40px rgba(0, 0, 0, 0.35);
}

.qa-sheet-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
}

.qa-sheet-head button {
  border: 0;
  background: transparent;
  color: #1a1a1a;
  border-radius: 10px;
  width: 34px;
  height: 34px;
  cursor: pointer;
  position: absolute;
  right: 0;
  top: 0;
}

.qa-sheet-head strong {
  margin: 0 auto;
  font-size: 16px;
  color: #1a1a1a;
}

.qa-chat-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 8px 2px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: flex-start;
}

.qa-bubble {
  max-width: 80%;
  padding: 8px 12px;
  border-radius: 18px;
  border: 0;
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
  height: auto;
}

.qa-bubble.user {
  align-self: flex-end;
  background: #3c3c3c;
  color: #ffffff;
}

.qa-bubble.ai {
  align-self: flex-start;
  background: #f5f5f5;
  color: #1a1a1a;
}

.qa-bubble.thinking::after {
  content: '...';
  display: inline-block;
  margin-left: 4px;
  animation: qaDots 1.2s infinite;
}

@keyframes qaDots {
  0% {
    opacity: 0.2;
  }
  50% {
    opacity: 0.9;
  }
  100% {
    opacity: 0.2;
  }
}

.qa-input-bar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

#qaQuestionInput {
  width: 100%;
  min-height: 40px;
  height: 40px;
  border-radius: 16px;
  border: 1px solid #e5e5e5;
  background: #ffffff;
  color: #1a1a1a;
  /* 9px vertical padding centers a single line of ~16px text within 40px total height */
  padding: 9px 14px;
  resize: none;
  overflow: hidden;
  line-height: 1.4;
}

#qaQuestionInput:focus {
  outline: none;
  border-color: #3c3c3c;
}

.qa-input-bar button {
  border: 0;
  background: #3c3c3c;
  color: #ffffff;
  height: 40px;
  padding: 0 18px;
  border-radius: 24px;
  cursor: pointer;
  align-self: end;
  flex-shrink: 0;
}

.qa-error {
  color: var(--danger);
  font-size: 12px;
  min-height: 16px;
}

.selection-menu {
  position: absolute;
  z-index: 50;
  background: #2c2c2c;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
  display: flex;
  gap: 4px;
  padding: 8px 6px;
  align-items: stretch;
}

.selection-menu button {
  border: 0;
  background: transparent;
  color: #ffffff;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 12px;
  display: grid;
  grid-template-rows: 24px 16px;
  align-items: center;
  justify-items: center;
  row-gap: 6px;
  min-height: 54px;
  text-align: center;
  white-space: nowrap;
}

.selection-menu button:hover {
  background: rgba(255, 255, 255, 0.08);
}

.selection-menu svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  display: block;
}

.selection-menu .btn-label {
  line-height: 16px;
  display: block;
}

/* 细线图标用缩放补视觉体积，但不改变占位尺寸，避免破坏对齐 */
.selection-menu button[data-action="highlight"] svg,
.selection-menu button[data-action="remove-highlight"] svg,
.selection-menu button[data-action="reference"] svg {
  transform: scale(1.18);
  transform-origin: center;
}

.selection-menu::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -8px;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-top: 8px solid #2c2c2c;
}

/* When menu is positioned below the selection, arrow points upward */
.selection-menu.menu-below::after {
  top: -8px;
  bottom: auto;
  border-top: none;
  border-bottom: 8px solid #2c2c2c;
}

::selection {
  background: rgba(255, 180, 60, 0.4);
}

::-webkit-selection {
  background: rgba(255, 180, 60, 0.4);
}

.highlight-mark {
  background: rgba(255, 193, 80, 0.35);
  box-shadow: 0 0 0 2px rgba(255, 193, 80, 0.2);
  border-radius: 4px;
  padding: 4px 0;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

.highlight-mark-other {
  background: transparent;
  border-bottom: 2px dashed rgba(255, 193, 80, 0.9);
  border-radius: 0;
  padding: 0;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

.hidden {
  display: none !important;
}

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: flex;
  justify-content: space-between;
  gap: 0;
  padding: 8px 22px calc(env(safe-area-inset-bottom, 12px) + 2px);
  border-top-left-radius: 18px;
  border-top-right-radius: 18px;
  box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.04);
  z-index: 25;
  transform: translateZ(0);
  will-change: transform;
}

.bottom-nav .tab-btn {
  border: 0;
  background: transparent;
  color: #94a3b8;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  cursor: pointer;
  border-radius: 12px;
  padding: 6px 4px;
  transition: transform 0.18s ease, color 0.18s ease, background-color 0.18s ease;
}

.bottom-nav .tab-btn:active {
  transform: scale(0.98);
}

.bottom-nav .tab-icon {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
}

.bottom-nav svg {
  width: 22px;
  height: 22px;
}

.bottom-nav .tab-btn.is-active {
  color: #0f766e;
  background: rgba(13, 148, 136, 0.1);
}

body.theme-dark .bottom-nav {
  background: rgba(24, 28, 35, 0.92);
}

/* Theme toggle in topbar — icon-btn provides border/bg/size */
.theme-toggle {
  padding: 0;
  font-size: 16px;
}

/* Button group on the right of the topbar */
.topbar-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

.reading-mode .topbar,
.reading-mode .filter-panel,
.reading-mode .bottom-nav {
  display: none !important;
}

.admin-mode .topbar,
.admin-mode .filter-panel,
.admin-mode .bottom-nav {
  display: none !important;
}

.reading-mode .reader {
  position: fixed;
  inset: 0;
  margin: 0;
  border: 0;
  border-radius: 0;
  background: var(--bg);
  padding: 0 14px max(env(safe-area-inset-bottom, 0px), 12px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: auto;
  touch-action: pan-y pinch-zoom;
  contain: none;
}

.reading-mode .reader-header {
  margin-bottom: 8px;
}

.reading-mode .reader-header p {
  display: none;
}

.reader-bar-hidden .reader-header {
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
}

.reader-bar-hidden .reader-header + * {
  margin-top: 0;
}

.restoring-list-scroll #tab-today,
.restoring-list-scroll #tab-notes {
  visibility: hidden;
}

.custom-selection .reader-content {
  -webkit-touch-callout: none;
  -webkit-user-select: text;
  user-select: text;
  touch-action: pan-y pinch-zoom;
}

.no-custom-selection .reader-content {
  -webkit-touch-callout: default;
}

/* Perf diagnostics toggles (query params): keep default UX unchanged. */
body.perf-no-glass .login-overlay {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

body.perf-no-glass .bottom-nav {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  background: #ffffff !important;
}

body.perf-no-reader-contain.reading-mode .reader {
  contain: none !important;
}

body.perf-no-reader-sticky.reading-mode .reader-header {
  position: static !important;
}

body.perf-no-layer-promote .topbar,
body.perf-no-layer-promote .bottom-nav {
  transform: none !important;
  will-change: auto !important;
}

.perf-overlay {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 8px);
  right: 8px;
  z-index: 220;
  min-width: 170px;
  border-radius: 10px;
  padding: 8px 10px;
  background: rgba(16, 24, 32, 0.9);
  color: #d1d5db;
  font-size: 11px;
  line-height: 1.25;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.28);
  pointer-events: none;
}

.perf-overlay-title {
  font-weight: 700;
  color: #f3f4f6;
  margin-bottom: 6px;
}

.perf-overlay-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  column-gap: 10px;
  row-gap: 4px;
}

.perf-overlay-grid strong {
  color: #5eead4;
  font-weight: 700;
}

@media (max-width: 720px) {
  .filter-panel {
    top: 70px;
  }

  .reader-content {
    font-size: 17px;
  }
}
