/* ============================================================
   偶然 · 样式
   ============================================================ */

/* 中文字体（FangSong / ZhongSong / SinoTorch）不在这里声明：
   它们由 app.js 按当前页面实际用字动态生成 woff2 并注入 @font-face，
   避免一次下载 10–28 MB 的完整字体。拉丁字体体积小，做静态子集。 */

/* 界面基线字体：固定的 401 个界面用字，配合 index.html 里的 preload，
   让按钮、标签、标题这类文字不必等 JS 算完用字就能用上仿宋。 */
@font-face {
  font-family: "FangSongBase";
  src: url("/fonts/base/fangsong-ui.woff2?v=5bee49cb") format("woff2");
  font-display: swap;
  unicode-range: U+2000-206F, U+3000-303F, U+3400-4DBF, U+4E00-9FFF, U+FF00-FFEF;
}
@font-face {
  font-family: "Antiqua";
  src: url("/fonts/antiqua.woff2") format("woff2");
  font-display: swap;
}
@font-face {
  font-family: "TimesLatin";
  src: url("/fonts/times.woff2") format("woff2");
  font-display: swap;
}

:root {
  /* 内测反馈：仿宋在小字号下发灰。正文颜色整体压深一档 */
  --ink: #2e2619;
  --ink-soft: #5c4f3c;
  --ink-faint: #857152;
  --line: #d8c9a8;
  --line-soft: rgba(201, 184, 150, 0.5);
  --paper: #f7f1e2;
  --paper-raise: rgba(255, 255, 255, 0.38);
  --accent: #9c7b4a;
  --danger: #8a4a3a;
  --body-size: 16px;
  /* FangSongBase 在前：界面文字用它（静态、已 preload）；
     它没有的字符再落到 FangSong（按页面动态裁的子集） */
  --serif: "TimesLatin", "Times New Roman", "FangSongBase", "FangSong", "华文仿宋", "FangSong_GB2312", "Songti SC", serif;
  --latin: "Times New Roman", "Antiqua", serif;
}

* { box-sizing: border-box; }

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

body {
  background: var(--paper) url("/assets/paper.jpg") center / cover no-repeat;
  color: var(--ink);
  font-family: var(--serif);
  font-size: var(--body-size);
  line-height: 1.6;
  /* 极轻微描边：比浏览器合成的加粗可控，不会把字糊成一团 */
  -webkit-text-stroke: 0.15px currentColor;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

.app {
  max-width: 440px;
  margin: 0 auto;
  padding: 0 24px 56px;
  min-height: 100vh;
}

/* ------------------------------------------------------------ 通用 */

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }

.rule {
  width: 32px;
  height: 1px;
  background: var(--line);
  margin: 40px auto;
  border: 0;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 0 10px;
  min-height: 56px;
}

.back {
  border: 0;
  background: none;
  padding: 6px 2px;
  font-size: 17px;
  color: var(--ink);
  cursor: pointer;
  letter-spacing: 0.05em;
}
/* 下划线只给"返回"两个字，尖括号不加 */
.back-text {
  text-decoration: underline;
  text-underline-offset: 4px;
  text-decoration-thickness: 1px;
  text-decoration-color: var(--line);
}
.back:hover .back-text { text-decoration-color: var(--accent); }

.title {
  margin: 6px 0 26px;
  font-size: 23px;
  font-weight: 700;
  letter-spacing: 0.22em;
  color: var(--ink);
}

.hint {
  font-size: 13px;
  color: var(--ink-faint);
  letter-spacing: 0.04em;
}

/* ------------------------------------------------------------ 主页 */

.home {
  padding-top: 64px;
  text-align: center;
}

.brand {
  margin: 0;
  font-size: 46px;
  font-weight: 400;
  letter-spacing: 0.34em;
  text-indent: 0.34em;
}

.brand-sub {
  margin: 10px 0 0;
  font-size: 14px;
  letter-spacing: 0.42em;
  text-indent: 0.42em;
  color: var(--ink-soft);
}

