:root {
  --paper: #f4f1e8;
  --paper-deep: #e9e4d8;
  --ink: #1f2927;
  --ink-muted: #68736e;
  --line: rgba(31, 41, 39, 0.14);
  --card: rgba(255, 254, 249, 0.82);
  --green: #1f6755;
  --green-bright: #2d8a70;
  --green-soft: #dcebe3;
  --orange: #c56d3b;
  --orange-soft: #f2dfd2;
  --blue-soft: #dfe8ed;
  --shadow: 0 18px 60px rgba(54, 59, 47, 0.08);
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: linear-gradient(rgba(31, 41, 39, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(31, 41, 39, 0.02) 1px, transparent 1px),
    var(--paper);
  background-size:
    32px 32px,
    32px 32px,
    auto;
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  line-height: 1.55;
  padding-bottom: env(safe-area-inset-bottom);
}

button,
input,
textarea,
select {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: inherit;
}

.hidden {
  display: none !important;
}

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 100;
  padding: 8px 12px;
  color: white;
  background: var(--green);
  border-radius: 8px;
  transform: translateY(-150%);
}

.skip-link:focus {
  transform: translateY(0);
}

.ambient {
  position: fixed;
  z-index: -1;
  border-radius: 50%;
  filter: blur(1px);
  pointer-events: none;
}

.ambient-one {
  top: -180px;
  right: -80px;
  width: 440px;
  height: 440px;
  background: radial-gradient(
    circle,
    rgba(78, 145, 119, 0.13),
    transparent 68%
  );
}

.ambient-two {
  bottom: -220px;
  left: 30%;
  width: 520px;
  height: 520px;
  background: radial-gradient(
    circle,
    rgba(197, 109, 59, 0.08),
    transparent 70%
  );
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 76px;
  padding: 0 42px;
  background: rgba(244, 241, 232, 0.82);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  gap: 12px;
  align-items: center;
  color: var(--ink);
  text-decoration: none;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 20px;
  letter-spacing: 0.01em;
}

.brand small {
  margin-top: -2px;
  color: var(--ink-muted);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.radar-mark {
  position: relative;
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid rgba(31, 103, 85, 0.35);
  border-radius: 50%;
}

.radar-mark::before,
.radar-mark::after {
  position: absolute;
  content: "";
  border: 1px solid rgba(31, 103, 85, 0.25);
  border-radius: 50%;
}

.radar-mark::before {
  width: 24px;
  height: 24px;
}

.radar-mark::after {
  width: 10px;
  height: 10px;
}

.radar-mark span {
  width: 5px;
  height: 5px;
  margin: -13px 0 0 15px;
  background: var(--orange);
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(197, 109, 59, 0.12);
}

.header-meta {
  display: flex;
  gap: 12px;
  align-items: center;
  color: var(--ink-muted);
  font-size: 12px;
}

.install-link {
  padding: 5px 9px;
  color: var(--green);
  font-weight: 700;
  text-decoration: none;
  background: transparent;
  border: 1px solid rgba(31, 103, 85, 0.24);
  border-radius: 999px;
  cursor: pointer;
}

.install-link:hover {
  color: white;
  background: var(--green);
}

.install-dialog {
  width: min(440px, calc(100% - 32px));
  padding: 34px;
  color: var(--ink);
  background: #fffdf8;
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: 0 30px 90px rgba(31, 41, 39, 0.22);
}

.install-dialog::backdrop {
  background: rgba(31, 41, 39, 0.42);
  backdrop-filter: blur(5px);
}

.install-dialog h2 {
  margin: 6px 0 18px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 30px;
  font-weight: 500;
  line-height: 1.12;
}

.install-mark {
  margin-bottom: 22px;
}

.dialog-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 34px;
  height: 34px;
  color: var(--ink-muted);
  background: var(--paper);
  border: 0;
  border-radius: 50%;
  cursor: pointer;
}

