:root {
  --bg-app: #141414;
  --bg-sidebar: #1c1c1c;
  --bg-surface: #1e1e1e;
  --bg-hover: #282828;
  --bg-active: #2c2c2c;
  --bg-input: #121212;
  --border: #2c2c2c;
  --border-subtle: #242424;
  --text-primary: #efefef;
  --text-secondary: #a1a1aa;
  --text-muted: #71717a;
  --accent: #2bb24c;
  --accent-hover: #249b41;
  --accent-soft: rgba(43, 178, 76, 0.14);
  --danger: #ef4444;
  --warning: #f59e0b;
  --info: #3b82f6;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-reader: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-si: 'Noto Sans Sinhala', 'Iskoola Pota', 'Nirmala UI', var(--font-sans);
  --reader-font-size: 17px;
  --density-pad: 14px;
}

html[data-theme="oled"] {
  --bg-app: #000000;
  --bg-sidebar: #090909;
  --bg-surface: #0e0e0e;
  --bg-hover: #181818;
  --bg-active: #1f1f1f;
  --bg-input: #050505;
  --border: #1e1e1e;
}

html[data-theme="light"] {
  --bg-app: #ffffff;
  --bg-sidebar: #f6f7f8;
  --bg-surface: #ffffff;
  --bg-hover: #eceef0;
  --bg-active: #e4e7ea;
  --bg-input: #f1f3f5;
  --border: #e2e5e9;
  --border-subtle: #edf0f3;
  --text-primary: #18181b;
  --text-secondary: #52525b;
  --text-muted: #71717a;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; background: var(--bg-app); color: var(--text-primary); font-family: var(--font-sans); -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: inherit; color: inherit; }

.sinhala-text { font-family: var(--font-si); line-height: 1.75; }
.hidden { display: none !important; }
.muted { color: var(--text-muted); }

.app-shell { display: flex; height: 100vh; overflow: hidden; }

/* Sidebar */
.sidebar {
  width: 264px;
  min-width: 264px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: width 0.18s ease, min-width 0.18s ease;
  z-index: 20;
}
.sidebar.collapsed { width: 0; min-width: 0; overflow: hidden; border-right: none; }

.sidebar-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 12px 8px; gap: 6px; }
.profile-btn { display: flex; align-items: center; gap: 8px; background: transparent; border: none; padding: 6px 8px; border-radius: 6px; cursor: pointer; flex: 1; min-width: 0; text-align: left; }
.profile-btn:hover { background: var(--bg-hover); }
.avatar-circle { width: 24px; height: 24px; border-radius: 50%; background: linear-gradient(135deg, #2bb24c, #15803d); color: #fff; font-weight: 700; font-size: 12px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.profile-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 4px 10px 14px; }
.sidebar-nav::-webkit-scrollbar { width: 5px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-divider { height: 1px; background: var(--border); margin: 10px 6px; }
.nav-section-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 10px 6px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); }

.nav-item { display: flex; align-items: center; gap: 10px; width: 100%; background: transparent; border: none; border-radius: 6px; padding: 7px 10px; font-size: 13.5px; color: var(--text-secondary); cursor: pointer; text-align: left; transition: background 0.12s, color 0.12s; }
.nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-item.active { background: var(--bg-active); color: var(--text-primary); font-weight: 600; }
.nav-item span:first-of-type { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.badge-count { font-size: 11px; color: var(--text-muted); font-weight: 500; padding: 1px 6px; border-radius: 10px; }
.badge-count.has-unread { color: var(--text-primary); }
.kbd-hint { font-size: 10px; color: var(--text-muted); border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px; }

.folder-block { display: flex; flex-direction: column; }
.folder-row { display: flex; align-items: center; gap: 4px; border-radius: 6px; }
.folder-row:hover { background: var(--bg-hover); }
.folder-row.active { background: var(--bg-active); }
.folder-chevron { background: transparent; border: none; color: var(--text-muted); padding: 6px 4px 6px 8px; cursor: pointer; display: flex; align-items: center; }
.folder-chevron svg { transition: transform 0.15s; }
.folder-chevron.expanded svg { transform: rotate(90deg); }
.folder-label { flex: 1; background: transparent; border: none; text-align: left; padding: 6px 8px 6px 2px; font-size: 13.5px; color: var(--text-secondary); cursor: pointer; display: flex; align-items: center; justify-content: space-between; min-width: 0; }
.folder-row.active .folder-label { color: var(--text-primary); font-weight: 600; }
.folder-feeds { padding-left: 18px; display: flex; flex-direction: column; gap: 1px; margin-bottom: 4px; }
.feed-item { display: flex; align-items: center; gap: 8px; background: transparent; border: none; border-radius: 6px; padding: 5px 8px; font-size: 13px; color: var(--text-secondary); cursor: pointer; text-align: left; width: 100%; }
.feed-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.feed-item.active { background: var(--bg-active); color: var(--text-primary); font-weight: 600; }
.feed-favicon { width: 15px; height: 15px; border-radius: 3px; flex-shrink: 0; object-fit: cover; background: var(--bg-hover); }
.feed-title { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.web-tag { font-size: 9px; font-weight: 700; letter-spacing: 0.04em; color: var(--info); background: rgba(59, 130, 246, 0.14); padding: 1px 5px; border-radius: 3px; }
.video-tag { font-size: 9px; font-weight: 700; letter-spacing: 0.04em; color: #f59e0b; background: rgba(245, 158, 11, 0.16); padding: 1px 5px; border-radius: 3px; }

.sidebar-footer { border-top: 1px solid var(--border); padding: 8px 10px 10px; display: flex; flex-direction: column; gap: 2px; }

/* Icons & Buttons */
.icon-sm { width: 16px; height: 16px; flex-shrink: 0; }
.icon-md { width: 20px; height: 20px; flex-shrink: 0; }
.icon-btn { background: transparent; border: 1px solid transparent; border-radius: 6px; padding: 6px; color: var(--text-secondary); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.icon-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.icon-btn.active { color: var(--accent); background: var(--accent-soft); }
.mini-icon-btn { background: transparent; border: none; color: var(--text-muted); cursor: pointer; font-size: 15px; line-height: 1; padding: 2px 5px; border-radius: 4px; }
.mini-icon-btn:hover { background: var(--bg-hover); color: var(--text-primary); }

.btn-green, .btn-green-sm { background: var(--accent); color: #ffffff; border: none; border-radius: 6px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.btn-green { padding: 9px 16px; font-size: 13.5px; }
.btn-green-sm { padding: 6px 11px; font-size: 12.5px; }
.btn-green:hover, .btn-green-sm:hover { background: var(--accent-hover); }

.btn-outline, .btn-outline-sm { background: transparent; color: var(--text-secondary); border: 1px solid var(--border); border-radius: 6px; font-weight: 500; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.btn-outline { padding: 8px 14px; font-size: 13.5px; }
.btn-outline-sm { padding: 5px 10px; font-size: 12px; }
.btn-outline:hover, .btn-outline-sm:hover { background: var(--bg-hover); color: var(--text-primary); }
.btn-danger-sm { background: rgba(239, 68, 68, 0.14); color: var(--danger); border: 1px solid rgba(239, 68, 68, 0.3); border-radius: 6px; padding: 5px 10px; font-size: 12px; cursor: pointer; }

/* Main Area & Topbar */
.main-area { flex: 1; display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.topbar { height: 52px; border-bottom: 1px solid var(--border-subtle); display: flex; align-items: center; justify-content: space-between; padding: 0 20px; gap: 12px; flex-shrink: 0; }
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 10px; }
.pro-pill { background: var(--accent); color: #fff; font-size: 10px; font-weight: 700; letter-spacing: 0.06em; padding: 2px 7px; border-radius: 4px; }
.domain-tag { font-size: 12.5px; color: var(--text-muted); font-weight: 500; }

.translation-bar { display: flex; align-items: center; gap: 8px; background: var(--bg-surface); border: 1px solid var(--border); border-radius: 8px; padding: 3px 8px; }
.trans-label { font-size: 12px; color: var(--text-secondary); font-weight: 500; }
.seg-group { display: inline-flex; background: var(--bg-input); border: 1px solid var(--border); border-radius: 6px; padding: 2px; gap: 2px; }
.seg-btn { background: transparent; border: none; color: var(--text-secondary); font-size: 12px; font-weight: 500; padding: 4px 9px; border-radius: 4px; cursor: pointer; }
.seg-btn:hover { color: var(--text-primary); }
.seg-btn.active { background: var(--accent); color: #fff; font-weight: 600; }

/* Main Content */
.main-content { flex: 1; overflow-y: auto; padding: 28px 36px 60px; }
.content-wrap { max-width: 980px; margin: 0 auto; }

.view-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.view-title { font-size: 28px; font-weight: 700; margin: 0 0 4px; letter-spacing: -0.02em; }
.view-subtitle { font-size: 13.5px; color: var(--text-muted); margin: 0; }
.view-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; position: relative; }

.dropdown-wrap { position: relative; display: inline-flex; }
.dropdown-menu {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 6px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px;
  min-width: 210px;
  z-index: 40;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
}
.dropdown-item { width: 100%; background: transparent; border: none; color: var(--text-secondary); padding: 8px 10px; border-radius: 6px; text-align: left; font-size: 13px; cursor: pointer; display: block; }
.dropdown-item:hover { background: var(--bg-hover); color: var(--text-primary); }

.tabs-bar { display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tabs-list { display: flex; gap: 22px; }
.tab-btn { background: transparent; border: none; border-bottom: 2px solid transparent; padding: 10px 2px; font-size: 14px; font-weight: 500; color: var(--text-secondary); cursor: pointer; }
.tab-btn.active { color: var(--text-primary); border-bottom-color: var(--accent); font-weight: 600; }

.toolbar-select { background: var(--bg-surface); border: 1px solid var(--border); border-radius: 6px; padding: 5px 8px; font-size: 12px; color: var(--text-secondary); cursor: pointer; }

/* Most Popular Top 3 Showcase */
.popular-showcase { margin-bottom: 22px; }
.popular-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--accent); margin-bottom: 10px; }
.popular-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.popular-mini-card { background: var(--bg-surface); border: 1px solid var(--border); border-radius: 8px; padding: 12px; cursor: pointer; display: flex; gap: 12px; align-items: center; }
.popular-mini-card:hover { border-color: var(--accent); }
.popular-mini-img { width: 64px; height: 64px; border-radius: 6px; object-fit: cover; flex-shrink: 0; background: var(--bg-hover); }

/* Article Layouts */
.articles-stream { display: flex; flex-direction: column; gap: 10px; }
.articles-stream.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }

.article-mag { display: flex; gap: 16px; padding: var(--density-pad); border-radius: 8px; border: 1px solid transparent; background: transparent; cursor: pointer; transition: background 0.12s, border-color 0.12s; }
.article-mag:hover { background: var(--bg-surface); border-color: var(--border); }
.article-mag.is-read { opacity: 0.62; }
.thumb-wrap { position: relative; width: 136px; height: 92px; flex-shrink: 0; border-radius: 6px; overflow: hidden; background: var(--bg-hover); }
.article-thumb { width: 100%; height: 100%; object-fit: cover; display: block; }
.play-badge { position: absolute; inset: auto 6px 6px auto; background: rgba(0,0,0,0.78); color: #fff; font-size: 10px; font-weight: 700; padding: 2px 6px; border-radius: 4px; }

.article-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.article-title { font-size: 16px; font-weight: 600; line-height: 1.38; margin: 0; color: var(--text-primary); }
.article-title-bilingual-sub { font-size: 13.5px; color: var(--text-secondary); margin: 2px 0 0; font-weight: 500; }
.article-meta { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-muted); flex-wrap: wrap; }
.article-summary { font-size: 13.5px; color: var(--text-secondary); line-height: 1.5; margin: 2px 0 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.article-actions-row { display: flex; align-items: center; gap: 6px; margin-top: 4px; flex-wrap: wrap; }

.entity-chip { font-size: 11px; padding: 1px 7px; border-radius: 10px; background: var(--bg-hover); color: var(--text-secondary); border: 1px solid var(--border); cursor: pointer; }
.entity-chip:hover { border-color: var(--accent); color: var(--text-primary); }

.cluster-bar { margin-top: 6px; font-size: 12px; color: var(--info); cursor: pointer; }

.article-title-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 12px; border-bottom: 1px solid var(--border-subtle); cursor: pointer; border-radius: 4px; }
.article-title-row:hover { background: var(--bg-surface); }
.article-title-row.is-read { opacity: 0.58; }
.article-title-row-left { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.article-title-row .source-pill { font-size: 11.5px; color: var(--text-muted); width: 135px; flex-shrink: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.article-title-row .row-headline { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.article-card { display: flex; flex-direction: column; background: var(--bg-surface); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; cursor: pointer; transition: transform 0.12s, border-color 0.12s; }
.article-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.article-card.is-read { opacity: 0.65; }
.article-card-img { width: 100%; height: 158px; object-fit: cover; background: var(--bg-hover); }
.article-card-inner { padding: 14px; display: flex; flex-direction: column; gap: 8px; flex: 1; }

.article-expanded { background: var(--bg-surface); border: 1px solid var(--border); border-radius: 10px; padding: 20px 24px; margin-bottom: 16px; }
.article-expanded-body { margin-top: 14px; font-size: 15px; line-height: 1.7; color: var(--text-secondary); font-family: var(--font-reader); }
.article-expanded-body img { max-width: 100%; border-radius: 8px; margin: 10px 0; }
.article-expanded-body video, .article-expanded-body iframe { width: 100%; max-height: 440px; border-radius: 8px; margin: 12px 0; aspect-ratio: 16/9; }

.giant-mark-read-btn {
  width: 100%;
  margin-top: 24px;
  padding: 16px;
  border: 1px dashed var(--border);
  border-radius: 10px;
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.giant-mark-read-btn:hover { border-color: var(--accent); color: var(--accent); }

.si-badge { font-size: 10.5px; font-weight: 600; color: var(--accent); background: var(--accent-soft); padding: 1px 6px; border-radius: 4px; }
.board-chip { font-size: 10.5px; padding: 1px 6px; border-radius: 4px; background: rgba(59, 130, 246, 0.14); color: var(--info); }

/* Panels / Forms */
.panel-card { background: var(--bg-surface); border: 1px solid var(--border); border-radius: 10px; padding: 20px; margin-bottom: 18px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.form-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.form-field label { font-size: 12.5px; font-weight: 600; color: var(--text-secondary); }
.input-box { background: var(--bg-input); border: 1px solid var(--border); border-radius: 7px; padding: 9px 12px; font-size: 13.5px; color: var(--text-primary); width: 100%; }
.input-box:focus { outline: none; border-color: var(--accent); }
.input-row { display: flex; gap: 10px; align-items: center; }

.candidate-card { border: 1px solid var(--border); background: var(--bg-app); border-radius: 8px; padding: 14px 16px; margin-top: 12px; }
.candidate-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.preview-list { margin: 10px 0 0; padding-left: 18px; font-size: 13px; color: var(--text-secondary); }
.preview-list li { margin-bottom: 5px; }

.directory-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.directory-item { border: 1px solid var(--border); background: var(--bg-surface); border-radius: 8px; padding: 14px; display: flex; flex-direction: column; justify-content: space-between; gap: 10px; }

/* Reader Overlay */
.reader-overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.72); display: flex; justify-content: flex-end; z-index: 50; }
.reader-panel { width: min(940px, 100vw); height: 100%; background: var(--bg-app); border-left: 1px solid var(--border); display: flex; flex-direction: column; transition: width 0.2s ease; }
.reader-panel.wide-bilingual { width: min(1240px, 100vw); }

.reader-toolbar { height: 54px; border-bottom: 1px solid var(--border); padding: 0 16px; display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-shrink: 0; overflow-x: auto; }
.reader-toolbar-left, .reader-toolbar-right { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

.reader-scroll { flex: 1; overflow-y: auto; padding: 30px 40px 80px; }
.reader-article-wrap { max-width: 760px; margin: 0 auto; }
.reader-panel.wide-bilingual .reader-article-wrap { max-width: 1120px; }

.reader-h1 { font-size: 28px; font-weight: 700; line-height: 1.3; margin: 0 0 10px; }
.reader-meta { font-size: 13px; color: var(--text-muted); margin-bottom: 18px; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

.core-meaning-box {
  background: var(--accent-soft);
  border-left: 4px solid var(--accent);
  border-radius: 6px;
  padding: 12px 16px;
  margin-bottom: 20px;
}
.core-meaning-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--accent); margin-bottom: 4px; }

.reader-hero { width: 100%; max-height: 400px; object-fit: cover; border-radius: 10px; margin-bottom: 20px; }
.reader-video-box { width: 100%; border-radius: 10px; overflow: hidden; margin-bottom: 20px; background: #000; }
.reader-video-box video, .reader-video-box iframe { width: 100%; aspect-ratio: 16/9; display: block; border: none; }

.media-gallery-strip { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin: 18px 0; }
.media-gallery-strip img { width: 100%; height: 100px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); cursor: pointer; }

.reader-prose { font-family: var(--font-reader); font-size: var(--reader-font-size); line-height: 1.75; color: var(--text-primary); }
.reader-prose.sinhala-text { font-family: var(--font-si); }
.reader-prose p { margin: 0 0 16px; }
.reader-prose h2, .reader-prose h3 { margin: 24px 0 10px; }
.reader-prose img { max-width: 100%; border-radius: 8px; }
.reader-prose video, .reader-prose iframe { width: 100%; aspect-ratio: 16/9; border-radius: 8px; margin: 12px 0; }
.reader-prose blockquote { border-left: 3px solid var(--accent); margin: 16px 0; padding: 4px 16px; color: var(--text-secondary); }
.reader-prose pre { background: var(--bg-surface); border: 1px solid var(--border); padding: 14px; border-radius: 8px; overflow-x: auto; font-size: 13px; }

.bilingual-grid { display: flex; flex-direction: column; gap: 14px; margin-top: 12px; }
.bilingual-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; padding: 14px 16px; background: var(--bg-surface); border: 1px solid var(--border); border-radius: 8px; }
.bilingual-col-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); margin-bottom: 6px; }
.bilingual-en { font-family: var(--font-reader); font-size: 15.5px; line-height: 1.65; color: var(--text-secondary); }
.bilingual-si { font-family: var(--font-si); font-size: 16px; line-height: 1.78; color: var(--text-primary); }

/* Contextual Selection Popup */
.selection-popup {
  position: fixed;
  z-index: 95;
  display: flex;
  gap: 4px;
  background: var(--bg-surface);
  border: 1px solid var(--accent);
  padding: 5px;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55);
}
.sel-btn { background: transparent; border: none; color: var(--text-primary); font-size: 12px; font-weight: 600; padding: 5px 9px; border-radius: 5px; cursor: pointer; }
.sel-btn:hover { background: var(--accent); color: #fff; }

/* Highlights & Notes */
.notes-box { margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--border); }
.highlight-chip { border-left: 3px solid var(--accent); background: var(--bg-surface); padding: 10px 12px; border-radius: 6px; margin-bottom: 8px; font-size: 13.5px; }

/* Preferences Modal (Matches Feedly Screenshots) */
.prefs-modal {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: min(860px, 96vw);
  height: min(640px, 90vh);
  display: flex;
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
}
.prefs-sidebar { width: 210px; background: var(--bg-sidebar); border-right: 1px solid var(--border); padding: 18px 12px; display: flex; flex-direction: column; gap: 4px; flex-shrink: 0; }
.prefs-title { font-size: 15px; font-weight: 700; padding: 4px 10px 14px; }
.prefs-nav-btn { background: transparent; border: none; text-align: left; padding: 9px 12px; border-radius: 6px; font-size: 13.5px; color: var(--text-secondary); cursor: pointer; }
.prefs-nav-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.prefs-nav-btn.active { background: var(--bg-active); color: var(--text-primary); font-weight: 600; }

.prefs-body { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.prefs-top { display: flex; align-items: center; justify-content: space-between; padding: 16px 24px; border-bottom: 1px solid var(--border); }
.prefs-scroll { flex: 1; overflow-y: auto; padding: 20px 24px; }
.prefs-footer { padding: 14px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

.pref-group { margin-bottom: 22px; }
.pref-group-title { font-size: 14px; font-weight: 700; margin: 0 0 4px; }
.pref-group-desc { font-size: 12.5px; color: var(--text-muted); margin: 0 0 10px; }
.radio-stack { display: flex; flex-direction: column; gap: 7px; }
.radio-option { display: flex; align-items: center; gap: 9px; font-size: 13.5px; cursor: pointer; color: var(--text-secondary); }
.radio-option input { accent-color: var(--accent); width: 15px; height: 15px; }

/* Modals & Palette */
.modal-overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.65); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 80; }
.modal-card { background: var(--bg-surface); border: 1px solid var(--border); border-radius: 12px; width: min(560px, 100%); max-height: 85vh; overflow-y: auto; padding: 20px; }
.command-palette { padding: 0; overflow: hidden; }
.palette-input-row { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.palette-input-row input { flex: 1; background: transparent; border: none; font-size: 15px; outline: none; }
.palette-results { max-height: 360px; overflow-y: auto; padding: 8px; }
.palette-item { display: flex; align-items: center; justify-content: space-between; padding: 9px 12px; border-radius: 6px; cursor: pointer; font-size: 13.5px; }
.palette-item:hover { background: var(--bg-hover); }

.spinner-xs { width: 12px; height: 12px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

.toast { position: fixed; bottom: 20px; right: 20px; background: var(--bg-surface); border: 1px solid var(--accent); color: var(--text-primary); padding: 10px 16px; border-radius: 8px; font-size: 13px; font-weight: 500; z-index: 100; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4); }

.mobile-only { display: none; }
@media (max-width: 860px) {
  .mobile-only { display: inline-flex; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; }
  .main-content { padding: 18px 16px 50px; }
  .bilingual-pair { grid-template-columns: 1fr; }
  .reader-scroll { padding: 20px 18px 60px; }
  .trans-label, .domain-tag { display: none; }
  .prefs-modal { flex-direction: column; height: 92vh; }
  .prefs-sidebar { width: 100%; flex-direction: row; overflow-x: auto; border-right: none; border-bottom: 1px solid var(--border); }
}
