/* 喵嗷小纸条 · 横线手账 Ink Diary 组件体系
   纸张 #FDFAF2 / 墨水 #3D4862 / 1px 细线 / 虚线 / 荧光笔 #F3E39A / 楷体 + 等宽 */
:root {
  /* 固定浅色，不跟随系统深色 */
  color-scheme: light;
  color-scheme: only light;

  --bg: #e6e4de;
  --paper: #fdfaf2;
  --paper-2: #f5f1e6;
  --paper-3: #eee8d8;
  --kraft: #d9c4a0;
  --kraft-2: #c9af86;
  --ink: #3d4862;
  --ink-2: #5a6480;
  --ink-soft: #8c93a6;
  --ink-blue: #7c88a6;
  --line: #cbcfd9;
  --rule: #b9becb;
  --track: #e7e3d7;
  --hl: #f3e39a;
  --hl-soft: #f8f0c6;
  --red: #b85a4e;
  --red-soft: #f2dcd5;
  --sage: #8da48a;
  --sage-soft: #dfe7d7;
  --sky: #9fb6cc;
  --sky-soft: #dde6ee;
  --pink-soft: #f5e3df;
  --r-l: 18px;
  --r-m: 12px;
  --r-s: 4px;
  --r-pill: 999px;
  --ease: cubic-bezier(0.3, 0.7, 0.3, 1);
  --f-kai: "LXGW WenKai", "Kaiti SC", "STKaiti", "KaiTi", serif;
  --f-mono: "Courier Prime", "Courier New", monospace;
  --mark: linear-gradient(100deg, transparent 1%, var(--hl) 3% 97%, transparent 99%) 0 85% / 100% 55% no-repeat;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

html,
body {
  color-scheme: only light;
}

html {
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

input,
textarea,
select {
  color-scheme: light;
}

body {
  font-family: var(--f-kai);
  font-size: 16px;
  line-height: 1.7;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.5;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .24 0 0 0 0 .28 0 0 0 0 .38 0 0 0 .07 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

button,
input,
textarea {
  font: inherit;
  color: inherit;
}

button {
  appearance: none;
  cursor: pointer;
  background: none;
  border: none;
}

:focus-visible {
  outline: 1.5px dashed var(--ink);
  outline-offset: 3px;
}

.app {
  position: relative;
  z-index: 1;
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  background: var(--paper);
  display: flex;
  flex-direction: column;
  box-shadow: 0 0 60px rgba(61, 72, 98, 0.1);
}

/* ---------- 顶栏 ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px 10px;
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px dashed transparent;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.seal {
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 50%;
  border: 1px solid var(--ink);
  background: var(--paper-2);
  color: var(--ink);
  font-size: 16px;
  display: grid;
  place-items: center;
}

.brand b {
  display: block;
  font-size: 17px;
  font-weight: 400;
  letter-spacing: 0.06em;
  line-height: 1.1;
  white-space: nowrap;
}

.brand small {
  display: block;
  font: 10px var(--f-mono);
  color: var(--ink-soft);
  letter-spacing: 0.12em;
  margin-top: 3px;
}

.icon-btn {
  width: 40px;
  height: 40px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--paper-2);
  color: var(--ink);
  transition: background 0.15s;
}

.icon-btn:hover {
  background: var(--hl-soft);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.who-chip {
  display: none;
  font-size: 13px;
  color: var(--ink-2);
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  padding: 6px 14px;
}

.topnav {
  display: none;
  gap: 18px;
  margin-left: auto;
  position: relative;
}

.topnav-item {
  position: relative;
  padding: 4px 2px 8px;
  font-size: 15px;
  color: var(--ink-soft);
  transition: color 0.15s;
}

.topnav-item.active {
  color: var(--ink);
}

.topnav-item.active::after {
  content: "";
  position: absolute;
  left: -4px;
  right: -4px;
  bottom: 0;
  height: 8px;
  background: var(--hl);
  opacity: 0.85;
  border-radius: 2px;
  z-index: -1;
  transform: skewX(-8deg);
}

.topnav-dot {
  position: absolute;
  top: -2px;
  right: -6px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: var(--r-pill);
  background: var(--red);
  color: var(--paper);
  font: 11px/16px var(--f-mono);
  font-style: normal;
  text-align: center;
}

/* ---------- 主体 ---------- */

.view {
  flex: 1;
  min-width: 0;
  padding: 10px 16px 26px;
}

.view-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin: 2px 2px 16px;
  padding-bottom: 10px;
  border-bottom: 1px dashed var(--line);
}

.view-title h1 {
  font-size: 26px;
  font-weight: 400;
  margin: 0;
  letter-spacing: 0.04em;
}

.view-title span {
  font: 11px var(--f-mono);
  color: var(--ink-soft);
  letter-spacing: 0.12em;
}

/* ---------- 登录 ---------- */

.login {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 28px 22px 36px;
  gap: 22px;
}

.login-mark {
  text-align: center;
}

.login-mark .big-seal {
  width: 66px;
  height: 66px;
  margin: 0 auto 18px;
  border-radius: 50%;
  border: 1.5px solid var(--ink);
  background: var(--paper-2);
  color: var(--ink);
  font-size: 28px;
  display: grid;
  place-items: center;
  transform: rotate(-2deg);
}

.login-mark h1 {
  font-size: 30px;
  font-weight: 400;
  letter-spacing: 0.12em;
  margin: 0 0 8px;
}

.login-mark p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 14px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field-label {
  font: 11px var(--f-mono);
  color: var(--ink-soft);
  letter-spacing: 0.16em;
  margin-left: 4px;
}

.code-input {
  width: 100%;
  height: 44px;
  padding: 0 4px;
  background: transparent;
  border: none;
  border-bottom: 1px dashed var(--ink-soft);
  font-size: 17px;
  letter-spacing: 0.08em;
  text-align: center;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}

.code-input:focus {
  border-bottom: 1px solid var(--ink);
  background: linear-gradient(transparent 70%, var(--hl-soft) 70%);
}

.login-error {
  color: var(--red);
  font-size: 13px;
  text-align: center;
  min-height: 18px;
}

.demo-box {
  border: 1px dashed var(--line);
  border-radius: var(--r-m);
  padding: 12px 14px;
  font-size: 13px;
  color: var(--ink-soft);
  line-height: 1.9;
}

.demo-box b {
  color: var(--ink);
  font-weight: 400;
}

.demo-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.demo-code {
  font: 11px var(--f-mono);
  color: var(--ink-soft);
  letter-spacing: 0.04em;
}

.link-btn {
  border: none;
  background: none;
  color: var(--ink);
  font-size: 13px;
  padding: 2px 0;
  text-decoration: underline wavy var(--ink-soft) 1px;
  text-underline-offset: 5px;
}

.footnote {
  text-align: center;
  font: 11px var(--f-mono);
  color: var(--ink-soft);
  line-height: 1.9;
  letter-spacing: 0.06em;
}

/* ---------- 按钮 ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 20px;
  font-size: 15px;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--ink);
  border-radius: var(--r-pill);
  white-space: nowrap;
  transition: background 0.15s, transform 0.12s;
}

.btn:hover {
  background: var(--paper-2);
}

.btn:active {
  transform: translateY(1px);
}

.btn.primary {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

.btn.primary:hover {
  background: #2f3850;
}

.btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
  transform: none;
}

.btn.small {
  height: 32px;
  padding: 0 14px;
  font-size: 13px;
}

/* ---------- 写信 ---------- */

.compose-letter {
  padding: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.compose-bar {
  padding: 12px 16px 6px;
  border-bottom: none;
}

.compose-title {
  flex: 1;
  text-align: center;
  font: 13px var(--f-mono);
  color: var(--ink-soft);
  letter-spacing: 0.18em;
}

.send-btn {
  padding: 0 22px;
  font-size: 14px;
}

.paper-stage {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 18px 6px;
}

.paper {
  --pw: 340px;
  --lh-px: calc(var(--pw) * var(--k-body) * var(--lh));
  position: relative;
  width: min(100%, 430px);
  aspect-ratio: 3 / 4;
  padding: calc(var(--pw) * var(--k-pad));
  display: flex;
  flex-direction: column;
  border-radius: var(--r-m);
  background-color: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-weight: var(--weight, 400);
  overflow: hidden;
}

.paper[data-paper="a"] {
  border: 7px solid transparent;
  border-radius: 6px;
  background:
    linear-gradient(var(--paper), var(--paper)) padding-box,
    repeating-linear-gradient(-45deg, #b85a4e 0 12px, #fdfaf2 12px 18px, #9fb6cc 18px 30px, #fdfaf2 30px 36px) border-box;
}

.paper[data-paper="b"] {
  border-radius: 4px;
  box-shadow: 0 1px 0 rgba(61, 72, 98, 0.08), 0 10px 20px rgba(61, 72, 98, 0.12);
}

.paper[data-paper="c"] {
  background: #f7eba6;
  border-radius: 2px 2px 26px 2px;
  box-shadow: 4px 8px 20px rgba(61, 72, 98, 0.16);
}

.paper[data-paper="c"]::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 0;
  width: calc(var(--pw) * 0.063);
  height: calc(var(--pw) * 0.063);
  background: linear-gradient(135deg, #e6d57d 50%, transparent 50%);
  border-radius: 0 0 26px 0;
  pointer-events: none;
}

.paper[data-paper="d"] {
  border-radius: 0;
  -webkit-mask:
    conic-gradient(from 135deg at top, #0000, #000 1deg 89deg, #0000 90deg) top / 18px 51% repeat-x,
    conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) bottom / 18px 51% repeat-x;
  mask:
    conic-gradient(from 135deg at top, #0000, #000 1deg 89deg, #0000 90deg) top / 18px 51% repeat-x,
    conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) bottom / 18px 51% repeat-x;
}

.paper[data-paper="d"]::after {
  content: "";
  position: absolute;
  left: calc(var(--pw) * 0.11);
  right: calc(var(--pw) * 0.11);
  bottom: calc(var(--pw) * 0.155);
  height: calc(var(--pw) * 0.038);
  background: repeating-linear-gradient(90deg, var(--ink) 0 3px, transparent 3px 6px, var(--ink) 6px 9px, transparent 9px 14px);
  opacity: 0.75;
  pointer-events: none;
}

.paper[data-paper="d"] .paper-body {
  margin-bottom: calc(var(--pw) * 0.14);
}

.paper[data-paper="b"] .paper-greeting {
  padding-top: calc(var(--pw) * 0.16);
}

.paper[data-paper="b"] .paper-body {
  margin-bottom: calc(var(--pw) * 0.33);
}

/* 明信片的地址面 */

.pc-postmark {
  position: absolute;
  top: calc(var(--pw) * 0.041);
  left: calc(var(--pw) * 0.081);
  font: calc(var(--pw) * 0.0115) var(--f-mono);
  letter-spacing: 0.34em;
  color: var(--ink-soft);
  pointer-events: none;
}

.pc-stamp {
  position: absolute;
  top: calc(var(--pw) * 0.032);
  right: calc(var(--pw) * 0.081);
  width: calc(var(--pw) * 0.13);
  height: calc(var(--pw) * 0.155);
  display: grid;
  place-items: center;
  background: #fdfaf2;
  border: 2px dashed var(--red);
  color: var(--red);
  font-size: calc(var(--pw) * 0.041);
  border-radius: 2px;
  pointer-events: none;
}

.pc-divider {
  position: absolute;
  left: calc(var(--pw) * 0.081);
  right: calc(var(--pw) * 0.081);
  bottom: calc(var(--pw) * 0.366);
  border-top: 1px dashed var(--rule);
  pointer-events: none;
}

.pc-to {
  position: absolute;
  left: calc(var(--pw) * 0.081);
  bottom: calc(var(--pw) * 0.337);
  font: calc(var(--pw) * 0.0165) var(--f-mono);
  color: var(--ink-soft);
  pointer-events: none;
}

.pc-line {
  position: absolute;
  left: calc(var(--pw) * 0.081);
  right: calc(var(--pw) * 0.081);
  border-top: 1px dotted var(--rule);
  pointer-events: none;
}

.pc-line-1 {
  bottom: calc(var(--pw) * 0.292);
}

.pc-line-2 {
  bottom: calc(var(--pw) * 0.222);
}

/* v1.02 滚动条：点状轨道 + 荧光笔滑块 */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: repeating-linear-gradient(var(--rule) 0 2px, transparent 2px 7px) center / 1px 100% no-repeat;
}

::-webkit-scrollbar-thumb {
  min-height: 36px;
  border: 3px solid transparent;
  border-radius: 99px;
  background: var(--ink-soft) padding-box;
}

::-webkit-scrollbar-thumb:hover {
  border-width: 2px;
  background: var(--ink-blue) padding-box;
}

::-webkit-scrollbar-thumb:active {
  background: var(--ink) padding-box;
}

::-webkit-scrollbar-button,
::-webkit-scrollbar-corner {
  display: none;
  background: transparent;
}

* {
  scrollbar-width: thin;
  scrollbar-color: var(--ink-soft) transparent;
}

/* 纸面装饰 */

.deco-tape {
  position: absolute;
  top: calc(var(--pw) * 0.03);
  left: 50%;
  width: calc(var(--pw) * 0.21);
  height: calc(var(--pw) * 0.052);
  margin-left: calc(var(--pw) * -0.105);
  background: rgba(243, 227, 154, 0.85);
  transform: rotate(-3deg);
  pointer-events: none;
}

.deco-dash {
  position: absolute;
  inset: calc(var(--pw) * 0.035);
  border: 2px dashed var(--rule);
  border-radius: 10px;
  pointer-events: none;
}

.deco-flap {
  position: absolute;
  inset: 0 0 auto;
  height: calc(var(--pw) * 0.14);
  background: #e3d1b1;
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  border-bottom: 1px solid var(--kraft-2);
  pointer-events: none;
}

.deco-stamp {
  position: absolute;
  top: calc(var(--pw) * 0.09);
  right: calc(var(--pw) * 0.075);
  width: calc(var(--pw) * 0.13);
  height: calc(var(--pw) * 0.155);
  display: grid;
  place-items: center;
  background: var(--paper);
  border: 2px dashed var(--red);
  color: var(--red);
  font-size: calc(var(--pw) * 0.045);
  transform: rotate(-3deg);
  pointer-events: none;
}

/* 纸面上的字 */

.paper-date {
  flex: none;
  align-self: stretch;
  border: none;
  background: none;
  padding: 0;
  appearance: none;
  -webkit-appearance: none;
  font-family: var(--f-mono);
  font-size: calc(var(--pw) * var(--k-meta) * 0.92);
  color: var(--ink-soft);
  line-height: 1.7;
  letter-spacing: 0.1em;
  cursor: pointer;
}

.paper-date.left {
  text-align: left;
}

.paper-date.right {
  text-align: right;
}

.paper-date.center {
  text-align: center;
  letter-spacing: 0.24em;
}

.paper-rule {
  flex: none;
  height: 1px;
  background: var(--rule);
  margin: calc(var(--pw) * 0.02) 0 calc(var(--pw) * 0.028);
}

.paper-greeting {
  flex: none;
  font-size: calc(var(--pw) * var(--k-body));
  line-height: var(--lh);
  padding-top: calc(var(--pw) * var(--k-body) * 0.2);
}

.paper-body {
  flex: 1;
  min-height: 0;
  width: 100%;
  border: none;
  outline: none;
  resize: none;
  background: transparent;
  padding: 0;
  margin-top: calc(var(--pw) * var(--k-body) * 0.14);
  font-family: inherit;
  font-weight: inherit;
  font-size: calc(var(--pw) * var(--k-body));
  line-height: var(--lh);
  color: inherit;
  overflow-y: auto;
}

.paper-body::placeholder {
  color: var(--ink-soft);
  opacity: 0.7;
}

.paper[data-paper="a"] .paper-body {
  /* 文字在行框里是垂直居中的（不是贴着行顶），所以点线要落在基线下：
     行高 1.92em、半行距 0.46em、基线约 1.34em，点线取 0.74 行 ≈ 1.42em */
  background-image: radial-gradient(circle, var(--rule) 1px, transparent 1.4px);
  background-size: 7px var(--lh-px);
  background-position: 0 calc(var(--lh-px) * 0.26);
  background-attachment: local;
}

.paper-images {
  flex: none;
  display: flex;
  gap: calc(var(--pw) * 0.016);
  margin-top: calc(var(--pw) * 0.028);
}

.paper-images .pi {
  position: relative;
  flex: 1;
  aspect-ratio: 1;
  border-radius: var(--r-s);
  overflow: hidden;
  border: 1px solid var(--line);
}

.paper-images img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.paper-images .pi button {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: none;
  background: var(--ink);
  color: var(--paper);
  font-size: 11px;
  line-height: 1;
  display: grid;
  place-items: center;
}

.paper-foot {
  flex: none;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
  margin-top: calc(var(--pw) * 0.028);
}

.paper-sign {
  font-size: calc(var(--pw) * var(--k-body) * 0.92);
  line-height: 1.4;
}

.paper-avatar {
  width: calc(var(--pw) * 0.088);
  height: calc(var(--pw) * 0.088);
  display: grid;
  place-items: center;
}

.paper-avatar svg {
  width: 100%;
  height: 100%;
}

.paper-hint {
  flex: none;
  text-align: center;
  font: 11px var(--f-mono);
  color: var(--red);
  padding: 0 0 6px;
  letter-spacing: 0.06em;
}

/* ---------- 信纸选择条 ---------- */

.tray {
  flex: none;
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 14px calc(12px + env(safe-area-inset-bottom));
  padding: 8px 10px;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--r-l);
}

.tray-list {
  display: flex;
  gap: 2px;
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.tray-list::-webkit-scrollbar {
  display: none;
}

.tray-item {
  flex: none;
  width: 68px;
  border: none;
  background: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 5px 3px 4px;
  border-radius: var(--r-m);
  transition: background 0.15s;
}

.tray-item.active {
  background: var(--hl);
}

.tray-swatch {
  width: 40px;
  height: 40px;
  border-radius: 3px 3px 9px 3px;
  background: var(--sw-bg);
  border: 1px solid var(--sw-line);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  padding: 0 8px;
}

.tray-swatch i {
  display: block;
  height: 1.5px;
  border-radius: 2px;
  background: var(--sw-ink);
  opacity: 0.45;
}

.tray-swatch i:nth-child(2) {
  width: 82%;
}

.tray-swatch i:nth-child(3) {
  width: 56%;
}

.tray-name {
  font-size: 11px;
  color: var(--ink-soft);
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.tray-item.active .tray-name {
  color: var(--ink);
}

.tray-btn {
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--paper);
  display: grid;
  place-items: center;
  color: var(--ink);
  transition: background 0.15s;
}

.tray-btn:hover {
  background: var(--hl-soft);
}

/* ---------- 纸箱 / 信箱 ---------- */

.filters {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 0 2px 14px;
  scrollbar-width: none;
}

.filters::-webkit-scrollbar {
  display: none;
}

.filter {
  white-space: nowrap;
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: var(--r-pill);
  padding: 6px 14px;
  font-size: 13px;
  color: var(--ink-2);
  transition: all 0.15s;
}

.filter.active {
  background: var(--hl);
  border-color: var(--ink);
  color: var(--ink);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 14px;
}

.card-tile {
  position: relative;
  border: none;
  padding: 0;
  min-width: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.card-tile canvas {
  width: 100%;
  aspect-ratio: 3 / 4;
  display: block;
  border-radius: 3px 3px 10px 3px;
  border: 1px solid var(--line);
  background: #fff;
  transition: transform 0.15s var(--ease);
}

.card-tile:nth-child(odd) canvas {
  transform: rotate(-1.2deg);
}

.card-tile:nth-child(even) canvas {
  transform: rotate(1deg);
}

.card-tile:hover canvas {
  transform: rotate(0) translateY(-2px);
}

.card-tile .cap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 11px;
  color: var(--ink-soft);
  margin-top: 8px;
  padding: 0 2px;
}

.card-tile .cap .who {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge {
  display: inline-block;
  font: 10px var(--f-mono);
  padding: 2px 8px;
  border-radius: var(--r-pill);
  background: var(--hl);
  color: var(--ink);
  letter-spacing: 0.06em;
}

.badge.sent {
  background: none;
  border: 1px dashed var(--ink-soft);
  color: var(--ink-soft);
}

.mail-list {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  min-width: 0;
}

.mail-row {
  display: flex;
  gap: 12px;
  align-items: center;
  width: 100%;
  min-width: 0;
  overflow: hidden;
  text-align: left;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-m);
  padding: 10px;
  position: relative;
  transition: border-color 0.15s, transform 0.15s;
}

.mail-row:hover {
  border-color: var(--rule);
  transform: translateY(-1px);
}

.mail-row canvas {
  width: 54px;
  height: 72px;
  border-radius: 2px 2px 6px 2px;
  flex: none;
  border: 1px solid var(--line);
}

.mail-row .info {
  min-width: 0;
  flex: 1;
  overflow: hidden;
}

.mail-row .from {
  font: 11px var(--f-mono);
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: 0.04em;
}

.mail-row .title {
  font-size: 16px;
  font-weight: 400;
  margin: 3px 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mail-row .excerpt {
  font-size: 12.5px;
  color: var(--ink-soft);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mail-row.unread {
  border-color: var(--ink);
}

.mail-row.unread::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 50%;
  width: 6px;
  height: 6px;
  margin-top: -3px;
  border-radius: 50%;
  background: var(--red);
}

.empty {
  text-align: center;
  color: var(--ink-soft);
  font-size: 14px;
  padding: 56px 24px;
  line-height: 2;
}

.empty .glyph {
  font-size: 26px;
  opacity: 0.35;
  display: block;
  margin-bottom: 10px;
  letter-spacing: 6px;
}

/* ---------- 底部导航 ---------- */

.tabs {
  position: sticky;
  bottom: 0;
  z-index: 20;
  display: flex;
  gap: 26px;
  justify-content: center;
  padding: 9px 18px calc(10px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--paper) 94%, transparent);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
}

.tab {
  position: relative;
  border: none;
  background: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 4px 2px 7px;
  font-size: 11px;
  color: var(--ink-soft);
  letter-spacing: 0.04em;
}

.tab svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tab.active {
  color: var(--ink);
}

.tab.active::after {
  content: "";
  position: absolute;
  left: -4px;
  right: -4px;
  bottom: 0;
  height: 8px;
  background: var(--hl);
  opacity: 0.85;
  border-radius: 2px;
  z-index: -1;
  transform: skewX(-8deg);
}

.tab .dot {
  position: absolute;
  top: 0;
  right: calc(50% - 20px);
  min-width: 15px;
  height: 15px;
  padding: 0 4px;
  border-radius: var(--r-pill);
  background: var(--red);
  color: var(--paper);
  font: 10px/15px var(--f-mono);
  text-align: center;
}

/* ---------- 浮层 ---------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(61, 72, 98, 0.28);
  backdrop-filter: blur(1.5px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fade 0.2s var(--ease);
}

@keyframes fade {
  from {
    opacity: 0;
  }
}

@keyframes drop {
  from {
    opacity: 0;
    transform: translateY(16px) rotate(-1.5deg);
  }
}

.sheet {
  position: relative;
  width: 100%;
  max-width: 420px;
  max-height: 92dvh;
  overflow: auto;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-l);
  padding: 30px 20px calc(18px + env(safe-area-inset-bottom));
  box-shadow: 0 18px 40px rgba(61, 72, 98, 0.18);
  animation: drop 0.3s var(--ease);
}

.sheet::before {
  content: "";
  position: absolute;
  top: -11px;
  left: 50%;
  width: 92px;
  height: 24px;
  margin-left: -46px;
  background: rgba(243, 227, 154, 0.85);
  transform: rotate(-3deg);
}

.sheet h2 {
  font-size: 22px;
  font-weight: 400;
  text-align: center;
  margin: 0 0 4px;
}

.viewer-sheet {
  padding-top: 34px;
}

.sheet .sub {
  text-align: center;
  font: 11px var(--f-mono);
  color: var(--ink-soft);
  letter-spacing: 0.1em;
  margin-bottom: 14px;
}

.sheet-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 34px;
  height: 34px;
  border: none;
  background: none;
  border-radius: 50%;
  font-size: 16px;
  color: var(--ink-soft);
  line-height: 1;
  z-index: 2;
}

.sheet-close:hover {
  background: var(--paper-2);
  color: var(--ink);
}

.viewer-card {
  display: block;
  width: 100%;
  max-width: 360px;
  margin: 0 auto;
  border-radius: 2px 2px 10px 2px;
  border: 1px solid var(--line);
  box-shadow: 0 10px 26px rgba(61, 72, 98, 0.14);
}

.viewer-meta {
  text-align: center;
  font: 11px var(--f-mono);
  color: var(--ink-soft);
  margin: 14px 0 16px;
  line-height: 1.9;
  letter-spacing: 0.06em;
}

.viewer-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.row-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 2px;
  border-bottom: 1px dashed var(--line);
  font-size: 14px;
}

.row-item:last-child {
  border-bottom: none;
}

.row-item .k {
  color: var(--ink-soft);
  font-size: 13px;
}

.row-item button {
  border: none;
  background: none;
  color: var(--ink);
  font-size: 13px;
  text-decoration: underline wavy var(--ink-soft) 1px;
  text-underline-offset: 5px;
}

.role-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  background: var(--paper);
  border: 1px dashed var(--line);
  border-radius: var(--r-m);
  padding: 10px 12px;
  margin-bottom: 10px;
  transition: background 0.15s, border-color 0.15s;
}

.role-row.active {
  background: var(--hl-soft);
  border: 1px solid var(--ink);
}

.role-row-text b {
  display: block;
  font-size: 15px;
  font-weight: 400;
}

.role-row-text small {
  display: block;
  font-size: 12px;
  color: var(--ink-soft);
  margin-top: 2px;
  line-height: 1.5;
}

.date-input {
  width: 100%;
  height: 44px;
  border: none;
  border-bottom: 1px dashed var(--ink-soft);
  background: transparent;
  padding: 0 4px;
  font-size: 17px;
  color: var(--ink);
  outline: none;
}

.date-input:focus {
  border-bottom: 1px solid var(--ink);
  background: linear-gradient(transparent 70%, var(--hl-soft) 70%);
}

.nick-input {
  height: 34px;
  border: none;
  border-bottom: 1px dashed var(--ink-soft);
  background: transparent;
  padding: 0 4px;
  font-size: 15px;
  width: 140px;
  text-align: center;
  outline: none;
}

.nick-input:focus {
  border-bottom: 1px solid var(--ink);
}

.settings-block {
  padding: 14px 2px;
  border-bottom: 1px dashed var(--line);
}

.settings-block .k {
  font-size: 13px;
  color: var(--ink-soft);
}

.avatar-row {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}

.avatar-pick {
  width: 48px;
  height: 48px;
  border: 1px dashed var(--line);
  border-radius: 50%;
  background: var(--paper);
  display: grid;
  place-items: center;
  transition: background 0.15s, border-color 0.15s;
}

.avatar-pick.active {
  background: var(--hl-soft);
  border: 1px solid var(--ink);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 92px;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--paper);
  font-size: 14px;
  padding: 8px 18px;
  border-radius: var(--r-pill);
  z-index: 80;
  white-space: nowrap;
  animation: drop 0.3s var(--ease);
}

.hint {
  font-size: 12px;
  color: var(--ink-soft);
  line-height: 1.8;
}

.reply-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--hl-soft);
  color: var(--ink);
  font-size: 12.5px;
  padding: 8px 14px;
  border-radius: var(--r-s);
  margin: 0 14px 8px;
}

.reply-banner button {
  border: none;
  background: none;
  color: var(--ink);
  font-size: 12.5px;
  text-decoration: underline wavy var(--ink-soft) 1px;
  text-underline-offset: 4px;
  flex: none;
}

/* ---------- 大小屏适配 ---------- */

@media (max-width: 480px) {
  .overlay {
    padding: 10px;
  }

  .sheet {
    padding-left: 14px;
    padding-right: 14px;
    border-radius: 14px;
  }
}

@media (min-width: 700px) {
  .app {
    max-width: 860px;
  }

  .view {
    padding: 12px 32px 40px;
  }

  .tabs {
    display: none;
  }

  .topnav {
    display: flex;
  }

  .who-chip {
    display: inline-flex;
  }

  .compose-letter {
    max-width: 560px;
    margin: 0 auto;
    width: 100%;
  }

  .grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 18px;
  }

  .mail-list {
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 12px;
  }

  .login {
    max-width: 420px;
    margin: 0 auto;
    width: 100%;
  }

  .paper {
    width: min(100%, 460px);
  }
}

@media (min-width: 1200px) {
  .app {
    max-width: 1040px;
  }

  .view {
    padding: 14px 44px 48px;
  }

  .grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  }
}

@media (max-height: 760px) {
  .paper {
    width: min(100%, 380px);
  }
}

@media (max-height: 680px) {
  .paper {
    width: min(100%, 330px);
  }
}
/* ---------- 首页：日期条 + 时间轴 ---------- */

.home {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-bottom: 92px;
}

.cs-card {
  padding: 14px 12px 12px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 20px;
}

.cs-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 0 4px 8px;
}

