:root {
  color-scheme: dark;
  --bg: #0c0a09;
  --card: #1c1c1c;
  --panel: #1b1918;
  --ink: #e7e5e4;
  --muted: #a8a29e;
  --dim: #78716c;
  --gold: #f59e0b;
  --gold-soft: #d2ae72;
  --button: #c69e62;
  --button-hover: #dbb77c;
  --line: rgba(210, 174, 114, .22);
  --line-strong: rgba(217, 119, 6, .45);
  --danger: #f87171;
  --success: #34d399;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { min-height: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  padding: max(16px, env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom));
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 50% 12%, rgba(170, 137, 87, .1), transparent 40%),
    radial-gradient(circle at 50% 100%, rgba(217, 119, 6, .05), transparent 45%),
    var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

.account-card {
  width: min(100%, 560px);
  padding: 28px 24px calc(24px + env(safe-area-inset-bottom));
  border: 1px solid var(--line);
  border-radius: 30px;
  background: var(--card);
  box-shadow: 15px 15px 30px #080706, -15px -15px 30px #302d2a;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--gold-soft);
  font-size: 11px;
  letter-spacing: .22em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(26px, 7vw, 34px);
  font-weight: 600;
  letter-spacing: .04em;
}

.lede {
  margin: 12px 0 22px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.field {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
}

.field > span {
  color: var(--gold-soft);
  font-size: 12px;
  letter-spacing: .08em;
}

input, textarea, select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid rgba(120, 113, 108, .4);
  border-radius: 12px;
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  font-size: 16px;
  line-height: 1.5;
  transition: border-color .2s, box-shadow .2s, background .2s;
}

input::placeholder, textarea::placeholder { color: #6b6560; }

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--line-strong);
  box-shadow: 0 0 0 3px rgba(217, 119, 6, .14);
  background: #211d1a;
}

textarea { resize: vertical; min-height: 92px; }

.hint {
  margin: -6px 0 14px;
  color: var(--dim);
  font-size: 11px;
  line-height: 1.6;
}

.primary {
  width: 100%;
  min-height: 48px;
  margin-top: 6px;
  padding: 0 20px;
  border: 1px solid rgba(213, 177, 111, .65);
  border-radius: 999px;
  background: var(--button);
  color: #201c18;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .06em;
  cursor: pointer;
  transition: background .2s, transform .15s, box-shadow .2s, opacity .2s;
}

.primary:hover:not(:disabled) { background: var(--button-hover); box-shadow: 0 0 26px rgba(205, 164, 96, .2); }
.primary:active:not(:disabled) { transform: translateY(1px); }
.primary:disabled { opacity: .55; cursor: default; }

.ghost {
  padding: 8px 14px;
  border: 1px solid rgba(210, 174, 114, .32);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  letter-spacing: .06em;
  cursor: pointer;
  transition: color .2s, border-color .2s, background .2s;
}

.ghost:hover { color: var(--gold); border-color: var(--line-strong); background: rgba(81, 53, 27, .35); }

