:root {
  --bg: #0f1115;
  --panel: #181c23;
  --panel-soft: #202733;
  --line: #2a3242;
  --text: #e9edf3;
  --muted: #9aa6b8;
  --accent: #88d6b5;
  --danger: #ff7b7b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at 20% 0%, #1f2734 0%, var(--bg) 55%);
  color: var(--text);
  font-family: 'Noto Serif SC', 'PingFang SC', Georgia, serif;
}

.app-shell {
  max-width: 840px;
  margin: 0 auto;
  padding: 20px 14px 60px;
}

.topbar h1 {
  margin: 0;
  font-size: 30px;
  letter-spacing: 0.6px;
}

.topbar p {
  margin: 6px 0 0;
  color: var(--muted);
}

.tabs {
  display: flex;
  gap: 10px;
  margin: 20px 0;
}

.tab-btn {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  padding: 8px 16px;
  border-radius: 999px;
  cursor: pointer;
}

.tab-btn.is-active {
  border-color: var(--accent);
  color: var(--text);
  background: color-mix(in srgb, var(--accent) 15%, transparent);
}

.filters {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

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

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

.state-text {
  color: var(--muted);
  margin: 6px 0 10px;
}

.articles-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 12px;
}

.article-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  cursor: pointer;
}

.article-card h3 {
  margin: 0 0 6px;
  line-height: 1.45;
}

.article-meta {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 8px;
}

.article-summary {
  font-size: 15px;
  line-height: 1.7;
  color: #dce3ee;
  margin: 0 0 10px;
}

.progress {
  height: 8px;
  border-radius: 99px;
  background: var(--panel-soft);
  overflow: hidden;
}

.progress > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #4fd7bc, #85d5ab);
}

.progress-label {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
}

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

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

.reader-header {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 16px;
}

.reader-header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

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

.reader-header h2 {
  margin: 0;
  font-size: 20px;
}

.reader-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

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

.reference-banner-text {
  font-size: 14px;
  color: #d6dff0;
}

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

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

.reader-content {
  line-height: 1.95;
  font-size: 18px;
  word-break: break-word;
  user-select: text;
  -webkit-user-select: text;
  -webkit-touch-callout: none;
}

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

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

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

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

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

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

.note-item {
  padding: 8px 10px;
  border-radius: 10px;
  background: #111723;
  border: 1px solid var(--line);
  margin-bottom: 8px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1.6;
}

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

.note-item span {
  color: var(--muted);
  font-size: 12px;
  display: block;
  margin-bottom: 4px;
}

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

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

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

.notes-panel {
  position: fixed;
  right: 16px;
  bottom: 16px;
  width: min(420px, calc(100vw - 32px));
  max-height: 70vh;
  background: #101721;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
  z-index: 65;
  display: flex;
  flex-direction: column;
}

.notes-panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

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

.notes-panel-body {
  padding: 12px 14px;
  overflow: auto;
  display: grid;
  gap: 10px;
}

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

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

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

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

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

.long-press-menu button:hover {
  background: #242d3b;
}

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

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

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

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

.origin-snippet pre {
  margin: 0;
  white-space: pre-wrap;
  line-height: 1.7;
  color: #d5dfed;
}

.qa-modal {
  position: fixed;
  inset: 0;
  background: rgba(8, 10, 15, 0.68);
  display: grid;
  place-items: center;
  z-index: 60;
}

.qa-card {
  width: min(90vw, 560px);
  background: #101721;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.4);
}

.qa-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

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

.qa-label {
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 6px;
}

.qa-context {
  background: #151d2a;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  font-size: 14px;
  color: #d6dff0;
  margin-bottom: 12px;
  max-height: 140px;
  overflow: auto;
}

#qaQuestionInput {
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #111723;
  color: var(--text);
  padding: 10px;
  margin-bottom: 8px;
}

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

.qa-answer {
  background: #121a28;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  font-size: 14px;
  color: #d6dff0;
  min-height: 44px;
  white-space: pre-wrap;
}

.qa-card-actions {
  display: flex;
  justify-content: flex-end;
}

.qa-card-actions button {
  border: 1px solid var(--line);
  background: #1a2332;
  color: var(--text);
  padding: 8px 14px;
  border-radius: 10px;
  cursor: pointer;
}

.selection-menu {
  position: absolute;
  z-index: 50;
  background: #121926;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
  display: flex;
  overflow: hidden;
}

.selection-menu button {
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
}

.selection-menu button:hover {
  background: #253247;
}

.highlight-mark {
  background: rgba(255, 232, 138, 0.28);
  box-shadow: 0 0 0 2px rgba(255, 232, 138, 0.15);
  border-radius: 4px;
  padding: 0 2px;
}

.hidden {
  display: none !important;
}

@media (max-width: 720px) {
  .filters {
    grid-template-columns: 1fr;
  }

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