/* ══════════════════════════════════════════════════════════════════
   mini 留言板 样式
   视觉参照「简易留言板」模板（蓝色顶栏 + 左侧导航 + 卡片列表），
   但完全手写、零外部依赖：
     · 不用 cdn.tailwindcss.com —— 那是浏览器端实时编译的开发工具，
       官方明确不建议用于生产，每次加载都要在客户端跑一遍编译器
     · 不用 Font Awesome —— 图标全部内联 SVG
   主题色、圆角、间距都集中在 :root，改一处全局生效。
   ══════════════════════════════════════════════════════════════════ */

:root {
  --primary:      #3b82f6;
  --primary-dark: #2563eb;
  --primary-soft: #eff6ff;

  --bg:      #f3f4f6;
  --card:    #ffffff;
  --line:    #e5e7eb;
  --fg:      #1f2937;
  --fg-dim:  #6b7280;
  --fg-mute: #9ca3af;

  --danger:  #ef4444;
  --like:    #f43f5e;
  --ok:      #10b981;

  --radius:  10px;
  --radius-sm: 8px;
  --shadow:  0 1px 2px rgba(0, 0, 0, .05);
  --shadow-lg: 0 1px 3px rgba(0, 0, 0, .08), 0 1px 2px rgba(0, 0, 0, .04);
  --topbar-h: 52px;
  --side-w: 256px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --primary:      #3b82f6;
    --primary-dark: #60a5fa;
    --primary-soft: #1e293b;

    --bg:      #0f1115;
    --card:    #171a21;
    --line:    #262b36;
    --fg:      #e5e7eb;
    --fg-dim:  #9ca3af;
    --fg-mute: #6b7280;

    --shadow:  0 1px 2px rgba(0, 0, 0, .4);
    --shadow-lg: 0 1px 3px rgba(0, 0, 0, .5);
  }
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI",
        "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
        Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  overflow: hidden;            /* 滚动交给 .main，顶栏与侧栏保持不动 */
}

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

/* ── 顶栏（永远可见）───────────────────────────────────────────── */
.topbar {
  flex: 0 0 auto;
  height: var(--topbar-h);
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  gap: 12px;
  z-index: 30;
}

.tb-left { display: flex; align-items: center; gap: 10px; min-width: 0; }

.brand {
  color: #fff;
  font-size: 17px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand:hover { text-decoration: none; opacity: .9; }

.tb-right { font-size: 13px; display: flex; align-items: center; gap: 6px; }
.tb-right a { color: #fff; text-decoration: none; border-bottom: 1px solid rgba(255,255,255,.45); }
.tb-right a:hover { border-bottom-color: #fff; }

.menubtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: rgba(255, 255, 255, .14);
  color: #fff;
  cursor: pointer;
}
.menubtn:hover { background: rgba(255, 255, 255, .24); }
.menubtn svg { width: 18px; height: 18px; }

/* ── 布局骨架 ─────────────────────────────────────────────────── */
.shell {
  flex: 1 1 auto;
  display: flex;
  min-height: 0;
  position: relative;
}

.sidebar {
  flex: 0 0 var(--side-w);
  width: var(--side-w);
  background: var(--card);
  border-right: 1px solid var(--line);
  box-shadow: 2px 0 8px rgba(0, 0, 0, .04);
  overflow-y: auto;
  z-index: 20;
}

.sidepad { padding: 12px; }

.sidegroup { padding-bottom: 10px; margin-bottom: 10px; border-bottom: 1px solid var(--line); }
.sidegroup:last-child { border-bottom: 0; margin-bottom: 0; }

.sidelabel {
  font-size: 12px;
  color: var(--fg-mute);
  margin: 0 0 8px 2px;
}

.navlist { display: flex; flex-direction: column; gap: 2px; }

.navitem {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--fg);
  font-size: 14px;
  cursor: pointer;
  user-select: none;
  text-decoration: none;
}
.navitem:hover { background: var(--bg); text-decoration: none; }
.navitem.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }

.navitem .ico { width: 17px; height: 17px; flex: 0 0 17px; }

.navitem.asbutton {
  width: 100%;
  border: 0;
  background: none;
  font: inherit;
  font-size: 14px;
  text-align: left;
  color: var(--fg);
  cursor: pointer;
}
.navitem.asbutton:hover { background: var(--bg); }

.sideout { margin: 0; }
.sidehint { font-size: 13px; color: var(--fg-mute); margin: 4px 2px; }

