/* ==========================================================================
   叮咚关系台 · Kinship Mobile Rhythm · 设计系统
   移动端（390–430px）基础层：令牌 / 排版 / 布局 / 通用组件
   ========================================================================== */

@font-face {
  font-family: 'Plus Jakarta Sans';
  src: url('../fonts/plus-jakarta-sans.woff2') format('woff2');
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}

:root {
  /* 品牌色 */
  --rose-solid: #d4536f;
  --rose-deep: #b23c57;
  --rose-ink: #a12f49;
  --rose-soft: #fdeef2;
  --rose-wash: #fff8fa;

  /* 画布与面板 */
  --surface: #f9f9ff;
  --surface-container: #ecedf7;
  --surface-container-high: #e6e8f2;
  --surface-variant: #e0e2ec;
  --panel: #ffffff;
  --panel-raised: #fbfbfd;
  --panel-sunken: #fafbfc;
  --line: #e7e9ef;
  --line-soft: #dfe3ea;

  /* 文字 */
  --ink: #171a21;
  --ink-secondary: #4a5361;
  --ink-muted: #838c9b;

  /* 深色锚点 */
  --bar-bg: #171a21;
  --preview-bg: #0b0d12;

  /* 七阶段色谱 */
  --stage-acquaintance: #8b95a5;
  --stage-acquaintance-soft: #eef1f5;
  --stage-chatting: #3b7ddd;
  --stage-chatting-soft: #e9f1fd;
  --stage-met: #0e9f9a;
  --stage-met-soft: #e3f6f4;
  --stage-progressing: #d4536f;
  --stage-progressing-soft: #fdeef2;
  --stage-stable: #16a34a;
  --stage-stable-soft: #e8f6ec;
  --stage-cooling: #d97706;
  --stage-cooling-soft: #fdf1e0;
  --stage-ended: #64748b;
  --stage-ended-soft: #eef1f5;

  /* 阴影层级 */
  --sh-1: 0 1px 3px rgba(23, 26, 33, .03), 0 4px 12px -2px rgba(23, 26, 33, .02);
  --sh-2: 0 8px 24px -4px rgba(212, 83, 111, .08), 0 2px 6px rgba(23, 26, 33, .03);
  --sh-3: 0 12px 32px -4px rgba(11, 13, 18, .35);

  /* 栅格 */
  --margin: 16px;
  --gutter: 12px;
  --radius: 16px;
  --radius-lg: 22px;
  --head-h: 56px;
  --tabbar-h: 60px;
  /* 桌面预览时把 430px 手机栏居中，配合各固定层的 left/right 使用 */
  --edge: max(0px, calc(50% - 215px));

  --font: 'Plus Jakarta Sans', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

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

html {
  width: 100%;
  margin: 0;
  padding: 0;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  padding: 0;
  width: 100%;
  min-height: 100dvh;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 20px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overscroll-behavior-y: none;
}

h1, h2, h3, h4, p, figure { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; font-size: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }
::-webkit-scrollbar { width: 0; height: 0; }

/* ---------- 排版 ---------- */
.t-xl { font-size: 26px; line-height: 34px; font-weight: 700; letter-spacing: -.015em; }
.t-lg { font-size: 20px; line-height: 28px; font-weight: 600; letter-spacing: -.01em; }
.t-md { font-size: 17px; line-height: 24px; font-weight: 600; letter-spacing: -.01em; }
.t-body { font-size: 14px; line-height: 20px; }
.t-sm { font-size: 12px; line-height: 18px; }
.t-label { font-size: 13px; line-height: 18px; font-weight: 600; letter-spacing: .01em; }
.t-label-sm { font-size: 11px; line-height: 15px; font-weight: 600; letter-spacing: .02em; }
.t-cap { font-size: 10px; line-height: 14px; font-weight: 500; letter-spacing: .02em; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-muted); }
.dim { color: var(--ink-secondary); }
.rose { color: var(--rose-solid); }
.bold { font-weight: 700; }
.semibold { font-weight: 600; }