.link-button {
  border: 0;
  background: none;
  color: var(--gold-soft);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.form-message {
  min-height: 18px;
  margin: 10px 0 0;
  color: var(--danger);
  font-size: 12px;
  line-height: 1.6;
}

.form-message.is-ok { color: var(--success); }

.switch {
  margin: 18px 0 0;
  color: var(--dim);
  font-size: 12px;
  text-align: center;
}

.switch a { color: var(--gold-soft); }

.noscript {
  margin: 18px 0 0;
  color: var(--danger);
  font-size: 12px;
}

/* 评论区 */
.comments-card { display: block; }

.comments-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

.user-box {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.current-user {
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--gold);
  font-size: 12px;
  letter-spacing: .04em;
}

.comment-list {
  display: grid;
  gap: 0;
  margin: 0 0 8px;
  border-top: 1px solid rgba(120, 113, 108, .18);
}

.comment-item {
  padding: 14px 2px;
  border-bottom: 1px solid rgba(120, 113, 108, .18);
}

.comment-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.comment-author {
  overflow-wrap: anywhere;
  color: var(--gold);
  font-size: 12px;
  letter-spacing: .04em;
}

.comment-time {
  flex: 0 0 auto;
  color: var(--dim);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.comment-body {
  margin: 0;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.75;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.empty {
  margin: 26px 0;
  color: var(--dim);
  font-size: 12px;
  text-align: center;
}

.list-actions { display: flex; justify-content: center; margin: 10px 0 16px; }

.composer {
  position: sticky;
  bottom: 0;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid rgba(210, 174, 114, .18);
  background: linear-gradient(to bottom, rgba(28, 28, 28, .86), var(--card) 26%);
}

.composer .primary { width: auto; min-width: 96px; min-height: 42px; margin: 0; padding: 0 22px; font-size: 14px; }

.composer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
}

.count {
  color: var(--dim);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* 后台管理 */
body[data-page="admin"] .account-card { width: min(100%, 1000px); }

.admin-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 18px 0 4px;
}

.admin-tabs button {
  padding: 8px 16px;
  border: 1px solid rgba(210, 174, 114, .26);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  letter-spacing: .04em;
  cursor: pointer;
  transition: color .2s, border-color .2s, background .2s;
}

.admin-tabs button:hover { color: var(--gold-soft); }
.admin-tabs button.is-active {
  color: var(--gold);
  border-color: var(--line-strong);
  background: rgba(81, 53, 27, .45);
}

.admin-panel { margin-top: 14px; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  margin-top: 8px;
}

.stat-card {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border: 1px solid rgba(120, 113, 108, .22);
  border-radius: 14px;
  background: var(--panel);
}

.stat-card strong {
  color: var(--gold);
  font-size: 22px;
  font-variant-numeric: tabular-nums;
}

.stat-card span { color: var(--dim); font-size: 11px; letter-spacing: .04em; }

.admin-form-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 14px 0 10px;
}

.admin-form-row input, .admin-form-row select { flex: 1 1 180px; width: auto; }
.admin-form-row .primary { width: auto; min-height: 44px; margin: 0; padding: 0 20px; font-size: 13px; }

.admin-table-wrap {
  overflow-x: auto;
  margin-top: 10px;
  border: 1px solid rgba(120, 113, 108, .2);
  border-radius: 14px;
}

.admin-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.admin-table th, .admin-table td {
  padding: 9px 10px;
  border-bottom: 1px solid rgba(120, 113, 108, .16);
  text-align: left;
  vertical-align: top;
}
.admin-table th {
  color: var(--gold-soft);
  font-weight: 500;
  white-space: nowrap;
  background: rgba(27, 25, 24, .7);
}
.admin-table tr:last-child td { border-bottom: 0; }
.admin-table td { color: var(--muted); }
.admin-table td.wrap { max-width: 220px; overflow-wrap: anywhere; }

.admin-comment-cell { min-width: 220px; max-width: 380px; }
.admin-comment-body {
  max-height: 7.5em;
  overflow: auto;
  color: var(--ink);
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.admin-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.admin-action { padding: 5px 10px; font-size: 11px; white-space: nowrap; }

.admin-table code { color: var(--gold); letter-spacing: .08em; cursor: copy; }
.admin-votes { display: grid; gap: 2px; min-width: 180px; }
.admin-vote { color: var(--muted); line-height: 1.5; }
.admin-task-comment { display: flex; align-items: flex-start; gap: 8px; justify-content: space-between; }
.admin-task-comment span { flex: 1; overflow-wrap: anywhere; }
.admin-task-comment .admin-action { padding: 2px 8px; }

.badge {
  display: inline-block;
  padding: 3px 8px;
  border: 1px solid rgba(120, 113, 108, .35);
  border-radius: 999px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.4;
  white-space: nowrap;
}
.badge.ok { color: var(--success); border-color: rgba(52, 211, 153, .35); }
.badge.warn { color: var(--gold); border-color: rgba(245, 158, 11, .4); }
.badge.bad { color: var(--danger); border-color: rgba(248, 113, 113, .4); }
.badge.gold { color: var(--button-hover); border-color: rgba(210, 174, 114, .45); }
.badge.muted { color: var(--dim); }

.admin-empty { padding: 26px 10px; color: var(--dim); text-align: center; }

.admin-code {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 8px 0 4px;
  padding: 10px 12px;
  border: 1px dashed rgba(210, 174, 114, .45);
  border-radius: 12px;
  background: rgba(81, 53, 27, .25);
  color: var(--muted);
  font-size: 12px;
}
.admin-code code { color: var(--gold); font-size: 15px; letter-spacing: .08em; }

.admin-secret {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 10px 0;
  padding: 10px 12px;
  border: 1px solid rgba(245, 158, 11, .4);
  border-radius: 12px;
  background: rgba(81, 53, 27, .35);
  color: var(--muted);
  font-size: 12px;
}
.admin-secret code { color: var(--gold); font-size: 14px; }

@media (max-width: 640px) {
  .admin-tabs { gap: 6px; }
  .admin-tabs button { padding: 7px 12px; }
  .admin-table { font-size: 11px; }
}

@media (max-width: 380px) {
  body { padding-inline: 10px; }
  .account-card { padding: 22px 16px calc(20px + env(safe-area-inset-bottom)); border-radius: 24px; }
  .comments-header { flex-direction: column; align-items: flex-start; }
  .user-box { justify-content: flex-start; }
}