.sidetagline {
  font-size: 12px;
  line-height: 1.6;
  color: var(--fg-dim);
  margin: 0 2px 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

/* ── 主区域 ───────────────────────────────────────────────────── */
.main {
  flex: 1 1 auto;
  min-width: 0;
  overflow-y: auto;
  padding: 14px;
  -webkit-overflow-scrolling: touch;
}

.main-narrow { max-width: 720px; margin: 0 auto; width: 100%; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  margin-bottom: 14px;
}

.cardhead {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.cardtitle { margin: 0 0 10px; font-size: 16px; font-weight: 700; }
.cardhead .cardtitle { margin: 0; }
.cardmeta { font-size: 12px; color: var(--fg-mute); }

/* ── 表单控件 ─────────────────────────────────────────────────── */
textarea, input[type="text"], input[type="password"], select {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--fg);
  font: inherit;
  font-size: 14px;
}

textarea { resize: vertical; min-height: 76px; line-height: 1.6; }

textarea:focus, input:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 15%, transparent);
}

select { width: auto; max-width: 100%; font-size: 13px; padding: 8px 10px; }

.boardselect { flex: 0 1 auto; }

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

.btn {
  display: inline-block;
  padding: 8px 18px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: #fff;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.4;
  text-decoration: none;
  cursor: pointer;
  transition: background .15s;
}
.btn:hover { background: var(--primary-dark); text-decoration: none; }
.btn.small { padding: 6px 14px; font-size: 13px; }

.btn.ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--fg);
}
.btn.ghost:hover { border-color: var(--primary); color: var(--primary); background: transparent; }

.linkbtn {
  background: none;
  border: 0;
  padding: 0;
  color: var(--fg-dim);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.linkbtn:hover { color: var(--primary); text-decoration: underline; }
.linkbtn.danger { color: var(--danger); }
.linkbtn.danger:hover { color: var(--danger); }

.hint { font-size: 13px; color: var(--fg-dim); margin: 0 0 10px; }

/* 蜜罐字段：对真人不可见（不用 display:none，部分机器人会跳过隐藏元素） */
.hp {
  position: absolute;
  left: -9999px;
  width: 1px; height: 1px;
  overflow: hidden;
}

/* ── 图片上传 ── */
.uprow {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  flex-wrap: wrap;
}
.uprow input[type="file"] { font: inherit; font-size: 13px; color: var(--fg-dim); max-width: 100%; }
.uprow input[type="file"]::file-selector-button {
  padding: 6px 12px;
  margin-right: 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--fg);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.uprow input[type="file"]::file-selector-button:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.uphint { font-size: 12px; color: var(--fg-mute); }

.upmsg { font-size: 13px; margin-top: 6px; }
.upmsg.error { color: var(--danger); }
.upmsg.ok { color: var(--ok); }

.uppreview { display: none; align-items: flex-start; gap: 12px; margin-top: 10px; }
.uppreview.on { display: flex; }
.uppreview img {
  max-width: 170px; max-height: 130px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
}

/* ── 留言列表 ─────────────────────────────────────────────────── */
.msglist { display: flex; flex-direction: column; }

.post {
  border-bottom: 1px solid var(--line);
  padding: 14px 0;
  scroll-margin-top: 16px;
}
.post:first-child { padding-top: 0; }
.post:last-child { border-bottom: 0; padding-bottom: 2px; }
.post[hidden] { display: none; }

.post:target { background: color-mix(in srgb, var(--primary) 6%, transparent); border-radius: var(--radius-sm); }

.ph {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.pn { font-weight: 600; font-size: 14px; color: var(--primary); }
.pn a { color: inherit; text-decoration: none; }
.pn a:hover { text-decoration: underline; }

.ph time {
  font-size: 12px;
  color: var(--fg-mute);
  margin-left: auto;
  white-space: nowrap;
}

.bbadge {
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--bg);
  color: var(--fg-dim);
  border: 1px solid var(--line);
}

.edited {
  font-size: 11px;
  color: var(--fg-mute);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 0 5px;
}

.pb { font-size: 15px; line-height: 1.75; overflow-wrap: anywhere; }

.ract {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 9px;
  flex-wrap: wrap;
}

.replybtn {
  background: none;
  border: 0;
  padding: 0;
  color: var(--fg-dim);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.replybtn:hover { color: var(--primary); text-decoration: underline; }

.rcount { font-size: 12px; color: var(--fg-mute); margin-left: auto; }

.replies {
  margin-top: 12px;
  padding-left: 14px;
  border-left: 2px solid var(--line);
}
.replies:empty { display: none; margin: 0; padding: 0; border: 0; }

.reply {
  padding: 9px 0;
  border-top: 1px dashed var(--line);
  scroll-margin-top: 16px;
}
.reply:first-child { border-top: 0; padding-top: 2px; }
.reply:target { background: color-mix(in srgb, var(--primary) 7%, transparent); border-radius: var(--radius-sm); }
.reply .pn { font-size: 13px; }
.reply .pb { font-size: 14px; }
.reply .ract { margin-top: 6px; }

.to { font-size: 12px; color: var(--fg-mute); }

.empty {
  padding: 28px 12px;
  text-align: center;
  color: var(--fg-mute);
  font-size: 14px;
}

.guestnote {
  margin-top: 14px;
  padding: 12px 14px;
  text-align: center;
  font-size: 13px;
  color: var(--fg-dim);
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg);
}

.pagefoot { text-align: center; font-size: 12px; color: var(--fg-mute); padding: 6px 0 18px; }

/* ── 点赞 ── */
.likebtn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--fg-dim);
  font: inherit;
  font-size: 12px;
  line-height: 1.6;
  cursor: pointer;
  transition: border-color .15s, color .15s, background .15s;
}
.likebtn:hover { border-color: var(--like); color: var(--like); }
.likebtn.on { border-color: var(--like); color: var(--like); background: color-mix(in srgb, var(--like) 10%, transparent); }
.likebtn.readonly { cursor: default; border-style: dashed; }
.likebtn.readonly:hover { border-color: var(--line); color: var(--fg-dim); }
.likebtn:disabled { opacity: .6; cursor: default; }

