/* public/app.css — 全局样式
 *
 * 纯手写 CSS（没有使用 TinyVue 等组件库），因此颜色可自由使用。
 * 主色：Reddit 橙 #ff4500
 */

:root {
  --accent: #ff4500;
  --accent-dark: #d63b00;
  --accent-soft: #fff1ea;

  --bg: #f6f7f8;
  --card: #ffffff;
  --card-2: #fafbfc;

  --border: #e2e4e8;
  --border-soft: #eef0f3;

  --text: #17181c;
  --text-2: #44474f;
  --muted: #858a94;

  --ok: #0a8754;
  --ok-soft: #e6f5ee;
  --warn: #a86200;
  --warn-soft: #fff4e0;
  --err: #c62828;
  --err-soft: #fdecec;
  --run: #1b6fd4;
  --run-soft: #e8f1fd;
  --info-soft: #eef1f6;

  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --shadow: 0 1px 2px rgba(16, 18, 22, 0.06), 0 8px 22px rgba(16, 18, 22, 0.05);
  --shadow-lg: 0 12px 40px rgba(16, 18, 22, 0.16);

  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3, h4 { margin: 0 0 .4em; line-height: 1.35; font-weight: 600; }
h1 { font-size: 20px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
p { margin: 0 0 .7em; }
p:last-child { margin-bottom: 0; }

a { color: var(--accent-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

code, pre, .mono { font-family: var(--mono); font-size: 12.5px; }
.mono { font-size: 12px; color: var(--text-2); }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.hidden, [hidden] { display: none !important; }
.spacer { flex: 1; }
.right { margin-left: auto; }

/* ─────────────────────────── 顶栏 ─────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand { display: flex; align-items: center; gap: 8px; color: var(--text); font-weight: 600; }
.brand:hover { text-decoration: none; }
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent); color: #fff; font-size: 12px; font-weight: 700;
}
.brand-text { font-size: 15px; }
.topbar-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }

/* ─────────────────────────── 布局 ─────────────────────────── */
.container { max-width: 1180px; margin: 0 auto; padding: 20px; }
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 20px;
  align-items: start;
}
.sidebar { position: sticky; top: 70px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.panel { padding: 18px 20px; margin-bottom: 18px; }
.panel-title { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.panel-title .right { font-size: 12px; font-weight: 400; }

/* ─────────────────────────── 按钮 ─────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 14px;
  font: inherit; font-size: 13px; line-height: 1.4;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { background: var(--card-2); border-color: #d3d6dc; text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn-danger { background: var(--err); border-color: var(--err); color: #fff; }
.btn-danger:hover { background: #a91f1f; border-color: #a91f1f; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--info-soft); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-tiny { padding: 1px 8px; font-size: 11.5px; border-radius: 6px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

/* ─────────────────────────── 徽标 ─────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 11.5px; font-weight: 500; line-height: 1.7;
  background: var(--info-soft); color: var(--text-2);
  white-space: nowrap;
}
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-err { background: var(--err-soft); color: var(--err); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-run { background: var(--run-soft); color: var(--run); }
.badge-muted { background: var(--info-soft); color: var(--muted); }
.badge-op { background: var(--accent-soft); color: var(--accent-dark); font-weight: 600; }
.badge-dist { background: #ede7f6; color: #5b3fa8; }
.badge-accent { background: var(--accent-soft); color: var(--accent-dark); }

/* ─────────────────────────── 表单 ─────────────────────────── */
.form { display: block; }
.form-row { margin-bottom: 14px; }
.form-label {
  display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; color: var(--text);
}
.form-label .hint { display: block; font-weight: 400; }
.hint { color: var(--muted); font-size: 12px; font-weight: 400; margin-top: 3px; }
.input {
  width: 100%;
  padding: 8px 11px;
  font: inherit; font-size: 13.5px;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255, 69, 0, .12); }
.textarea { resize: vertical; min-height: 120px; font-family: var(--mono); font-size: 12.5px; line-height: 1.6; }
.form-inline { display: flex; align-items: center; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
.form-actions { display: flex; gap: 8px; align-items: center; margin-top: 16px; flex-wrap: wrap; }
.check { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; font-size: 13px; }
.check input { accent-color: var(--accent); width: 15px; height: 15px; }

/* ─────────────────────────── 提示条 ─────────────────────────── */
.alert {
  padding: 9px 13px; border-radius: var(--radius-sm); font-size: 13px; margin: 10px 0;
  border: 1px solid transparent;
}
.alert-err { background: var(--err-soft); color: var(--err); border-color: #f6d5d5; }
.alert-warn { background: var(--warn-soft); color: var(--warn); border-color: #f3e0bd; }
.alert-ok { background: var(--ok-soft); color: var(--ok); border-color: #c9e8da; }
.alert-info { background: var(--run-soft); color: var(--run); border-color: #cfe1f8; }

.empty {
  padding: 36px 20px; text-align: center; color: var(--muted);
  background: var(--card); border: 1px dashed var(--border); border-radius: var(--radius);
}

/* ─────────────────────────── 统计 ─────────────────────────── */
.stat-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.stat {
  flex: 1 1 96px; min-width: 96px;
  padding: 8px 11px;
  background: var(--card-2); border: 1px solid var(--border-soft); border-radius: var(--radius-sm);
}
.stat-label { font-size: 11.5px; color: var(--muted); }
.stat-value { font-size: 16px; font-weight: 600; line-height: 1.35; word-break: break-all; }
.stat-value.sm { font-size: 13px; font-weight: 500; }
.summary-bar {
  display: flex; flex-wrap: wrap; gap: 8px;
  padding: 12px 14px; margin-bottom: 16px;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* ─────────────────────────── 任务卡片 ─────────────────────────── */
.task-list { display: grid; gap: 12px; }
.task-card {
  padding: 14px 16px;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.task-card:hover { border-color: #d8dbe1; }
.task-card-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.task-name { font-size: 15px; font-weight: 600; color: var(--text); }
.task-name:hover { color: var(--accent-dark); }
.task-meta { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 4px; }
.task-card-foot { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border-soft); align-items: center; }

/* ─────────────────────────── 进度 ─────────────────────────── */
.progress-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.progress-message { margin: 10px 0 8px; font-size: 13.5px; }
.progress-bar { height: 7px; background: var(--border-soft); border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: var(--accent); border-radius: 999px; transition: width .3s ease; }
.progress-counts { margin-top: 8px; font-size: 12px; color: var(--muted); display: flex; gap: 16px; flex-wrap: wrap; }

/* ─────────────────────────── 表格 ─────────────────────────── */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--border-soft); vertical-align: top; }
.table th { background: var(--card-2); font-weight: 600; color: var(--text-2); font-size: 12px; white-space: nowrap; position: sticky; top: 0; }
.table tr:last-child td { border-bottom: none; }
/* 极淡的隔行斑马纹，方便横向扫读 */
.table tbody tr:nth-child(even) { background: var(--card-2); }
.table tbody tr:hover { background: var(--info-soft); }
.table td.num { text-align: right; font-family: var(--mono); font-size: 12px; white-space: nowrap; }

/* 表格里的帖子标题：比正文略大一点，靠字重和颜色拉开层级；超长标题截两行 */
.table .post-title-cell { min-width: 200px; }
.table .post-title {
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1.45;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}
.table .post-title:hover { color: var(--accent-dark); text-decoration: none; }
.table .post-id {
  display: block;
  font-family: var(--mono); font-size: 11px; color: var(--muted);
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ─────────────────────────── 帖子正文 ─────────────────────────── */
.post-head { padding: 18px 20px; }
.post-title { font-size: 20px; font-weight: 600; line-height: 1.4; margin: 0 0 8px; word-break: break-word; }
.post-meta { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12.5px; color: var(--muted); align-items: center; }
.post-meta .sep { color: var(--border); }
.post-flair { background: var(--accent-soft); color: var(--accent-dark); padding: 1px 8px; border-radius: 999px; font-size: 11.5px; }
.post-body { padding: 4px 20px 20px; }
.post-body-empty { color: var(--muted); font-style: normal; }

.meta-list { display: grid; gap: 7px; }
.meta-list div { display: flex; gap: 10px; font-size: 12.5px; border-bottom: 1px dashed var(--border-soft); padding-bottom: 6px; }
.meta-list dt, .meta-list .k { color: var(--muted); flex: 0 0 84px; }
.meta-list .v { color: var(--text-2); word-break: break-all; }
.meta-list .v a { word-break: break-all; }

.user-card .k { flex-basis: 74px; }

/* ─────────────────────────── Markdown ─────────────────────────── */
.md { font-size: 13.8px; line-height: 1.7; word-break: break-word; overflow-wrap: anywhere; }
.md p { margin: 0 0 .7em; }
.md p:last-child { margin-bottom: 0; }
.md ul, .md ol { margin: .3em 0 .7em; padding-left: 22px; }
.md li { margin: .15em 0; }
.md blockquote {
  margin: .4em 0; padding: 4px 0 4px 12px;
  border-left: 3px solid var(--border);
  color: var(--text-2);
}
.md code { background: var(--info-soft); padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.md a { color: var(--accent-dark); }
.md img { max-width: 100%; }
.md .md-media { color: var(--muted); font-size: 12.5px; }

/* ─────────────────────────── 评论树 ─────────────────────────── */
.comment-list, .comment-children { list-style: none; margin: 0; padding: 0; }
.comment-children { padding-left: 20px; border-left: 2px solid var(--border); margin-left: 4px; }
.comment { padding: 10px 0 4px; }
/* 分隔线只留在顶层评论之间，嵌套层内不再画横线 */
.comment-list > .comment { border-bottom: 1px solid var(--border-soft); }
.comment-list > .comment:last-child { border-bottom: none; }
.comment-children .comment { border-bottom: none; }
.comment-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12.5px; }
.c-author { font-weight: 600; color: var(--text); }
.c-score { color: var(--text-2); font-family: var(--mono); font-size: 11.5px; }
.c-time { color: var(--muted); }
.comment-body { margin: 6px 0 2px; }
.comment-placeholder { color: var(--muted); font-style: italic; margin: 0; }
.comment-actions { display: flex; align-items: center; gap: 10px; margin: 2px 0 6px; flex-wrap: wrap; }
.comment-path { color: var(--muted); font-size: 11px; }
.comment-more { margin: 10px 0 4px; }
.more-btn { margin-top: 14px; }

/* ─────────────────────────── 折叠 ─────────────────────────── */
details.fold { border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); margin-bottom: 16px; }
details.fold > summary {
  cursor: pointer; padding: 11px 16px; font-weight: 600; font-size: 13.5px;
  list-style: none; display: flex; align-items: center; gap: 8px;
}
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary::before { content: "▸"; color: var(--muted); font-size: 11px; }
details.fold[open] > summary::before { content: "▾"; }
details.fold > .fold-body { padding: 0 16px 14px; border-top: 1px solid var(--border-soft); }

/* ─────────────────────────── 弹窗 ─────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(16, 18, 22, .42);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  animation: fade-in .12s ease-out;
}
.modal {
  width: 100%; max-width: 460px;
  background: var(--card); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 20px;
  animation: pop-in .14s ease-out;
}
.modal-title { margin-bottom: 10px; }
.modal-body { font-size: 13.5px; color: var(--text-2); }
.modal-body .input { margin-top: 8px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
.modal-error { color: var(--err); font-size: 12.5px; margin-top: 8px; }
.share-link-box { display: flex; gap: 8px; margin-top: 10px; }
.share-link-box .input { font-family: var(--mono); font-size: 12px; }

@keyframes fade-in { from { opacity: 0 } to { opacity: 1 } }
@keyframes pop-in { from { opacity: 0; transform: translateY(8px) scale(.98) } to { opacity: 1; transform: none } }
@keyframes spin { to { transform: rotate(360deg) } }

/* ─────────────────────────── Toast ─────────────────────────── */
.toast-wrap {
  position: fixed; right: 18px; bottom: 18px; z-index: 200;
  display: flex; flex-direction: column; gap: 8px; align-items: flex-end;
}
.toast {
  padding: 9px 14px; border-radius: var(--radius-sm);
  background: #1c1f26; color: #fff; font-size: 13px;
  box-shadow: var(--shadow-lg); max-width: 380px;
  animation: pop-in .14s ease-out;
}
.toast-ok { background: #0f7a4d; }
.toast-err { background: #b3261e; }
.toast-warn { background: #a86200; }

/* ─────────────────────────── 加载态 ─────────────────────────── */
.spinner {
  display: inline-block; width: 15px; height: 15px;
  border: 2px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .7s linear infinite; vertical-align: -2px;
}
.loading-box { display: flex; align-items: center; gap: 10px; padding: 26px; color: var(--muted); justify-content: center; }
.skeleton {
  background: linear-gradient(90deg, #eef0f3 25%, #f6f7f8 37%, #eef0f3 63%);
  background-size: 400% 100%;
  animation: shimmer 1.3s ease infinite;
  border-radius: 6px; height: 13px; margin: 8px 0;
}
@keyframes shimmer { 0% { background-position: 100% 50% } 100% { background-position: 0 50% } }
.skeleton-line { width: 100%; }
.skeleton-line.short { width: 42%; }

/* ─────────────────────────── 分享页 ─────────────────────────── */
.notice-banner {
  padding: 12px 18px; margin-bottom: 16px;
  background: var(--accent-soft); border: 1px solid #ffd9c9; color: #8a2c00;
  border-radius: var(--radius); font-size: 13.5px; font-weight: 500;
}
.unlock-box { max-width: 420px; margin: 40px auto; text-align: center; }
.unlock-box .input { text-align: center; letter-spacing: 1px; }
.share-post { margin-bottom: 18px; }
.share-post .post-body { padding: 0 20px 18px; }
.share-post .post-head { padding-bottom: 8px; }
.share-posts { display: grid; gap: 18px; }

.footnote { color: var(--muted); font-size: 12px; margin-top: 26px; text-align: center; }

/* ─────────────────────────── 登录页 ─────────────────────────── */
.auth-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(circle at 15% 0%, rgba(255, 69, 0, .07), transparent 45%),
    radial-gradient(circle at 85% 100%, rgba(27, 111, 212, .06), transparent 45%),
    var(--bg);
}
.auth-wrap { width: 100%; max-width: 400px; }
.auth-card { padding: 28px 26px 22px; }
.auth-brand {
  display: flex; align-items: center; gap: 9px;
  font-size: 13px; font-weight: 600; color: var(--text-2);
  margin-bottom: 22px;
}
.auth-title { font-size: 21px; margin: 0 0 6px; }
.auth-desc { color: var(--muted); font-size: 13px; line-height: 1.65; margin: 0 0 20px; }
.auth-submit { width: 100%; justify-content: center; padding: 9px 14px; }
.auth-foot { margin: 16px 0 0; text-align: center; font-size: 12.5px; color: var(--muted); }
.auth-note { text-align: center; color: var(--muted); font-size: 11.5px; margin-top: 16px; }

/* 顶栏用户区 */
.user-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px 3px 4px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12.5px; color: var(--text-2);
  background: var(--card);
}
.user-avatar {
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent-dark);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
}

/* 可点击的账号设置入口 */
.user-chip-btn {
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.user-chip-btn:hover { background: var(--card-2); border-color: #d3d6dc; }
.user-chip-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.user-gear {
  font-size: 11px; color: var(--muted);
  margin-left: 1px; line-height: 1;
}
.user-chip-btn:hover .user-gear { color: var(--accent-dark); }

/* 配额提示条 */
.quota-bar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 8px 14px; margin-bottom: 14px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px; color: var(--muted);
}
.quota-bar b { color: var(--text-2); font-family: var(--mono); font-weight: 600; }
.quota-bar .sep { color: var(--border); }

/* ─────────────────────────── 响应式 ─────────────────────────── */
@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: static; order: 2; }
  .container { padding: 14px; }
  .topbar-inner { padding: 10px 14px; }
  .post-title { font-size: 17px; }
  .comment-children { padding-left: 12px; }
  .panel { padding: 14px; }
}
@media (max-width: 560px) {
  .brand-text { display: none; }
  .task-card-foot .btn { flex: 1 1 auto; }
  .comment-children { padding-left: 10px; }
}
