/* ============================================================
   liuyanban —— 留言板样式
   风格：和主站博客一致的「黑白珍珠」——浅色底、细金属边、圆角卡片
   ============================================================ */

:root {
  --ink: #16171c;
  --ink-soft: rgba(22, 23, 28, 0.62);
  --ink-faint: rgba(22, 23, 28, 0.36);
  --line: rgba(22, 23, 28, 0.12);
  --line-soft: rgba(22, 23, 28, 0.07);
  --card: rgba(255, 255, 255, 0.7);
  --card-solid: #ffffff;
  --shadow: 0 16px 40px rgba(24, 25, 32, 0.09);
  --shadow-lift: 0 22px 52px rgba(24, 25, 32, 0.14);
  --radius: 16px;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --font: "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  background:
    radial-gradient(1100px 620px at 8% -12%, rgba(255, 255, 255, 0.95) 0%, rgba(255, 255, 255, 0) 60%),
    radial-gradient(900px 520px at 102% -4%, rgba(232, 233, 240, 0.9) 0%, rgba(232, 233, 240, 0) 58%),
    linear-gradient(168deg, #f6f6f8 0%, #ededf2 48%, #e5e6eb 100%);
  background-attachment: fixed;
}

[hidden] { display: none !important; }

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(247, 247, 250, 0.82);
  backdrop-filter: blur(14px) saturate(150%);
  -webkit-backdrop-filter: blur(14px) saturate(150%);
  border-bottom: 1px solid var(--line-soft);
}

.topbar::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 1px;
  background: linear-gradient(90deg,
    rgba(22, 23, 28, 0) 0%,
    rgba(22, 23, 28, 0.22) 22%,
    rgba(255, 255, 255, 0.9) 50%,
    rgba(22, 23, 28, 0.22) 78%,
    rgba(22, 23, 28, 0) 100%);
}

.topbar-inner {
  max-width: 780px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--ink);
  text-decoration: none;
}

.brand .dot { margin: 0 3px; color: var(--ink-faint); }

.topbar-actions { display: flex; align-items: center; gap: 10px; }

.pill {
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.7);
  font-size: 12px;
  color: var(--ink-soft);
  white-space: nowrap;
}

.pill.is-unlocked {
  background: var(--ink);
  border-color: transparent;
  color: #fff;
}

.ghost-btn {
  padding: 6px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.7);
  color: var(--ink-soft);
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
  transition: background-color 180ms var(--ease), color 180ms var(--ease), border-color 180ms var(--ease);
}

