:root {
  --paper: #F7F4EF;
  --page: #FFFFFF;
  --page-alt: #EFECE6;
  --line: #E5E0D8;
  --ink: #2C2A28;
  --ink-soft: #7A746E;
  --ink-faint: #A69F98;
  --sage: #5E806A;
  --sage-bg: #EEF3EF;
  --rose: #C46D5E;
  --rose-bg: #F9EFEA;
  --amber: #C89046;
  --amber-bg: #FAF3E8;
  --serif: "Noto Serif SC", "Songti SC", "SimSun", Georgia, serif;
  --sans: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  --mono: "IBM Plex Mono", "SF Mono", Consolas, monospace;
  --sidebar-w: 300px;
  --radius: 2px;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background:
    radial-gradient(ellipse at 12% 0%, rgba(94, 128, 106, 0.06), transparent 42%),
    radial-gradient(ellipse at 88% 100%, rgba(196, 144, 70, 0.05), transparent 40%),
    var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-weight: 400;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

body.nav-open {
  overflow: hidden;
  touch-action: none;
}

button, input, textarea, select {
  font: inherit;
  color: inherit;
}

.serif { font-family: var(--serif); }
.mono { font-family: var(--mono); }
.muted { color: var(--ink-soft); }
.small { font-size: 0.85rem; }
.hidden { display: none !important; }

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
  max-width: 1280px;
  margin: 0 auto;
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
  background: var(--paper);
}

/* —— 左侧索引 —— */
.sidebar {
  display: flex;
  flex-direction: column;
  border-right: 1px dashed var(--line);
  background: linear-gradient(180deg, rgba(239, 236, 230, 0.55), transparent 28%);
  min-height: 100vh;
  position: sticky;
  top: 0;
  max-height: 100vh;
}

.mobile-topbar {
  display: none;
}

.sidebar-backdrop {
  display: none;
}

.nav-close {
  display: none;
}

.sidebar-brand {
  padding: 1.75rem 1.25rem 1rem;
  animation: fadeRise 0.7s ease both;
}

.sidebar-brand-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.empty-mobile-hint {
  display: none;
  margin: 0.35rem 0 0;
}

.brand-title {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1.3;
}

.brand-sub {
  margin: 0.4rem 0 0;
  font-size: 0.82rem;
  color: var(--ink-soft);
  letter-spacing: 0.02em;
}

.search-wrap { padding: 0 1rem; }

.search-input {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--page);
  padding: 0.55rem 0.75rem;
  outline: none;
  transition: border-color 0.2s ease;
}

.search-input:focus { border-color: var(--sage); }

.sidebar-actions {
  padding: 0.85rem 1rem 0.4rem;
}

.friend-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 0.65rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.friend-item {
  display: grid;
  grid-template-columns: 40px 1fr;
  gap: 0.65rem;
  align-items: center;
  padding: 0.55rem 0.55rem;
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.friend-item:hover { background: rgba(255, 255, 255, 0.55); }
.friend-item.active {
  background: var(--page);
  border-color: var(--line);
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 1.05rem;
  flex-shrink: 0;
}

.friend-meta { min-width: 0; }
.friend-name {
  font-family: var(--serif);
  font-size: 0.98rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.friend-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.15rem;
  font-size: 0.72rem;
  color: var(--ink-faint);
}
.tag-pill {
  border: 1px solid var(--line);
  padding: 0 0.35rem;
  background: var(--page-alt);
}
.bday-hint {
  color: var(--rose);
  border-color: #e8cfc8;
  background: var(--rose-bg);
}

.sidebar-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1.1rem 1rem;
  border-top: 1px dashed var(--line);
  font-size: 0.8rem;
}

