:root {
  --red: #ff2442;
  --red-dark: #e01736;
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #1f2329;
  --muted: #8a8f99;
  --border: #eceef1;
  --primary: #ff2442;
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
}

.no-scroll { overflow: hidden; }

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand .logo { font-size: 24px; }
.brand h1 { font-size: 18px; margin: 0; }
.app-header nav a {
  color: var(--muted);
  text-decoration: none;
  margin-left: 18px;
  font-weight: 500;
}
.app-header nav a.active { color: var(--red); }

.container { max-width: 1100px; margin: 24px auto; padding: 0 20px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}
.card h2 { margin: 0 0 8px; font-size: 18px; }
.hint { color: var(--muted); font-size: 13px; margin: 4px 0 18px; }

.field { margin-bottom: 16px; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 15px;
  outline: none;
}
.field input:focus { border-color: var(--red); }
.url-preview {
  display: block;
  padding: 10px 12px;
  background: #fafafa;
  border-radius: 8px;
  font-size: 12px;
  color: #555;
  word-break: break-all;
}

.actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 8px; align-items: center; }
.actions input[type="text"] { padding: 9px 12px; border: 1px solid var(--border); border-radius: 9px; font-size: 14px; min-width: 200px; }
.btn {
  padding: 10px 22px;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  cursor: pointer;
  font-weight: 600;
  transition: background 0.15s, transform 0.05s;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--red-dark); }