.ghost-btn:hover { background: #fff; color: var(--ink); border-color: rgba(22, 23, 28, 0.24); }

/* ---------------- 版心 ---------------- */

.wrap {
  max-width: 780px;
  margin: 0 auto;
  padding: 28px 20px 60px;
}

.intro { margin-bottom: 22px; }

.intro h1 {
  margin: 0 0 8px;
  font-size: 30px;
  letter-spacing: 0.02em;
  font-weight: 800;
  background: linear-gradient(96deg, #101116 12%, #4b4d59 46%, #101116 82%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.intro p {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.7;
  color: var(--ink-soft);
}

/* ---------------- 卡片与表单 ---------------- */

.card {
  margin-bottom: 16px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.row { display: flex; align-items: center; gap: 10px; }
.row.foot { margin-top: 10px; }
.spacer { flex: 1 1 auto; }

.input, .textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.86);
  color: var(--ink);
  font: inherit;
  font-size: 13.5px;
  outline: none;
  transition: border-color 160ms var(--ease), box-shadow 160ms var(--ease), background-color 160ms var(--ease);
}

.input::placeholder, .textarea::placeholder { color: var(--ink-faint); }

.input:focus, .textarea:focus {
  background: #fff;
  border-color: rgba(22, 23, 28, 0.4);
  box-shadow: 0 0 0 3px rgba(22, 23, 28, 0.07);
}

.textarea {
  margin-top: 10px;
  min-height: 132px;
  padding: 12px 13px;
  line-height: 1.75;
  resize: vertical;
}

.btn {
  flex: 0 0 auto;
  padding: 10px 18px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 140ms var(--ease), background-color 180ms var(--ease), color 180ms var(--ease), box-shadow 180ms var(--ease);
}

.btn:hover { background: #fff; box-shadow: 0 8px 22px rgba(24, 25, 32, 0.1); }
.btn:active { transform: scale(0.975); }
.btn[disabled] { opacity: 0.55; cursor: default; box-shadow: none; transform: none; }

.btn.primary {
  border-color: transparent;
  background: linear-gradient(160deg, #31323a, #16171c);
  color: #fff;
}

.btn.primary:hover { background: linear-gradient(160deg, #3d3e48, #22232a); }

.btn.danger { color: #9b2222; border-color: rgba(155, 34, 34, 0.28); }
.btn.danger:hover { background: rgba(200, 60, 60, 0.1); }

.hint {
  margin: 10px 0 0;
  font-size: 12px;
  line-height: 1.6;
  color: var(--ink-faint);
}

.count {
  flex: 0 0 auto;
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  color: var(--ink-faint);
}

.file-btn {
  display: inline-flex;
  align-items: center;
  padding: 8px 14px;
  border: 1px dashed rgba(22, 23, 28, 0.24);
  border-radius: 10px;
  font-size: 13px;
  color: var(--ink-soft);
  cursor: pointer;
  transition: border-color 180ms var(--ease), color 180ms var(--ease), background-color 180ms var(--ease);
}

.file-btn:hover { border-color: rgba(22, 23, 28, 0.44); color: var(--ink); background: rgba(255, 255, 255, 0.7); }

/* 待发图片的缩略图 */
.thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.thumb {
  position: relative;
  width: 78px;
  height: 78px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #fff;
}

.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.thumb button {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 20px;
  height: 20px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(16, 17, 22, 0.72);
  color: #fff;
  font-size: 12px;
  line-height: 20px;
  cursor: pointer;
}

/* ---------------- 留言列表 ---------------- */

.list-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 26px 0 12px;
}

.list-head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--ink);
}

.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }

.msg {
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: 0 10px 28px rgba(24, 25, 32, 0.06);
  animation: msgIn 260ms var(--ease);
}

.msg.is-new { border-color: rgba(22, 23, 28, 0.3); }

@keyframes msgIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.msg-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 12px;
  color: var(--ink-faint);
}

.msg-name { font-size: 13.5px; font-weight: 700; color: var(--ink); }

.msg-time { font-variant-numeric: tabular-nums; }

.msg-edited {
  padding: 1px 6px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 10.5px;
  color: var(--ink-faint);
}

.msg-body {
  font-size: 14.5px;
  line-height: 1.8;
  color: rgba(22, 23, 28, 0.9);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.msg-imgs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.msg-imgs a {
  display: block;
  width: 108px;
  height: 108px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #fff;
}

.msg-imgs img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 300ms var(--ease);
}

.msg-imgs a:hover img { transform: scale(1.06); }

.msg-tools {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line-soft);
}

.msg-tools .btn { padding: 6px 12px; font-size: 12.5px; font-weight: 500; }

.msg-edit { margin-top: 4px; }

.msg-edit .btn { padding: 7px 14px; font-size: 12.5px; }

.empty {
  padding: 28px 0;
  text-align: center;
  font-size: 13.5px;
  color: var(--ink-faint);
}

/* ---------------- 页脚 / 提示 ---------------- */

.foot {
  margin-top: 30px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--ink-faint);
}

.foot a { color: var(--ink-soft); text-underline-offset: 3px; }
.foot a:hover { color: var(--ink); }
.foot .sep { opacity: 0.5; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  z-index: 50;
  max-width: min(90vw, 460px);
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(16, 17, 22, 0.9);
  color: #fff;
  font-size: 13px;
  line-height: 1.5;
  box-shadow: 0 14px 34px rgba(16, 17, 22, 0.3);
  animation: toastIn 200ms var(--ease);
}

