/* ============================================================
   留言板页。配色跟 photos.css 取同一套，别改 --accent-* 的名字。
   手机优先，360~430px 调过。
   ============================================================ */

:root {
  --accent-a: #ff9ec4;
  --accent-b: #ffd9a8;
  --accent-c: #b58cff;
  --muted: rgba(255, 255, 255, 0.52);
  --faint: rgba(255, 255, 255, 0.3);
  --line: rgba(255, 255, 255, 0.1);
  --glow: rgba(255, 120, 170, 0.32);
  --bg: #100a14;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

/* 跟相册页同一条兜底：别的规则写了 display 也会盖掉 hidden */
[hidden] {
  display: none !important;
}

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

body {
  min-height: 100dvh;
  background-color: var(--bg);
  background-image:
    radial-gradient(120% 70% at 18% 0%, rgba(255, 120, 170, 0.16), transparent 62%),
    radial-gradient(110% 60% at 88% 100%, rgba(120, 140, 255, 0.13), transparent 62%);
  background-attachment: fixed;

  color: #fff;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC",
    "Noto Sans SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;

  padding: 0 calc(env(safe-area-inset-right) + 12px)
           calc(env(safe-area-inset-bottom) + 40px)
           calc(env(safe-area-inset-left) + 12px);

  -webkit-user-select: none;
  user-select: none;
  overscroll-behavior-y: none;
}

/* ---------- 顶部 ---------- */

.top {
  position: sticky;
  top: 0;
  z-index: 20;

  display: flex;
  align-items: center;
  gap: 10px;

  margin: 0 -12px;
  padding: calc(env(safe-area-inset-top) + 12px) 16px 10px;

  background: linear-gradient(to bottom, rgba(16, 10, 20, 0.96) 55%, rgba(16, 10, 20, 0));
  backdrop-filter: blur(10px);
}

.back {
  flex: none;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;

  font-size: 26px;
  line-height: 1;
  padding-bottom: 4px;

  color: var(--muted);
  text-decoration: none;
  border-radius: 50%;
  transition: background 0.2s, color 0.2s;
}

.back:active {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.top h1 {
  flex: 1;
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.14em;
}

.nav {
  flex: none;
  display: flex;
  gap: 6px;
}

.nav a {
  padding: 6px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;

  font-size: 12px;
  letter-spacing: 0.08em;
  line-height: 1;
  color: var(--muted);
  text-decoration: none;

  background: rgba(255, 255, 255, 0.055);
  transition: background 0.2s, color 0.2s, transform 0.15s;
}

.nav a:active {
  background: rgba(255, 255, 255, 0.13);
  color: #fff;
  transform: scale(0.96);
}

/* ---------- 写留言 ---------- */

.wrap {
  padding-top: 4px;
}

.compose {
  margin-bottom: 18px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.045);
}

.compose input,
.compose textarea {
  width: 100%;
  padding: 11px 12px;
  border-radius: 12px;

  font-family: inherit;
  /* 16px 是分水岭：再小 iOS 一聚焦就自动放大页面 */
  font-size: 16px;
  line-height: 1.6;

  color: #fff;
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid rgba(255, 255, 255, 0.12);
  outline: none;

  -webkit-appearance: none;
  appearance: none;
  -webkit-user-select: text;
  user-select: text;
}

.compose input {
  letter-spacing: 0.04em;
}

.compose textarea {
  margin-top: 8px;
  display: block;
  resize: vertical;
  min-height: 88px;
  max-height: 40vh;
}

.compose input::placeholder,
.compose textarea::placeholder {
  color: rgba(255, 255, 255, 0.28);
}

.compose input:focus,
.compose textarea:focus {
  border-color: rgba(255, 158, 196, 0.55);
  box-shadow: 0 0 0 3px rgba(255, 158, 196, 0.12);
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;

  margin-top: 10px;
}

.count {
  font-size: 11.5px;
  letter-spacing: 0.06em;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}

.count.warn {
  color: var(--accent-a);
}

.send {
  flex: none;
  padding: 10px 24px;
  border: 0;
  border-radius: 999px;

  font-family: inherit;
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: 0.14em;
  line-height: 1;
  color: #1a0d16;

  background: linear-gradient(150deg, var(--accent-b), var(--accent-a) 55%, var(--accent-c));
  box-shadow: 0 8px 20px -8px var(--glow);

  cursor: pointer;
  transition: transform 0.15s, opacity 0.2s;
}

.send:active {
  transform: scale(0.96);
}

.send:disabled {
  opacity: 0.55;
}

.err {
  min-height: 16px;
  margin: 6px 2px 0;
  font-size: 11.5px;
  letter-spacing: 0.04em;
  color: #ff8f9e;
}

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

.list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.msg {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);

  animation: rise 0.28s cubic-bezier(0.2, 0.9, 0.25, 1);
}

.msg.fresh {
  border-color: rgba(255, 158, 196, 0.38);
  box-shadow: 0 0 0 3px rgba(255, 158, 196, 0.08);
}

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

.msg-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 6px;
}

.msg-name {
  min-width: 0;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--accent-a);

  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.msg-time {
  flex: none;
  margin-left: auto;
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}

.msg-body {
  margin: 0;
  font-size: 14.5px;
  line-height: 1.75;
  letter-spacing: 0.02em;
  color: rgba(255, 255, 255, 0.92);

  /* 换行照原样显示，长串别把卡片撑破 */
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;

  -webkit-user-select: text;
  user-select: text;
}

.empty {
  padding: 40px 20px 20px;
  margin: 0;
  text-align: center;
  font-size: 12.5px;
  letter-spacing: 0.08em;
  color: var(--faint);
}

/* ---------- 提示条 ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 28px);
  transform: translate(-50%, 10px);
  z-index: 90;

  max-width: 80vw;
  padding: 9px 16px;
  border-radius: 999px;

  font-size: 12.5px;
  letter-spacing: 0.05em;

  color: #fff;
  background: rgba(40, 28, 46, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.8);

  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------- 宽一点的看着不散 ---------- */

@media (min-width: 640px) {
  body {
    max-width: 640px;
    margin: 0 auto;
  }
}

/* ---------- 减少动态效果 ---------- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