.btn.danger { background: #fff; color: #d0021b; border: 1px solid #f5c2c8; }
.btn.danger:hover:not(:disabled) { background: #fff0f2; }
.btn.ghost { background: #fff; color: var(--muted); border: 1px solid var(--border); }
.btn.small { padding: 7px 14px; font-size: 13px; }

.status { margin-top: 18px; }
.status-line { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.spinner {
  width: 16px; height: 16px;
  border: 2px solid #f1c4cf;
  border-top-color: var(--red);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.pct { margin-left: auto; color: var(--red); font-weight: 700; }
.progress { height: 8px; background: #eef0f3; border-radius: 6px; margin-top: 10px; overflow: hidden; }
.progress-bar { height: 100%; background: linear-gradient(90deg, #ff6b81, var(--red)); transition: width 0.3s; }

.log {
  background: #111;
  color: #d7e0ea;
  padding: 16px;
  border-radius: 10px;
  font-size: 12px;
  min-height: 140px;
  max-height: 320px;
  overflow: auto;
  white-space: pre-wrap;
  font-family: "Consolas", "Microsoft YaHei", monospace;
}

.toolbar { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; }
.toolbar-left { display: flex; align-items: center; gap: 8px; }
.toolbar-left input {
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; width: 200px;
}
.toolbar-left select {
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px;
  min-width: 200px; background: #fff; color: var(--text);
}
.toolbar-right { display: flex; align-items: center; gap: 14px; }
.count { color: var(--muted); font-size: 14px; }
.summary { margin-top: 12px; font-size: 14px; color: #555; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 16px;
}
.note-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s;
}
.note-card:hover { transform: translateY(-3px); box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1); }
.cover-wrap { width: 100%; aspect-ratio: 3 / 4; background: #f0f0f0; overflow: hidden; }
.cover { width: 100%; height: 100%; object-fit: cover; display: block; }
.cover.no-cover { display: flex; align-items: center; justify-content: center; color: #bbb; background: #f0f0f0; }
.cover.no-cover::after { content: "无封面"; }
.note-info { padding: 10px 12px; }
.note-title {
  font-size: 14px; line-height: 1.4; height: 40px; overflow: hidden; display: -webkit-box;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical; margin-bottom: 6px;
}
.note-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.note-meta .author { color: #333; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 90px; }
.note-meta .time { color: #999; }
.note-meta .likes { color: var(--red); }

.badge-warn {
  display: inline-block;
  margin-top: 6px;
  padding: 2px 8px;
  border-radius: 6px;
  background: #fff3e0;
  color: #c77700;
  font-size: 11px;
}
.detail-warn {
  background: #fff7e6;
  color: #b26a00;
  border: 1px solid #ffe0b2;
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 12px;
  font-size: 13px;
}

.empty { text-align: center; padding: 60px; color: var(--muted); }
.empty a { color: var(--red); }

.pagination {
  display: flex; align-items: center; justify-content: center; gap: 16px;
  margin: 22px 0 30px;
}
.page-info { color: var(--muted); font-size: 14px; }
.title-strong { font-size: 17px; font-weight: 600; }

/* 结果页搜索栏 */
.search-bar { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.search-bar input {
  padding: 9px 12px; border: 1px solid var(--border); border-radius: 9px; font-size: 14px; flex: 1; min-width: 120px;
}
.search-bar input:focus { border-color: var(--red); }

/* 任务表 */
.task-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.task-table th, .task-table td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--border); }
.task-table th { color: var(--muted); font-weight: 600; background: #fafafa; }
.task-link { color: var(--red); text-decoration: none; }
.task-link:hover { text-decoration: underline; }
.toolbar-left select { padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; }

/* 账号管理 */
.account-select { display: flex; flex-wrap: wrap; gap: 10px; }
.acct-opt {
  display: inline-flex; align-items: center; gap: 6px;
  background: #fafafa; border: 1px solid var(--border); border-radius: 8px;
  padding: 6px 10px; font-size: 13px; cursor: pointer;
}
.acct-opt:has(input:checked) { background: #fff0f2; border-color: #ffb3bf; }
.acct-row {
  display: flex; align-items: center; gap: 12px; padding: 8px 10px;
  border: 1px solid var(--border); border-radius: 8px; margin-bottom: 8px;
}
.acct-name { font-weight: 600; }
.acct-status { color: var(--muted); font-size: 12px; margin-right: 6px; }
.acct-count { color: var(--muted); font-size: 12px; margin-right: auto; }
.st-ready { color: #1a9c4b; font-weight: 600; }
.st-offline { color: #999; }
.st-expired { color: #d0021b; font-weight: 600; }
.st-logging { color: #e6a23c; }
.st-collecting { color: #409eff; }
.radio-opt { display: inline-flex; align-items: center; gap: 6px; margin-right: 18px; font-size: 14px; cursor: pointer; }
.task-list { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.task-row { font-size: 13px; color: #555; background: #fafafa; border-radius: 6px; padding: 6px 10px; }
.task-row::before { content: '▸ '; color: var(--red); }

.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; }
/* 关键：.modal 的 display:flex 会覆盖 hidden 属性的默认 display:none，
   必须显式让 hidden 时隐藏，否则弹窗遮罩一直挡住页面。 */
.modal[hidden] { display: none !important; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.55); }
.modal-content {
  position: relative;
  background: #fff;
  width: min(760px, 92vw);
  max-height: 88vh;
  border-radius: 16px;
  overflow: auto;
  padding: 24px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}
.modal-close {
  position: absolute; top: 12px; right: 14px;
  background: #f2f3f5; border: none; border-radius: 50%;
  width: 30px; height: 30px; cursor: pointer; font-size: 15px;
}
.modal-cover { width: 100%; max-height: 380px; object-fit: cover; border-radius: 12px; margin-bottom: 14px; }
.modal-title { margin: 4px 0 8px; font-size: 20px; }
.modal-open { margin-bottom: 12px; }
.modal-meta { color: var(--muted); font-size: 13px; margin-bottom: 14px; }
.modal-content-text {
  background: #fafafa; padding: 16px; border-radius: 10px; line-height: 1.7;
  white-space: pre-wrap; margin-bottom: 20px; font-size: 15px;
}
.modal-content-text a { color: #4a90d9; }
.modal h4 { margin: 8px 0 12px; }
.comment-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.comment-table th, .comment-table td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--border); }
.comment-table th { color: var(--muted); font-weight: 600; background: #fafafa; }
.cmt-content { max-width: 380px; }
.no-comments { color: var(--muted); }

/* 结构化评论（评论 / 回复） */
.comment-block { margin-bottom: 14px; }
.comment-row {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
}
.comment-row-sub {
  background: #fafbfc;
  border-left: 3px solid #f0c2c9;
}
.comment-sub-list { margin: 8px 0 0 18px; display: flex; flex-direction: column; gap: 8px; }
.comment-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.comment-author { font-weight: 600; color: #333; }
.comment-uid { font-size: 11px; color: #b8bcc4; }
.comment-badge {
  font-size: 11px; color: #fff; background: #ff2442; border-radius: 5px; padding: 1px 6px;
}
.comment-badge.reply { background: #7c8db5; }
.comment-badge.author { background: #ff8f1f; }
.comment-time { color: #999; font-size: 12px; }
.comment-body { color: #444; line-height: 1.6; font-size: 14px; white-space: pre-wrap; }

.tag-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.tag-chip {
  background: #fff0f2; color: #e0245e; border: 1px solid #ffdce0;
  border-radius: 6px; padding: 2px 8px; font-size: 12px;
}
