/* Dehors · 在外头 —— 纸墨论坛体
   底子：宣纸 + 墨，安静；唯一的大胆处：三对伴侣各占一个墨彩，
   头像、名字、成员 chips 全按 CP 着色。 */

:root {
  --paper: #f6f4ee;
  --paper-raised: #fdfcf8;
  --ink: #2a2721;
  --ink-soft: #8a8375;
  --line: #e2ddce;
  --danger: #a8433b;

  /* 三对 CP 的墨彩（青 / 绛 / 赭），未配对成员用中性灰 */
  --pair-0: #3f7d6f;
  --pair-1: #8f4f62;
  --pair-2: #9c6a2e;
  --pair-none: #8a8375;

  --serif: Georgia, "Times New Roman", "Songti SC", "SimSun", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "HarmonyOS Sans SC", "MiSans", "Microsoft YaHei", sans-serif;

  --column: 720px;
}

* { box-sizing: border-box; }

html {
  background: var(--paper);
  /* 桌面点滚动条保持纸色 */
  color-scheme: light;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.hidden { display: none !important; }

:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
  border-radius: 2px;
}

/* ---------------- 进入页 ---------------- */

.gate {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.gate-card {
  width: 100%;
  max-width: 340px;
  text-align: center;
}

.gate-brand {
  font-family: var(--serif);
  font-size: 44px;
  font-style: italic;
  letter-spacing: 0.02em;
  margin: 0;
  line-height: 1.1;
}

.gate-tagline {
  margin: 6px 0 30px;
  color: var(--ink-soft);
  font-size: 14px;
}

#gate-token {
  width: 100%;
  padding: 12px 14px;
  font-size: 16px; /* ≥16px 防止 iOS 聚焦缩放 */
  font-family: var(--sans);
  text-align: center;
  letter-spacing: 0.04em;
  color: var(--ink);
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: 6px;
  transition: border-color 0.15s;
}

#gate-token:focus { border-color: var(--ink); outline: none; }

.gate-card button {
  width: 100%;
  margin-top: 12px;
  padding: 12px;
  font-size: 15px;
  font-family: var(--sans);
  color: var(--paper);
  background: var(--ink);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: opacity 0.15s;
}

.gate-card button:hover { opacity: 0.85; }

.gate-error {
  min-height: 22px;
  margin: 12px 0 0;
  color: var(--danger);
  font-size: 13.5px;
}

.gate-hint {
  margin: 0;
  color: var(--ink-soft);
  font-size: 13px;
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: var(--column);
  margin: 0 auto;
  padding: 10px clamp(16px, 4vw, 24px);
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}

.brand {
  font-family: var(--serif);
  font-style: italic;
  font-size: 22px;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.brand-sub {
  font-family: var(--sans);
  font-style: normal;
  font-size: 13px;
  color: var(--ink-soft);
  margin-left: 8px;
}

.me-chip {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 7px;
  justify-content: flex-end;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
}

.me-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

.me-partner { color: var(--ink-soft); font-size: 12.5px; }

.linkish {
  border: none;
  background: none;
  padding: 4px 2px;
  font-family: var(--sans);
  font-size: 13.5px;
  color: var(--ink-soft);
  cursor: pointer;
}

.linkish:hover { color: var(--ink); }

/* ---------------- 成员（伴侣对） ---------------- */

.wrap {
  max-width: var(--column);
  margin: 0 auto;
  padding: 0 clamp(16px, 4vw, 24px) 140px; /* 底部给固定回复框留位 */
}

.pairs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 14px 0 4px;
}

.pair-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 3px 12px;
  font-size: 13px;
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: 999px;
  white-space: nowrap;
}

.pair-chip .x { color: var(--ink-soft); font-size: 11px; }

/* ---------------- 楼层 ---------------- */

.posts { margin-top: 6px; }

.day-divider {
  text-align: center;
  margin: 18px 0 6px;
  color: var(--ink-soft);
  font-size: 12.5px;
}

.day-divider span {
  display: inline-block;
  padding: 2px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--paper-raised);
}

/* 经典论坛排版：左栏名字+标签，右栏楼层内容 */
.post {
  display: grid;
  grid-template-columns: 118px 1fr;
  gap: 16px;
  padding: 16px 0 15px;
  border-bottom: 1px solid var(--line);
}