.toast.is-bad { background: rgba(150, 30, 30, 0.94); }

@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ---------------- 窄屏 ---------------- */

@media (max-width: 560px) {
  .wrap { padding: 20px 14px 48px; }
  .intro h1 { font-size: 25px; }
  .card { padding: 14px; }
  .row { flex-wrap: wrap; }
  .row .input { flex: 1 1 100%; }
  .row .btn { flex: 1 1 100%; }
  .row.foot .btn { flex: 0 0 auto; }
  .msg-imgs a { width: 88px; height: 88px; }
  .topbar-inner { padding: 10px 14px; }
  .brand { font-size: 13px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ---------------- 顶栏小图标按钮 / 右下角刷新倒计时 ---------------- */

.icon-btn {
  width: 30px;
  height: 28px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  line-height: 1;
}

.refresh-pill {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 40;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.86);
  color: var(--ink-soft);
  font: inherit;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  cursor: pointer;
  box-shadow: 0 10px 26px rgba(24, 25, 32, 0.12);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: color 180ms var(--ease), background-color 180ms var(--ease), transform 140ms var(--ease);
}

.refresh-pill:hover { color: var(--ink); transform: translateY(-1px); }
.refresh-pill.is-loading { opacity: 0.6; }

.keyform {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line-soft);
}

/* ---------------- 留言正文截断 / 查看器 ---------------- */

.msg-body.is-clamped { cursor: pointer; }

.msg-more {
  color: var(--ink-soft);
  border-bottom: 1px dotted rgba(128, 128, 128, 0.5);
  cursor: pointer;
}

.msg-imgs a { cursor: zoom-in; }

.viewer {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px;
}

.viewer-scrim {
  position: absolute;
  inset: 0;
  background: rgba(12, 12, 14, 0.72);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

.viewer-box {
  position: relative;
  z-index: 1;
  max-width: min(92vw, 880px);
  max-height: 88vh;
  overflow: auto;
  padding: 22px 22px 20px;
  border-radius: 14px;
  background: #ffffff;
  color: var(--ink);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.34);
  animation: viewerIn 200ms var(--ease);
}

@keyframes viewerIn {
  from { opacity: 0; transform: translateY(8px) scale(0.99); }
  to { opacity: 1; transform: none; }
}

.viewer-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.06);
  color: #16171c;
  font-size: 16px;
  line-height: 30px;
  cursor: pointer;
}

.viewer-close:hover { background: rgba(0, 0, 0, 0.12); }

.viewer-media img {
  display: block;
  max-width: 100%;
  max-height: 76vh;
  border-radius: 10px;
}

.viewer-text { max-width: 660px; }

.viewer-meta {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 10px;
  font-size: 12px;
  color: rgba(22, 23, 28, 0.5);
}