.cs-head b {
  font-size: 18px;
  font-weight: 400;
}

.cs-head span {
  font: 11px var(--f-mono);
  color: var(--ink-soft);
  letter-spacing: 0.08em;
}

.cs-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.cs-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 0 8px;
  border: none;
  background: none;
  color: var(--ink-2);
  border-radius: 14px;
  transition: background 0.15s;
}

.cs-day:hover {
  background: var(--paper-2);
}

.cs-day .cs-wd {
  font: 10px var(--f-mono);
  color: var(--ink-soft);
}

.cs-day .cs-num {
  font: 15px var(--f-mono);
  line-height: 1.1;
}

.cs-day.today {
  background: var(--hl-soft);
}

.cs-day.today .cs-num {
  font-weight: 700;
}

.cs-plus {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--paper-2);
  color: var(--ink-soft);
  display: grid;
  place-items: center;
  font: 13px var(--f-mono);
}

.cs-marks {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 22px;
}

.cs-av {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  font-style: normal;
}

.cs-av svg {
  width: 100%;
  height: 100%;
}

.timeline {
  display: block;
}

.tl-title {
  font: 12px var(--f-mono);
  color: var(--ink-soft);
  letter-spacing: 0.18em;
  margin: 4px 2px 8px;
}

.tl-item {
  position: relative;
  padding-left: 62px;
  padding-bottom: 14px;
}