/* ---------- 图标 ---------- */
.ic {
  width: 20px; height: 20px; flex: none;
  display: inline-block; vertical-align: -.19em;
  overflow: visible;
}
.ic-13 { width: 13px; height: 13px; }
.ic-14 { width: 14px; height: 14px; }
.ic-16 { width: 16px; height: 16px; }
.ic-18 { width: 18px; height: 18px; }
.ic-22 { width: 22px; height: 22px; }
.ic-24 { width: 24px; height: 24px; }
.ic-26 { width: 26px; height: 26px; }
.ic-28 { width: 28px; height: 28px; }

/* ---------- 布局外壳 ---------- */
.app-header {
  position: fixed; top: 0; left: var(--edge); right: var(--edge); z-index: 40;
  background: rgba(249, 249, 255, .94);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  padding-top: env(safe-area-inset-top, 0px);
}
.app-header::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: -1px; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(23, 26, 33, .06), transparent);
  opacity: 0; transition: opacity .2s;
}
.app-header.is-stuck::after { opacity: 1; }
.hd {
  height: var(--head-h); padding: 0 var(--margin);
  display: flex; align-items: center; justify-content: space-between;
}
.hd-title { display: flex; align-items: center; gap: 8px; font-size: 17px; font-weight: 700; letter-spacing: -.01em; }
.hd-dot { width: 10px; height: 10px; border-radius: 99px; background: var(--rose-solid); box-shadow: 0 0 8px rgba(212, 83, 111, .6); }
.hd-act { display: flex; align-items: center; gap: 2px; }
.hd-btn {
  width: 44px; height: 44px; display: grid; place-items: center;
  border-radius: 999px; color: var(--ink-secondary); position: relative;
  transition: color .18s, background .18s;
}
.hd-btn:active { background: rgba(23, 26, 33, .05); color: var(--ink); }
.hd-btn .badge { position: absolute; top: 9px; right: 9px; width: 7px; height: 7px; border-radius: 99px; background: var(--rose-solid); box-shadow: 0 0 0 2px var(--surface); }
.hd-av {
  width: 32px; height: 32px; border-radius: 999px; background: var(--rose-solid);
  color: #fff; display: grid; place-items: center; flex: none;
}

.view {
  padding: calc(env(safe-area-inset-top, 0px) + var(--head-h) + 6px) var(--margin)
           calc(var(--tabbar-h) + 46px + env(safe-area-inset-bottom, 0px));
  min-height: 100dvh;
}
.view.no-tab {
  padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
}

.stack { display: flex; flex-direction: column; gap: var(--gutter); }
.stack-8 { display: flex; flex-direction: column; gap: 8px; }
.stack-10 { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; align-items: center; }
.between { display: flex; align-items: center; justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.gap-4 { gap: 4px; } .gap-6 { gap: 6px; } .gap-8 { gap: 8px; } .gap-10 { gap: 10px; } .gap-12 { gap: 12px; }

/* ---------- 底部导航 ---------- */
.tabbar {
  position: fixed; left: calc(var(--edge) + var(--margin)); right: calc(var(--edge) + var(--margin));
  bottom: calc(12px + env(safe-area-inset-bottom, 0px)); z-index: 60;
  height: var(--tabbar-h); padding: 0 6px;
  background: var(--bar-bg); border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, .12);
  box-shadow: var(--sh-3);
  display: flex; align-items: center; justify-content: space-around;
}
.tab {
  position: relative; width: 56px; height: 44px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--ink-muted); transition: color .18s;
}
.tab .t { font-size: 10px; line-height: 13px; margin-top: 2px; letter-spacing: .01em; font-weight: 500; }
.tab.on { color: var(--rose-solid); }
.tab.on .t { font-weight: 600; }
.tab .dot { position: absolute; top: 3px; right: 9px; width: 8px; height: 8px; border-radius: 99px; background: var(--rose-solid); box-shadow: 0 0 0 2px var(--bar-bg); }
.tab:active { transform: scale(.94); }

/* ---------- 卡片 ---------- */
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--sh-1); padding: 14px;
}
.card.flat { box-shadow: none; }
.card.sunken { background: var(--panel-sunken); box-shadow: none; }
.card.lg { border-radius: var(--radius-lg); }
.sect-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 2px 0; }
.sect-head .h { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; color: var(--ink); }

