/* AI 报纸 · 网页样式（手机优先；跟随系统深色模式） */

:root {
  --bg: #f7f3ec;
  --paper: #fffdf9;
  --ink: #23201c;
  --muted: #7a7268;
  --faint: #a69e93;
  --line: #e6dfd3;
  --accent: #b5532f;
  --accent-soft: rgba(181, 83, 47, 0.1);
  --tag: #6b5b95;
  --tag-bg: rgba(107, 91, 149, 0.12);
  --danger: #c0392b;
  --reader-size: 17px;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --serif: "Songti SC", "Noto Serif SC", "Source Han Serif SC", Georgia, serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1a19;
    --paper: #232120;
    --ink: #ece6dc;
    --muted: #a39b90;
    --faint: #7c756c;
    --line: #36322e;
    --accent: #e08a62;
    --accent-soft: rgba(224, 138, 98, 0.14);
    --tag: #b9a8e8;
    --tag-bg: rgba(185, 168, 232, 0.14);
    --danger: #ef6f5e;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-text-size-adjust: 100%;
}

button, input { font: inherit; color: inherit; }
button { cursor: pointer; }

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: 0.04em; }
.error { color: var(--danger); min-height: 1.2em; font-size: 14px; }

/* ---------- 登录 / 密钥 ---------- */

.screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px calc(24px + env(safe-area-inset-bottom));
}

.card {
  width: 100%;
  max-width: 400px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 28px 22px;
}

.card h1 { margin: 0 0 10px; font-size: 22px; }
.card p { line-height: 1.6; margin: 8px 0; }
.card form { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; }

.card input {
  width: 100%;
  padding: 13px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg);
  font-size: 16px; /* 16px 以上，iPhone 不会自动放大 */
}

button.primary {
  border: 0;
  border-radius: 12px;
  padding: 13px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

/* ---------- 顶栏 ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: calc(10px + env(safe-area-inset-top)) 12px 10px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.brand { margin: 0 0 0 4px; font-size: 19px; font-family: var(--serif); font-weight: 700; letter-spacing: 0.04em; }
.spacer { flex: 1; }

.icon-button {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 0;
  background: transparent;
  font-size: 20px;
  line-height: 1;
  color: var(--muted);
}
.icon-button:active { background: var(--accent-soft); }
.icon-button.back { font-size: 30px; color: var(--accent); }
#refreshButton.spinning { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 类别 ---------- */

.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 10px 14px;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }

.chip {
  flex: none;
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: 999px;
  padding: 5px 13px;
  font-size: 14px;
  color: var(--muted);
}
.chip.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }

/* ---------- 列表 ---------- */

.notice {
  margin: 4px 14px 8px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
  line-height: 1.5;
}

.item {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  outline: none;
}
.item:active, .item.selected { background: var(--accent-soft); }
.item:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); }

.meta { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--faint); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); flex: none; }

.tag {
  color: var(--tag);
  background: var(--tag-bg);
  border-radius: 5px;
  padding: 1px 6px;
  font-size: 12px;
  font-weight: 600;
}

.item .title {
  margin-top: 7px;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.45;
  font-family: var(--serif);
}
.item.read .title { font-weight: 400; color: var(--muted); }

.item .summary {
  margin-top: 5px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.empty { padding: 48px 24px; text-align: center; line-height: 1.7; }

.more {
  display: block;
  margin: 16px auto 32px;
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: 999px;
  padding: 8px 22px;
  color: var(--muted);
}

/* ---------- 阅读 ---------- */

.reader-empty { padding: 80px 24px; text-align: center; }

.reader-inner {
  max-width: 680px;
  margin: 0 auto;
  padding: 22px 20px calc(48px + env(safe-area-inset-bottom));
}

.reader-meta { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--faint); }

.reader-title {
  font-family: var(--serif);
  font-size: calc(var(--reader-size) * 1.55);
  line-height: 1.35;
  margin: 12px 0 14px;
}

.reader-summary {
  margin: 0 0 22px;
  padding: 12px 14px;
  border-left: 3px solid var(--accent);
  background: var(--paper);
  border-radius: 0 10px 10px 0;
  color: var(--muted);
  font-size: calc(var(--reader-size) * 0.94);
  line-height: 1.7;
}

.body {
  font-size: var(--reader-size);
  line-height: 1.85;
  letter-spacing: 0.01em;
  word-break: break-word;
}
.body p { margin: 0 0 1em; }
.body h2, .body h3 {
  font-family: var(--serif);
  line-height: 1.4;
  margin: 1.6em 0 0.6em;
}
.body h2 { font-size: 1.2em; }
.body h3 { font-size: 1.07em; }
.body ul, .body ol { margin: 0 0 1em; padding-left: 1.4em; }
.body li { margin: 0.3em 0; }
.body blockquote {
  margin: 0 0 1em;
  padding: 0.2em 0 0.2em 0.9em;
  border-left: 3px solid var(--line);
  color: var(--muted);
}
.body strong { font-weight: 700; }

a { color: var(--accent); text-decoration: none; }
a:active { opacity: 0.6; }

.sources-title { font-size: 16px; margin: 32px 0 10px; }
.sources { list-style: none; padding: 0; margin: 0; }
.sources li { padding: 6px 0; font-size: 14px; line-height: 1.5; border-bottom: 1px dashed var(--line); }
.sources .host { margin-left: 8px; color: var(--faint); font-size: 12px; }

.disclaimer { margin-top: 28px; font-size: 12px; color: var(--faint); line-height: 1.6; }

/* ---------- 手机模式：一栏，点开一篇占满屏 ---------- */

body.phone .layout { display: block; }
body.phone .reader { display: none; }
body.phone.reading .list-pane,
body.phone.reading .chips { display: none; }
body.phone.reading .reader { display: block; }

/* ---------- 电脑模式：左边列表，右边正文 ---------- */

body.desktop #main { height: 100vh; display: flex; flex-direction: column; }
body.desktop .layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(300px, 380px) 1fr;
  border-top: 1px solid var(--line);
}
body.desktop .list-pane { overflow-y: auto; border-right: 1px solid var(--line); }
body.desktop .reader { overflow-y: auto; background: var(--paper); }
body.desktop .reader-inner { padding-top: 36px; }

/* ---------- 设置 ---------- */

.sheet {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
body.desktop .sheet { align-items: center; }

.sheet-card {
  width: 100%;
  max-width: 460px;
  background: var(--paper);
  border-radius: 18px 18px 0 0;
  padding: 18px 18px calc(22px + env(safe-area-inset-bottom));
}
body.desktop .sheet-card { border-radius: 18px; }

.sheet-head { display: flex; align-items: center; justify-content: space-between; }
.sheet-head h2 { margin: 0; font-size: 18px; }

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

.segmented { display: flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.segmented button {
  border: 0;
  background: transparent;
  padding: 6px 12px;
  font-size: 14px;
  color: var(--muted);
}
.segmented button + button { border-left: 1px solid var(--line); }
.segmented button.on { background: var(--ink); color: var(--bg); }

.sheet-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.sheet-actions button {
  border: 1px solid var(--line);
  background: var(--bg);
  border-radius: 12px;
  padding: 11px;
}
.sheet-actions .danger { color: var(--danger); }

/* ---------- 提示 ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(20px);
  max-width: calc(100% - 32px);
  padding: 10px 16px;
  border-radius: 12px;
  background: var(--ink);
  color: var(--bg);
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 30;
}
.toast.visible { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--danger); color: #fff; }