.linkish {
  background: none;
  border: none;
  color: var(--sage);
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* —— 右侧手账 —— */
.canvas {
  min-width: 0;
  padding: 1.75rem 2rem 3rem;
  animation: fadeIn 0.45s ease both;
}

.empty-canvas {
  min-height: 60vh;
  display: grid;
  place-content: center;
  text-align: center;
  gap: 0.4rem;
  opacity: 0.85;
}

.lead {
  font-size: 1.35rem;
  margin: 0;
}

.scrapbook {
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
  animation: pageTurn 0.45s ease both;
}

.profile-header {
  display: grid;
  grid-template-columns: 72px 1fr auto;
  gap: 1rem;
  align-items: start;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--line);
}

.avatar.lg {
  width: 72px;
  height: 72px;
  font-size: 1.8rem;
}

.profile-name {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.85rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.profile-nick {
  margin: 0.2rem 0 0;
  color: var(--ink-soft);
  font-size: 0.92rem;
}

.profile-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.55rem;
}

.bond-card {
  margin: 1rem 0 0.35rem;
  padding: 1rem 1.05rem;
  background:
    linear-gradient(135deg, rgba(255, 252, 246, 0.95), rgba(244, 236, 222, 0.7)),
    var(--page);
  border: 1px solid var(--line);
}
.bond-card--empty {
  padding: 0.75rem 1rem;
  text-align: center;
}
.bond-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr;
  gap: 1rem;
}
.bond-title {
  margin: 0 0 0.45rem;
  font-family: var(--serif);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
}
.bond-text {
  margin: 0;
  white-space: pre-wrap;
  line-height: 1.55;
  font-size: 0.92rem;
}
.role-pair {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}
.role-pill {
  flex: 1;
  min-width: 7rem;
  padding: 0.5rem 0.65rem;
  background: var(--sage-bg);
  border: 1px solid #c9d6cc;
}
.role-pill--them {
  background: var(--amber-bg);
  border-color: #e8d5b4;
}
.role-who {
  display: block;
  font-size: 0.7rem;
  color: var(--ink-soft);
  letter-spacing: 0.08em;
  margin-bottom: 0.15rem;
}
.role-what {
  font-size: 0.92rem;
  font-weight: 600;
}
.role-arrow {
  color: var(--ink-soft);
  opacity: 0.55;
  font-size: 0.95rem;
}
.score-row {
  display: grid;
  grid-template-columns: 4.5rem 1fr 2.4rem;
  gap: 0.4rem;
  align-items: center;
  margin: 0.35rem 0;
}
.score-label { font-size: 0.78rem; color: var(--ink-soft); }
.score-track {
  height: 0.42rem;
  background: #ebe4d6;
  overflow: hidden;
}
.score-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--sage), var(--amber));
  transition: width 0.35s ease;
}
.score-num {
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.score-num small { color: var(--ink-soft); font-size: 0.7rem; }
.score-row--empty .score-fill { opacity: 0.25; }

@media (max-width: 900px) {
  .bond-grid { grid-template-columns: 1fr; }
}

.chip {
  font-size: 0.75rem;
  padding: 0.15rem 0.5rem;
  border: 1px solid var(--line);
  background: var(--page);
  color: var(--ink-soft);
}

.chip.sage { background: var(--sage-bg); color: var(--sage); border-color: #c9d6cc; }
.chip.rose { background: var(--rose-bg); color: var(--rose); border-color: #e8cfc8; }
.chip.amber { background: var(--amber-bg); color: var(--amber); border-color: #e8d5b4; }

.profile-actions {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  align-items: flex-end;
}

.bday-banner {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--rose);
  background: var(--rose-bg);
  border: 1px dashed #e0b8ae;
  padding: 0.45rem 0.7rem;
  white-space: nowrap;
}

.bday-banner.today {
  font-family: var(--serif);
  font-size: 0.9rem;
}

.section {
  background: var(--page);
  border: 1px solid var(--line);
  padding: 1.15rem 1.25rem 1.3rem;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 0.9rem;
  padding-bottom: 0.55rem;
  border-bottom: 1px dashed var(--line);
}

.section-title {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.06em;
}

.section-hint {
  margin: 0.15rem 0 0;
  font-size: 0.78rem;
  color: var(--ink-faint);
}

.quote-list, .joke-list, .pref-list, .memo-list, .moment-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.quote-card {
  position: relative;
  background: var(--amber-bg);
  border: 1px solid #ead9bc;
  padding: 0.9rem 1rem 0.85rem 1.15rem;
}

.quote-card::before {
  content: "“";
  font-family: var(--serif);
  font-size: 2.4rem;
  line-height: 1;
  color: var(--amber);
  position: absolute;
  left: 0.35rem;
  top: 0.15rem;
  opacity: 0.55;
}

.quote-text {
  font-family: var(--serif);
  font-size: 1.05rem;
  margin: 0 0 0 0.85rem;
  line-height: 1.55;
}

.item-row {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: flex-start;
}

.btn-x, .btn-edit {
  border: none;
  background: transparent;
  color: var(--ink-faint);
  cursor: pointer;
  padding: 0 0.2rem;
  line-height: 1;
  font-size: 0.95rem;
}
.btn-x:hover { color: var(--rose); }
.btn-edit:hover { color: var(--sage); }
.item-actions {
  display: inline-flex;
  gap: 0.15rem;
  flex-shrink: 0;
  opacity: 0.55;
  transition: opacity 0.15s ease;
}
.item-row:hover .item-actions,
.memo-item:hover .item-actions,
.moment-item:hover .item-actions,
.tag-chip:hover .item-actions { opacity: 1; }

.section-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  justify-content: flex-end;
}

.add-section-bar {
  text-align: center;
  padding: 1.25rem 1rem 0.5rem;
  border: 1px dashed var(--line);
  background: rgba(255,255,255,0.35);
}
.add-section-bar p { margin: 0.55rem 0 0; }

.custom-section.accent-sage { border-color: #d2ddd5; }
.custom-section.accent-rose { border-color: #e8d5cf; }
.custom-section.accent-amber { border-color: #e8d5b4; }
.custom-section.accent-sage .section-title { color: var(--sage); }
.custom-section.accent-rose .section-title { color: var(--rose); }
.custom-section.accent-amber .section-title { color: var(--amber); }

.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}
.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}
.freeform-block {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--line);
  line-height: 1.7;
}
.freeform-block:last-child { border-bottom: none; }

/* —— 纪念日 / 倒计时 —— */
.anniv-list { list-style: none; margin: 0; padding: 0; }
.anniv-item {
  display: flex;
  justify-content: space-between;
  gap: 0.85rem;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--line);
  align-items: flex-start;
}
.anniv-item:last-child { border-bottom: none; }
.anniv-title { margin: 0; font-size: 1.05rem; display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
.anniv-label { margin: 0.35rem 0 0; color: var(--rose); font-size: 0.88rem; }
.anniv-side { display: flex; flex-direction: column; align-items: flex-end; gap: 0.4rem; }
.anniv-badge {
  font-family: var(--mono);
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  background: var(--rose-bg);
  color: var(--rose);
  border: 1px dashed #e0b8ae;
  white-space: nowrap;
}
.anniv-badge.today {
  font-family: var(--serif);
  background: var(--rose);
  color: #fff;
  border-style: solid;
}
.anniv-badge.muted { color: var(--ink-faint); background: var(--page-alt); border-color: var(--line); }

.countdown-modal { width: min(640px, 96vw) !important; }
.countdown-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.55rem;
  margin: 0.75rem 0;
}
.countdown-board {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 280px;
  overflow: auto;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px dashed var(--line);
}
.countdown-card {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 0.75rem;
  align-items: center;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--line);
  background: var(--page);
}
.countdown-card.urgency-today { border-color: #e0b8ae; background: var(--rose-bg); }
.countdown-card.urgency-soon { border-color: #e8d5b4; background: var(--amber-bg); }
.countdown-days {
  font-size: 1.05rem;
  text-align: center;
  color: var(--rose);
}
.countdown-label { margin: 0; font-family: var(--serif); font-size: 0.95rem; }
.countdown-sub { font-size: 1rem; margin: 0.5rem 0 0.35rem; }

/* —— 嘴皮详情 —— */
.quote-card-open { cursor: pointer; }
.quote-card-open:hover { background: #faf7f1; }
.quote-main { min-width: 0; flex: 1; }
.quote-meta { margin: 0.35rem 0 0 0.85rem; }

.mouthpiece-card { width: min(720px, 96vw) !important; }

.chat-thread {
  max-height: 340px;
  overflow: auto;
  padding: 0.85rem 0.7rem;
  margin: 0.4rem 0 0.85rem;
  background:
    linear-gradient(180deg, rgba(255, 252, 245, 0.9), rgba(246, 240, 228, 0.95)),
    repeating-linear-gradient(
      -12deg,
      transparent,
      transparent 10px,
      rgba(180, 150, 100, 0.03) 10px,
      rgba(180, 150, 100, 0.03) 11px
    );
  border: 1px solid var(--line);
}
.chat-empty { margin: 0.4rem 0; text-align: center; }
.chat-row {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  margin: 0.55rem 0;
  max-width: 88%;
}
.chat-row--self {
  align-items: flex-end;
  margin-left: auto;
}
.chat-meta {
  display: flex;
  gap: 0.45rem;
  align-items: baseline;
  margin: 0 0.25rem 0.2rem;
  font-size: 0.72rem;
  color: var(--ink-soft);
}
.chat-row--self .chat-meta { flex-direction: row-reverse; }
.chat-sender { font-weight: 600; color: var(--ink); }
.chat-time { opacity: 0.75; }
.chat-bubble {
  padding: 0.55rem 0.75rem;
  border-radius: 4px 14px 14px 14px;
  background: #fff;
  border: 1px solid #e6dcc8;
  box-shadow: 0 1px 0 rgba(80, 60, 20, 0.04);
  max-width: 100%;
  word-break: break-word;
}
.chat-row--self .chat-bubble {
  border-radius: 14px 4px 14px 14px;
  background: #e8f2ea;
  border-color: #c9dfce;
}
.chat-bubble--hit .chat-bubble,
.chat-row.chat-bubble--hit .chat-bubble {
  outline: 2px solid var(--amber);
  background: var(--amber-bg);
}
.chat-text { margin: 0; white-space: pre-wrap; line-height: 1.45; font-size: 0.92rem; }
.chat-img {
  display: block;
  max-width: min(240px, 70vw);
  max-height: 180px;
  border-radius: 6px;
  object-fit: cover;
}

.mp-attach-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.25rem;
}
.mouthpiece-quote {
  margin: 0.5rem 0 0.35rem;
  padding: 0.9rem 1rem 0.9rem 1.2rem;
  background: var(--amber-bg);
  border: 1px solid #ead9bc;
  font-family: var(--serif);
  font-size: 1.2rem;
  line-height: 1.55;
  position: relative;
}
.mouthpiece-quote::before {
  content: "“";
  font-size: 2.2rem;
  color: var(--amber);
  opacity: 0.5;
  position: absolute;
  left: 0.35rem;
  top: 0.1rem;
}
.mp-label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.82rem;
  color: var(--ink-soft);
  margin: 0.85rem 0 0.4rem;
}
.mp-label textarea {
  border: 1px solid var(--line);
  background: var(--paper);
  padding: 0.5rem 0.6rem;
  outline: none;
  font: inherit;
  color: var(--ink);
  resize: vertical;
}
.mp-label textarea:focus { border-color: var(--sage); }

.mp-upload-zone {
  border: 1px dashed var(--line);
  background: var(--page-alt);
  padding: 1rem;
  text-align: center;
  margin: 0.5rem 0 0.75rem;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.mp-upload-zone.dragover {
  border-color: var(--sage);
  background: var(--sage-bg);
}
.mp-note-inline {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  justify-content: center;
  margin-top: 0.65rem;
  font-size: 0.8rem;
  color: var(--ink-soft);
}
.mp-note-inline input {
  border: 1px solid var(--line);
  background: var(--page);
  padding: 0.3rem 0.45rem;
  min-width: 160px;
}

.mp-attach-list { list-style: none; margin: 0; padding: 0; max-height: 260px; overflow: auto; }
.mp-attach-item {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: 0.65rem;
  align-items: center;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--line);
}
.mp-attach-preview {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  background: var(--page);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
}
.mp-thumb { width: 100%; height: 100%; object-fit: cover; }
.mp-ext { font-size: 0.72rem; color: var(--ink-soft); }
.mp-attach-name { margin: 0; font-size: 0.9rem; word-break: break-all; }

.joke-card {
  border: 1px dashed var(--amber);
  background: linear-gradient(135deg, var(--amber-bg), var(--page));
  padding: 0.85rem 1rem;
  position: relative;
}

.joke-card::after {
  content: "梗";
  position: absolute;
  top: -0.45rem;
  right: 0.7rem;
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  background: var(--amber);
  color: #fff;
  padding: 0.05rem 0.4rem;
}

.joke-title {
  margin: 0;
  font-family: var(--serif);
  font-size: 0.98rem;
}
.joke-story {
  margin: 0.35rem 0 0;
  font-size: 0.86rem;
  color: var(--ink-soft);
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}

.pref-panel {
  background: var(--page-alt);
  border: 1px solid var(--line);
  padding: 0.85rem;
  min-height: 120px;
}

.pref-panel.likes { background: var(--sage-bg); border-color: #d2ddd5; }
.pref-panel.dislikes { background: var(--rose-bg); border-color: #e8d5cf; }

.pref-label {
  font-family: var(--serif);
  font-size: 0.88rem;
  margin: 0 0 0.55rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.pref-label.likes { color: var(--sage); }
.pref-label.dislikes { color: var(--rose); }

.pref-item {
  font-size: 0.88rem;
  padding: 0.25rem 0;
  border-bottom: 1px dotted rgba(0,0,0,0.06);
}

.memo-grid {
  background:
    radial-gradient(circle, #d8d2c8 1px, transparent 1px);
  background-size: 12px 12px;
  background-color: var(--page);
  border: 1px solid var(--line);
  padding: 0.85rem;
  min-height: 80px;
}

.memo-item {
  display: grid;
  grid-template-columns: 110px 1fr auto;
  gap: 0.5rem;
  align-items: baseline;
  padding: 0.35rem 0;
  border-bottom: 1px dotted var(--line);
  font-size: 0.9rem;
}
.memo-label {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--ink-soft);
}

.moment-item {
  display: grid;
  grid-template-columns: 92px 1fr auto;
  gap: 0.85rem;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--line);
}
.moment-item:last-child { border-bottom: none; }
.moment-date {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--ink-soft);
  padding-top: 0.2rem;
}
.moment-title {
  margin: 0;
  font-family: var(--serif);
  font-size: 1rem;
}
.moment-body {
  margin: 0.25rem 0 0;
  font-size: 0.88rem;
  color: var(--ink-soft);
}

.empty-hint {
  margin: 0.35rem 0 0;
  color: var(--ink-faint);
  font-size: 0.88rem;
  font-style: italic;
}

/* —— 按钮 —— */
.btn {
  border: 1px solid var(--line);
  background: var(--page);
  padding: 0.4rem 0.8rem;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.btn:hover { background: var(--page-alt); }
.btn-primary {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}
.btn-primary:hover { background: #3d3a37; }
.btn-ghost {
  background: transparent;
  border-style: dashed;
  font-size: 0.82rem;
  color: var(--ink-soft);
}
.btn-sm { padding: 0.25rem 0.55rem; font-size: 0.8rem; }

/* —— 弹窗 —— */
.modal {
  border: 1px solid var(--line);
  padding: 0;
  background: transparent;
  max-width: calc(100vw - 2rem);
}
.modal::backdrop {
  background: rgba(44, 42, 40, 0.28);
}
.modal-card {
  background: var(--page);
  padding: 1.35rem 1.4rem 1.2rem;
  width: min(440px, 92vw);
  border: 1px solid var(--line);
}
.modal-card.wide { width: min(560px, 94vw); }
.modal-card h2 {
  margin: 0 0 0.85rem;
  font-size: 1.2rem;
}
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.7rem;
}
.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.8rem;
  color: var(--ink-soft);
}
.form-grid label.full { grid-column: 1 / -1; }
.form-grid input,
.form-grid textarea,
.form-grid select {
  border: 1px solid var(--line);
  background: var(--paper);
  padding: 0.45rem 0.55rem;
  outline: none;
}
.form-grid input:focus,
.form-grid textarea:focus { border-color: var(--sage); }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1rem;
}

.reminder-toolbar {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin: 0.75rem 0;
}
.reminder-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 360px;
  overflow: auto;
  border-top: 1px dashed var(--line);
}
.reminder-item {
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
}
.reminder-title { font-family: var(--serif); margin: 0; }
.reminder-meta {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--ink-faint);
  margin-top: 0.2rem;
}
.status-pending { color: var(--amber); }
.status-fired { color: var(--sage); }
.status-cancelled { color: var(--ink-faint); text-decoration: line-through; }

