@keyframes spin { to { transform: rotate(360deg); } }
:root {
  --bg: #f5f6f8;
  --card: #fff;
  --text: #1a1a2e;
  --text2: #444;
  --text3: #888;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --border: #e5e7eb;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-lg: 0 10px 30px rgba(0,0,0,0.12);
  --shadow-soft:
    0 2px 5px rgba(0,0,0,0.04),
    0 4px 10px rgba(0,0,0,0.034),
    0 7px 16px rgba(0,0,0,0.028),
    0 11px 24px rgba(0,0,0,0.022),
    0 16px 34px rgba(0,0,0,0.016),
    0 22px 46px rgba(0,0,0,0.011),
    0 30px 60px rgba(0,0,0,0.006);
  --mark-critical: #c75b39;
  --mark-reference: #4a7c59;
  --mark-edge: #6b7b8c;
  --success: #16a34a;
}
[data-theme="dark"] {
  --bg: #0f1115;
  --card: #1a1d24;
  --text: #e8eaed;
  --text2: #b0b3b8;
  --text3: #80848a;
  --accent: #5b8def;
  --accent-hover: #7aa7f5;
  --border: var(--bg);
  --success: #22c55e;
  --shadow: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-lg: 0 10px 30px rgba(0,0,0,0.4);
  --shadow-soft:
    0 5px 15px rgba(0,0,0,0.32),
    0 0 12px rgba(255,255,255,0.35),
    0 0 24px rgba(15,15,255,0.1);
  --mark-critical: #d47050;
  --mark-reference: #5a9069;
  --mark-edge: #7b8b9c;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { overflow-y: scroll; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
}
body.no-scroll { overflow: hidden; height: 100vh; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.container { max-width: 880px; margin: 0 auto; padding: 32px 20px; }
.header-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.header-top h1 { flex-shrink: 0; }
.header-top-right { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.header-divider { color: var(--text3); font-size: 13px; user-select: none; }
.header-nav-icons { display: flex; align-items: center; gap: 12px; }
.header-bottom { margin-top: 10px; }
.header-bottom p { color: var(--text2); font-size: 14px; }
.header-actions { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
header { margin-bottom: 16px; }
header h1 { font-size: 26px; font-weight: 700; letter-spacing: -0.3px; }
header p { color: var(--text2); font-size: 14px; }
.search-wrapper { position: fixed; top: 20px; right: 20px; z-index: 20; }
[data-theme="dark"] .actions .mark-group button {
  background: var(--card); color: var(--text3);
}
[data-theme="dark"] .actions .mark-group button:hover {
  border-color: var(--text2); color: var(--text2);
}
[data-theme="dark"] .btn-secondary {
  background: #2a2e36; color: var(--text);
}
[data-theme="dark"] .btn-secondary:hover {
  background: #363b45;
}
[data-theme="dark"] .icon-btn {
  background: #2a2e36; color: var(--text); border-color: #3a3f4a;
}
[data-theme="dark"] .icon-btn:hover {
  background: #363b45; color: var(--text2); border-color: var(--text2);
}
[data-theme="dark"] .section-body code {
  background: rgba(91, 141, 239, 0.12); color: #93c5fd;
}
[data-theme="dark"] .type-badge {
  background: #1e3a5f; color: var(--accent);
}
[data-theme="dark"] .heart-empty {
  color: #3a3f4a;
}
[data-theme="dark"] .score-high { background: #5a9070; }
[data-theme="dark"] .score-mid { background: #b09d60; }
[data-theme="dark"] .score-low { background: #b06050; }
.header-right { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.header-actions { display: flex; align-items: center; gap: 12px; }
.header-icon {
  display: flex; align-items: center; justify-content: center;
  color: var(--text3); cursor: pointer; transition: color .15s;
}
.header-icon:hover { color: var(--text); }
.header-icon.active { color: var(--accent); }
.header-search-wrap { position: relative; }
.search-panel {
  position: absolute; top: calc(100% + 6px); right: 0;
  display: flex; gap: 8px; align-items: center;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 8px 12px;
  opacity: 0; transform: translateY(-6px); pointer-events: none;
  transition: all .25s ease; width: 280px; z-index: 100;
}
.search-panel.open { opacity: 1; transform: translateY(0); pointer-events: auto; }
.search-panel input {
  flex: 1; border: none; outline: none; font-size: 14px;
  background: transparent; color: var(--text);
}
.search-panel button {
  padding: 6px 14px; border-radius: 6px; font-size: 13px;
  border: none; background: var(--accent); color: #fff; cursor: pointer;
  transition: background .2s;
}
.search-panel button:hover { background: var(--accent-hover); }
.header-auth-wrap { position: relative; }
.auth-panel {
  position: absolute; top: calc(100% + 6px); right: 0;
  display: flex; gap: 8px; align-items: center;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 8px 12px;
  opacity: 0; transform: translateY(-6px); pointer-events: none;
  transition: all .25s ease; width: 280px; z-index: 100;
}
.auth-panel.open { opacity: 1; transform: translateY(0); pointer-events: auto; }
.auth-panel input {
  flex: 1; border: none; outline: none; font-size: 14px;
  background: transparent; color: var(--text);
}
.auth-panel input::placeholder { color: var(--text3); }
.auth-panel button {
  padding: 6px 14px; border-radius: 6px; font-size: 13px;
  border: none; background: var(--accent); color: #fff; cursor: pointer;
  transition: background .2s; white-space: nowrap; flex-shrink: 0;
}
.auth-panel button:hover { background: var(--accent-hover); }
.auth-panel .auth-msg {
  font-size: 12px; color: var(--mark-critical); white-space: nowrap;
}
.auth-panel .auth-msg.ok { color: var(--mark-reference); }
.insight-overlay {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.45); z-index: 200;
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(4px); opacity: 0; pointer-events: none;
  transition: opacity .2s ease;
}
.insight-overlay.open { opacity: 1; pointer-events: auto; }
.insight-dialog {
  position: relative; isolation: isolate;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  width: 92%; max-width: 640px; max-height: 90vh;
  display: flex; flex-direction: column;
  transition: box-shadow 0.3s ease;
}
.insight-dialog::before {
  content: ''; position: absolute; inset: 0;
  border-radius: var(--radius); box-shadow: var(--shadow-soft);
  pointer-events: none; z-index: -1;
}
.insight-dialog-header {
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
}
.insight-dialog-header h3 { font-size: 16px; font-weight: 700; color: var(--text); margin: 0; }
.insight-dialog-header .close-btn {
  width: 28px; height: 28px; border-radius: 50%; border: none;
  background: rgba(0,0,0,0.08); color: var(--text3); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; line-height: 1; transition: all .2s;
}
.insight-dialog-header .close-btn:hover { background: rgba(0,0,0,0.15); color: var(--text); }
.insight-dialog-body { padding: 16px 20px; overflow-y: auto; flex: 1; }
.insight-dialog-body textarea {
  width: 100%; min-height: 400px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 8px;
  font-size: 14px; font-family: inherit; line-height: 1.7;
  background: var(--card); color: var(--text); outline: none;
  resize: vertical;
}
.insight-dialog-body textarea:focus { border-color: var(--accent); }
.insight-dialog-toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.insight-dialog-toolbar .insight-provider-select,
.insight-dialog-toolbar .insight-dialog-field,
.insight-dialog-toolbar .insight-dialog-check { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--text3); }
.insight-dialog-toolbar select,
.insight-dialog-toolbar input[type="text"] { padding: 3px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--card); color: var(--text); font-size: 13px; outline: none; }
.insight-dialog-toolbar .insight-dialog-field input[type="text"] { width: 80px; }
.insight-dialog-toolbar input[type="checkbox"] { width: 14px; height: 14px; cursor: pointer; accent-color: var(--accent); }
[data-theme="dark"] .insight-dialog-toolbar input[type="checkbox"] { filter: invert(0.85) hue-rotate(180deg); }
.insight-dialog-toolbar span { color: var(--text); }
.insight-dialog-footer {
  padding: 14px 20px; border-top: 1px solid var(--border);
  display: flex; gap: 10px; justify-content: flex-end; align-items: center;
}
.insight-dialog-footer button {
  padding: 8px 18px; border-radius: 8px; font-size: 13px;
  cursor: pointer; border: none; font-weight: 500;
}
.insight-dialog-footer .insight-loading-inline {
  font-size: 13px; color: var(--text3); margin-right: auto;
}
.toast-container {
  position: fixed; top: 16px; right: 16px; z-index: 300;
  display: flex; flex-direction: column; gap: 8px;
  max-width: 320px;
}
.toast {
  padding: 12px 28px 12px 16px; border-radius: 10px; font-size: 13px; line-height: 1.5;
  background: var(--card); border: 1px solid var(--border);
  box-shadow: var(--shadow-lg); color: var(--text);
  animation: toastIn .25s ease; cursor: default;
  position: relative;
}
.toast.toast-success { border-left: 3px solid var(--mark-reference); }
.toast.toast-info { border-left: 3px solid var(--accent); }
.toast.toast-error { border-left: 3px solid var(--mark-critical); }
.toast .toast-link {
  color: var(--accent); cursor: pointer; font-weight: 600;
}
.toast .toast-link:hover { text-decoration: underline; }
.toast .toast-close {
  position: absolute; top: 10px; right: 10px;
  color: var(--text3); cursor: pointer;
  font-size: 16px; line-height: 1; padding: 0 2px;
}
.toast .toast-close:hover { color: var(--text); }
.toast .toast-actions { display: flex; gap: 8px; margin-top: 8px; }
.toast .toast-title {
  font-weight: 600; color: var(--text); line-height: 1.5;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  max-width: 280px;
}
.toast .toast-subtitle {
  font-size: 12px; color: var(--text2); margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  max-width: 280px;
}
.toast .toast-actions {
  display: flex; gap: 8px; margin-top: 10px; align-items: center;
}
.toast .toast-actions button {
  font-size: 12px; padding: 5px 12px; border-radius: 6px;
  border: 1px solid var(--accent); background: rgba(37,99,235,0.06);
  color: var(--accent); cursor: pointer; transition: all .15s;
}
.toast .toast-actions button:hover {
  background: var(--accent); color: #fff;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}
.toast.toast-out {
  animation: toastOut .25s ease forwards;
}
@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(20px); }
}
.filter-bar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.filter-bar button {
  padding: 5px 14px; border: 1px solid var(--border); border-radius: 20px;
  background: var(--card); color: var(--text2); font-size: 13px;
  cursor: pointer; transition: all .2s; font-weight: 500;
}
.filter-bar button:hover { border-color: var(--text3); color: var(--text); }
.filter-bar button.active {
  background: var(--accent); color: #fff; border-color: var(--accent);
}
.filter-bar button.active[data-filter="critical"] { background: var(--mark-critical); border-color: var(--mark-critical); }
.filter-bar button.active[data-filter="reference"] { background: var(--mark-reference); border-color: var(--mark-reference); }
.filter-bar button.active[data-filter="edge"] { background: var(--mark-edge); border-color: var(--mark-edge); }
.filter-bar button.active[data-filter="checked"] { background: #4a7c59; border-color: #4a7c59; }
.filter-dropdown { position: relative; margin-left: auto; flex-shrink: 0; }
.filter-dropdown-btn { display: flex; align-items: center; gap: 6px; padding: 5px 12px; border: 1px solid var(--border); border-radius: 20px; background: var(--card); color: var(--text2); font-size: 13px; cursor: pointer; transition: all .2s; font-weight: 500; }
.filter-dropdown-btn:hover { border-color: var(--text3); color: var(--text); }
.filter-dropdown.open .filter-dropdown-btn { border-color: var(--accent); color: var(--accent); }
.filter-dropdown-menu { position: absolute; top: calc(100% + 6px); right: 0; min-width: 180px; background: rgba(255,255,255,0.72); border: 1px solid rgba(0,0,0,0.06); border-radius: var(--radius); padding: 8px 0; display: none; z-index: 100; backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.filter-dropdown.open .filter-dropdown-menu { display: block; }
.filter-dropdown-section { padding: 4px 14px; font-size: 11px; font-weight: 600; color: var(--text3); text-transform: uppercase; letter-spacing: 0.5px; }
.filter-dropdown-option { display: flex; align-items: center; justify-content: space-between; padding: 7px 14px; font-size: 13px; color: var(--text2); cursor: pointer; transition: all .1s; gap: 10px; }
.filter-dropdown-option:hover { background: var(--bg); color: var(--text); }
.filter-dropdown-option.active { color: var(--accent); font-weight: 600; }
.filter-dropdown-option .check-icon { opacity: 0; flex-shrink: 0; }
.filter-dropdown-option.active .check-icon { opacity: 1; }
.filter-dropdown-divider { height: 1px; background: var(--border); margin: 6px 10px; }
.filter-dropdown-check { display: flex; align-items: center; gap: 8px; padding: 7px 14px; font-size: 13px; color: var(--text2); cursor: pointer; user-select: none; transition: all .1s; }
.filter-dropdown-check:hover { background: var(--bg); color: var(--text); }
.filter-dropdown-check .check-box { width: 16px; height: 16px; border: 2px solid var(--text3); border-radius: 4px; display: flex; align-items: center; justify-content: center; transition: all .2s; flex-shrink: 0; font-size: 11px; line-height: 1; }
/* State: has (checked) */
.filter-dropdown-check[data-state="has"] .check-box { border-color: var(--accent); background: var(--accent); color: #fff; }
.filter-dropdown-check[data-state="has"] .check-box::after { content: '✓'; }
/* State: none (excluded) */
.filter-dropdown-check[data-state="none"] .check-box { border-color: #e74c3c; background: #e74c3c; color: #fff; }
.filter-dropdown-check[data-state="none"] .check-box::after { content: '✕'; }
@media (max-width: 640px) {
  header { margin-bottom: 16px; }
  header h1 { font-size: 18px; letter-spacing: 0; }
  .header-top { gap: 6px; }
  .header-bottom { gap: 6px; margin-top: 8px; }
  .header-bottom p { font-size: 13px; }
  .nav-links { gap: 2px; }
  .nav-link { padding: 3px 6px; font-size: 13px; }
  .filter-bar { gap: 6px; margin-bottom: 12px; }
  .filter-bar { gap: 4px; flex-wrap: nowrap; }
  .filter-bar button { padding: 4px 10px; font-size: 13px; white-space: nowrap; }
  .filter-dropdown { margin-left: auto; flex-shrink: 0; }
  .filter-dropdown-btn { padding: 4px 10px; font-size: 13px; white-space: nowrap; }
  .filter-dropdown-menu { min-width: 160px; }
  .filter-dropdown-option { padding: 6px 12px; font-size: 12px; }
  .filter-dropdown-check { padding: 6px 12px; font-size: 12px; }
  .filter-dropdown-check .check-box { width: 14px; height: 14px; border-radius: 3px; }
  .filter-dropdown-check .check-box::after { width: 7px; height: 7px; }
}
.search-bar input {
  flex: 1; padding: 12px 16px; border: 1px solid var(--border);
  border-radius: var(--radius); font-size: 15px; outline: none;
  background: var(--card); transition: border .2s;
}
.search-bar input:focus { border-color: var(--accent); }
.search-bar button {
  padding: 12px 22px; border: none; border-radius: var(--radius);
  background: var(--accent); color: #fff; font-size: 14px; cursor: pointer;
  transition: background .2s;
}
.search-bar button:hover { background: var(--accent-hover); }
.stats { font-size: 13px; color: var(--text3); margin-bottom: 16px; min-height: 20px; }
.paper-list { display: flex; flex-direction: column; gap: 18px; }
.paper-card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 24px 26px;
  border: 1px solid var(--border); transition: box-shadow .2s;
  position: relative; isolation: isolate;
}
.paper-card::before {
  content: ''; position: absolute; inset: 0;
  border-radius: var(--radius); box-shadow: 0 0 0 transparent;
  pointer-events: none; z-index: -1;
  transition: box-shadow .2s;
}
.paper-card:hover::before { box-shadow: var(--shadow-soft); }
.paper-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 10px; }
.heart-icon { width: 20px; height: 20px; flex-shrink: 0; margin-top: 2px; }
.heart-critical { color: var(--mark-critical); }
.heart-reference { color: var(--mark-reference); }
.heart-edge { color: var(--mark-edge); }
.heart-empty { color: #e5e7eb; }
.paper-title { font-size: 17px; font-weight: 700; line-height: 1.45; flex: 1; color: var(--text); }
.paper-meta {
  font-size: 13px; color: var(--text2);
  display: flex; justify-content: space-between; align-items: center;
  gap: 10px; margin-bottom: 15px;
}
.meta-left { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.meta-right { font-size: 12px; color: var(--text3); flex-shrink: 0; }
.meta-link { color: var(--accent); font-size: 12px; text-decoration: none; cursor: pointer; }
.meta-link:hover { text-decoration: underline; }
.tag-inline { position: relative; display: inline-flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.tag-mini { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 10px; font-size: 11px; background: #e5e7eb; color: var(--text); font-weight: 500; white-space: nowrap; }
.tag-more { padding: 2px 6px; border-radius: 10px; font-size: 11px; background: #d1d5db; color: var(--text); font-weight: 500; cursor: default; }
.tag-tooltip { display: none; position: absolute; top: calc(100% + 6px); right: 0; background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; box-shadow: 0 4px 12px rgba(0,0,0,0.08); z-index: 10; flex-wrap: wrap; gap: 4px; max-width: 320px; }
.tag-inline:hover .tag-tooltip { display: flex; }
.tag-link { color: var(--text3); text-decoration: none; }
[data-theme="dark"] .tag-mini { background: #3a3f4a; color: var(--text); }
[data-theme="dark"] .tag-more { background: #4a5060; color: var(--text); }
[data-theme="dark"] .tag-tooltip { background: #1e2128; border-color: #3a3f4a; }
.related-papers { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--border); }
.related-papers h4 { font-size: 14px; font-weight: 700; color: var(--text); margin-bottom: 12px; }
.tag-cloud { display: none; flex-wrap: wrap; gap: 8px; padding: 16px 20px; background: var(--card); border-radius: var(--radius); border: 1px solid var(--border); margin-bottom: 16px; }
.tag-cloud.open { display: flex; }
.tag-cloud h4 { width: 100%; font-size: 13px; font-weight: 700; color: var(--text); margin: 0 0 8px; }
.tag-cloud-item { padding: 4px 12px; border-radius: 14px; font-size: 13px; background: var(--bg); color: var(--text2); border: 1px solid var(--border); cursor: pointer; transition: all .2s; white-space: nowrap; }
.tag-cloud-item:hover { border-color: var(--accent); color: var(--accent); background: rgba(37,99,235,0.06); transform: translateY(-1px); }
[data-theme="dark"] .tag-cloud-item { background: #1e2128; }
.related-item { display: flex; align-items: center; gap: 10px; padding: 8px 0; cursor: pointer; }
.related-item:hover { color: var(--accent); }
.related-item .rel-score { font-size: 11px; font-weight: 700; color: #fff; background: var(--accent); padding: 2px 7px; border-radius: 10px; }
.related-item .rel-title { font-size: 13px; color: var(--text2); flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.score-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 36px; height: 20px; padding: 0 8px; border-radius: 16px;
  font-size: 12px; font-weight: 700; color: #fff; flex-shrink: 0;
}
.score-high { background: #4a7c59; }
.score-mid { background: #9c7b40; }
.score-low { background: #9c5040; }
.checked-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 20px; border-radius: 50%;
  font-size: 12px; font-weight: 700; color: #fff;
  background: #4a7c59; flex-shrink: 0; margin-right: 4px;
}
.checked-active { color: #4a7c59 !important; font-weight: 600; }
.type-badge {
  font-size: 12px; padding: 2px 10px; border-radius: 6px;
  background: #eef2ff; color: var(--accent); font-weight: 600;
}
.section { margin-bottom: 16px; }
.section:last-child { margin-bottom: 0; }
.section-label {
  font-size: 11px; font-weight: 700; color: var(--text3);
  text-transform: uppercase; letter-spacing: 0.6px;
  margin-bottom: 5px;
}
.section-body { font-size: 14px; color: var(--text2); line-height: 1.75; }
.section-body.dark { color: var(--text); }
.section-body h1, .section-body h2, .section-body h3 { font-size: 15px; font-weight: 700; margin: 14px 0 6px; color: var(--text); }
.section-body h4, .section-body h5, .section-body h6 { clear: both; }
.section-body ul, .section-body ol { margin: 6px 0 6px 20px; }
.section-body li { margin: 4px 0; }
.section-body strong, .section-body em { text-decoration: underline; text-underline-offset: 2px; font-weight: 400; font-style: normal; }
.section-body p { margin: 6px 0; }
.section-body code { background: rgba(37, 99, 235, 0.07); color: #1d4ed8; padding: 1px 5px; border-radius: 4px; font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; font-size: 0.9em; }
.actions { display: flex; gap: 10px; justify-content: space-between; align-items: center; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.actions .mark-group { display: flex; gap: 6px; align-items: center; }
.actions .mark-group button {
  padding: 5px 12px; border-radius: 6px; font-size: 12px; cursor: pointer;
  border: 1px solid var(--border); background: #fff; color: var(--text3);
  transition: all .2s;
}
.actions .mark-group button:hover { border-color: var(--text2); color: var(--text2); }
.actions .mark-group button.active { color: #fff; border-color: transparent; }
.actions .mark-group button.active[data-mark="critical"] { background: var(--mark-critical); }
.actions .mark-group button.active[data-mark="reference"] { background: var(--mark-reference); }
.actions .mark-group button.active[data-mark="edge"] { background: var(--mark-edge); }
.actions .right-group { display: flex; gap: 8px; align-items: center; }
.actions button, .btn-primary, .btn-secondary {
  padding: 8px 18px; border-radius: 8px; font-size: 13px; cursor: pointer;
  border: none; transition: background .2s; font-weight: 500;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: #f3f4f6; color: var(--text); }
.btn-secondary:hover { background: #e5e7eb; }
.btn-danger { background: #dc2626; color: #fff; }
.btn-danger:hover { background: #b91c1c; }
[data-theme="dark"] .btn-danger { background: #dc2626; }
[data-theme="dark"] .btn-danger:hover { background: #b91c1c; }
.paper-card .btn-danger { display: none; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--border); background: #fff; color: var(--text); cursor: pointer; transition: all .2s; }
.icon-btn:hover { border-color: var(--text2); color: var(--text2); background: var(--bg); }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 11px; font-weight: 700; color: var(--text3); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 5px; }
.field input, .field textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 14px; font-family: inherit;
  outline: none; transition: border .2s; background: var(--card);
  color: var(--text);
}
.field input:focus, .field textarea:focus { border-color: var(--accent); }
.field input[readonly] {
  background: var(--bg); color: var(--text3);
}
.field textarea { resize: vertical; min-height: 80px; line-height: 1.7; }
.field-row { display: flex; gap: 14px; }
.field-row .field { flex: 1; }
.loading { text-align: center; padding: 60px 0; color: var(--text3); font-size: 14px; }
.empty { text-align: center; padding: 60px 0; color: var(--text3); font-size: 14px; }
.pagination {
  display: flex; justify-content: center; align-items: center;
  gap: 8px; margin-top: 28px;
}
.pagination button {
  padding: 8px 14px; border: 1px solid var(--border); background: var(--card);
  border-radius: 8px; cursor: pointer; font-size: 13px; color: var(--text2);
  transition: all .2s;
}
.pagination button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.pagination button:disabled { opacity: .4; cursor: not-allowed; }
.pagination .page-info { font-size: 13px; color: var(--text3); min-width: 80px; text-align: center; }

@media (max-width: 640px) {
  .container { padding: 20px 14px; }
  .paper-card { padding: 18px 16px; }
  .field-row { flex-direction: column; gap: 0; }
  .actions .mark-group { flex-wrap: wrap; }
  .meta-left { flex-wrap: nowrap; overflow: hidden; min-width: 0; }
  .meta-left > span:not(.type-badge) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 120px; }
  .type-badge { flex-shrink: 0; }
  .meta-link { flex-shrink: 0; }
  .icon-btn { width: 40px; height: 40px; }
  .pagination button { padding: 10px 16px; font-size: 14px; }
}
.insight-page { display: none; }
.insight-page.open { display: block; position: relative; isolation: isolate; background: var(--card); border-radius: var(--radius); padding: 24px 26px; margin-top: 20px; transition: box-shadow 0.3s ease; }
.insight-page.open::before { content: ''; position: absolute; inset: 0; border-radius: var(--radius); box-shadow: var(--shadow-soft); pointer-events: none; z-index: -1; }
.insight-page-header { margin-bottom: 20px; border-bottom: 1px solid var(--border); }
.insight-page-header-inner { display: flex; align-items: flex-start; gap: 10px; }
.insight-page-header-inner h2 { font-size: 20px; font-weight: 700; line-height: 1.4; margin-bottom: 8px; flex: 1; }
.insight-page-close {
  width: 32px; height: 32px; flex-shrink: 0;
  border: none; border-radius: 50%; background: rgba(0,0,0,0.06); color: var(--text3);
  font-size: 20px; line-height: 1; cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.insight-page-close:hover { background: rgba(0,0,0,0.12); color: var(--text); }
.insight-page-body { font-size: 14px; line-height: 1.75; color: var(--text2); }
.insight-page-body h1, .insight-page-body h2, .insight-page-body h3 { font-size: 15px; font-weight: 700; margin: 14px 0 6px; color: var(--text); }
.insight-page-body h4, .insight-page-body h5, .insight-page-body h6 { clear: both; }
.insight-page-body strong, .insight-page-body em { text-decoration: underline; text-underline-offset: 2px; font-weight: 400; font-style: normal; }
.insight-page-body p { margin: 6px 0; }
.insight-page-body ul, .insight-page-body ol { margin: 6px 0 6px 20px; }
.insight-page-body li { margin: 4px 0; }
.insight-page-body blockquote {
  max-width: 100%;
  margin: 6px 0 10px 0;
  padding: 4px 0 4px 14px;
  text-align: left;
  border-left: 2px solid var(--border);
  border-right: none;
  background: none;
  color: var(--text2);
  font-size: 15px;
  font-style: italic;
  line-height: 1.6;
}
/* Only the first blockquote in an insight page is right-aligned (pull-quote style) */
.insight-page-body blockquote:first-of-type {
  float: right;
  margin: 2px 0 10px 20px;
  padding: 4px 14px 4px 0;
  text-align: right;
  border-left: none;
  border-right: 2px solid var(--border);
}
.insight-page-body blockquote::before {
  content: '"';
  color: var(--text3);
  margin-right: 2px;
}
.insight-page-body blockquote::after {
  content: '"';
  color: var(--text3);
  margin-left: 2px;
}
[data-theme="dark"] .insight-page-body blockquote { background: none; }
.insight-page-body blockquote p { margin: 0; display: inline; }
.insight-page-body hr { border: none; margin: 0; }
.insight-page-body table {
  border-collapse: collapse;
  width: 100%;
  font-size: 14px;
  margin: 12px 0;
}
.insight-page-body .table-scroll {
  overflow-x: auto;
  max-width: 100%;
  margin: 12px 0;
}
.insight-page-body .table-scroll table {
  margin: 0;
}
.insight-page-body th, .insight-page-body td {
  border: 1px solid var(--border); padding: 8px 12px; text-align: left;
}
.insight-page-body th { white-space: nowrap; background: var(--bg); font-weight: 600; color: var(--text); }
.insight-page-body pre[class*="language-"] {
  padding: 0; border-radius: 10px; overflow-x: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13px; line-height: 1.65; margin: 14px 0;
}
.insight-page-body pre[class*="language-"] code {
  display: block; padding: 16px 18px; background: transparent; border-radius: 0;
  font-size: 13px;
}
.insight-page-body code:not(pre code) {
  background: rgba(37, 99, 235, 0.07); color: #1d4ed8; padding: 1px 5px; border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.9em;
}
[data-theme="dark"] .insight-page-body code:not(pre code) {
  background: rgba(91, 141, 239, 0.12); color: #93c5fd;
}
.insight-page-body code:not(pre code):empty,
.insight-page-body code:not(pre code):has(> img):not(:has(> :not(img):not(div))) {
  padding: 0;
}
.insight-review-section code:not(pre code) {
  background: none; padding: 0; border-radius: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 14px; color: var(--text);
}
.insight-page-body img { max-width: 100%; border-radius: 8px; opacity: 0.95; }
[data-theme="dark"] .insight-page-body img { mix-blend-mode: screen; filter: invert(1) hue-rotate(180deg); }
.insight-review-section { margin-top: 32px; padding-top: 24px; border-top: 2px solid var(--border); }
.insight-review-header { font-size: 13px; font-weight: 600; color: var(--accent); margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.insight-review-body { background: rgba(0,0,0,0.02); border-radius: 8px; padding: 16px; }
.insight-review-status { font-size: 11px; padding: 1px 6px; border-radius: 4px; background: rgba(0,0,0,0.04); color: var(--text3); }
.insight-review-status.accent { color: var(--accent); }
.insight-review-date { font-size: 11px; color: var(--text3); font-weight: 400; }
.insight-loading-state { color: var(--text3); padding: 40px 0; text-align: center; }
.insight-loading-state.small { padding: 20px 0; }
.insight-empty-state { color: var(--text3); }
.backup-list { max-height: 60vh; overflow-y: auto; }
.backup-item { padding: 10px 0; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.backup-item-body { flex: 1; min-width: 0; }
.backup-item-meta { font-size: 12px; color: var(--text3); margin-bottom: 2px; }
.backup-item-preview { font-size: 13px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.backup-review-tag { color: var(--accent); font-size: 11px; }
.btn-small { padding: 4px 10px; font-size: 12px; white-space: nowrap; }
.insight-page-body .katex { font-size: 1.2em; margin: 0 0.25em; }
.insight-page-body .katex-display { text-align: center; margin: 1em 0; overflow-x: auto; overflow-y: hidden; }
.section-body .katex-display { overflow-x: auto; overflow-y: hidden; }
.insight-page-body .math-block { overflow-x: auto; padding: 8px 0; }
/* Match pseudocode line height with body text for consistent rhythm */
.ps-root { margin: 1.2em 0; }
.ps-root .ps-line { line-height: 1.7 !important; }
.ps-root .ps-algorithm { margin: 0.3em 0 !important; }
.insight-editor { display: flex; flex-direction: column; }
.insight-editor textarea {
  width: 100%; min-height: 400px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 14px; line-height: 1.7; padding: 12px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--card); color: var(--text); resize: vertical;
  -webkit-overflow-scrolling: touch;
}
.insight-editor-actions { margin-top: 12px; display: flex; gap: 10px; }

.insight-meta-toggle {
  color: var(--text3); cursor: pointer; margin-left: 4px;
  transition: transform .2s; vertical-align: middle;
}
.insight-meta-toggle:hover { color: var(--text2); }
.meta-icon-group {
  display: flex; align-items: center; gap: 10px;
}
.meta-icon {
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--accent); cursor: pointer;
  transition: color .2s;
}
.meta-icon:hover { color: var(--accent-hover); }
.meta-icon.checked-active { color: #4a7c59; }
[data-theme="dark"] .meta-icon.checked-active { color: #5a9069; }
.insight-meta-info {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 8px 0 16px;
  overflow: hidden;
}
[data-theme="dark"] .insight-meta-info {
  background: #14171d;
  border-color: #2a2e36;
}
.insight-meta-info-inner {
  padding: 12px 16px 14px;
}
.insight-meta-info .info-section { margin-top: 12px; }
.insight-meta-info .info-section:first-of-type { margin-top: 0; }
.insight-meta-info .info-label {
  font-size: 12px; font-weight: 600; color: var(--text3);
  text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px;
}
.insight-meta-info .info-content {
  font-size: 13px; line-height: 1.65; color: var(--text);
}
.insight-meta-info .info-content.dark {
  color: var(--text2);
}
.insight-meta-info .info-content h1,
.insight-meta-info .info-content h2,
.insight-meta-info .info-content h3,
.insight-meta-info .info-content h4,
.insight-meta-info .info-content h5,
.insight-meta-info .info-content h6 {
  font-size: 13px; font-weight: 600; margin: 8px 0 4px; color: var(--text);
}
/* Paragraph rhythm inside meta info */
.insight-meta-info .info-content p { margin: 6px 0; }
.insight-meta-info .info-content p:first-child { margin-top: 0; }
.insight-meta-info .info-content p:last-child { margin-bottom: 0; }
.insight-meta-info .info-content ul,
.insight-meta-info .info-content ol {
  margin: 8px 0 8px 18px; padding: 0;
}
.insight-meta-info .info-content li { margin: 4px 0; }
.insight-meta-info .info-content li:first-child { margin-top: 0; }
.insight-meta-info .info-content li:last-child { margin-bottom: 0; }
.insight-meta-info-footer {
  display: flex; align-items: center; justify-content: flex-end;
  gap: 8px; flex-wrap: wrap; margin-top: 12px; padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 13px; color: var(--text2);
}
.insight-tag-chip {
  display: inline-block; padding: 2px 8px; border-radius: 4px;
  font-size: 12px; background: var(--card); color: var(--text2);
  border: 1px solid var(--border);
}

/* Comment/Annotation System */
.insight-comments { position: fixed; top: 80px; right: 20px; width: 300px; max-height: calc(100vh - 100px); display: none; flex-direction: column; background: var(--card); border: 1px solid var(--border); border-radius: 16px; box-shadow: 0 8px 32px rgba(0,0,0,0.08), 0 2px 8px rgba(0,0,0,0.04); padding: 16px; z-index: 50; overflow: hidden; }
.insight-comments.open { display: flex; }
.comments-panel-header { font-size: 13px; font-weight: 700; color: var(--text); padding: 0 2px 12px; border-bottom: 1px solid var(--border); margin-bottom: 12px; display: flex; align-items: center; justify-content: space-between; letter-spacing: 0.3px; }
.comments-panel-header .count { background: var(--accent); color: #fff; font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 10px; margin-left: 6px; }
.comments-panel-close { background: none; border: none; color: var(--text3); cursor: pointer; font-size: 16px; line-height: 1; padding: 2px 4px; margin-left: 8px; border-radius: 4px; transition: color .15s, background .15s; }
.comments-panel-close:hover { color: var(--text); background: var(--bg); }
.comments-toggle-btn { position: fixed; top: 80px; right: 20px; z-index: 49; display: none; align-items: center; gap: 6px; background: var(--card); border: 1px solid var(--border); border-radius: 20px; box-shadow: 0 2px 8px rgba(0,0,0,0.06); padding: 7px 14px; font-size: 12px; font-weight: 600; color: var(--accent); cursor: pointer; transition: all .2s ease; backdrop-filter: blur(8px); }
.comments-toggle-btn:hover { background: rgba(37,99,235,0.06); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
.comments-toggle-btn.show { display: flex; }
.comments-toggle-btn svg { width: 14px; height: 14px; }
.comments-toggle-btn .count { background: var(--accent); color: #fff; font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 8px; min-width: 16px; text-align: center; }
.comments-list { flex: 1; overflow-y: auto; padding-right: 2px; }
.comment-card { background: var(--bg); border: none; border-radius: 12px; padding: 14px; margin-bottom: 10px; cursor: pointer; transition: all .2s ease; }
.comment-card:hover { background: rgba(37,99,235,0.04); transform: translateX(2px); }
.comment-card.active { background: rgba(37,99,235,0.06); box-shadow: inset 3px 0 0 var(--accent); }
@keyframes commentSlideIn { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: translateX(0); } }
.comment-card.anim-enter { animation: commentSlideIn .45s cubic-bezier(0.22,1,0.36,1) forwards; }
.comment-card-quote { font-size: 12px; color: var(--text3); margin-bottom: 10px; padding: 8px 10px; background: rgba(37,99,235,0.04); border-radius: 8px; border-left: 3px solid rgba(37,99,235,0.2); line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.comment-card-body { font-size: 13px; color: var(--text2); line-height: 1.6; word-break: break-word; }
.comment-card-meta { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; font-size: 11px; color: var(--text3); }
.comment-card-meta .delete-btn { background: none; border: none; color: var(--text3); cursor: pointer; font-size: 11px; padding: 3px 7px; border-radius: 6px; transition: all .15s; }
.comment-card-meta .delete-btn:hover { color: #dc2626; background: rgba(220,38,38,0.06); }
.comment-form { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.comment-form-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text3); margin-bottom: 8px; }
.comment-form-quote { font-size: 12px; color: var(--text2); background: rgba(37,99,235,0.04); padding: 8px 12px; border-radius: 8px; margin-bottom: 10px; line-height: 1.5; border-left: 3px solid rgba(37,99,235,0.25); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.comment-form textarea { width: 100%; min-height: 64px; font-size: 13px; line-height: 1.6; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); color: var(--text); resize: vertical; transition: border-color .2s, box-shadow .2s; }
.comment-form textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,0.08); }
.comment-form-actions { display: flex; gap: 8px; margin-top: 10px; justify-content: flex-end; }
.comment-form-actions button { font-size: 12px; font-weight: 500; padding: 6px 14px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg); color: var(--text2); cursor: pointer; transition: all .15s; }
.comment-form-actions button:hover { background: var(--border); }
.comment-form-actions button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.comment-form-actions button.primary:hover { opacity: 0.9; transform: translateY(-1px); }
.empty-comments { font-size: 13px; color: var(--text3); text-align: center; padding: 20px 0; }

.comment-highlight { background: rgba(37,99,235,0.08); border-bottom: 2px dashed rgba(37,99,235,0.3); color: inherit; cursor: pointer; padding: 0 1px; transition: all .2s ease; }
.comment-highlight:hover { background: rgba(37,99,235,0.15); border-bottom-color: rgba(37,99,235,0.5); }
.comment-highlight.active { background: rgba(37,99,235,0.18); border-bottom: 2px solid var(--accent); box-shadow: 0 1px 0 var(--accent); }
[data-theme="dark"] .comment-highlight { background: rgba(96,165,250,0.12); border-bottom-color: rgba(96,165,250,0.3); }
[data-theme="dark"] .comment-highlight:hover { background: rgba(96,165,250,0.2); border-bottom-color: rgba(96,165,250,0.5); }
[data-theme="dark"] .comment-highlight.active { background: rgba(96,165,250,0.25); border-bottom: 2px solid #60a5fa; box-shadow: 0 1px 0 #60a5fa; }

.selection-tooltip { position: absolute; z-index: 100; background: var(--card); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,0.12); padding: 8px 14px; font-size: 13px; font-weight: 500; color: var(--text); cursor: pointer; display: flex; align-items: center; gap: 8px; opacity: 0; pointer-events: none; transform: translateY(8px) scale(0.92); transition: opacity .2s ease, transform .25s cubic-bezier(0.34,1.56,0.64,1); }
.selection-tooltip.show { opacity: 1; pointer-events: auto; transform: translateY(0) scale(1); }
.selection-tooltip:hover { background: var(--bg); color: var(--accent); }
.selection-tooltip svg { width: 15px; height: 15px; color: var(--accent); flex-shrink: 0; }

@media (max-width: 860px) {
  .insight-comments { position: fixed; bottom: 0; left: 0; right: 0; width: auto; max-height: 60vh; top: auto; border: none; border-top: 1px solid var(--border); border-radius: 16px 16px 0 0; box-shadow: 0 -4px 24px rgba(0,0,0,0.12); padding: 16px 20px; transform: translateY(100%); transition: transform .3s ease; }
  .insight-comments.open { display: flex; transform: translateY(0); }
  .insight-comments-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.2); z-index: 149; opacity: 0; pointer-events: none; transition: opacity .25s; }
  .insight-comments-overlay.open { opacity: 1; pointer-events: auto; }
}

.progress-panel {
  position: fixed; bottom: 16px; left: 16px; z-index: 30;
  background: rgba(255,255,255,0.72); border: 1px solid rgba(0,0,0,0.06); border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.10); padding: 14px 18px; min-width: 260px; max-width: 340px;
  font-size: 13px; line-height: 1.5;
  transition: transform 0.55s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  transform: translateX(-120%) scale(0.96);
  transform-origin: left center;
  pointer-events: none;
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  user-select: none;
}
[data-theme="dark"] .progress-panel {
  background: rgba(26,29,36,0.72);
  border-color: rgba(255,255,255,0.08);
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}
.progress-panel.show { transform: translateX(0) scale(1); pointer-events: auto; }
.panel-collapse-btn {
  position: absolute; top: 8px; right: 8px;
  width: 22px; height: 22px; border-radius: 6px;
  border: none; background: transparent; color: var(--text3);
  font-size: 18px; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
  pointer-events: auto; padding: 0;
}
.panel-collapse-btn:hover { background: rgba(0,0,0,0.06); color: var(--text); }
[data-theme="dark"] .panel-collapse-btn:hover { background: rgba(255,255,255,0.08); }
.panel-collapse-btn:active { transform: scale(0.9); }
.progress-panel-header { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; padding-right: 28px; color: var(--text); font-weight: 600; font-size: 13px; }
.progress-panel-header .spinner { width: 14px; height: 14px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; flex-shrink: 0; }
.progress-panel-header .badge { background: var(--accent); color: #fff; font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 10px; margin-left: auto; }
.progress-titles {}
.progress-title-item { display: flex; align-items: center; gap: 8px; padding: 6px 0; color: var(--text2); font-size: 12.5px; border-bottom: 1px solid var(--border); cursor: pointer; transition: color .15s; }
.progress-title-item:last-child { border-bottom: none; }
.progress-title-item:hover { color: var(--accent); }
.progress-title-item .dot { width: 6px; height: 6px; background: var(--accent); border-radius: 50%; flex-shrink: 0; animation: pulse 1.5s ease-in-out infinite; }
.progress-title-item span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.progress-title-item.completed .dot { background: var(--success); animation: none; }
.progress-completed-header { display: flex; align-items: center; gap: 6px; margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border); color: var(--success); font-size: 12px; font-weight: 600; }
.progress-completed-header .completed-dot { width: 6px; height: 6px; background: var(--success); border-radius: 50%; flex-shrink: 0; }
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .4 } }
.progress-panel-close { background: none; border: none; color: var(--text3); cursor: pointer; font-size: 16px; line-height: 1; padding: 2px; margin-left: auto; border-radius: 4px; transition: color .15s; }
.progress-panel-close:hover { color: var(--text); }
.progress-bar {
  position: fixed; left: 0; bottom: 24px; z-index: 30;
  width: 32px; height: 40px;
  --progress-icon-color: #111;
  --progress-fill-color: rgba(60,60,60,0.55);
  background: rgba(255,255,255,0.14);
  border: 1px solid rgba(150,150,150,0.24);
  border-left: none;
  border-radius: 0 10px 10px 0;
  cursor: pointer;
  transition: transform 0.55s cubic-bezier(0.175, 0.885, 0.32, 1.275), background 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
  transform: translateX(-120%);
  transform-origin: left center;
  pointer-events: none;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.08) inset,
    0 2px 6px rgba(0,0,0,0.08),
    0 0 16px rgba(150,150,150,0.08),
    0 0 32px rgba(150,150,150,0.03);
  display: flex;
  align-items: center;
  justify-content: center;
}
.progress-bar.show { transform: translateX(-2px); pointer-events: auto; }
.progress-bar:hover {
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.18) inset,
    0 6px 16px rgba(0,0,0,0.15),
    0 0 32px rgba(150,150,150,0.2),
    0 0 64px rgba(150,150,150,0.08);
}
.flask-fill { transform: translateY(0); transition: transform 1.2s cubic-bezier(0.4, 0, 0.2, 1); }
.progress-bar:hover .flask-fill { transform: translateY(-24px) !important; }
.progress-bar:active {
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.22) inset,
    0 8px 20px rgba(0,0,0,0.18),
    0 0 40px rgba(150,150,150,0.25),
    0 0 80px rgba(150,150,150,0.1);
}
.progress-bar.pulsing {
  --progress-fill-color: rgba(37,99,235,0.55);
  animation: barPulse 2.2s ease-in-out infinite;
  background: rgba(37,99,235,0.52);
  border-color: rgba(37,99,235,0.44);
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.08) inset,
    0 2px 6px rgba(0,0,0,0.08),
    0 0 16px rgba(37,99,235,0.12),
    0 0 32px rgba(37,99,235,0.05);
}
.progress-bar.pulsing:hover {
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.18) inset,
    0 6px 16px rgba(0,0,0,0.15),
    0 0 32px rgba(37,99,235,0.3),
    0 0 64px rgba(37,99,235,0.12);
}
.progress-bar.pulsing:active {
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.22) inset,
    0 8px 20px rgba(0,0,0,0.18),
    0 0 40px rgba(37,99,235,0.35),
    0 0 80px rgba(37,99,235,0.15);
}
@media (max-width: 640px) {
  .progress-bar { width: 36px; height: 48px; border-radius: 0 12px 12px 0; }
  .progress-bar:hover { box-shadow: 0 0 0 1px rgba(255,255,255,0.18) inset, 0 6px 16px rgba(0,0,0,0.15), 0 0 32px rgba(150,150,150,0.2), 0 0 64px rgba(150,150,150,0.08); }
  .progress-bar:active { box-shadow: 0 0 0 1px rgba(255,255,255,0.22) inset, 0 8px 20px rgba(0,0,0,0.18), 0 0 40px rgba(150,150,150,0.25), 0 0 80px rgba(150,150,150,0.1); }
  .progress-bar.pulsing:hover { box-shadow: 0 0 0 1px rgba(255,255,255,0.18) inset, 0 6px 16px rgba(0,0,0,0.15), 0 0 32px rgba(37,99,235,0.3), 0 0 64px rgba(37,99,235,0.12); }
  .progress-bar.pulsing:active { box-shadow: 0 0 0 1px rgba(255,255,255,0.22) inset, 0 8px 20px rgba(0,0,0,0.18), 0 0 40px rgba(37,99,235,0.35), 0 0 80px rgba(37,99,235,0.15); }
}
.progress-bar.done {
  --progress-fill-color: rgba(22,163,74,0.55);
  background: rgba(22,163,74,0.52);
  border-color: rgba(22,163,74,0.44);
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.08) inset,
    0 2px 6px rgba(0,0,0,0.08),
    0 0 16px rgba(22,163,74,0.12),
    0 0 32px rgba(22,163,74,0.05);
}
.progress-bar.done:hover {
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.18) inset,
    0 6px 16px rgba(0,0,0,0.15),
    0 0 32px rgba(22,163,74,0.3),
    0 0 64px rgba(22,163,74,0.12);
}
.progress-bar.done:active {
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.22) inset,
    0 8px 20px rgba(0,0,0,0.18),
    0 0 40px rgba(22,163,74,0.35),
    0 0 80px rgba(22,163,74,0.15);
}
.progress-bar.idle {
  --progress-fill-color: rgba(60,60,60,0.55);
  background: rgba(255,255,255,0.14);
  border-color: rgba(150,150,150,0.24);
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.08) inset,
    0 2px 6px rgba(0,0,0,0.08),
    0 0 16px rgba(150,150,150,0.08),
    0 0 32px rgba(150,150,150,0.03);
}
.progress-bar.idle:hover {
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.18) inset,
    0 6px 16px rgba(0,0,0,0.15),
    0 0 32px rgba(150,150,150,0.2),
    0 0 64px rgba(150,150,150,0.08);
}
.progress-bar.idle:active {
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.22) inset,
    0 8px 20px rgba(0,0,0,0.18),
    0 0 40px rgba(150,150,150,0.25),
    0 0 80px rgba(150,150,150,0.1);
}
@keyframes barPulse { 0%, 100% { filter: brightness(1); } 50% { filter: brightness(1.35); } }
[data-theme="dark"] .filter-bar .filter-dropdown-menu {
  background: rgba(26,29,36,0.58); border-color: rgba(255,255,255,0.06);
  transition: box-shadow 0.3s ease;
}
[data-theme="dark"] .progress-bar {
  --progress-icon-color: #fff;
  --progress-fill-color: rgba(230,230,230,0.5);
  background: rgba(180,180,180,0.12);
  border-color: rgba(180,180,180,0.2);
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.05) inset,
    0 2px 6px rgba(0,0,0,0.16),
    0 0 16px rgba(180,180,180,0.08),
    0 0 32px rgba(180,180,180,0.03);
}
[data-theme="dark"] .progress-bar:hover {
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.12) inset,
    0 6px 16px rgba(0,0,0,0.25),
    0 0 32px rgba(180,180,180,0.2),
    0 0 64px rgba(180,180,180,0.08);
}
[data-theme="dark"] .progress-bar:active {
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.16) inset,
    0 8px 20px rgba(0,0,0,0.3),
    0 0 40px rgba(180,180,180,0.25),
    0 0 80px rgba(180,180,180,0.1);
}
[data-theme="dark"] .progress-bar.pulsing {
  --progress-fill-color: rgba(91,141,239,0.45);
  background: rgba(91,141,239,0.1);
  border-color: rgba(91,141,239,0.18);
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.06) inset,
    0 2px 6px rgba(0,0,0,0.16),
    0 0 16px rgba(91,141,239,0.12),
    0 0 32px rgba(91,141,239,0.05);
}
[data-theme="dark"] .progress-bar.pulsing:hover {
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.14) inset,
    0 6px 16px rgba(0,0,0,0.25),
    0 0 32px rgba(91,141,239,0.3),
    0 0 64px rgba(91,141,239,0.12);
}
[data-theme="dark"] .progress-bar.pulsing:active {
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.18) inset,
    0 8px 20px rgba(0,0,0,0.3),
    0 0 40px rgba(91,141,239,0.35),
    0 0 80px rgba(91,141,239,0.15);
}
[data-theme="dark"] .progress-bar.done {
  --progress-fill-color: rgba(34,197,94,0.45);
  background: rgba(34,197,94,0.1);
  border-color: rgba(34,197,94,0.18);
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.06) inset,
    0 2px 6px rgba(0,0,0,0.16),
    0 0 16px rgba(34,197,94,0.12),
    0 0 32px rgba(34,197,94,0.05);
}
[data-theme="dark"] .progress-bar.done:hover {
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.14) inset,
    0 6px 16px rgba(0,0,0,0.25),
    0 0 32px rgba(34,197,94,0.3),
    0 0 64px rgba(34,197,94,0.12);
}
[data-theme="dark"] .progress-bar.done:active {
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.18) inset,
    0 8px 20px rgba(0,0,0,0.3),
    0 0 40px rgba(34,197,94,0.35),
    0 0 80px rgba(34,197,94,0.15);
}
[data-theme="dark"] .progress-bar.idle {
  --progress-fill-color: rgba(230,230,230,0.5);
  background: rgba(180,180,180,0.12);
  border-color: rgba(180,180,180,0.2);
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.05) inset,
    0 2px 6px rgba(0,0,0,0.16),
    0 0 16px rgba(180,180,180,0.08),
    0 0 32px rgba(180,180,180,0.03);
}
[data-theme="dark"] .progress-bar.idle:hover {
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.12) inset,
    0 6px 16px rgba(0,0,0,0.25),
    0 0 32px rgba(180,180,180,0.2),
    0 0 64px rgba(180,180,180,0.08);
}
[data-theme="dark"] .progress-bar.idle:active {
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.16) inset,
    0 8px 20px rgba(0,0,0,0.3),
    0 0 40px rgba(180,180,180,0.25),
    0 0 80px rgba(180,180,180,0.1);
}
@media (max-width: 640px) {
  .insight-page.open { padding: 18px 16px; }
  .insight-page-header-inner h2 { font-size: 17px; }
  .insight-page-body blockquote,
  .insight-page-body blockquote:first-of-type { float: none; max-width: 100%; margin: 6px 0 10px 0; padding: 4px 0 4px 14px; margin-left: 0; text-align: left; border-left: 2px solid var(--border); border-right: none; }
  .insight-page-body img { max-width: 100%; border-radius: 6px; }
  .insight-page-close { width: 44px; height: 44px; font-size: 24px; }
  .insight-editor textarea { min-height: 60vh; font-size: 16px; padding: 14px; }
  .insight-editor-actions { position: sticky; bottom: 0; background: var(--card); padding: 10px 0; margin-top: 8px; border-top: 1px solid var(--border); }
  .insight-editor-actions button { flex: 1; justify-content: center; padding: 12px 16px; font-size: 15px; }
  .progress-panel { bottom: 10px; left: 10px; right: 10px; max-width: none; min-width: auto; }
  .search-bar input { font-size: 16px; }
}
.tags-page { display: none; }
.tags-page.open { display: block; }
.dates-page { display: none; }
.dates-page.open { display: block; }
.dates-layout { display: flex; gap: 24px; min-height: 60vh; }
.dates-sidebar { width: 240px; flex-shrink: 0; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; max-height: calc(100vh - 140px); overflow-y: auto; box-shadow: var(--shadow); }
.dates-sidebar-header { font-size: 14px; font-weight: 700; color: var(--text); margin-bottom: 12px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.date-tree-year { margin-bottom: 4px; }
.date-tree-year-label { display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-radius: 8px; cursor: pointer; font-size: 13px; font-weight: 600; color: var(--text); transition: background .15s; user-select: none; }
.date-tree-year-label:hover { background: var(--bg); }
.date-tree-year-label .arrow { font-size: 10px; color: var(--text3); transition: transform .2s; display: inline-block; width: 12px; }
.date-tree-year-label.open .arrow { transform: rotate(90deg); }
.date-tree-year-label .count { font-size: 11px; color: var(--text3); font-weight: 400; margin-left: auto; }
.date-tree-months { padding-left: 18px; display: none; }
.date-tree-months.open { display: block; }
.date-tree-month { margin-bottom: 2px; }
.date-tree-month-label { display: flex; align-items: center; gap: 6px; padding: 4px 8px; border-radius: 6px; cursor: pointer; font-size: 12px; font-weight: 500; color: var(--text2); transition: background .15s; user-select: none; }
.date-tree-month-label:hover { background: var(--bg); }
.date-tree-month-label .arrow { font-size: 9px; color: var(--text3); transition: transform .2s; display: inline-block; width: 10px; }
.date-tree-month-label.open .arrow { transform: rotate(90deg); }
.date-tree-month-label .count { font-size: 10px; color: var(--text3); font-weight: 400; margin-left: auto; }
.date-tree-days { padding-left: 16px; display: none; }
.date-tree-days.open { display: block; }
.date-tree-day { display: flex; align-items: center; gap: 6px; padding: 3px 8px; border-radius: 6px; cursor: pointer; font-size: 12px; color: var(--text3); transition: all .15s; }
.date-tree-day:hover { background: rgba(37,99,235,0.06); color: var(--accent); }
.date-tree-day.active { background: rgba(37,99,235,0.1); color: var(--accent); font-weight: 600; }
.date-tree-day .count { font-size: 10px; margin-left: auto; }
.dates-main { flex: 1; min-width: 0; }
.dates-main-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.dates-main-header h2 { font-size: 18px; font-weight: 600; color: var(--text); }
.dates-main-header .date-label { font-size: 13px; color: var(--text3); }
.dates-paper-list { display: flex; flex-direction: column; gap: 12px; }
.dates-paper-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); transition: all .15s; cursor: pointer; }
.dates-paper-card:hover { border-color: var(--accent); box-shadow: var(--shadow-lg); transform: translateY(-1px); }
.dates-paper-title { font-size: 15px; font-weight: 600; color: var(--text); line-height: 1.4; margin-bottom: 6px; }
.dates-paper-meta { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; font-size: 12px; color: var(--text3); }
.dates-paper-meta .score-badge-mini { display: inline-flex; align-items: center; justify-content: center; min-width: 24px; padding: 1px 6px; border-radius: 10px; font-size: 10px; font-weight: 700; color: #fff; }
.dates-paper-abstract { font-size: 13px; color: var(--text2); line-height: 1.7; }
.dates-empty { text-align: center; padding: 60px 0; color: var(--text3); font-size: 14px; }
@media (max-width: 640px) {
  .dates-layout { flex-direction: column; }
  .dates-sidebar { width: auto; max-height: 40vh; }
}
.tags-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; margin-top: 20px; }
.tag-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); transition: transform .1s, box-shadow .1s; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.tag-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.tag-card-left { min-width: 0; }
.tag-card-name { font-size: 16px; font-weight: 600; color: var(--accent); text-decoration: none; cursor: pointer; }
.tag-card-name:hover { text-decoration: underline; }
.tag-card-count { font-size: 13px; color: var(--text3); margin-top: 2px; }
.tag-card-actions { display: flex; gap: 8px; flex-shrink: 0; }
.tag-card-actions button { font-size: 12px; padding: 4px 10px; border-radius: 6px; border: 1px solid var(--border); background: var(--bg); color: var(--text2); cursor: pointer; }
.tag-card-actions button:hover { border-color: #dc2626; color: #dc2626; }
[data-theme="dark"] .tag-card-actions button { background: #1a1d24; }
.tags-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.tags-header h2 { font-size: 20px; font-weight: 600; }
.nav-links { display: flex; gap: 2px; align-items: center; }
.nav-link { padding: 4px 10px; font-size: 14px; color: var(--text3); text-decoration: none; border-radius: 6px; transition: all .15s; }
.nav-link:hover { color: var(--text); background: var(--bg); }
.nav-link.active { color: var(--accent); font-weight: 500; }
.tags-layout { display: flex; gap: 20px; }
.tags-main { flex: 1; min-width: 0; }
.orphan-drawer { position: fixed; top: 0; right: 0; bottom: 0; width: 600px; background: var(--card); border-left: 1px solid var(--border); box-shadow: var(--shadow-lg); z-index: 200; transform: translateX(100%); transition: transform .25s ease; display: flex; flex-direction: column; }
.orphan-drawer.open { transform: translateX(0); }
.orphan-drawer-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.orphan-drawer-header h3 { font-size: 16px; font-weight: 600; }
.orphan-drawer-close { background: none; border: none; font-size: 24px; color: var(--text3); cursor: pointer; line-height: 1; padding: 0; width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; border-radius: 6px; }
.orphan-drawer-close:hover { background: var(--bg); color: var(--text); }
.orphan-drawer-body { flex: 1; overflow-y: auto; padding: 16px 20px; }
.orphan-drawer-footer { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; gap: 10px; }
.orphan-drawer-footer button { flex: 1; font-size: 13px; padding: 8px 0; border-radius: 6px; border: 1px solid var(--border); background: var(--bg); color: var(--text2); cursor: pointer; }
.orphan-drawer-footer button.btn-danger { background: #dc2626; color: #fff; border-color: #dc2626; }
.orphan-drawer-footer button.btn-danger:hover { background: #b91c1c; }
.orphan-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.2); z-index: 199; opacity: 0; pointer-events: none; transition: opacity .25s ease; }
.orphan-overlay.open { opacity: 1; pointer-events: auto; }
.orphan-card { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; background: var(--bg); }
.orphan-card-header { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 8px; }
.orphan-card-header input[type="checkbox"] { margin-top: 4px; flex-shrink: 0; }
.orphan-card-title { font-size: 14px; font-weight: 600; color: var(--text); line-height: 1.5; flex: 1; cursor: pointer; }
.orphan-card-title:hover { color: var(--accent); }
.orphan-card-tags { font-size: 12px; color: var(--text3); margin-bottom: 6px; }
.orphan-card-tags .tag-link { margin-right: 8px; }
.orphan-card-abstract { font-size: 12.5px; color: var(--text2); line-height: 1.65; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.disinterest-tags-list { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.disinterest-tag-check, .neutral-tag-check { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); cursor: pointer; font-size: 12.5px; color: var(--text); user-select: none; }
.disinterest-tag-check:hover, .neutral-tag-check:hover { border-color: var(--accent); }
.disinterest-tag-check input[type="checkbox"], .neutral-tag-check input[type="checkbox"] { margin: 0; cursor: pointer; }
.disinterest-tag-count { color: var(--text3); font-size: 11px; }
.disinterest-tag-check { border-left: 3px solid #dc2626; }
.neutral-tag-check { opacity: 0.85; }
@media (max-width: 640px) {
  .orphan-drawer { width: 100%; }
  /* iOS Safari auto-zoom fix: all inputs must be >= 16px */
  .auth-panel input,
  .insight-dialog-toolbar input[type="text"],
  .insight-dialog-toolbar select,
  .field input,
  .field textarea { font-size: 16px; }
  /* Larger touch targets */
  .meta-link { padding: 4px 0; display: inline-block; min-height: 28px; }
  /* Remove tap highlight and disable double-tap zoom on interactive elements */
  button, a, .meta-link, .icon-btn, .paper-card, .insight-page-close,
  .filter-bar button, .filter-dropdown-btn, .tag-mini, .tag-cloud-item,
  .pagination button, .dates-paper-card, .tag-card, .related-item,
  .date-tree-year-label, .date-tree-month-label, .date-tree-day {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
  }
  /* Tables in insight body: force horizontal scroll when too wide */
  .insight-page-body table { display: block; overflow-x: auto; white-space: nowrap; }
}