/* ── 编辑 / 回复内联框 ── */
.editbox {
  margin-top: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg);
}

/* ── 图片 ── */
.pimg { margin: 10px 0 2px; padding: 0; }
.pimg img {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
}
.reply .pimg img { max-width: min(100%, 420px); }

/* ── 提示条 ── */
.notice {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 12px;
  border: 1px solid transparent;
}
.notice.error {
  background: color-mix(in srgb, var(--danger) 10%, transparent);
  border-color: color-mix(in srgb, var(--danger) 35%, transparent);
  color: var(--danger);
}
.notice.ok {
  background: color-mix(in srgb, var(--ok) 10%, transparent);
  border-color: color-mix(in srgb, var(--ok) 35%, transparent);
  color: var(--ok);
}

/* ── 注册验证码 ── */
.captcha {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg);
}

.captcha .cq {
  font: 600 17px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: 1px;
  color: var(--fg);
  white-space: nowrap;
}

.captcha input {
  width: 92px;
  flex: 0 0 92px;
  text-align: center;
  font-size: 15px;
  background: var(--card);
}

.captcha .chint { font-size: 12px; color: var(--fg-mute); }

/* ── 卡片式表单（注册 / 登录 / 我的留言 / 个人主页）────────────── */
.compose { max-width: 100%; }
.compose .row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
/* 只有一个输入框的行（如免邀请码注册时的用户名）让它占满整行 */
.compose .row.full { grid-template-columns: 1fr; }
.compose .actions { display: flex; align-items: center; gap: 14px; margin-top: 12px; flex-wrap: wrap; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.cardlink {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: inherit;
  text-decoration: none;
}
.cardlink:hover { border-color: var(--primary); text-decoration: none; }
.cardlink .ico { font-size: 16px; color: var(--primary); }
.cardlink .t { font-weight: 600; font-size: 15px; }
.cardlink .d { font-size: 13px; color: var(--fg-dim); }

/* 我的留言 / 个人主页里的管理项 */
.mineitem {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--card);
  padding: 13px 15px;
  margin-bottom: 12px;
}
.minehead { margin: 0 0 10px; font-size: 12px; color: var(--fg-mute); }
.minehead a { color: var(--primary); }
.mineitem textarea { background: var(--bg); min-height: 66px; }
.deline { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--line); }
.inlinelogout { display: inline; }

/* 个人主页 */
.profhead { text-align: center; }
.profhead .avatar {
  width: 72px; height: 72px;
  margin: 0 auto 16px;
  display: grid; place-items: center;
  border-radius: 22px;
  background: linear-gradient(145deg, var(--primary), #7b5cff);
  color: #fff;
  font-size: 32px; font-weight: 600;
  box-shadow: 0 10px 26px -14px var(--primary);
}
.profhead h1 { margin: 0 0 6px; font-size: 24px; }
.profstats {
  display: flex;
  justify-content: center;
  gap: 30px;
  flex-wrap: wrap;
  margin: 20px 0 6px;
  font-size: 13px;
  color: var(--fg-dim);
}
.profstats strong { display: block; font-size: 21px; color: var(--fg); font-weight: 700; }

/* ── 移动端：侧边栏变成抽屉 ───────────────────────────────────── */
.mask {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .45);
  z-index: 10;
}
.mask[hidden] { display: none; }

@media (max-width: 767px) {
  .sidebar {
    position: absolute;
    top: 0; left: 0; bottom: 0;
    transform: translateX(-100%);
    transition: transform .22s ease;
    box-shadow: 4px 0 16px rgba(0, 0, 0, .18);
  }
  .sidebar.open { transform: translateX(0); }
  .main { padding: 10px; }
  .card { padding: 12px; }
  .compose .row { grid-template-columns: 1fr; }
  .ph time { margin-left: 0; }
  .rcount { margin-left: 0; }
}

@media (min-width: 768px) {
  .menubtn { display: none; }
  .mask { display: none !important; }
}

/* 尊重"减少动态效果"偏好 */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