@keyframes fadeRise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes pageTurn {
  from { opacity: 0; transform: translateX(10px); }
  to { opacity: 1; transform: none; }
}

/* —— 登录门廊 —— */
.auth-gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem 1rem;
  background:
    radial-gradient(ellipse at 20% 10%, rgba(94, 128, 106, 0.08), transparent 45%),
    radial-gradient(ellipse at 80% 90%, rgba(196, 109, 94, 0.06), transparent 40%),
    var(--paper);
}
.auth-panel {
  width: min(400px, 100%);
  background: var(--page);
  border: 1px solid var(--line);
  padding: 2rem 1.6rem 1.4rem;
  animation: fadeRise 0.55s ease both;
}
.auth-tabs {
  display: flex;
  gap: 0.5rem;
  margin: 1.25rem 0 1rem;
  border-bottom: 1px dashed var(--line);
  padding-bottom: 0.5rem;
}
.auth-tab {
  background: none;
  border: none;
  font-family: var(--serif);
  color: var(--ink-faint);
  cursor: pointer;
  padding: 0.2rem 0.4rem;
}
.auth-tab.active { color: var(--ink); }
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.auth-form label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.8rem;
  color: var(--ink-soft);
}
.auth-form input {
  border: 1px solid var(--line);
  background: var(--paper);
  padding: 0.5rem 0.6rem;
  outline: none;
}
.auth-form input:focus { border-color: var(--sage); }
.auth-submit { width: 100%; margin-top: 0.35rem; }
.auth-error {
  margin: 0;
  color: var(--rose);
  font-size: 0.85rem;
}
.auth-hint { margin: 1rem 0 0; text-align: center; }