.tl-item::before {
  content: "";
  position: absolute;
  left: 52px;
  top: 12px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--paper);
  border: 1.5px solid var(--ink-soft);
}

.tl-item::after {
  content: "";
  position: absolute;
  left: 56px;
  top: 22px;
  bottom: 0;
  border-left: 1px dashed var(--line);
}

.tl-item:last-child::after {
  display: none;
}

.tl-when {
  position: absolute;
  left: 0;
  top: 8px;
  width: 44px;
  text-align: right;
}

.tl-when b {
  display: block;
  font: 12px var(--f-mono);
  color: var(--ink-2);
}

.tl-when span {
  font: 10px var(--f-mono);
  color: var(--ink-soft);
}

.tl-card {
  padding: 12px 14px;
  border-radius: 4px 4px 14px 4px;
}

.tl-card.diary {
  background: var(--c, var(--paper));
  border: 1px solid var(--line);
  color: var(--c-ink, var(--ink));
}

.tl-card.event {
  background: var(--paper-2);
  border-left: 3px solid var(--ink-blue);
  border-radius: 4px 10px 10px 4px;
}

.tl-text {
  font-size: 15.5px;
  line-height: 1.7;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.tl-foot {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  font: 11px var(--f-mono);
  color: var(--ink-soft);
}

.tl-foot em {
  font-style: normal;
  margin-left: auto;
}

.tl-evt-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.tl-evt-head b {
  font-weight: 400;
  font-size: 16px;
}

.tl-rule {
  flex: none;
  font: 10px var(--f-mono);
  color: var(--ink-soft);
  background: var(--paper);
  border: 1px dashed var(--line);
  border-radius: 99px;
  padding: 1px 8px;
}

.fab {
  position: fixed;
  right: 18px;
  bottom: calc(82px + env(safe-area-inset-bottom));
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--paper);
  display: grid;
  place-items: center;
  box-shadow: 0 8px 22px rgba(61, 72, 98, 0.28);
  z-index: 30;
}