.install-steps {
  display: grid;
  gap: 12px;
  margin: 0;
  padding-left: 24px;
}

.install-steps li {
  padding-left: 5px;
}

.install-hint {
  margin: 22px 0 0;
  padding-top: 18px;
  color: var(--ink-muted);
  font-size: 13px;
  border-top: 1px solid var(--line);
}

.mode-badge {
  padding: 4px 8px;
  color: var(--green);
  font-weight: 800;
  letter-spacing: 0.08em;
  background: var(--green-soft);
  border-radius: 999px;
}

.app-shell {
  display: grid;
  grid-template-columns: 238px minmax(0, 1fr);
  max-width: 1440px;
  min-height: calc(100vh - 76px);
  margin: 0 auto;
}

.sidebar {
  position: sticky;
  top: 76px;
  align-self: start;
  height: calc(100vh - 76px);
  padding: 34px 24px;
  border-right: 1px solid var(--line);
}

.sidebar nav {
  display: grid;
  gap: 7px;
}

.nav-item {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  gap: 8px;
  align-items: center;
  width: 100%;
  padding: 10px 12px;
  color: var(--ink-muted);
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
}

.nav-item:hover,
.nav-item.active {
  color: var(--green);
  background: rgba(255, 255, 255, 0.52);
}

.nav-item.active {
  box-shadow: inset 3px 0 var(--green);
}

.nav-item b {
  min-width: 22px;
  padding: 1px 6px;
  color: var(--ink-muted);
  font-size: 11px;
  text-align: center;
  background: var(--paper-deep);
  border-radius: 999px;
}

.sidebar-section {
  margin-top: 38px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 13px;
  color: var(--ink-muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.16em;
}

.focus-list {
  display: grid;
  gap: 9px;
}

.focus-item {
  display: grid;
  grid-template-columns: 8px 1fr auto;
  gap: 8px;
  align-items: center;
  color: var(--ink-muted);
  font-size: 12px;
}

.focus-item i {
  width: 7px;
  height: 7px;
  background: var(--green-bright);
  border-radius: 50%;
}

.focus-item b {
  color: var(--ink);
  font-size: 10px;
}

.sidebar-note {
  position: absolute;
  right: 24px;
  bottom: 24px;
  left: 24px;
  margin: 0;
  color: var(--ink-muted);
  font-size: 11px;
}

.pulse-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 7px;
  background: var(--green-bright);
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(45, 138, 112, 0.12);
}

main {
  width: 100%;
  max-width: 1040px;
  padding: 54px 56px 90px;
  outline: none;
}

.view-header {
  display: flex;
  gap: 24px;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 30px;
}

.view-header h1 {
  margin: 3px 0 4px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(34px, 5vw, 54px);
  font-weight: 500;
  line-height: 1.05;
  letter-spacing: -0.03em;
}

.view-header p {
  max-width: 670px;
  margin: 0;
  color: var(--ink-muted);
}

.date-stamp {
  flex: 0 0 auto;
  padding: 8px 11px;
  color: var(--green);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.1em;
  background: rgba(255, 255, 255, 0.52);
  border: 1px solid var(--line);
  border-radius: 9px;
}

.summary-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-bottom: 23px;
}

.summary-chip,
.topic-chip,
.signal-chip {
  display: inline-flex;
  align-items: center;
  padding: 5px 9px;
  font-size: 10px;
  font-weight: 700;
  background: var(--paper-deep);
  border-radius: 999px;
}

.summary-chip strong {
  margin-right: 4px;
  color: var(--green);
}

.paper-list {
  display: grid;
  gap: 16px;
}

.mobile-deck-controls {
  display: none;
}

.paper-card {
  position: relative;
  overflow: hidden;
  padding: 24px 26px 22px;
  background: var(--card);
  border: 1px solid rgba(31, 41, 39, 0.12);
  border-radius: var(--radius);
  box-shadow: 0 2px 0 rgba(255, 255, 255, 0.6) inset;
  transition:
    transform 180ms ease,
    box-shadow 180ms ease,
    border-color 180ms ease;
}