.user-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  padding: 0 1.1rem 0.75rem;
  flex-wrap: wrap;
}
.user-chip {
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
  font-size: 0.85rem;
  min-width: 0;
}
.user-actions {
  display: flex;
  gap: 0.65rem;
  align-items: center;
  font-size: 0.8rem;
}

/* —— 管理后台 —— */
.admin-shell {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
}
.admin-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--line);
}
.admin-title {
  margin: 0.35rem 0 0;
  font-size: 1.6rem;
}
.admin-user {
  text-align: right;
  font-size: 0.9rem;
}
.admin-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--page);
  border: 1px solid var(--line);
  padding: 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.stat-card .mono { font-size: 1.35rem; }
.admin-section { margin-top: 0.5rem; }
.admin-table-wrap { overflow-x: auto; }
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
.admin-table th,
.admin-table td {
  text-align: left;
  padding: 0.55rem 0.45rem;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.admin-table th {
  font-weight: 500;
  color: var(--ink-soft);
  font-size: 0.78rem;
}
.admin-row-actions {
  display: flex;
  gap: 0.3rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* —— 平板横屏：收窄侧栏 —— */
@media (max-width: 1100px) and (min-width: 961px) {
  :root { --sidebar-w: 260px; }
  .canvas { padding: 1.5rem 1.35rem 2.5rem; }
  .scrapbook { max-width: 100%; }
}

/* —— 平板竖屏 / 手机：抽屉导航 —— */
@media (max-width: 960px) {
  .app {
    display: block;
    max-width: none;
    border: none;
    min-height: 100dvh;
    padding-top: calc(3.35rem + env(safe-area-inset-top, 0px));
  }

  .mobile-topbar {
    display: grid;
    grid-template-columns: 2.6rem 1fr auto;
    align-items: center;
    gap: 0.55rem;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 40;
    min-height: 3.35rem;
    padding:
      calc(0.45rem + env(safe-area-inset-top, 0px))
      max(0.75rem, env(safe-area-inset-right, 0px))
      0.45rem
      max(0.65rem, env(safe-area-inset-left, 0px));
    background: rgba(247, 244, 239, 0.94);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
  }

  .mobile-topbar-title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .mobile-topbar-sub {
    margin: 0.05rem 0 0;
    font-size: 0.72rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .mobile-add {
    min-width: 2.2rem;
    min-height: 2.2rem;
    padding: 0;
    font-size: 1.15rem;
    line-height: 1;
  }

  .nav-toggle {
    width: 2.4rem;
    height: 2.4rem;
    border: 1px solid var(--line);
    background: var(--page);
    display: grid;
    place-items: center;
    cursor: pointer;
    padding: 0;
    border-radius: 2px;
  }
  .nav-toggle-bars,
  .nav-toggle-bars::before,
  .nav-toggle-bars::after {
    display: block;
    width: 1rem;
    height: 1.5px;
    background: var(--ink);
    position: relative;
  }
  .nav-toggle-bars::before,
  .nav-toggle-bars::after {
    content: "";
    position: absolute;
    left: 0;
  }
  .nav-toggle-bars::before { top: -5px; }
  .nav-toggle-bars::after { top: 5px; }
  body.nav-open .nav-toggle-bars { background: transparent; }
  body.nav-open .nav-toggle-bars::before {
    top: 0;
    transform: rotate(45deg);
  }
  body.nav-open .nav-toggle-bars::after {
    top: 0;
    transform: rotate(-45deg);
  }

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 45;
    background: rgba(44, 42, 40, 0.34);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease;
  }
  body.nav-open .sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
  }
  .sidebar-backdrop[hidden] { display: none !important; }
  body.nav-open .sidebar-backdrop[hidden] { display: block !important; }

  .sidebar {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(86vw, 320px);
    max-height: none;
    height: 100dvh;
    z-index: 50;
    background: var(--paper);
    border-right: 1px solid var(--line);
    border-bottom: none;
    transform: translateX(-105%);
    transition: transform 0.26s ease;
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    box-shadow: none;
  }
  body.nav-open .sidebar {
    transform: translateX(0);
    box-shadow: 8px 0 28px rgba(44, 42, 40, 0.12);
  }

  .nav-close {
    display: grid;
    place-items: center;
    width: 2.2rem;
    height: 2.2rem;
    border: 1px solid var(--line);
    background: var(--page);
    font-size: 1.35rem;
    line-height: 1;
    cursor: pointer;
    flex-shrink: 0;
  }

  .sidebar-brand { padding: 1.1rem 1rem 0.75rem; }
  .brand-title { font-size: 1.3rem; }
  .friend-list {
    max-height: none;
    flex: 1;
    -webkit-overflow-scrolling: touch;
  }
  .friend-item {
    min-height: 3.1rem;
    padding: 0.55rem 0.65rem;
  }

  .canvas {
    padding:
      1rem
      max(0.9rem, env(safe-area-inset-right, 0px))
      calc(2.2rem + env(safe-area-inset-bottom, 0px))
      max(0.9rem, env(safe-area-inset-left, 0px));
    min-height: calc(100dvh - 3.35rem - env(safe-area-inset-top, 0px));
  }
  .scrapbook {
    max-width: 100%;
    gap: 1.25rem;
  }
  .empty-mobile-hint { display: block; }

  .profile-header {
    grid-template-columns: 56px 1fr;
    gap: 0.75rem;
  }
  .avatar.lg {
    width: 56px;
    height: 56px;
    font-size: 1.45rem;
  }
  .profile-name { font-size: 1.45rem; }
  .profile-actions {
    grid-column: 1 / -1;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    width: 100%;
  }
  .profile-actions .btn { min-height: 2.2rem; }

  .section { padding: 0.95rem 0.9rem 1.05rem; }
  .section-head {
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 0.55rem;
  }
  .section-head .btn,
  .section-head .btn-ghost { min-height: 2.1rem; }

  .two-col { grid-template-columns: 1fr; }
  .bond-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .memo-item { grid-template-columns: 1fr auto; }
  .memo-label { grid-column: 1 / -1; }
  .moment-item { grid-template-columns: 1fr auto; }

  .countdown-summary { grid-template-columns: 1fr; }
  .countdown-modal,
  .mouthpiece-card,
  .modal-card.wide {
    width: min(100vw - 1rem, 96vw) !important;
  }

  .modal {
    width: calc(100vw - 0.75rem);
    max-width: calc(100vw - 0.75rem);
    max-height: calc(100dvh - 1rem);
    margin: auto;
    border: none;
  }
  .modal-card,
  .modal-card.wide,
  .mouthpiece-card,
  .countdown-modal {
    width: 100% !important;
    max-width: 100%;
    max-height: calc(100dvh - 1.25rem);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 1.1rem 1rem 1rem;
  }

  .chat-thread { max-height: min(42dvh, 280px); }
  .mp-attach-list { max-height: 180px; }

  .search-input,
  .form-grid input,
  .form-grid textarea,
  .form-grid select,
  .auth-form input,
  .mp-label textarea,
  .mp-note-inline input {
    font-size: 16px;
  }

  .btn, .linkish, .btn-x, .btn-edit {
    touch-action: manipulation;
  }

  .admin-shell {
    padding:
      1rem
      max(0.85rem, env(safe-area-inset-right, 0px))
      calc(2rem + env(safe-area-inset-bottom, 0px))
      max(0.85rem, env(safe-area-inset-left, 0px));
  }
  .admin-top {
    flex-direction: column;
    align-items: flex-start;
  }
  .admin-user { text-align: left; }
}

/* —— 小屏手机 —— */
@media (max-width: 480px) {
  .profile-name { font-size: 1.28rem; }
  .lead { font-size: 1.15rem; }
  .mp-attach-item {
    grid-template-columns: 48px 1fr;
  }
  .mp-attach-actions {
    grid-column: 1 / -1;
    flex-direction: row;
    justify-content: flex-end;
    width: 100%;
  }
  .role-pair { flex-direction: column; align-items: stretch; }
  .role-arrow {
    transform: rotate(90deg);
    align-self: center;
  }
  .score-row {
    grid-template-columns: 3.8rem 1fr 2.2rem;
  }
  .auth-panel { padding: 1.5rem 1.1rem 1.15rem; }
  .user-bar { padding: 0 0.9rem 0.65rem; }
}