.fab svg {
  width: 23px;
  height: 23px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

@media (min-width: 700px) {
  .fab {
    display: none;
  }
}

.mini-av {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  flex: none;
}

.mini-av svg {
  width: 100%;
  height: 100%;
}

.day-list {
  display: grid;
  gap: 8px;
  margin: 6px 0 16px;
}

.day-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--paper-2);
  border-radius: var(--r-m);
}

.day-main {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 2px;
}

.day-main b {
  font-weight: 400;
  font-size: 15px;
}

.day-main small {
  font: 11px var(--f-mono);
  color: var(--ink-soft);
}

.day-del {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  color: var(--ink-soft);
  display: grid;
  place-items: center;
}

.day-del:hover {
  background: var(--red-soft);
  color: var(--red);
}

.field {
  display: block;
  margin-bottom: 14px;
}

.field .lb {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--ink-2);
  margin-bottom: 4px;
}

.ink-input {
  width: 100%;
  height: 42px;
  padding: 0 4px;
  border: none;
  border-bottom: 1px dashed var(--ink-soft);
  background: transparent;
  font-size: 16px;
  outline: none;
}

.ink-input:focus {
  border-bottom: 1px solid var(--ink);
  background: linear-gradient(transparent 70%, var(--hl-soft) 70%);
}