.paper-card::before {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 3px;
  content: "";
  background: var(--green);
  opacity: 0;
  transition: opacity 180ms ease;
}

.paper-card:hover {
  border-color: rgba(31, 103, 85, 0.28);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.paper-card:hover::before {
  opacity: 1;
}

.paper-topline {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 13px;
}

.paper-labels {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.topic-chip {
  color: var(--green);
  background: var(--green-soft);
}

.topic-chip.transferable {
  color: #85502f;
  background: var(--orange-soft);
}

.category-chip {
  color: var(--ink-muted);
  background: var(--blue-soft);
}

.brief-source-chip {
  color: #85502f;
  background: var(--orange-soft);
}

.score {
  display: grid;
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
  place-items: center;
  background: radial-gradient(
      circle at center,
      var(--card) 57%,
      transparent 59%
    ),
    conic-gradient(var(--green) var(--score-angle), var(--paper-deep) 0);
  border-radius: 50%;
}

.paper-card h2 {
  max-width: 790px;
  margin: 0 0 8px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(20px, 2.5vw, 27px);
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: -0.012em;
}

.paper-meta {
  margin: 0 0 14px;
  color: var(--ink-muted);
  font-size: 11px;
}

.takeaway {
  margin: 0 0 18px;
  color: #3f4c48;
  font-size: 14px;
}

.three-line-brief {
  display: grid;
  gap: 1px;
  margin: 18px 0;
  overflow: hidden;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: 11px;
}

.brief-signal {
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 7px;
  align-items: start;
  padding: 11px 14px;
  background: rgba(255, 253, 248, 0.96);
}

.brief-signal > span {
  font-size: 17px;
  line-height: 1.4;
}

.brief-signal p {
  margin: 0;
  color: #3f4c48;
  font-size: 13px;
  line-height: 1.58;
}

.match-line {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-bottom: 19px;
  color: var(--ink-muted);
  font-size: 10px;
}

.signal-chip {
  padding: 3px 7px;
  font-weight: 600;
}

.paper-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding-top: 17px;
  border-top: 1px solid var(--line);
}

.action-button,
.link-button,
.primary-button,
.secondary-button,
.danger-button {
  padding: 7px 10px;
  color: var(--ink-muted);
  text-decoration: none;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}

.action-button:hover,
.link-button:hover,
.secondary-button:hover {
  color: var(--green);
  background: white;
  border-color: rgba(31, 103, 85, 0.32);
}

.action-button.active {
  color: var(--green);
  background: var(--green-soft);
  border-color: transparent;
}

.action-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.deep-dive-button:not(:disabled) {
  color: #85502f;
  background: var(--orange-soft);
  border-color: transparent;
}

.deep-dive-dialog {
  width: min(940px, calc(100vw - 32px));
  max-width: none;
  max-height: min(90vh, 1000px);
  padding: 0;
  color: var(--ink);
  background: var(--card);
  border: 1px solid rgba(31, 103, 85, 0.25);
  border-radius: 18px;
  box-shadow: 0 28px 90px rgba(24, 39, 35, 0.28);
}

.deep-dive-dialog::backdrop {
  background: rgba(22, 31, 29, 0.56);
  backdrop-filter: blur(5px);
}

.deep-dive-shell {
  min-height: 100%;
}

.deep-dive-header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  gap: 24px;
  align-items: flex-start;
  justify-content: space-between;
  padding: 24px 28px 20px;
  background: rgba(255, 253, 248, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.deep-dive-header h2 {
  max-width: 760px;
  margin: 5px 0 7px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(24px, 4vw, 36px);
  font-weight: 500;
  line-height: 1.15;
}

.deep-dive-header p {
  margin: 0;
  color: var(--ink-muted);
  font-size: 11px;
}

.dialog-close {
  display: grid;
  flex: 0 0 38px;
  width: 38px;
  height: 38px;
  padding: 0;
  color: var(--ink-muted);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 50%;
  cursor: pointer;
  place-items: center;
  font-size: 24px;
}

.deep-dive-content {
  padding: 6px 28px 30px;
}

.deep-dive-content > section,
.deep-dive-columns {
  padding-top: 24px;
}

.deep-dive-content h3 {
  margin: 0 0 11px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 23px;
  font-weight: 500;
}

.deep-dive-content > section > p {
  margin: 0;
  color: #3f4c48;
  font-size: 14px;
  line-height: 1.72;
}

.deep-dive-items {
  display: grid;
  gap: 10px;
}

.deep-dive-items article {
  padding: 13px 15px;
  background: var(--paper);
  border-left: 3px solid var(--green);
  border-radius: 0 9px 9px 0;
}

.deep-dive-items h4 {
  margin: 0 0 4px;
  color: var(--green);
  font-size: 13px;
}

.deep-dive-items p,
.deep-dive-content li,
.deep-dive-missing {
  margin: 0;
  color: #3f4c48;
  font-size: 13px;
  line-height: 1.65;
}

.deep-dive-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
}

.deep-dive-content ul {
  display: grid;
  gap: 7px;
  margin: 0;
  padding-left: 20px;
}

.deep-dive-content footer {
  margin-top: 28px;
  padding-top: 14px;
  color: var(--ink-muted);
  font-size: 10px;
  border-top: 1px solid var(--line);
}

.link-button {
  margin-left: auto;
}

.expand-button {
  border-style: dashed;
}

.paper-details {
  display: none;
  padding-top: 20px;
}

.paper-card.expanded .paper-details {
  display: block;
  animation: reveal 180ms ease-out;
}

@keyframes reveal {
  from {
    opacity: 0;
    transform: translateY(-5px);
  }
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.summary-cell {
  padding: 13px 14px;
  background: rgba(244, 241, 232, 0.68);
  border-radius: 10px;
}

.summary-cell h3 {
  margin: 0 0 5px;
  color: var(--green);
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.summary-cell p {
  margin: 0;
  font-size: 12px;
}

.abstract {
  margin: 14px 0 0;
  padding: 14px;
  color: var(--ink-muted);
  font-size: 11px;
  background: rgba(255, 255, 255, 0.42);
  border-left: 2px solid var(--paper-deep);
}

.feedback-menu {
  position: relative;
}

.feedback-popover {
  position: absolute;
  bottom: calc(100% + 7px);
  left: 0;
  z-index: 5;
  display: none;
  width: 225px;
  padding: 7px;
  background: #fffef9;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
}

.feedback-menu.open .feedback-popover {
  display: grid;
}

.feedback-popover button {
  padding: 8px;
  color: var(--ink-muted);
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 7px;
  cursor: pointer;
}

.feedback-popover button:hover {
  color: var(--ink);
  background: var(--paper);
}

.empty-state,
.error-state,
.loading-state {
  padding: 80px 20px;
  color: var(--ink-muted);
  text-align: center;
}

.empty-state h2 {
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 500;
}

.loader {
  display: block;
  width: 34px;
  height: 34px;
  margin: 0 auto 14px;
  border: 2px solid var(--paper-deep);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

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

.preference-layout {
  display: grid;
  gap: 18px;
}

.panel {
  padding: 23px 24px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.panel-heading {
  display: flex;
  gap: 18px;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 18px;
}

.panel h2 {
  margin: 0 0 3px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 22px;
  font-weight: 500;
}

.panel-heading p,
.panel > p {
  margin: 0;
  color: var(--ink-muted);
  font-size: 12px;
}

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

.hidden-paper-list > p {
  margin: 0;
  color: var(--ink-muted);
}

.hidden-paper-row {
  display: flex;
  gap: 18px;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  border-top: 1px solid var(--line);
}

.hidden-paper-row div {
  display: grid;
  gap: 4px;
}

.hidden-paper-row span {
  color: var(--ink-muted);
  font-size: 13px;
}

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

.topic-editor {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(160px, 0.8fr) 110px 36px;
  gap: 14px;
  align-items: center;
  padding: 13px;
  background: rgba(244, 241, 232, 0.55);
  border-radius: 11px;
}

.topic-editor input[type="text"],
.topic-editor textarea,
.topic-editor select,
.command-box input,
.add-topic-grid input,
.add-topic-grid textarea,
.auth-row input {
  width: 100%;
  padding: 8px 9px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.64);
  border: 1px solid var(--line);
  border-radius: 7px;
  outline: none;
}

.topic-editor input:focus,
.topic-editor textarea:focus,
.topic-editor select:focus,
.command-box input:focus,
.add-topic-grid input:focus,
.add-topic-grid textarea:focus,
.auth-row input:focus {
  border-color: var(--green-bright);
  box-shadow: 0 0 0 3px rgba(45, 138, 112, 0.1);
}

.topic-editor textarea {
  min-height: 58px;
  resize: vertical;
}

.topic-name-field {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 8px;
  align-items: start;
}

.topic-name-field input[type="checkbox"] {
  margin-top: 10px;
  accent-color: var(--green);
}

.weight-control {
  display: grid;
  grid-template-columns: 1fr 35px;
  gap: 8px;
  align-items: center;
  font-size: 11px;
}

.weight-control input {
  accent-color: var(--green);
}

.topic-feedback {
  grid-column: 1 / -1;
  margin: -4px 0 0 30px;
  color: var(--ink-muted);
  font-size: 12px;
  line-height: 1.45;
}

.topic-feedback.active {
  color: var(--green);
}

.remove-topic {
  width: 34px;
  height: 34px;
  color: var(--ink-muted);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}

.remove-topic:hover {
  color: #9d3d30;
  border-color: rgba(157, 61, 48, 0.3);
}

.command-box {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 9px;
}

.add-topic-grid {
  display: grid;
  grid-template-columns: 0.45fr 1fr auto;
  gap: 9px;
  align-items: start;
}

.add-topic-grid textarea {
  min-height: 42px;
  resize: vertical;
}

.primary-button {
  color: white;
  background: var(--green);
  border-color: var(--green);
}

.primary-button:hover {
  background: #164f40;
}

.danger-button {
  color: #9d3d30;
}

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

.auth-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 9px;
  margin-top: 14px;
}

.display-settings {
  display: grid;
  gap: 12px;
}

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

.setting-row > span {
  font-size: 13px;
  font-weight: 700;
}

.segmented-control {
  display: inline-grid;
  grid-auto-flow: column;
  gap: 3px;
  padding: 3px;
  background: var(--paper-deep);
  border-radius: 10px;
}

.segmented-control button {
  min-width: 74px;
  padding: 7px 11px;
  color: var(--ink-muted);
  background: transparent;
  border: 0;
  border-radius: 7px;
  cursor: pointer;
}

.segmented-control button.active {
  color: var(--green);
  background: var(--card);
  box-shadow: 0 1px 4px rgba(31, 41, 39, 0.12);
}

.settings-note {
  margin-top: 12px !important;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 50;
  max-width: 340px;
  padding: 11px 14px;
  color: white;
  font-size: 12px;
  background: var(--ink);
  border-radius: 9px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition:
    opacity 160ms ease,
    transform 160ms ease;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 900px) {
  .site-header {
    padding: 0 20px;
  }

  .app-shell {
    display: block;
  }

  .sidebar {
    position: sticky;
    top: 76px;
    z-index: 15;
    width: 100%;
    height: auto;
    padding: 8px 14px;
    overflow-x: auto;
    background: rgba(244, 241, 232, 0.92);
    border-right: 0;
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(12px);
  }

  .sidebar nav {
    display: flex;
    min-width: max-content;
  }

  .nav-item {
    display: flex;
    width: auto;
  }

  .nav-item.active {
    box-shadow: inset 0 -2px var(--green);
  }

  .sidebar-section,
  .sidebar-note {
    display: none;
  }

  main {
    padding: 40px 20px 70px;
  }
}

@media (max-width: 650px) {
  body {
    background: #f3f1eb;
  }

  body.paper-page {
    height: 100dvh;
    padding-bottom: 0;
    overflow: hidden;
  }

  .site-header {
    height: 56px;
    padding-right: max(14px, env(safe-area-inset-right));
    padding-left: max(14px, env(safe-area-inset-left));
    background: rgba(248, 247, 242, 0.94);
  }

  .brand {
    gap: 8px;
  }

  .brand small {
    display: none;
  }

  .brand strong {
    font-size: 18px;
  }

  .radar-mark {
    width: 30px;
    height: 30px;
  }

  .radar-mark::before {
    width: 19px;
    height: 19px;
  }

  .radar-mark::after {
    width: 8px;
    height: 8px;
  }

  .mode-badge {
    display: inline-flex;
    padding: 4px 7px;
    font-size: 9px;
  }

  .install-link {
    padding: 5px 8px;
    font-size: 10px;
  }

  .install-dialog {
    padding: 30px 24px;
  }

  .header-meta #lastUpdated {
    display: none;
  }

  .app-shell {
    min-height: calc(100dvh - 56px);
  }

  .sidebar {
    position: fixed;
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 30;
    height: auto;
    padding: 7px max(8px, env(safe-area-inset-right))
      max(7px, env(safe-area-inset-bottom))
      max(8px, env(safe-area-inset-left));
    overflow: visible;
    background: rgba(252, 251, 247, 0.96);
    border-top: 1px solid var(--line);
    border-bottom: 0;
    backdrop-filter: blur(20px);
  }

  .sidebar nav {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    min-width: 0;
  }

  .nav-item {
    position: relative;
    display: grid;
    grid-template-columns: 1fr;
    gap: 0;
    justify-items: center;
    padding: 4px 2px 2px;
    font-size: 10px;
    line-height: 1.3;
    border-radius: 12px;
  }

  .nav-item > span[aria-hidden] {
    font-size: 17px;
    line-height: 1.2;
  }

  .nav-item .nav-label {
    font-size: 10px;
    line-height: 1.3;
  }

  .nav-item b {
    position: absolute;
    top: 1px;
    right: calc(50% - 25px);
    min-width: 15px;
    padding: 1px 4px;
    font-size: 8px;
  }

  .nav-item.active {
    background: var(--green-soft);
    box-shadow: none;
  }

  main {
    padding: 16px 14px calc(84px + env(safe-area-inset-bottom));
  }

  .paper-page .app-shell {
    height: calc(100dvh - 56px);
    min-height: 0;
  }

  .paper-page main {
    height: 100%;
    max-width: none;
    padding: 0;
    overflow: hidden;
  }

  .paper-page #appContent {
    position: relative;
    height: 100%;
    overflow: hidden;
  }

  .paper-page .view-header,
  .paper-page .summary-strip {
    display: none;
  }

  .view-header {
    gap: 12px;
    align-items: center;
    margin-bottom: 12px;
  }

  .view-header .eyebrow,
  .view-header p {
    display: none;
  }

  .view-header h1 {
    margin: 0;
    font-size: 29px;
    line-height: 1.05;
  }

  .date-stamp {
    padding: 0;
    font-size: 9px;
    background: transparent;
    border: 0;
  }

  .summary-strip {
    display: none;
  }

  .paper-page .paper-card {
    display: flex;
    flex: 0 0 100%;
    flex-direction: column;
    width: 100%;
    height: 100%;
    padding: 58px max(18px, env(safe-area-inset-right))
      calc(88px + env(safe-area-inset-bottom))
      max(18px, env(safe-area-inset-left));
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    background: #fffefa;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    scroll-snap-align: start;
    scroll-snap-stop: always;
    -webkit-overflow-scrolling: touch;
  }

  .paper-page .paper-card::before {
    display: none;
  }

  .paper-page .paper-card:hover {
    transform: none;
  }

  .paper-page .paper-list {
    display: flex;
    gap: 0;
    align-items: stretch;
    width: 100%;
    height: 100%;
    padding: 0;
    margin: 0;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    scroll-padding-inline: 0;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .paper-page .paper-list::-webkit-scrollbar {
    display: none;
  }

  .paper-page .mobile-deck-controls {
    position: absolute;
    top: 9px;
    right: max(14px, env(safe-area-inset-right));
    left: max(14px, env(safe-area-inset-left));
    z-index: 4;
    display: grid;
    grid-template-columns: 38px 1fr 38px;
    gap: 10px;
    align-items: center;
    margin: 0;
    text-align: center;
    pointer-events: none;
  }

  .paper-page .mobile-deck-controls button {
    width: 34px;
    height: 34px;
    color: var(--green);
    font-size: 18px;
    background: rgba(255, 254, 250, 0.88);
    border: 1px solid var(--line);
    border-radius: 999px;
    box-shadow: 0 3px 14px rgba(38, 48, 43, 0.08);
    backdrop-filter: blur(14px);
    pointer-events: auto;
  }

  .mobile-deck-controls button:disabled {
    color: var(--ink-muted);
    opacity: 0.35;
  }

  .paper-page .mobile-deck-controls span {
    display: grid;
    justify-self: center;
    gap: 2px;
    padding: 5px 11px;
    color: var(--ink-muted);
    background: rgba(255, 254, 250, 0.82);
    border: 1px solid rgba(31, 41, 39, 0.08);
    border-radius: 999px;
    backdrop-filter: blur(14px);
  }

  .mobile-deck-controls strong {
    color: var(--ink);
    font-size: 12px;
  }

  .paper-page .mobile-deck-controls small {
    display: none;
  }

  .paper-topline {
    order: 1;
    margin-bottom: 11px;
  }

  .paper-labels {
    gap: 5px;
  }

  .topic-chip {
    padding: 4px 7px;
    font-size: 8px;
  }

  .brief-source-chip {
    display: none;
  }

  .score {
    flex-basis: 38px;
    width: 38px;
    height: 38px;
    font-size: 11px;
  }

  .paper-card h2 {
    order: 2;
    margin-bottom: 7px;
    font-size: 22px;
    line-height: 1.18;
  }

  .paper-meta {
    order: 3;
    margin-bottom: 13px;
    overflow: hidden;
    font-size: 10px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .paper-actions {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 7px;
    order: 4;
    padding: 12px 0;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
  }

  .paper-actions > * {
    display: grid;
    grid-column: span 2;
    min-width: 0;
    min-height: 38px;
    padding: 7px 5px;
    place-items: center;
    margin-left: 0;
    font-size: 10px;
    line-height: 1.15;
    text-align: center;
  }

  .paper-actions .save-button {
    color: var(--green);
    background: var(--green-soft);
    border-color: transparent;
  }

  .paper-actions [data-action="irrelevant"] {
    color: #9d4a3e;
  }

  .three-line-brief {
    gap: 8px;
    order: 5;
    margin: 14px 0 0;
    overflow: visible;
    background: transparent;
    border: 0;
  }

  .brief-signal {
    grid-template-columns: 25px 1fr;
    gap: 6px;
    padding: 10px 11px;
    background: #f6f4ee;
    border-radius: 12px;
  }

  .brief-signal > span {
    font-size: 15px;
  }

  .brief-signal p {
    font-size: 12px;
    line-height: 1.48;
  }

  .match-line {
    display: none;
  }

  .paper-details {
    order: 6;
  }

  .toast {
    right: 14px;
    bottom: calc(76px + env(safe-area-inset-bottom));
    left: 14px;
    max-width: none;
    text-align: center;
  }

  .summary-grid {
    grid-template-columns: 1fr;
  }

  .deep-dive-header {
    padding: 19px 18px 16px;
  }

  .deep-dive-content {
    padding: 4px 18px 22px;
  }

  .deep-dive-columns {
    grid-template-columns: 1fr;
  }

  .link-button {
    margin-left: 0;
  }

  .topic-editor {
    grid-template-columns: 1fr;
  }

  .remove-topic {
    width: 100%;
  }

  .command-box,
  .add-topic-grid,
  .auth-row {
    grid-template-columns: 1fr;
  }

  .setting-row {
    display: grid;
    gap: 8px;
  }

  .segmented-control {
    width: 100%;
  }

  .segmented-control button {
    min-width: 0;
  }
}

html[data-theme="dark"] {
  --paper: #111816;
  --paper-deep: #202a27;
  --ink: #edf3ef;
  --ink-muted: #a4b0aa;
  --line: rgba(224, 236, 229, 0.14);
  --card: rgba(27, 37, 34, 0.94);
  --green: #73c9ae;
  --green-bright: #67d1ae;
  --green-soft: #203f36;
  --orange: #e39767;
  --orange-soft: #4a3025;
  --blue-soft: #283b45;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.3);
}

html[data-theme="dark"] body {
  background: linear-gradient(rgba(226, 240, 232, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(226, 240, 232, 0.02) 1px, transparent 1px),
    var(--paper);
}

html[data-theme="dark"] .site-header,
html[data-theme="dark"] .sidebar {
  background: rgba(17, 24, 22, 0.92);
}

html[data-theme="dark"] .install-dialog,
html[data-theme="dark"] .feedback-popover,
html[data-theme="dark"] .topic-editor input[type="text"],
html[data-theme="dark"] .topic-editor textarea,
html[data-theme="dark"] .topic-editor select,
html[data-theme="dark"] .command-box input,
html[data-theme="dark"] .add-topic-grid input,
html[data-theme="dark"] .add-topic-grid textarea,
html[data-theme="dark"] .auth-row input {
  color: var(--ink);
  background: #18211e;
}

html[data-theme="dark"] .nav-item:hover,
html[data-theme="dark"] .nav-item.active,
html[data-theme="dark"] .date-stamp,
html[data-theme="dark"] .abstract {
  background: rgba(120, 170, 150, 0.1);
}

html[data-theme="dark"] .brief-signal,
html[data-theme="dark"] .deep-dive-header {
  background: rgba(25, 35, 32, 0.97);
}

html[data-theme="dark"] .takeaway,
html[data-theme="dark"] .brief-signal p,
html[data-theme="dark"] .deep-dive-content > section > p,
html[data-theme="dark"] .deep-dive-items p,
html[data-theme="dark"] .deep-dive-content li,
html[data-theme="dark"] .deep-dive-missing {
  color: #ccd7d1;
}

html[data-theme="dark"] .summary-cell,
html[data-theme="dark"] .topic-editor {
  background: rgba(33, 45, 41, 0.8);
}

html[data-theme="dark"] .toast {
  color: #edf3ef;
  background: #26332f;
  border: 1px solid var(--line);
}

html[data-theme="dark"] .deep-dive-button:not(:disabled),
html[data-theme="dark"] .topic-chip.transferable,
html[data-theme="dark"] .brief-source-chip {
  color: #efad80;
}

@media (max-width: 650px) {
  html[data-theme="dark"] body,
  html[data-theme="dark"] .paper-page .paper-card {
    background: #111816;
  }

  html[data-theme="dark"] .site-header,
  html[data-theme="dark"] .sidebar {
    background: rgba(17, 24, 22, 0.94);
  }

  html[data-theme="dark"] .paper-page .mobile-deck-controls button,
  html[data-theme="dark"] .paper-page .mobile-deck-controls span {
    background: rgba(25, 35, 32, 0.88);
  }

  html[data-theme="dark"] .brief-signal {
    background: #1c2623;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