/* ---------- 徽标 / 阶段 ---------- */
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  height: 20px; padding: 0 7px; border-radius: 999px;
  font-size: 11px; line-height: 1; font-weight: 600; white-space: nowrap;
}
.tag.rose { background: var(--rose-soft); color: var(--rose-ink); }
.tag.ink { background: var(--surface-container); color: var(--ink-secondary); }
.tag.warn { background: var(--stage-cooling-soft); color: var(--stage-cooling); }
.tag.ok { background: var(--stage-stable-soft); color: var(--stage-stable); }
.tag.info { background: var(--stage-chatting-soft); color: var(--stage-chatting); }
.tag.line { background: transparent; border: 1px solid var(--line-soft); color: var(--ink-secondary); font-weight: 500; }

.stage {
  display: inline-flex; align-items: center; gap: 4px;
  height: 20px; padding: 0 8px; border-radius: 999px;
  font-size: 11px; font-weight: 600; line-height: 1;
  background: var(--stage-acquaintance-soft); color: var(--stage-acquaintance);
}
.stage[data-stage="acquaintance"] { background: var(--stage-acquaintance-soft); color: var(--stage-acquaintance); }
.stage[data-stage="chatting"] { background: var(--stage-chatting-soft); color: var(--stage-chatting); }
.stage[data-stage="met"] { background: var(--stage-met-soft); color: var(--stage-met); }
.stage[data-stage="progressing"] { background: var(--stage-progressing-soft); color: var(--stage-progressing); }
.stage[data-stage="stable"] { background: var(--stage-stable-soft); color: var(--stage-stable); }
.stage[data-stage="cooling"] { background: var(--stage-cooling-soft); color: var(--stage-cooling); }
.stage[data-stage="ended"] { background: var(--stage-ended-soft); color: var(--stage-ended); }
.stage .pulse { width: 6px; height: 6px; border-radius: 99px; background: currentColor; animation: pulse 1.8s ease-in-out infinite; }

@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .35; transform: scale(.72); } }
@keyframes ping { 0% { transform: scale(1); opacity: .9; } 70%, 100% { transform: scale(2.4); opacity: 0; } }

/* ---------- 进度条 ---------- */
.meter { height: 4px; border-radius: 99px; background: var(--surface-container); overflow: hidden; }
.meter > i { display: block; height: 100%; border-radius: 99px; background: var(--rose-solid); }
.meter.thin { height: 3px; }