.seg {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 3px;
  border: 1px dashed var(--ink-soft);
  border-radius: var(--r-pill);
}

.seg-btn {
  padding: 5px 14px;
  border-radius: var(--r-pill);
  font-size: 13px;
  color: var(--ink-2);
}

.seg-btn.active {
  background: var(--ink);
  color: var(--paper);
}

.btn.block {
  width: 100%;
}
/* ---------- 日历 tab ---------- */

.calendar {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-bottom: 92px;
}

.mc-card {
  padding: 14px 12px 12px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 20px;
}

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

.mc-head b {
  flex: 1;
  text-align: center;
  font-size: 17px;
  font-weight: 400;
}

.mc-nav {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  color: var(--ink-2);
  font-size: 18px;
  line-height: 1;
  display: grid;
  place-items: center;
}

.mc-nav:hover {
  background: var(--paper-2);
}

.mc-today {
  margin-left: auto;
  border: 1px solid var(--ink);
  border-radius: 99px;
  padding: 4px 12px;
  font-size: 12px;
  color: var(--ink);
  white-space: nowrap;
}

.mc-weekhead {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  margin-bottom: 4px;
}

.mc-weekhead span {
  text-align: center;
  font: 10px var(--f-mono);
  color: var(--ink-soft);
}

.mc-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.mc-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 0 7px;
  border: none;
  background: none;
  border-radius: 10px;
  color: var(--ink);
}

