:root {
  color-scheme: light;
  --bg: #f5f5f5;
  --surface: #ffffff;
  --surface-soft: #ededed;
  --ink: #111111;
  --muted: #666666;
  --button: #111111;
  --button-hover: #2b2b2b;
  --button-ink: #ffffff;
  --line: rgba(0, 0, 0, 0.13);
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.08);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-width: 320px;
  min-height: 100dvh;
  color: var(--ink);
  background: var(--bg);
}
body.detail-open, body.import-open { overflow: hidden; }

button, input { font: inherit; }
button {
  color: var(--button-ink);
  background: var(--button);
}

.app-shell {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  max-width: 1680px;
  margin: 0 auto;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100dvh;
  padding: 34px 24px;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  background: rgba(245, 245, 245, 0.92);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  color: var(--button-ink);
  background: var(--button);
  font: 700 22px Georgia, serif;
}

.brand strong, .brand small { display: block; }
.brand strong { font: 700 19px Georgia, serif; letter-spacing: .02em; }
.brand small { margin-top: 2px; color: var(--muted); font-size: 11px; }

.nav-list { margin-top: 58px; display: grid; gap: 8px; }
.nav-item {
  border: 0;
  border-radius: 14px;
  padding: 13px 15px;
  color: var(--button-ink);
  background: var(--button);
  text-align: left;
  display: flex;
  gap: 13px;
  align-items: center;
  cursor: pointer;
}
.nav-item span { width: 24px; font-size: 20px; color: inherit; }
.nav-item:hover { background: var(--button-hover); }
.nav-item.active { background: #000000; color: #ffffff; box-shadow: 0 10px 28px rgba(0,0,0,.18); }
.nav-item.active span { color: inherit; }

.sidebar-note { margin-top: auto; padding: 15px; border-top: 1px solid var(--line); display: flex; gap: 10px; }
.settings-open { margin-top: 12px; border: 1px solid var(--line); border-radius: 11px; padding: 10px; color: var(--ink); background: var(--surface); cursor: pointer; font-size: 11px; font-weight: 700; }
.sidebar-note p { margin: 0; }
.sidebar-note strong, .sidebar-note small { display: block; }
.sidebar-note strong { font-size: 12px; }
.sidebar-note small { color: var(--muted); margin-top: 3px; font-size: 10px; }
.status-dot { width: 8px; height: 8px; margin-top: 4px; border-radius: 50%; background: #777777; box-shadow: 0 0 0 5px rgba(0,0,0,.08); }

.main-content { min-width: 0; padding: 52px clamp(28px, 5vw, 76px) 80px; }
.mobile-header { display: none; }

.search-hero {
  width: min(100%, 700px);
  padding: 0;
}
.search-hero[hidden] { display: none; }
.search-intent-feedback { margin-top: 7px; display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 10px; }
.search-intent-feedback[hidden] { display: none; }
.search-intent-feedback button { min-height: 27px; padding: 0 9px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); cursor: pointer; font-size: 9px; font-weight: 700; }
.search-scope-row { margin-top: 10px; display: flex; align-items: center; gap: 10px; }
.search-correction { margin-top: 9px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-soft); }
.search-correction[hidden] { display: none; }
.search-correction > strong { display: block; color: var(--ink); font-size: 11px; }
.search-correction label { display: grid; gap: 5px; color: var(--muted); font-size: 9px; font-weight: 700; }
.search-correction > small { display: block; margin: 6px 0; color: var(--muted); font-size: 9px; line-height: 1.45; }
.search-correction-fields { margin-top: 9px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.search-correction input, .search-correction select { width: 100%; min-width: 0; height: 34px; padding: 0 9px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); background: var(--surface); outline: none; font: inherit; }
.search-correction input:focus, .search-correction select:focus { border-color: var(--ink); box-shadow: 0 0 0 2px rgba(0, 0, 0, .07); }
.search-correction-actions { display: flex; justify-content: flex-end; gap: 7px; }
.search-correction button { border: 1px solid var(--button); border-radius: 9px; padding: 8px 11px; color: var(--button-ink); background: var(--button); cursor: pointer; font-size: 10px; font-weight: 700; }
.search-correction button.secondary { border-color: var(--line); color: var(--ink); background: var(--surface); }
.search-scope { width: fit-content; flex: 0 0 auto; padding: 3px; border: 1px solid var(--line); border-radius: 10px; display: flex; gap: 2px; background: var(--surface-soft); }
.search-scope button { min-height: 30px; padding: 0 11px; border: 0; border-radius: 7px; color: var(--muted); background: transparent; cursor: pointer; font-size: 10px; font-weight: 700; }
.search-scope button.active { color: #ffffff; background: #111111; }
.search-progress { margin-top: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; display: flex; align-items: center; gap: 10px; color: var(--muted); background: var(--surface-soft); }
.search-progress[hidden] { display: none; }
.search-progress-pulse { width: 9px; height: 9px; flex: 0 0 auto; border-radius: 50%; background: var(--ink); animation: search-pulse 1.25s ease-in-out infinite; }
.search-progress-copy { min-width: 0; display: grid; gap: 2px; }
.search-progress-copy strong { color: var(--ink); font-size: 11px; font-weight: 750; }
.search-progress-copy small { font-size: 10px; line-height: 1.35; }
@keyframes search-pulse { 0%, 100% { opacity: .3; transform: scale(.8); } 50% { opacity: 1; transform: scale(1.15); } }
.eyebrow { margin: 0 0 10px; color: #777777; font-size: 10px; font-weight: 800; letter-spacing: .18em; }
h1, h2 { font-family: Georgia, "Times New Roman", serif; }
h1 { margin: 0; max-width: 680px; font-size: clamp(30px, 4vw, 46px); line-height: 1; letter-spacing: -.035em; }
.hero-copy { max-width: 620px; margin: 20px 0 26px; color: var(--muted); line-height: 1.7; }

.search-box {
  --search-control-height: 42px;
  height: 54px;
  padding: 6px 6px 6px 14px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.search-box input { width: 100%; min-width: 0; height: var(--search-control-height); padding: 0; border: 0; outline: 0; appearance: none; -webkit-appearance: none; background: transparent; color: var(--ink); line-height: var(--search-control-height); }
.search-box input::-webkit-search-decoration { display: none; }
.search-box button {
  min-height: var(--search-control-height);
  border: 0;
  border-radius: 14px;
  padding: 11px 18px;
  color: var(--button-ink);
  background: var(--button);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}
.search-box button:disabled { cursor: wait; opacity: .72; }
.ai-search-control { position: relative; margin-left: auto; display: inline-flex; }
.ai-search-action { min-width: 48px; min-height: 32px; padding: 0 14px; border: 1px solid #111111; border-radius: 9px; color: #ffffff; background: #111111; cursor: pointer; font-size: 13px; font-weight: 800; }
.ai-search-action[aria-pressed="true"] { color: #111111; background: #ffffff; }
.ai-search-action:hover { color: #ffffff; background: #2b2b2b; }
.ai-search-action[aria-pressed="true"]:hover { color: #111111; background: #f3f3f3; }
.ai-search-action:disabled { cursor: wait; opacity: .6; }
.ai-search-hint { position: absolute; z-index: 5; top: calc(100% + 7px); right: 0; width: max-content; max-width: min(280px, calc(100vw - 32px)); padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; color: #111111; background: #ffffff; box-shadow: 0 8px 22px rgba(0, 0, 0, .12); font-size: 11px; font-weight: 650; line-height: 1.35; text-align: right; animation: ai-hint-in .18s ease-out; }
@keyframes ai-hint-in { from { opacity: 0; transform: translateX(5px); } to { opacity: 1; transform: translateX(0); } }

.search-fallback-note { margin: 9px 2px 0; color: var(--muted); font-size: 11px; }

.suggestions { display: grid; gap: 9px; margin-top: 13px; }
.suggestions[hidden] { display: none; }
.suggestion-group { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.suggestion-group-name { min-width: 58px; color: var(--muted); font-size: 10px; font-weight: 700; }
.search-utility-row { display: flex; align-items: center; justify-content: flex-end; gap: 10px; min-height: 36px; margin-top: 8px; }
.library-document-count { display: flex; align-items: center; justify-content: flex-end; gap: 7px; min-height: 25px; color: var(--muted); font-size: 11px; font-weight: 650; }

/* —— 每日推荐卡片 —— 复用 paper-card 样式，仅做少量覆盖 */
.daily-recommend {
  width: 100%;
  max-width: none;
  min-height: 360px;
  margin: 18px auto 0;
}
.daily-recommend[hidden] { display: none; }
.daily-card-meta { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; }
.daily-card-meta strong { color: var(--ink); text-align: center; font-size: 12px; }
.daily-card-meta .paper-open-hint { text-align: right; }
.daily-keyword-current { margin-top: 14px; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 9px; align-items: baseline; font-size: 14px; }
.daily-keyword-current strong { color: var(--ink); }
.daily-keyword-current span { color: var(--muted); overflow-wrap: anywhere; }
.daily-keyword-editor { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 9px; margin-top: 9px; color: var(--muted); font-size: 14px; }
.daily-keyword-editor label { color: var(--ink); font-weight: 700; }
.daily-keyword-editor input { min-width: 0; border: 1px solid var(--line); border-radius: 9px; padding: 9px 10px; color: var(--ink); background: var(--surface); font: inherit; }
.daily-keyword-editor button { border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; color: var(--button-ink); background: var(--button); font: inherit; font-size: 12px; cursor: pointer; }
.daily-keyword-help { max-height: 0; margin: 0; overflow: hidden; visibility: hidden; opacity: 0; color: var(--muted); font-size: 11px; line-height: 1.45; transition: opacity .15s ease, max-height .15s ease, margin .15s ease; }
.daily-keyword-editor:focus-within + .daily-keyword-help { max-height: 40px; margin-top: 7px; visibility: visible; opacity: 1; }

.import-complete-note { color: #606060; }
.suggestions button, .tag {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 11px;
  background: var(--button);
  color: var(--button-ink);
  font-size: 11px;
  cursor: pointer;
}

.import-layer { position: fixed; inset: 0; z-index: 110; display: grid; place-items: center; padding: 24px; pointer-events: none; visibility: hidden; }
.import-layer.open { pointer-events: auto; visibility: visible; }
.import-backdrop { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; border-radius: 0; padding: 0; background: rgba(0,0,0,.58); opacity: 0; transition: opacity .2s ease; cursor: default; }
.import-layer.open .import-backdrop { opacity: 1; }
.import-dialog { position: relative; width: min(720px, 100%); max-height: min(760px, calc(100dvh - 48px)); overflow-y: auto; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 25px; box-shadow: 0 28px 90px rgba(0,0,0,.28); transform: translateY(18px) scale(.98); opacity: 0; transition: transform .22s ease, opacity .18s ease; outline: none; }
.import-layer.open .import-dialog { transform: translateY(0) scale(1); opacity: 1; }
.settings-layer { position: fixed; inset: 0; z-index: 115; display: grid; place-items: center; padding: 24px; pointer-events: none; visibility: hidden; }
.settings-layer.open { pointer-events: auto; visibility: visible; }
.settings-backdrop { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: rgba(0,0,0,.58); }
.settings-dialog { position: relative; width: min(520px, 100%); padding: 24px; border-radius: 22px; color: var(--ink); background: var(--surface); box-shadow: 0 28px 90px rgba(0,0,0,.28); outline: none; }
.settings-dialog header { display: flex; align-items: start; justify-content: space-between; gap: 16px; }
.settings-dialog header h2 { margin: 0; font-size: 28px; }
.settings-dialog header button { border: 0; border-radius: 50%; width: 32px; height: 32px; font-size: 22px; cursor: pointer; }
.settings-dialog > p { color: var(--muted); font-size: 12px; line-height: 1.5; }
.settings-checks { display: grid; gap: 9px; }
.settings-check { padding: 12px; border: 1px solid var(--line); border-radius: 12px; display: grid; gap: 4px; }
.settings-check strong { font-size: 12px; }
.settings-check span { color: var(--muted); font-size: 11px; }
.settings-check.ready { border-left: 4px solid #4d9c76; }
.settings-check.warning { border-left: 4px solid #c78332; }
.settings-check.optional { border-left: 4px solid #888; }
.import-header { position: sticky; top: 0; z-index: 1; padding: 24px 26px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; background: var(--surface); }
.import-header h2 { margin: 0; font-size: 28px; }
.import-close { width: 38px; height: 38px; padding: 0; border: 0; border-radius: 50%; color: #ffffff; background: #111111; cursor: pointer; font-size: 24px; line-height: 1; }
.import-panel { padding: 24px 26px 28px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 18px 22px; }
.import-copy > p { max-width: 500px; margin: 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.import-actions { display: flex; align-items: start; gap: 8px; }
.import-actions button, .import-job-action button, .import-job-action a { min-height: 38px; padding: 0 13px; border: 0; border-radius: 11px; color: #ffffff; background: #111111; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; white-space: nowrap; }
.import-actions button:hover, .import-job-action button:hover, .import-job-action a:hover { background: #2b2b2b; }
.import-job-action button:disabled { opacity: .5; cursor: wait; }
.drop-zone { grid-column: 1 / -1; min-height: 112px; padding: 20px; border: 1px dashed #777777; border-radius: 17px; display: grid; place-items: center; align-content: center; gap: 4px; color: var(--muted); background: var(--surface-soft); cursor: pointer; transition: border-color .15s ease, transform .15s ease; }
.drop-zone:hover, .drop-zone.dragging { border-color: var(--ink); transform: translateY(-1px); }
.drop-zone:focus-visible { outline: 3px solid #111111; outline-offset: 3px; }
.drop-zone span { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; color: #ffffff; background: #111111; font-size: 19px; }
.drop-zone strong { color: var(--ink); font-size: 13px; }
.drop-zone small { font-size: 10px; }
.import-jobs { grid-column: 1 / -1; display: grid; gap: 8px; }
.import-jobs:empty { display: none; }
.import-summary { min-width: 0; padding: 13px 14px; border: 1px solid var(--line); border-radius: 14px; display: grid; grid-template-columns: minmax(0, 1fr) minmax(90px, 170px) auto; align-items: center; gap: 12px; background: var(--surface); }
.import-summary-copy { min-width: 0; display: grid; gap: 4px; }
.import-summary-copy strong { font-size: 12px; }
.import-summary-copy span { color: var(--muted); font-size: 9px; }
.import-toggle { min-height: 34px; padding: 0 12px; border: 0; border-radius: 10px; color: #ffffff; background: #111111; cursor: pointer; font-size: 10px; font-weight: 700; }
.import-summary .import-toggle { grid-column: 3; }
.import-toggle:hover { background: #2b2b2b; }
.import-job-details { display: grid; gap: 8px; }
.import-job { min-width: 0; padding: 11px 12px; border: 1px solid var(--line); border-radius: 13px; display: grid; grid-template-columns: minmax(0, 1fr) minmax(80px, 150px) auto; align-items: center; gap: 12px; background: var(--surface); }
.import-job-copy { min-width: 0; display: grid; gap: 3px; }
.import-job-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
.import-job-copy span, .import-job-copy small { color: var(--muted); font-size: 9px; }
.import-job-copy .import-error { color: var(--ink); overflow-wrap: anywhere; white-space: normal; }
.import-progress { height: 5px; overflow: hidden; border-radius: 999px; background: var(--surface-soft); }
.import-progress i { height: 100%; display: block; border-radius: inherit; background: #111111; transition: width .2s ease; }
.import-job-action { min-width: 42px; display: flex; justify-content: flex-end; color: var(--muted); font-size: 10px; }
.import-completed .import-progress i { background: #555555; }
.import-failed .import-progress i { background: #999999; }

.collection { margin-top: 0; }
.search-hero:not([hidden]) + .collection { margin-top: 36px; }
.section-heading { display: flex; justify-content: space-between; align-items: end; margin-bottom: 20px; }
.section-heading h2 { margin: 0; font-size: 30px; }
.collection-tools { display: flex; align-items: center; gap: 10px; }
.import-open { min-height: 36px; padding: 0 13px; border: 0; border-radius: 11px; color: #ffffff; background: #111111; cursor: pointer; font-size: 11px; font-weight: 800; letter-spacing: .03em; }
.import-open:hover { background: #2b2b2b; }
.result-count { color: var(--muted); font-size: 12px; }
.load-more { min-height: 40px; margin: 20px auto 0; padding: 0 22px; border: 0; border-radius: 12px; display: block; color: var(--button-ink); background: var(--button); cursor: pointer; font-size: 11px; font-weight: 750; }
.load-more[hidden] { display: none; }
.load-more:disabled { opacity: .55; cursor: wait; }
.paper-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 310px), 1fr));
  gap: 18px;
  padding: 8px 0 28px;
  margin: -8px 0 -28px;
  align-items: stretch;
  isolation: isolate;
}

.paper-grid.search-results {
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  padding: 0;
  margin: 0;
}
.search-result {
  min-width: 0;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 15px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 9px 18px;
  background: var(--surface);
  cursor: pointer;
  transition: border-color .15s ease, transform .15s ease;
}
.search-result:hover { border-color: var(--ink); transform: translateY(-1px); }
.search-result:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
.search-result h3 { margin: 0; font: 700 16px/1.35 Georgia, serif; }
.search-result-meta { align-self: start; display: flex; gap: 7px; color: var(--muted); font-size: 11px; white-space: nowrap; }
.search-result-tags { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 5px; }
.search-result-tags .tag { padding: 4px 7px; font-size: 9px; }
.external-search-result { cursor: pointer; }
.external-result-abstract { grid-column: 1 / -1; margin: 0; color: var(--muted); font-size: 11px; line-height: 1.55; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.source-tag { background: var(--surface-soft); }
.preference-tag { border-color: var(--ink); }

.paper-card {
  --card-lift: 0px;
  min-width: 0;
  min-height: 360px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 24px;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  box-shadow: 0 12px 35px rgba(0,0,0,.05);
  transform: translateY(var(--card-lift));
  transition: transform .15s ease, box-shadow .18s ease;
  cursor: pointer;
}
.paper-card button, .paper-card a { cursor: pointer; }
.paper-card:hover { --card-lift: -3px; box-shadow: var(--shadow); }
.paper-card:focus-visible { outline: 3px solid #111111; outline-offset: 3px; }
.paper-meta { display: flex; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 11px; }
.paper-open-hint { color: var(--ink); font-weight: 700; }
.paper-card h3 { margin: 18px 0 12px; font: 700 21px/1.25 Georgia, serif; }
.sync-status { margin-top: 13px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 11px; display: flex; align-items: center; gap: 10px; background: var(--surface-soft); color: var(--muted); font-size: 10px; }
.sync-label { display: flex; align-items: center; gap: 7px; min-width: 0; }
.sync-dot { width: 7px; height: 7px; flex: 0 0 auto; border-radius: 50%; background: #777777; }
.sync-pending .sync-dot, .sync-syncing .sync-dot { animation: sync-pulse 1.2s ease-in-out infinite; }
.sync-failed { border-color: #777777; color: var(--ink); }
.sync-failed .sync-dot { background: #111111; box-shadow: 0 0 0 3px rgba(0,0,0,.12); }
.sync-retry { margin-left: auto; flex: 0 0 auto; border: 0; border-radius: 8px; padding: 6px 9px; color: #ffffff; background: #111111; cursor: pointer; font-size: 10px; }
.sync-retry:disabled { opacity: .5; cursor: wait; }
.sync-error { width: 100%; margin: 4px 0 0; color: var(--muted); line-height: 1.5; overflow-wrap: anywhere; }
@keyframes sync-pulse { 50% { opacity: .25; transform: scale(.75); } }
.paper-abstract { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.65; display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden; }
.paper-tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 18px 0; }
.tag { cursor: default; padding: 5px 8px; background: #2b2b2b; border: 0; color: #ffffff; }
.paper-actions { margin-top: auto; min-width: 0; padding-top: 15px; border-top: 1px solid var(--line); display: flex; flex-wrap: nowrap; align-items: center; gap: 6px; }
.paper-actions button, .paper-actions a { min-width: 42px; min-height: 42px; border: 0; border-radius: 12px; display: grid; place-items: center; color: var(--button-ink); text-decoration: none; background: var(--button); cursor: pointer; }
.paper-actions button:hover, .paper-actions a:hover { background: var(--button-hover); }
.paper-actions button:disabled { cursor: wait; opacity: .45; }
.paper-card[aria-busy="true"] { opacity: .78; }
.paper-actions .primary { min-width: 50px; margin-left: auto; padding: 0 10px; color: var(--button-ink); background: var(--button); font-size: 12px; }
.empty-card { grid-column: 1 / -1; min-height: 250px; align-items: center; justify-content: center; text-align: center; transform: none; opacity: 1; }
.empty-card span { font-size: 36px; }
.empty-card p { color: var(--muted); max-width: 360px; }

.skeleton { background: linear-gradient(110deg, #e5e5e5 8%, #f7f7f7 18%, #e5e5e5 33%); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
@keyframes shimmer { to { background-position-x: -200%; } }

.bottom-nav { display: none; }
.detail-layer { position: fixed; inset: 0; z-index: 100; pointer-events: none; visibility: hidden; }
.detail-layer.open { pointer-events: auto; visibility: visible; }
.detail-backdrop { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; border-radius: 0; padding: 0; background: rgba(0,0,0,.42); opacity: 0; transition: opacity .24s ease; cursor: default; }
.detail-layer.open .detail-backdrop { opacity: 1; }
.detail-panel { position: absolute; top: 0; right: 0; width: min(560px, 100%); height: 100%; padding: 26px 30px max(32px, env(safe-area-inset-bottom)); overflow-y: auto; color: var(--ink); background: var(--surface); border-left: 1px solid var(--line); box-shadow: -24px 0 70px rgba(0,0,0,.17); transform: translateX(102%); transition: transform .28s cubic-bezier(.22,.75,.25,1); outline: none; }
.detail-layer.open .detail-panel { transform: translateX(0); }
.detail-handle { display: none; }
.detail-header { position: sticky; top: -26px; z-index: 1; margin: -26px -30px 24px; padding: 26px 30px 14px; display: flex; align-items: center; justify-content: space-between; background: var(--surface); border-bottom: 1px solid var(--line); }
.detail-header .eyebrow { margin: 0; }
.detail-close { width: 38px; height: 38px; border: 0; border-radius: 50%; display: grid; place-items: center; color: #ffffff; background: #111111; cursor: pointer; font-size: 25px; line-height: 1; }
.detail-loading { min-height: 300px; display: grid; place-items: center; color: var(--muted); font-size: 13px; }
.detail-title { margin: 0 0 18px; font: 700 clamp(29px, 4vw, 40px)/1.08 Georgia, serif; letter-spacing: -.025em; }
.detail-content > .sync-status { margin: 0 0 24px; flex-wrap: wrap; }
.detail-facts { margin: 0 0 30px; border-top: 1px solid var(--line); }
.detail-row { padding: 11px 0; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 16px; font-size: 12px; }
.detail-row dt { color: var(--muted); }
.detail-row dd { margin: 0; overflow-wrap: anywhere; }
.detail-section-title { margin: 30px 0 12px; font: 700 17px Georgia, serif; }
.detail-tags { display: flex; flex-wrap: wrap; gap: 7px; }
.tag-editor { min-height: 32px; align-items: center; }
.editable-tag { padding: 0 4px 0 0; display: inline-flex; align-items: center; gap: 2px; }
.tag-edit { min-height: 30px; padding: 5px 5px 5px 8px; border: 0; color: #ffffff; background: transparent; cursor: text; }
.tag-remove { width: 0; height: 22px; padding: 0; border: 0; border-radius: 50%; overflow: hidden; opacity: 0; color: #ffffff; background: #000000; cursor: pointer; font-size: 16px; line-height: 1; transition: width .15s ease, opacity .15s ease; }
.editable-tag:hover .tag-remove, .editable-tag:focus-within .tag-remove { width: 22px; opacity: 1; }
.tag-add, .tag-confirm { width: 32px; height: 32px; padding: 0; border: 0; border-radius: 50%; color: #ffffff; background: #111111; cursor: pointer; font-size: 20px; line-height: 1; }
.tag-inline-form { display: inline-grid; grid-template-columns: minmax(110px, 180px) 32px; gap: 6px; }
.tag-inline-form input { min-width: 0; height: 32px; padding: 0 9px; border: 1px solid #555555; border-radius: 10px; color: var(--ink); background: var(--surface); outline: none; }
.tag-remove:disabled, .tag-add:disabled, .tag-confirm:disabled { opacity: .5; cursor: wait; }
.tag-suggestion-panel { margin-top: 18px; padding: 0 14px 8px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-soft); }
.tag-suggestion-panel .detail-section-title { margin-top: 14px; }
.tag-suggestion-intro { margin: -4px 0 10px; color: var(--muted); font-size: 12px; line-height: 1.55; }
.tag-suggestion-row { padding: 10px 0; border-top: 1px solid var(--line); display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: center; }
.tag-suggestion-copy { min-width: 0; display: grid; gap: 3px; font-size: 12px; }
.tag-suggestion-copy strong, .tag-suggestion-copy small { overflow-wrap: anywhere; }
.tag-suggestion-copy small { color: var(--muted); }
.tag-suggestion-actions { display: flex; gap: 6px; }
.tag-suggestion-actions button { min-height: 32px; padding: 0 10px; border: 1px solid #111111; border-radius: 10px; cursor: pointer; font-size: 12px; font-weight: 700; }
.tag-suggestion-reject { color: #111111; background: transparent; }
.tag-suggestion-actions button:disabled { opacity: .5; cursor: wait; }
.detail-abstract { margin: 0; color: var(--ink); font-size: 14px; line-height: 1.85; white-space: pre-wrap; }
.detail-abstract.original { color: var(--muted); }
.rating-summary-button { width: 100%; min-height: 42px; margin-top: 26px; border: 1px solid var(--line); border-radius: 12px; color: var(--ink); background: var(--surface-soft); cursor: pointer; font-size: 13px; font-weight: 700; }
.rating-sheet-layer { position: fixed; inset: 0; z-index: 150; display: flex; align-items: flex-end; justify-content: center; padding: 16px; background: rgba(0, 0, 0, .42); }
.rating-sheet { width: min(620px, 100%); max-height: min(80dvh, 720px); overflow-y: auto; padding: 18px; border-radius: 20px 20px 14px 14px; color: var(--ink); background: var(--surface); box-shadow: 0 -12px 38px rgba(0, 0, 0, .2); outline: none; }
.rating-sheet-header { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.rating-sheet-header h2 { margin: 0; font: 700 20px Georgia, serif; }
.rating-sheet-close { min-height: 34px; padding: 0 10px; border: 1px solid var(--line); border-radius: 9px; color: var(--ink); background: var(--surface-soft); cursor: pointer; font-size: 12px; font-weight: 700; }
.rating-sheet-intro, .rating-sheet-summary { margin: 12px 0; color: var(--muted); font-size: 12px; line-height: 1.55; white-space: pre-line; }
.rating-sheet-summary { color: var(--ink); font-weight: 650; }
.rating-sheet-error { color: #9d1c1c; }
.rating-form { display: grid; gap: 8px; }
.rating-field { display: grid; grid-template-columns: minmax(0, 1fr) 96px; gap: 10px; align-items: center; font-size: 13px; font-weight: 650; }
.rating-field select { min-height: 36px; padding: 0 8px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); background: var(--surface); font: inherit; font-weight: 500; }
.rating-save { min-height: 40px; margin-top: 4px; border: 0; border-radius: 11px; color: #ffffff; background: #111111; cursor: pointer; font-size: 13px; font-weight: 700; }
.rating-save:disabled { opacity: .55; cursor: wait; }
.rating-import { width: 100%; min-height: 40px; margin-top: 10px; border: 1px solid var(--line); border-radius: 11px; color: var(--ink); background: var(--surface-soft); cursor: pointer; font-size: 13px; font-weight: 700; }
.rating-import:disabled { opacity: .55; cursor: wait; }
.detail-note { margin: 0; padding: 12px; border-radius: 12px; color: var(--muted); background: var(--surface-soft); font-size: 12px; line-height: 1.65; }
.inbox-hint { margin: 10px 0 0; padding: 9px 11px; border-left: 3px solid #111111; color: #444444; background: var(--surface-soft); font-size: 12px; line-height: 1.55; }
.inbox-guidance { margin: 22px 0 8px; padding: 0 16px 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-soft); }
.inbox-guidance .detail-section-title { margin-top: 16px; }
.inbox-guidance-intro { margin: 0 0 12px; color: var(--muted); font-size: 12px; line-height: 1.65; }
.inbox-reason-list { margin: 0; padding: 0; display: grid; gap: 9px; list-style: none; }
.inbox-reason-list li { padding-top: 9px; border-top: 1px solid var(--line); display: grid; gap: 3px; font-size: 12px; line-height: 1.55; }
.inbox-reason-list span { color: var(--muted); }
.inbox-retry { min-height: 40px; margin-top: 14px; padding: 0 15px; border: 0; border-radius: 12px; cursor: pointer; font-weight: 700; }
.inbox-retry:disabled { opacity: .55; cursor: wait; }
.detail-pdf-actions { width: 100%; margin-top: 32px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.detail-pdf { min-width: 0; min-height: 48px; padding: 0 14px; border: 1px solid #111111; border-radius: 14px; display: flex; align-items: center; justify-content: center; color: #ffffff; background: #111111; text-align: center; text-decoration: none; font-size: 13px; font-weight: 700; }
.detail-pdf.secondary { color: var(--ink); background: var(--surface); }
.toast { position: fixed; left: 50%; bottom: 30px; z-index: 120; transform: translate(-50%, 20px); padding: 11px 16px; border-radius: 12px; color: #ffffff; background: #000000; opacity: 0; pointer-events: none; transition: .2s ease; font-size: 12px; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 1199px) {
  .app-shell { grid-template-columns: 210px minmax(0, 1fr); }
}

@media (max-width: 767px) {
  .app-shell { display: block; padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
  .sidebar { display: none; }
  .main-content { padding: 0 16px 30px; }
  .mobile-header { height: 72px; display: flex; align-items: center; justify-content: space-between; }
  .mobile-header .brand-mark { width: 36px; height: 36px; border-radius: 12px; font-size: 18px; }
  .mobile-header .brand strong { font-size: 17px; }
  .avatar { width: 36px; height: 36px; border: 0; border-radius: 50%; color: #ffffff; background: #111111; }
  .search-hero { padding: 8px 0 0; }
  .hero-copy { margin: 16px 0 22px; font-size: 13px; }
  .search-box { --search-control-height: 38px; height: 50px; padding-left: 12px; border-radius: 16px; }
  .search-box button { padding: 9px 12px; }
  .search-scope-row { flex-wrap: wrap; gap: 6px; }
  .search-correction-fields { grid-template-columns: 1fr; }
  .import-layer { padding: 0; place-items: end center; }
  .import-dialog { width: 100%; max-height: min(88dvh, 820px); border-radius: 24px 24px 0 0; transform: translateY(102%); opacity: 1; }
.import-layer.open .import-dialog { transform: translateY(0); }
  .import-header { padding: 20px 20px 14px; border-radius: 24px 24px 0 0; }
  .import-header h2 { font-size: 25px; }
  .import-panel { padding: 18px 20px max(24px, env(safe-area-inset-bottom)); grid-template-columns: 1fr; }
  .import-actions { grid-row: 2; }
  .import-actions button { flex: 1; }
  .drop-zone { grid-column: 1; min-height: 98px; }
  .import-jobs { grid-column: 1; }
  .import-summary { grid-template-columns: minmax(0, 1fr) auto; }
  .import-summary .import-progress { grid-column: 1 / -1; grid-row: 2; }
  .import-summary .import-toggle { grid-column: 2; grid-row: 1; }
  .import-job { grid-template-columns: minmax(0, 1fr) auto; }
  .import-progress { grid-column: 1 / -1; grid-row: 2; }
  .import-job-action { grid-column: 2; grid-row: 1; }
  .collection { margin-top: 8px; }
  .search-hero:not([hidden]) + .collection { margin-top: 28px; }
  .paper-grid { grid-template-columns: minmax(0, 1fr); gap: 12px; padding: 8px 0 24px; margin: -8px 0 -24px; }
  .paper-card { min-height: min(520px, calc(100dvh - 170px)); border-radius: 22px; }
  .paper-abstract { -webkit-line-clamp: 7; }
  .search-result { padding: 13px 14px; grid-template-columns: 1fr; gap: 7px; }
  .search-result-meta { grid-row: 2; }
  .search-result-tags { grid-row: 3; }
  .detail-panel { top: auto; bottom: 0; width: 100%; height: min(86dvh, 820px); padding: 16px 20px max(24px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); border-left: 0; border-radius: 24px 24px 0 0; transform: translateY(102%); }
  .detail-layer.open .detail-panel { transform: translateY(0); }
  .detail-handle { width: 42px; height: 4px; margin: -5px auto 12px; border-radius: 999px; display: block; background: #999999; }
  .detail-header { top: -16px; margin: -16px -20px 20px; padding: 20px 20px 12px; border-radius: 24px 24px 0 0; }
  .detail-title { font-size: 29px; }
  .detail-row { grid-template-columns: 92px minmax(0, 1fr); }
  .editable-tag .tag-remove { width: 22px; opacity: 1; }
  .bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 5;
    min-height: 66px;
    padding: 8px max(12px, env(safe-area-inset-left)) calc(8px + env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-right));
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    border-top: 1px solid var(--line);
    background: rgba(0,0,0,.94);
    backdrop-filter: blur(20px);
  }
  .bottom-nav button { border: 0; background: transparent; color: #bdbdbd; font-size: 9px; }
  .bottom-nav span { display: block; margin-bottom: 3px; font-size: 19px; }
  .bottom-nav button.active { color: #ffffff; font-weight: 800; }
  .bottom-nav .search-nav span { width: 42px; height: 42px; margin: -20px auto 2px; border: 1px solid #444444; border-radius: 50%; display: grid; place-items: center; color: #ffffff; background: #111111; box-shadow: 0 8px 22px rgba(0,0,0,.3); }
}

@media (prefers-color-scheme: dark) {
  :root { color-scheme: dark; --bg: #0a0a0a; --surface: #171717; --surface-soft: #242424; --ink: #f5f5f5; --muted: #a3a3a3; --button: #000000; --button-hover: #262626; --button-ink: #ffffff; --line: rgba(255,255,255,.14); --shadow: 0 18px 50px rgba(0,0,0,.32); }
  body { background: var(--bg); }
  .sidebar { background: rgba(10,10,10,.94); }
  .paper-card { background: var(--surface); }
  .paper-abstract { color: var(--muted); }
  .suggestions button { color: #ffffff; background: #000000; }
  .skeleton { background: linear-gradient(110deg, #171717 8%, #242424 18%, #171717 33%); background-size: 200% 100%; }
  .bottom-nav { background: rgba(0,0,0,.96); }
  .detail-panel, .detail-header { background: var(--surface); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
  .paper-card { transform: none; }
}