.viewer-meta b { font-size: 14px; color: #16171c; }

.viewer-body {
  font-size: 15px;
  line-height: 1.9;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: #16171c;
}

.viewer-imgs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.viewer-imgs img {
  width: 120px;
  height: 120px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid rgba(22, 23, 28, 0.12);
  cursor: zoom-in;
}

/* ---------------- 夜间模式：纯黑白，不用渐变和金属质感 ---------------- */

html[data-theme="dark"] {
  --ink: #f2f2f3;
  --ink-soft: rgba(242, 242, 243, 0.66);
  --ink-faint: rgba(242, 242, 243, 0.4);
  --line: rgba(255, 255, 255, 0.14);
  --line-soft: rgba(255, 255, 255, 0.08);
  --card: #141416;
  --card-solid: #17171a;
  --shadow: none;
  --shadow-lift: none;
  color-scheme: dark;
  background: #0d0d0f;
}

html[data-theme="dark"] body { background: #0d0d0f; }

html[data-theme="dark"] .topbar {
  background: #0d0d0f;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

html[data-theme="dark"] .topbar::after { display: none; }

html[data-theme="dark"] .brand { color: #f2f2f3; }

html[data-theme="dark"] .pill,
html[data-theme="dark"] .ghost-btn,
html[data-theme="dark"] .btn,
html[data-theme="dark"] .file-btn {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.18);
  color: rgba(242, 242, 243, 0.78);
  box-shadow: none;
}

html[data-theme="dark"] .ghost-btn:hover,
html[data-theme="dark"] .btn:hover,
html[data-theme="dark"] .file-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.34);
  color: #ffffff;
}

html[data-theme="dark"] .pill.is-unlocked {
  background: #f2f2f3;
  border-color: transparent;
  color: #0d0d0f;
}

html[data-theme="dark"] .btn.primary {
  background: #f2f2f3;
  border-color: transparent;
  color: #0d0d0f;
  box-shadow: none;
}

html[data-theme="dark"] .btn.primary:hover { background: #ffffff; }

html[data-theme="dark"] .btn.danger {
  color: #f0a0a0;
  border-color: rgba(240, 160, 160, 0.34);
}

html[data-theme="dark"] .btn.danger:hover { background: rgba(240, 120, 120, 0.12); }

html[data-theme="dark"] .input,
html[data-theme="dark"] .textarea {
  background: #141416;
  border-color: rgba(255, 255, 255, 0.14);
  color: #f2f2f3;
}

html[data-theme="dark"] .input:focus,
html[data-theme="dark"] .textarea:focus {
  background: #17171a;
  border-color: rgba(255, 255, 255, 0.36);
  box-shadow: none;
}

html[data-theme="dark"] .card,
html[data-theme="dark"] .msg {
  background: #141416;
  border-color: rgba(255, 255, 255, 0.1);
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

html[data-theme="dark"] .intro h1 {
  background: none;
  -webkit-background-clip: initial;
  background-clip: initial;
  color: #f2f2f3;
}

html[data-theme="dark"] .msg-body { color: rgba(242, 242, 243, 0.92); }
html[data-theme="dark"] .msg-name { color: #f2f2f3; }
html[data-theme="dark"] .msg.is-new { border-color: rgba(255, 255, 255, 0.3); }

html[data-theme="dark"] .msg-more {
  color: rgba(242, 242, 243, 0.66);
  border-bottom-color: rgba(255, 255, 255, 0.34);
}

html[data-theme="dark"] .msg-imgs a,
html[data-theme="dark"] .thumb {
  background: #101012;
  border-color: rgba(255, 255, 255, 0.12);
}

html[data-theme="dark"] .refresh-pill {
  background: #141416;
  border-color: rgba(255, 255, 255, 0.14);
  color: rgba(242, 242, 243, 0.7);
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

html[data-theme="dark"] .toast {
  background: #f2f2f3;
  color: #0d0d0f;
  box-shadow: none;
}

html[data-theme="dark"] .toast.is-bad { background: #c8443f; color: #ffffff; }

html[data-theme="dark"] .foot a { color: rgba(242, 242, 243, 0.6); }
html[data-theme="dark"] .foot a:hover { color: #ffffff; }

html[data-theme="dark"] .viewer-box {
  background: #141416;
  color: #f2f2f3;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

html[data-theme="dark"] .viewer-close { background: rgba(255, 255, 255, 0.08); color: #f2f2f3; }
html[data-theme="dark"] .viewer-close:hover { background: rgba(255, 255, 255, 0.16); }
html[data-theme="dark"] .viewer-meta { color: rgba(242, 242, 243, 0.5); }
html[data-theme="dark"] .viewer-meta b { color: #f2f2f3; }
html[data-theme="dark"] .viewer-body { color: rgba(242, 242, 243, 0.92); }
html[data-theme="dark"] .viewer-imgs img { border-color: rgba(255, 255, 255, 0.12); }