.mc-day:hover {
  background: var(--paper-2);
}

.mc-day.out {
  color: var(--ink-soft);
  opacity: 0.45;
}

.mc-day.has {
  background: var(--paper-2);
}

.mc-day.today {
  background: var(--hl-soft);
  box-shadow: inset 0 0 0 1.2px var(--ink);
}

.mc-num {
  font: 13px var(--f-mono);
}

.mc-day.today .mc-num {
  font-weight: 700;
}

.mc-marks {
  display: flex;
  gap: 2px;
  height: 16px;
}

.mc-marks .cs-av {
  width: 15px;
  height: 15px;
}

.agenda {
  display: grid;
  gap: 2px;
}

.ag-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 4px;
  border: none;
  border-bottom: 1px dashed var(--line);
  background: none;
  text-align: left;
}

.ag-date {
  width: 46px;
  flex: none;
  text-align: center;
  font: 12px var(--f-mono);
  color: var(--ink-2);
}

.ag-date b {
  display: block;
}

.ag-date span {
  font-size: 10px;
  color: var(--ink-soft);
}

.ag-main {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 2px;
}

.ag-main b {
  font-weight: 400;
  font-size: 15px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ag-main small {
  font: 11px var(--f-mono);
  color: var(--ink-soft);
}

.hint.center {
  text-align: center;
}

.tabs {
  gap: 12px;
}

.tab {
  font-size: 10.5px;
}

/* 弹层重复渲染时不重播动效 */
.overlay.still,
.overlay.still .sheet {
  animation: none;
}

/* 日历头部：左箭头 + 回到今天（占位固定，不挤动标题和右箭头） */
.mc-head {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
}

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

.mc-head b {
  text-align: center;
  white-space: nowrap;
}

.mc-next {
  justify-self: end;
}

.mc-today.is-hidden {
  visibility: hidden;
}