@media (max-width: 560px) {
  .post {
    grid-template-columns: 78px 1fr;
    gap: 10px;
    padding: 13px 0 12px;
  }
  .pname { font-size: 13.5px; }
  .ptag { font-size: 10.5px; }
}

.profile {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
  padding-top: 1px;
  min-width: 0;
}

.pname {
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1.35;
  word-break: break-all;
}

.ptags {
  display: flex;
  flex-direction: column;
  gap: 3px;
  align-items: flex-start;
}

.ptag {
  font-size: 11px;
  line-height: 1.5;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--ink-soft);
  background: var(--paper-raised);
  white-space: nowrap;
}

.ptag.partner { border-color: currentColor; }

.post-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 4px;
}

.floor {
  font-size: 13px;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.head-left {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
  flex-wrap: wrap;
}

/* 回复引用 chip：点击跳到被回复楼 */
.reply-chip {
  border: none;
  background: none;
  padding: 0;
  font-family: var(--sans);
  font-size: 12.5px;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: underline dotted;
  text-underline-offset: 3px;
}

.reply-chip:hover { opacity: 0.75; }

.post-time {
  font-size: 12.5px;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.post-content {
  white-space: pre-wrap;
  word-break: break-word;
  max-width: 66ch;
}

.post-actions {
  margin-top: 6px;
  display: flex;
  justify-content: flex-end;
}

.reply-btn {
  border: 1px solid var(--line);
  background: var(--paper-raised);
  border-radius: 5px;
  padding: 2px 12px;
  font-family: var(--sans);
  font-size: 12.5px;
  color: var(--ink-soft);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.reply-btn:hover { color: var(--ink); border-color: var(--ink-soft); }

/* 点击引用跳转后的目标楼高亮 */
.post.targeted { animation: target-flash 1.6s ease-out; }

@keyframes target-flash {
  0% { background: rgba(42, 39, 33, 0.08); }
  100% { background: transparent; }
}

@media (prefers-reduced-motion: reduce) {
  .post.targeted { animation: none; }
}

.post.fresh .post-content { animation: fresh-post 1.2s ease-out; }

@keyframes fresh-post {
  from { background: rgba(42, 39, 33, 0.06); }
  to { background: transparent; }
}

@media (prefers-reduced-motion: reduce) {
  .post.fresh .post-content { animation: none; }
  html { scroll-behavior: auto; }
}

.empty {
  text-align: center;
  color: var(--ink-soft);
  padding: 56px 16px;
  font-size: 14.5px;
}

/* ---------------- 新回复提示 ---------------- */

.new-pill {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 110px;
  z-index: 20;
  padding: 6px 16px;
  font-size: 13.5px;
  color: var(--paper);
  background: var(--ink);
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(42, 39, 33, 0.25);
}

/* ---------------- 回复框（固定底部） ---------------- */

.composer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 15;
  background: var(--paper-raised);
  border-top: 1px solid var(--line);
  padding: 8px 0 calc(10px + env(safe-area-inset-bottom));
}

/* 回复上下文条：正在回复谁 */
.reply-bar {
  max-width: var(--column);
  margin: 0 auto;
  padding: 2px clamp(16px, 4vw, 24px) 6px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--ink-soft);
}

#reply-bar-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

#reply-clear {
  border: none;
  background: none;
  color: var(--ink-soft);
  font-size: 16px;
  line-height: 1;
  padding: 2px 6px;
  cursor: pointer;
  flex-shrink: 0;
}

#reply-clear:hover { color: var(--ink); }

.composer-inner {
  max-width: var(--column);
  margin: 0 auto;
  padding: 0 clamp(16px, 4vw, 24px);
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

#input {
  flex: 1;
  resize: none;
  min-height: 44px;
  max-height: 140px;
  padding: 10px 14px;
  font-size: 16px; /* 防 iOS 缩放 */
  font-family: var(--sans);
  line-height: 1.55;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  transition: border-color 0.15s;
}

#input:focus { border-color: var(--ink); outline: none; }

#send {
  padding: 11px 22px;
  font-size: 15px;
  font-family: var(--sans);
  color: var(--paper);
  background: var(--ink);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity 0.15s;
}

#send:hover { opacity: 0.85; }
#send:disabled { opacity: 0.45; cursor: default; }

.send-error {
  max-width: var(--column);
  margin: 4px auto 0;
  padding: 0 clamp(16px, 4vw, 24px);
  color: var(--danger);
  font-size: 13px;
  min-height: 0;
}

.send-error:empty { display: none; }