/* ---------- 分段控件 ---------- */
.seg {
  display: flex; align-items: center; gap: 2px; padding: 3px;
  background: var(--surface-container); border-radius: 999px;
}
.seg button {
  flex: 1; height: 34px; border-radius: 999px; font-size: 12px; font-weight: 600;
  color: var(--ink-secondary); display: flex; align-items: center; justify-content: center; gap: 5px;
  transition: background .2s, color .2s, box-shadow .2s;
}
.seg button.on { background: var(--panel); color: var(--ink); box-shadow: 0 1px 3px rgba(23, 26, 33, .08); }
.seg .n { font-size: 10px; font-weight: 600; color: var(--ink-muted); }
.seg button.on .n { color: var(--rose-solid); }
.seg.dark { background: rgba(255, 255, 255, .08); }
.seg.dark button { color: rgba(255, 255, 255, .6); }
.seg.dark button.on { background: var(--rose-solid); color: #fff; box-shadow: 0 2px 10px rgba(212, 83, 111, .4); }
.seg.dark button.on .n { color: #fff; }

/* ---------- 横向药丸轨 ---------- */
.pills { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 4px; scroll-snap-type: x proximity; }
.pills::-webkit-scrollbar { display: none; }
.pill {
  flex: none; height: 32px; padding: 0 12px; border-radius: 999px;
  display: inline-flex; align-items: center; gap: 5px; white-space: nowrap;
  background: var(--panel); color: var(--ink-secondary);
  font-size: 11px; font-weight: 600; box-shadow: 0 1px 2px rgba(23, 26, 33, .04);
  border: 1px solid transparent; transition: transform .15s, background .2s, color .2s;
  scroll-snap-align: start;
}
.pill:active { transform: scale(.96); }
.pill.on { background: var(--ink); color: #fff; box-shadow: 0 2px 8px rgba(23, 26, 33, .22); }
.pill.rose { background: var(--rose-solid); color: #fff; box-shadow: 0 2px 8px -2px rgba(212, 83, 111, .5); }
.pill.rose .pill-n { background: rgba(255, 255, 255, .22); color: #fff; }
.pill.on .pill-n { background: rgba(255, 255, 255, .2); color: #fff; }
.pill.warn { background: var(--stage-cooling-soft); color: var(--stage-cooling); }
.pill .pill-n { font-size: 10px; padding: 1px 5px; border-radius: 999px; background: var(--surface-container); color: var(--ink-muted); }
.pill .pip { width: 6px; height: 6px; border-radius: 99px; background: var(--rose-solid); }

/* ---------- 头像 ---------- */
.av {
  position: relative; flex: none; border-radius: 14px;
  background: var(--surface-container);
}
.av img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }
/* 真实模式下没有头像图：首字母块 */
.av.letter {
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(140deg, #fbe4ea, #f3e7f7);
  color: var(--rose-deep); font-weight: 700; font-size: 17px;
  letter-spacing: .5px; user-select: none;
}
.av.letter b { font: inherit; }
.av.sq12 { width: 48px; height: 48px; border-radius: 14px; }
.av.sq10 { width: 40px; height: 40px; border-radius: 12px; }
.av.circle { border-radius: 999px; }
.av .st {
  position: absolute; right: -1px; bottom: -1px; width: 12px; height: 12px;
  border-radius: 99px; background: var(--stage-stable); box-shadow: 0 0 0 2px var(--panel);
}

/* ---------- 按钮 ---------- */
.btn {
  height: 48px; padding: 0 20px; border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-size: 15px; font-weight: 600; letter-spacing: .01em;
  background: var(--rose-solid); color: #fff;
  transition: transform .16s, background .16s, box-shadow .16s;
  box-shadow: 0 6px 16px -6px rgba(212, 83, 111, .55);
}
.btn:active { background: var(--rose-deep); transform: scale(.985); }
.btn.block { display: flex; width: 100%; }
.btn.ghost { background: var(--panel); color: var(--ink); box-shadow: var(--sh-1); font-size: 13px; }
.btn.ghost:active { background: var(--panel-sunken); }
.btn.subtle { background: var(--surface-container); color: var(--ink); box-shadow: none; font-size: 13px; }
.btn.sm { height: 32px; padding: 0 12px; font-size: 12px; font-weight: 600; gap: 4px; box-shadow: none; }
.btn.xs { height: 28px; padding: 0 11px; font-size: 11px; font-weight: 600; gap: 4px; box-shadow: none; }
.btn.warn { background: var(--stage-cooling); box-shadow: 0 6px 16px -6px rgba(217, 119, 6, .5); }
.btn[disabled] { opacity: .55; pointer-events: none; }

/* ---------- 输入 ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: 12px; font-weight: 600; color: var(--ink-secondary); display: flex; justify-content: space-between; }
.field > label .req { color: var(--rose-solid); font-weight: 500; }
.input-wrap { position: relative; display: flex; align-items: center; }
.input {
  width: 100%; height: 46px; padding: 0 14px; border-radius: 12px;
  background: var(--surface-container); border: 1px solid transparent;
  font-size: 14px; color: var(--ink); outline: none;
  transition: background .2s, border-color .2s, box-shadow .2s;
}
.input::placeholder { color: var(--ink-muted); }
.input:focus { background: var(--panel); border-color: var(--rose-solid); box-shadow: 0 0 0 3px rgba(212, 83, 111, .1); }
.input.icon-l { padding-left: 40px; }
.input.icon-r { padding-right: 44px; }
.input-wrap > .lead { position: absolute; left: 13px; color: var(--ink-muted); pointer-events: none; }
.input-wrap > .tail { position: absolute; right: 8px; color: var(--ink-muted); }
textarea.input { height: auto; padding: 12px 14px; line-height: 21px; resize: none; }

/* ---------- 遮罩与抽屉 ---------- */
.mask {
  position: fixed; top: 0; bottom: 0; left: var(--edge); right: var(--edge); z-index: 80;
  background: rgba(11, 13, 18, .55);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  animation: fade .22s ease both;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.985); } to { opacity: 1; transform: none; } }

.sheet {
  position: fixed; left: var(--edge); right: var(--edge); bottom: 0; z-index: 90;
  max-height: 92dvh; display: flex; flex-direction: column;
  background: var(--preview-bg); color: #fff;
  border-radius: 26px 26px 0 0;
  box-shadow: 0 -18px 48px rgba(0, 0, 0, .45);
  animation: rise .3s cubic-bezier(.22, 1, .36, 1) both;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.sheet-grab { width: 40px; height: 4px; border-radius: 99px; background: rgba(255, 255, 255, .22); margin: 8px auto 2px; flex: none; }

/* ---------- 浮起操作钮 ---------- */
.fab {
  position: fixed; right: calc(var(--edge) + 16px); bottom: calc(var(--tabbar-h) + 30px + env(safe-area-inset-bottom, 0px));
  z-index: 55; width: 56px; height: 56px; border-radius: 999px;
  background: var(--rose-solid); color: #fff; display: grid; place-items: center;
  box-shadow: 0 8px 20px rgba(212, 83, 111, .36);
  transition: transform .18s;
}
.fab:active { transform: scale(.94); }
.fab.ink { background: var(--ink); box-shadow: 0 8px 20px rgba(23, 26, 33, .3); }

/* ---------- 空态 ---------- */
.empty { padding: 48px 20px; text-align: center; color: var(--ink-muted); }
.empty .ic { color: var(--line-soft); margin-bottom: 10px; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 46px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%) translateY(8px); z-index: 120;
  background: rgba(23, 26, 33, .94); color: #fff;
  padding: 9px 16px; border-radius: 999px; font-size: 12px; font-weight: 500;
  box-shadow: 0 10px 24px rgba(0, 0, 0, .25); opacity: 0; pointer-events: none;
  transition: opacity .22s, transform .22s; white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- 启动骨架屏 ---------- */
.boot {
  min-height: 78vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 18px;
}
.boot-logo { position: relative; width: 46px; height: 46px; }
.boot-logo i {
  position: absolute; width: 22px; height: 22px; border-radius: 50%;
  opacity: .9; animation: bootPulse 1.4s ease-in-out infinite;
}
.boot-logo .b1 { left: 0; top: 0; background: var(--rose-solid); }
.boot-logo .b2 { right: 0; top: 6px; background: #3b7ddd; animation-delay: .16s; }
.boot-logo .b3 { left: 12px; bottom: 0; background: #0e9f9a; animation-delay: .32s; }
@keyframes bootPulse {
  0%, 100% { transform: scale(.82); opacity: .45; }
  50% { transform: scale(1); opacity: 1; }
}
.boot-t { font-size: 13px; color: var(--on-surface-variant); letter-spacing: .2px; }
.boot-bar {
  width: 132px; height: 3px; border-radius: 99px; overflow: hidden;
  background: var(--surface-container-high);
}
.boot-bar i {
  display: block; width: 40%; height: 100%; border-radius: 99px;
  background: linear-gradient(90deg, var(--rose-solid), #f0a0b4);
  animation: bootSlide 1.1s ease-in-out infinite;
}
@keyframes bootSlide {
  0% { transform: translateX(-110%); }
  100% { transform: translateX(320%); }
}

/* ---------- 空状态 ---------- */
.empty {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  gap: 10px; padding: 52px 24px; color: var(--on-surface-variant);
}
.empty .ic { width: 38px; height: 38px; opacity: .32; margin-bottom: 2px; }
.empty b { font-size: 14px; color: var(--on-surface); font-weight: 600; }
.empty p { font-size: 12px; line-height: 1.7; margin: 0; max-width: 250px; }
.empty .btn { margin-top: 6px; }

/* ---------- 骨架/动效 ---------- */
.stagger > * { animation: pop .38s cubic-bezier(.22, 1, .36, 1) both; }
.stagger > *:nth-child(2) { animation-delay: .04s; }
.stagger > *:nth-child(3) { animation-delay: .08s; }
.stagger > *:nth-child(4) { animation-delay: .12s; }
.stagger > *:nth-child(5) { animation-delay: .16s; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* 桌面/平板预览：以 430px 手机栏居中呈现 */
@media (min-width: 431px) {
  html { background: #e8eaf1; }
  body {
    max-width: 430px; margin: 0 auto;
    box-shadow: 0 0 0 1px rgba(23, 26, 33, .05), 0 20px 60px rgba(23, 26, 33, .16);
  }
}