.entry {
  display: block;
  margin: 14px 0;
  padding: 22px 18px;
  border: 1px solid var(--line);
  background: var(--paper-raise);
  text-align: center;
  transition: background 0.18s ease, border-color 0.18s ease;
}
.entry:hover { background: rgba(255, 255, 255, 0.62); border-color: #c6b38c; }
.entry span {
  display: block;
  font-size: 20px;
  letter-spacing: 0.3em;
  text-indent: 0.3em;
}
.entry small {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  color: var(--ink-soft);
  letter-spacing: 0.12em;
}

.home-bottom {
  margin-top: 46px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
}

.ghost-link {
  font-size: 17px;
  letter-spacing: 0.28em;
  text-indent: 0.28em;
  color: var(--ink);
  padding: 8px;
  text-decoration: underline;
  text-underline-offset: 5px;
  text-decoration-thickness: 1px;
  text-decoration-color: var(--line);
}
.ghost-link:hover { text-decoration-color: var(--accent); }

.tiny-link {
  font-size: 12px;
  color: var(--ink-faint);
  letter-spacing: 0.08em;
}

/* ------------------------------------------------------------ 表单 */

.field { margin: 22px 0; }

.field-label {
  display: block;
  font-size: 14px;
  letter-spacing: 0.16em;
  color: var(--ink-soft);
  margin-bottom: 10px;
}

.input {
  width: 100%;
  padding: 12px 2px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  /* 输入框只用设备本地字体，不加载任何网络字体：
     拉丁走 Times，中文优先华文中宋，没有就退到系统衬线体。
     代价是输入时看到的字形与页面上其它文字略有差异，
     换来的是打字全程零等待——不会为了一个新字去等一次网络往返。 */
  font-family: "Times New Roman", "STZhongsong", "华文中宋", "Songti SC", "SimSun", "宋体", serif;
  font-size: 19px;
  letter-spacing: 0.02em;
  outline: none;
  border-radius: 0;
}
.input::placeholder { color: #a8977b; }
.input:focus { border-bottom-color: var(--accent); }

/* 下拉框沿用输入框的下划线样式，但保留系统箭头，让人看得出可以点 */
select.input {
  appearance: auto;
  -webkit-appearance: auto;
  padding-right: 0;
  cursor: pointer;
}

/* 交会页：输入框与按钮比正文页收小一号，输入内容与占位文字居中 */
.meet-id { font-size: 16px; padding: 9px 2px; text-align: center; }
.meet-submit { font-size: 15px; padding: 12px 0; }
.meet-tip { margin: 0 0 20px; text-align: center; line-height: 1.9; }

.segmented {
  display: flex;
  border: 1px solid var(--line);
  background: var(--paper-raise);
}

.segmented button {
  flex: 1;
  padding: 11px 8px;
  border: 0;
  background: none;
  cursor: pointer;
  font-size: 15px;
  letter-spacing: 0.16em;
  text-indent: 0.16em;
  color: var(--ink-soft);
  transition: background 0.15s ease, color 0.15s ease;
}
.segmented button + button { border-left: 1px solid var(--line); }
.segmented button[aria-pressed="true"] {
  background: rgba(255, 255, 255, 0.7);
  color: var(--ink);
}

.btn-primary {
  display: block;
  width: 100%;
  margin-top: 34px;
  padding: 15px;
  border: 1px solid var(--accent);
  background: rgba(156, 123, 74, 0.1);
  color: var(--ink);
  font-size: 17px;
  letter-spacing: 0.3em;
  text-indent: 0.3em;
  cursor: pointer;
  transition: background 0.18s ease;
}
.btn-primary:hover:not(:disabled) { background: rgba(156, 123, 74, 0.2); }
.btn-primary:disabled { opacity: 0.5; cursor: default; }

.btn-quiet {
  border: 0;
  background: none;
  color: var(--ink-soft);
  font-size: 14px;
  letter-spacing: 0.08em;
  cursor: pointer;
  padding: 8px 2px;
  text-decoration: underline;
  text-underline-offset: 4px;
  text-decoration-color: var(--line);
}
.btn-quiet:hover { color: var(--ink); }

.btn-danger {
  border: 1px solid rgba(138, 74, 58, 0.35);
  background: transparent;
  color: var(--danger);
  padding: 11px 16px;
  font-size: 14px;
  letter-spacing: 0.1em;
  cursor: pointer;
}

/* ------------------------------------------------------------ 诗句排版 */

.poem {
  margin: 26px 0;
  padding: 26px 0;
  border-top: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
}

.poem-line {
  margin: 0 0 4px;
  font-family: "SinoTorch", "ZhongSong", var(--serif);
  font-size: 24px;
  line-height: 1.72;
  letter-spacing: 0.02em;
  word-break: break-word;
}
.poem-line + .poem-line { margin-bottom: 22px; }

.poem-sig {
  margin: 0;
  font-family: "Antiqua", "ZhongSong", var(--serif);
  font-size: 12px;
  color: var(--ink-soft);
  letter-spacing: 0.04em;
  word-break: break-word;
}

.poem-actions {
  display: flex;
  gap: 8px;
  margin-top: 18px;
  flex-wrap: wrap;
}

/* 关于我们里的题诗：正文居中，落款右对齐，都用中华薪火体 */
.verse {
  margin: 0;
  font-family: "SinoTorch", "ZhongSong", var(--serif);
  font-size: 21px;
  line-height: 2.05;
  letter-spacing: 0.04em;
  text-align: center;
}

.verse-src {
  margin: 16px 0 0;
  font-family: "SinoTorch", "ZhongSong", var(--serif);
  font-size: 15px;
  letter-spacing: 0.06em;
  text-align: right;
  color: var(--ink-soft);
}

.about-body p { margin: 0 0 16px; }

.chip {
  border: 1px solid var(--line);
  background: var(--paper-raise);
  padding: 7px 12px;
  font-size: 12px;
  letter-spacing: 0.08em;
  cursor: pointer;
  color: var(--ink-soft);
}
.chip:hover { border-color: var(--accent); color: var(--ink); }
.chip:disabled { opacity: 0.55; cursor: default; }

.id-row {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.id-chip {
  font-family: "Antiqua", "ZhongSong", var(--serif);
  font-size: 12px;
  letter-spacing: 0.05em;
  color: var(--ink-faint);
  border: 1px dashed var(--line);
  background: transparent;
  padding: 4px 8px;
  cursor: pointer;
}
.id-chip:hover { color: var(--ink-soft); border-style: solid; }

/* ------------------------------------------------------------ 列表 */

.item {
  padding: 18px 0;
  border-bottom: 1px solid var(--line-soft);
}

.item:first-of-type { border-top: 1px solid var(--line-soft); }

.item-text {
  margin: 0 0 6px;
  font-family: "SinoTorch", "ZhongSong", var(--serif);
  font-size: 19px;
  line-height: 1.6;
  word-break: break-word;
}

.item-meta {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--ink-faint);
}

.tag {
  border: 1px solid var(--line);
  padding: 1px 6px;
  font-size: 11px;
  letter-spacing: 0.08em;
}
.tag-warn { border-color: rgba(138, 74, 58, 0.4); color: var(--danger); }

.item-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.empty {
  padding: 60px 0;
  text-align: center;
  color: var(--ink-faint);
  font-size: 14px;
  letter-spacing: 0.08em;
}

.notice {
  margin: 22px 0;
  padding: 16px;
  border: 1px dashed var(--line);
  font-size: 14px;
  color: var(--ink-soft);
  text-align: center;
  letter-spacing: 0.04em;
}

/* ------------------------------------------------------------ 我的 */

.menu-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 2px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 17px;
  letter-spacing: 0.12em;
}
.menu-item:first-of-type { border-top: 1px solid var(--line-soft); }
.menu-item .arrow {
  color: var(--ink-soft);
  font-size: 22px;
  line-height: 1;
  transform: translateY(-1px);
}

/* 账号信息：标签与值分两列，值左对齐成一条线 */
.profile { margin: 0; }
.profile-row {
  display: grid;
  grid-template-columns: 76px 1fr;
  align-items: baseline;
  gap: 8px;
  padding: 16px 0;
  border-bottom: 1px solid var(--line-soft);
}
.profile-row:first-of-type { border-top: 1px solid var(--line-soft); }
.profile-row dt {
  margin: 0;
  font-size: 14px;
  letter-spacing: 0.1em;
  color: var(--ink-soft);
}
.profile-row dd {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0.04em;
  color: var(--ink);
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.kv {
  display: flex;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid var(--line-soft);
  font-size: 15px;
}
.kv dt { color: var(--ink-faint); font-size: 13px; letter-spacing: 0.1em; margin: 0; }
.kv dd { margin: 0; letter-spacing: 0.04em; }

.section-title {
  margin: 40px 0 6px;
  font-size: 13px;
  letter-spacing: 0.24em;
  color: var(--ink-faint);
  font-weight: 400;
}

/* ------------------------------------------------------------ 弹窗 */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(59, 50, 38, 0.28);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 50;
}

.modal {
  width: 100%;
  max-width: 380px;
  background: var(--paper) url("/assets/paper.png") center / cover;
  border: 1px solid var(--line);
  padding: 26px 24px 22px;
  position: relative;
  box-shadow: 0 18px 50px rgba(59, 50, 38, 0.18);
  max-height: 86vh;
  overflow: auto;
}

.modal h2 {
  margin: 0 0 18px;
  font-size: 18px;
  font-weight: 400;
  letter-spacing: 0.2em;
  text-align: center;
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 12px;
  border: 0;
  background: none;
  font-size: 20px;
  line-height: 1;
  color: var(--ink-faint);
  cursor: pointer;
  padding: 6px;
}

.tabs {
  display: flex;
  justify-content: center;
  gap: 22px;
  margin-bottom: 20px;
}
.tabs button {
  border: 0;
  background: none;
  padding: 4px 2px;
  font-size: 15px;
  color: var(--ink-faint);
  cursor: pointer;
  letter-spacing: 0.1em;
  border-bottom: 1px solid transparent;
}
.tabs button[aria-selected="true"] {
  color: var(--ink);
  border-bottom-color: var(--accent);
}

.modal .input { font-size: 17px; }

.remember {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 2px 0 0;
  font-size: 14px;
  color: var(--ink-soft);
  letter-spacing: 0.06em;
  cursor: pointer;
}
.remember input { width: 15px; height: 15px; accent-color: var(--accent); }

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 24px;
}
.modal-actions button { flex: 1; }

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

.toast-root {
  position: fixed;
  left: 50%;
  bottom: 34px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 80;
  pointer-events: none;
  width: min(360px, calc(100vw - 48px));
}

.toast {
  background: rgba(59, 50, 38, 0.9);
  color: #f7f1e2;
  padding: 11px 16px;
  font-size: 14px;
  letter-spacing: 0.04em;
  text-align: center;
  animation: toast-in 0.18s ease;
}
.toast.out { animation: toast-out 0.22s ease forwards; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
@keyframes toast-out {
  to { opacity: 0; transform: translateY(6px); }
}

/* ------------------------------------------------------------ 其它 */

.spinner {
  display: inline-block;
  width: 12px; height: 12px;
  border: 1px solid var(--ink-faint);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: -1px;
  margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.footer-note {
  margin-top: 54px;
  font-size: 11px;
  color: var(--ink-faint);
  text-align: center;
  letter-spacing: 0.06em;
  line-height: 1.9;
}

@media (max-width: 400px) {
  .app { padding: 0 20px 48px; }
  .brand { font-size: 40px; }
  .poem-line { font-size: 21px; }
}
