﻿:root {
  --bg: #fbf7fb;
  --bg-soft: #f3e9f6;
  --surface: #ffffff;
  --line: #ecdfec;
  --text: #2e2a3a;
  --muted: #8b8397;
  --them: #ffffff;
  --me: linear-gradient(180deg, #e8f2ff 0%, #fce8f4 100%);
  --me-text: #2f2b45;
  --accent: #7aa9e8;
  --accent-2: #ea8ab6;
  --accent-deep: #5f7fc0;
  --grad: linear-gradient(135deg, #8fbdf0 0%, #ef9cc3 100%);
  --danger: #d2688a;
  --shadow: 0 1px 1px rgba(90, 70, 110, 0.05), 0 8px 24px rgba(90, 70, 110, 0.07);
  --radius: 18px;
}

[data-theme='dark'] {
  --bg: #16131b;
  --bg-soft: #1f1a26;
  --surface: #221d29;
  --line: #332b3d;
  --text: #efe9f4;
  --muted: #a096ad;
  --them: #241f2c;
  --me: linear-gradient(180deg, #26354d 0%, #3d2a3d 100%);
  --me-text: #eef1fb;
  --accent: #9dbbf0;
  --accent-2: #f0a6c8;
  --accent-deep: #b3c9f2;
  --grad: linear-gradient(135deg, #5f8fd8 0%, #c4719c 100%);
  --danger: #e08aa8;
  --shadow: 0 1px 1px rgba(0, 0, 0, 0.3), 0 10px 30px rgba(0, 0, 0, 0.28);
}

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

html, body {
  margin: 0;
  height: 100%;
  overscroll-behavior: none;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Noto Sans SC', system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ── 头像 ─────────────────────────────── */
.avatar {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-size: 18px;
  font-weight: 600;
  color: #5f7fc0;
  background: linear-gradient(150deg, #e3efff, #fbe3f0);
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.04);
  letter-spacing: 0.5px;
  user-select: none;
  overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
[data-theme='dark'] .avatar {
  background: linear-gradient(150deg, #2b3c58, #3d2a3f);
  color: #c3d6f5;
}
.avatar.big { width: 72px; height: 72px; border-radius: 24px; font-size: 30px; }
.avatar.sm { width: 28px; height: 28px; flex-basis: 28px; border-radius: 10px; font-size: 13px; }

/* ── 头部 ─────────────────────────────── */
.top {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(env(safe-area-inset-top) + 10px) 14px 10px;
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
}
.who { flex: 1; min-width: 0; }
.name { font-weight: 600; font-size: 16px; letter-spacing: 0.2px; }
.status { font-size: 12px; color: var(--muted); margin-top: 1px; }
.status.typing { color: var(--accent-deep); }

.icon-btn {
  width: 36px; height: 36px;
  border: 0; border-radius: 12px;
  background: transparent;
  color: var(--muted);
  font-size: 17px;
  cursor: pointer;
  display: grid; place-items: center;
}
.icon-btn:active { background: var(--bg-soft); }

/* ── 列表 ─────────────────────────────── */
.hintbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  font-size: 12px;
  line-height: 1.4;
  color: var(--muted);
  background: var(--bg-soft);
  border-bottom: 1px solid var(--line);
}
.hintbar span { flex: 1; }
.hintbar button {
  border: 0;
  background: transparent;
  color: var(--accent-deep);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  padding: 4px 2px;
}
.hintbar button.x { color: var(--muted); font-size: 13px; }

.app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  height: 100vh;
}
@supports (height: 100dvh) { .app { height: 100dvh; } }

.list {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 14px 14px 4px;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.day {
  align-self: center;
  margin: 14px 0 10px;
  font-size: 11.5px;
  color: var(--muted);
  background: var(--bg-soft);
  padding: 3px 10px;
  border-radius: 20px;
}

.time-sep {
  align-self: center;
  font-size: 11px;
  color: var(--muted);
  opacity: 0.75;
  margin: 8px 0 4px;
}

.msg {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin: 3px 0;
  animation: pop 0.22s ease-out;
}
.msg.me { flex-direction: row-reverse; }
@keyframes pop {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

.bubble {
  max-width: min(78%, 460px);
  padding: 9px 13px;
  border-radius: var(--radius) var(--radius) var(--radius) 6px;
  background: var(--them);
  box-shadow: var(--shadow);
  font-size: 15.5px;
  line-height: 1.58;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.msg.me .bubble {
  background: var(--me);
  color: var(--me-text);
  border-radius: var(--radius) var(--radius) 6px var(--radius);
  box-shadow: 0 1px 1px rgba(70, 55, 35, 0.04);
}

.bubble.pending { opacity: 0.65; }
.bubble.error { border: 1px solid var(--danger); }

.caret::after {
  content: '';
  display: inline-block;
  width: 2px; height: 1em;
  margin-left: 1px;
  vertical-align: -0.15em;
  background: currentColor;
  opacity: 0.5;
  animation: blink 1s steps(2, start) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* ── 菜谱卡 ───────────────────────────── */
.opts {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 7px 0 2px 36px;
  max-width: min(84%, 480px);
  animation: pop 0.26s ease-out;
}
.opt {
  display: flex;
  align-items: baseline;
  gap: 8px;
  text-align: left;
  width: 100%;
  padding: 9px 12px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease;
}
.opt:active { transform: scale(0.985); background: var(--bg-soft); }
.opt .tag {
  flex: 0 0 auto;
  width: 18px; height: 18px;
  border-radius: 6px;
  font-size: 11px;
  display: grid; place-items: center;
  background: #e8f1fe;
  color: #5f7fc0;
  font-weight: 700;
  transform: translateY(-1px);
}
[data-theme='dark'] .opt .tag { background: #2c3d59; color: #c3d6f5; }
.opt .nm { font-weight: 500; }
.opt .note { margin-left: auto; font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.opt.reroll {
  justify-content: center;
  color: var(--muted);
  font-size: 13px;
  border-style: dashed;
  background: transparent;
}

/* ── 输入中 ───────────────────────────── */
.typing {
  display: flex;
  gap: 4px;
  padding: 2px 0 6px 50px;
}
.typing i {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--muted);
  opacity: 0.45;
  animation: bounce 1.15s infinite;
}
.typing i:nth-child(2) { animation-delay: 0.16s; }
.typing i:nth-child(3) { animation-delay: 0.32s; }
@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-5px); opacity: 0.85; }
}

/* ── 输入区 ───────────────────────────── */
.composer {
  padding: 6px 10px calc(env(safe-area-inset-bottom) + 8px);
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}

.chips {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding: 2px 2px 8px;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 20px;
  cursor: pointer;
  white-space: nowrap;
}
.chip:active { background: var(--bg-soft); }

.inputbar {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}
#input {
  flex: 1;
  resize: none;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: 22px;
  padding: 10px 15px;
  font-size: 16px; /* 防止 iOS 聚焦缩放 */
  line-height: 1.45;
  font-family: inherit;
  max-height: 120px;
  min-height: 44px;
  outline: none;
  transition: border-color 0.15s ease;
}
#input:focus { border-color: var(--accent); }
#input::placeholder { color: var(--muted); opacity: 0.8; }

.send {
  flex: 0 0 44px;
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 0;
  background: var(--grad);
  color: #fff;
  display: grid; place-items: center;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(122, 169, 232, 0.35);
  transition: transform 0.12s ease, opacity 0.15s ease, background 0.15s ease;
}
.send:active { transform: scale(0.94); }
.send:disabled { opacity: 0.35; }
[data-theme='dark'] .send { color: #17131f; box-shadow: 0 4px 16px rgba(95, 143, 216, 0.3); }

/* ── 登录 ─────────────────────────────── */
.login {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(120% 90% at 50% 0%, var(--bg-soft), var(--bg) 60%);
}
.login-card {
  width: 100%;
  max-width: 320px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  animation: pop 0.4s ease-out;
}
.login-card .avatar { margin-bottom: 6px; }
.login h1 { font-size: 22px; margin: 0; letter-spacing: 1px; font-weight: 600; }
.login-sub { margin: 0 0 12px; color: var(--muted); font-size: 13px; }
.pin {
  width: 100%;
  text-align: center;
  letter-spacing: 12px;
  font-size: 24px;
  padding: 12px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  outline: none;
}
.pin:focus { border-color: var(--accent); }
.err { color: var(--danger); font-size: 13px; min-height: 18px; margin: 2px 0 0; }
.shake { animation: shake 0.4s; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-7px); }
  75% { transform: translateX(7px); }
}

/* ── 按钮 ─────────────────────────────── */
.primary {
  width: 100%;
  padding: 12px;
  border-radius: 14px;
  border: 0;
  background: var(--grad);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.primary:active { opacity: 0.9; }
[data-theme='dark'] .primary { color: #fff; }
.ghost {
  width: 100%;
  padding: 11px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
}
.ghost:active { background: var(--bg-soft); }

/* ── 设置页 ───────────────────────────── */
.sheet-wrap { position: fixed; inset: 0; z-index: 30; }
.sheet-mask {
  position: absolute; inset: 0;
  background: rgba(30, 22, 12, 0.35);
  backdrop-filter: blur(2px);
  animation: fade 0.2s ease-out;
}
@keyframes fade { from { opacity: 0; } }

.sheet {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  max-height: 90dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--bg);
  border-radius: 24px 24px 0 0;
  padding: 8px 18px calc(env(safe-area-inset-bottom) + 24px);
  box-shadow: 0 -10px 40px rgba(40, 28, 15, 0.18);
  animation: slideup 0.28s cubic-bezier(0.2, 0.9, 0.25, 1);
}
@keyframes slideup { from { transform: translateY(100%); } }
.handle {
  width: 38px; height: 4px;
  border-radius: 3px;
  background: var(--line);
  margin: 6px auto 12px;
}
.sheet h2 { font-size: 17px; margin: 0 0 6px; font-weight: 600; }

.group { margin-top: 18px; }
.group-title {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.6px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.badge {
  font-size: 10.5px;
  padding: 2px 7px;
  border-radius: 10px;
  background: var(--bg-soft);
  color: var(--muted);
  letter-spacing: 0;
}
.badge.on { background: #e8f1fe; color: #5f7fc0; }
[data-theme='dark'] .badge.on { background: #2c3d59; color: #c3d6f5; }

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14.5px;
}
.row:last-child { border-bottom: 0; }
.row > span { flex: 0 0 84px; color: var(--muted); font-size: 13.5px; }
.row input[type='text'], .row input:not([type]) {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  outline: none;
  text-align: right;
  min-width: 0;
}
.row input[type='password'] {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  outline: none;
  text-align: right;
  min-width: 0;
}
.row input::placeholder { color: var(--muted); opacity: 0.6; }
.row.switch { justify-content: space-between; }
.row.switch > span { flex: 1; color: var(--text); font-size: 14.5px; }
.row input[type='checkbox'] {
  appearance: none;
  width: 46px; height: 28px;
  border-radius: 20px;
  background: var(--line);
  position: relative;
  transition: background 0.2s ease;
  cursor: pointer;
  flex: 0 0 46px;
}
.row input[type='checkbox']::after {
  content: '';
  position: absolute;
  top: 3px; left: 3px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s cubic-bezier(0.3, 1.2, 0.5, 1);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}
.row input[type='checkbox']:checked { background: var(--accent); }
.row input[type='checkbox']:checked::after { transform: translateX(18px); }

.seg {
  display: flex;
  gap: 4px;
  background: var(--bg-soft);
  padding: 3px;
  border-radius: 12px;
}
.seg button {
  flex: 1;
  padding: 8px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 13.5px;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.seg button.on {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(60, 45, 25, 0.1);
  font-weight: 500;
}

.hint { font-size: 12.5px; color: var(--muted); line-height: 1.6; margin: 6px 0 4px; }
.linkbtn {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 8px;
  border: 0;
  background: transparent;
  color: var(--danger);
  font-size: 12.5px;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
}.actions { display: flex; gap: 10px; margin-top: 22px; }
.actions .ghost { flex: 0 0 96px; }

/* ── toast ────────────────────────────── */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 90px);
  transform: translate(-50%, 10px);
  background: rgba(35, 28, 20, 0.92);
  color: #fff;
  font-size: 13.5px;
  padding: 9px 16px;
  border-radius: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
  z-index: 60;
  max-width: 84vw;
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* 桌面端：居中成一个小窗 */
@media (min-width: 720px) {
  body { background: var(--bg-soft); }
  .app, .login { max-width: 460px; margin: 0 auto; box-shadow: 0 0 0 1px var(--line); }
  .app { height: 100dvh; }
}

/* ── 空白开场 ─────────────────────────── */
.empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 48px 30px 72px;
  gap: 4px;
  animation: pop 0.5s ease-out;
}
.empty-avatar {
  width: 66px;
  height: 66px;
  border-radius: 22px;
  display: grid;
  place-items: center;
  font-size: 26px;
  color: var(--muted);
  border: 1.5px dashed var(--line);
  margin-bottom: 14px;
}
.empty-title { margin: 0; font-size: 15px; font-weight: 500; color: var(--text); }
.empty-sub { margin: 6px 0 0; font-size: 13px; line-height: 1.9; color: var(--muted); }

/* ── 她的样子 ─────────────────────────── */
.selfbox { display: flex; flex-direction: column; gap: 11px; margin: 2px 0 6px; }
.selfrow { display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline; }
.selfrow em {
  font-style: normal;
  font-size: 12px;
  color: var(--muted);
  flex: 0 0 58px;
}
.tagitem {
  font-size: 12.5px;
  padding: 4px 10px;
  border-radius: 10px;
  background: var(--bg-soft);
  color: var(--text);
  line-height: 1.5;
}

.hint a { color: var(--accent-deep); text-decoration: none; border-bottom: 1px solid color-mix(in srgb, var(--accent) 45%, transparent); }
.hint code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--bg-soft);
  color: var(--text);
}

/* ── 头像设置 ─────────────────────────── */
.avrow { display: flex; align-items: center; gap: 14px; margin: 6px 0 10px; }
.avrow .avatar.big { flex: 0 0 72px; }
.avbtns { display: flex; flex-direction: column; gap: 8px; flex: 1; }
.avbtns .ghost { padding: 9px; font-size: 13px; border-radius: 12px; }
.emojis { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 2px; }
.emoji {
  width: 38px; height: 38px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 19px;
  line-height: 1;
  display: grid; place-items: center;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease;
}
.emoji:active { transform: scale(0.92); background: var(--bg-soft); }

/* ── 文档导入 ─────────────────────────── */
.importbox {
  width: 100%;
  resize: vertical;
  min-height: 96px;
  max-height: 220px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: 14px;
  padding: 11px 13px;
  font-size: 16px;
  line-height: 1.55;
  font-family: inherit;
  outline: none;
}
.importbox:focus { border-color: var(--accent); }
.importbox::placeholder { color: var(--muted); opacity: 0.7; }

.tagitem.core {
  background: linear-gradient(135deg, #e8f1ff, #fbe7f3);
  border: 1px solid var(--line);
}
[data-theme='dark'] .tagitem.core { background: linear-gradient(135deg, #2b3c58, #3d2a3f); }

/* ── 记事本 ───────────────────────────── */
.icon-btn { position: relative; }
.dot {
  position: absolute;
  top: 4px; right: 4px;
  min-width: 15px; height: 15px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--accent-2);
  color: #fff;
  font-size: 10px;
  line-height: 15px;
  text-align: center;
  font-weight: 600;
}
.noterow { display: flex; gap: 8px; margin: 8px 0 12px; }
.noteinput {
  flex: 1;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: 14px;
  padding: 10px 13px;
  font-size: 16px;
  font-family: inherit;
  outline: none;
  min-width: 0;
}
.noteinput:focus { border-color: var(--accent); }
.notelist { display: flex; flex-direction: column; gap: 2px; }
.noteitem {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 4px;
  border-bottom: 1px solid var(--line);
}
.noteitem:last-child { border-bottom: 0; }
.notecheck {
  width: 22px; height: 22px;
  flex: 0 0 22px;
  border-radius: 7px;
  border: 1.5px solid var(--line);
  background: transparent;
  cursor: pointer;
  display: grid; place-items: center;
  font-size: 13px;
  color: transparent;
  padding: 0;
}
.notecheck.on {
  background: var(--grad);
  border-color: transparent;
  color: #fff;
}
.notetext { flex: 1; font-size: 14.5px; line-height: 1.5; word-break: break-word; }
.noteitem.done .notetext { text-decoration: line-through; color: var(--muted); }
.notetime { font-size: 11.5px; color: var(--accent-deep); white-space: nowrap; }
.notedel {
  border: 0; background: transparent; color: var(--muted);
  font-size: 15px; cursor: pointer; padding: 4px;
}
.notes-empty { text-align: center; color: var(--muted); font-size: 13px; padding: 22px 0; }
