/* ============================================================
   笙魚片 · design tokens & primitives
   ============================================================ */

:root {
  --paper: #fbf6ef;
  --paper-2: #f6ede1;
  --paper-3: #f1e4d5;
  --ink: #2b2723;
  --ink-2: #5c534b;
  --ink-3: #8c8078;
  --ink-4: #b3a79d;
  --line: rgba(43, 39, 35, 0.1);
  --line-strong: rgba(43, 39, 35, 0.18);
  --rose: #d96a7a;
  --rose-deep: #b84a5d;
  --rose-soft: #f7dee1;
  --rose-wash: #fdf1f1;
  --apricot: #e9a178;
  --apricot-soft: #fbe8da;
  --sage: #82927a;
  --sage-soft: #e9efe4;
  --plum: #4a3b52;
  --gold: #b98f52;
  --gold-soft: #f6ecd8;
  --alipay: #1677ff;

  --serif: "Songti SC", "Noto Serif SC", "Source Han Serif SC", "STSong", "SimSun", serif;
  --sans: "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "SF Mono", "JetBrains Mono", Consolas, monospace;

  --r-xl: 28px;
  --r-lg: 22px;
  --r-md: 16px;
  --r-sm: 11px;
  --r-pill: 999px;

  --sh-sm: 0 1px 2px rgba(43, 39, 35, 0.05), 0 2px 6px rgba(43, 39, 35, 0.04);
  --sh-md: 0 2px 4px rgba(43, 39, 35, 0.04), 0 14px 32px -20px rgba(43, 39, 35, 0.4);
  --sh-lg: 0 30px 70px -34px rgba(43, 39, 35, 0.45);
  --sh-pop: 0 18px 50px -16px rgba(43, 39, 35, 0.3);

  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --speed: 260ms;

  --max: 1180px;
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='0.045'/%3E%3C/svg%3E");
}

*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image: var(--grain);
}

#app { position: relative; z-index: 1; }

h1, h2, h3, h4 { font-family: var(--serif); font-weight: 600; letter-spacing: 0.01em; line-height: 1.25; margin: 0; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
ul, ol { margin: 0; padding: 0; list-style: none; }
hr { border: 0; border-top: 1px dashed var(--line-strong); margin: 20px 0; }

::selection { background: var(--rose-soft); color: var(--rose-deep); }

:focus-visible {
  outline: 2px solid var(--rose);
  outline-offset: 3px;
  border-radius: 6px;
}

.skip-link {
  position: absolute; left: -999px; top: 10px; z-index: 200;
  background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: var(--r-pill);
}
.skip-link:focus { left: 16px; }

/* ---------- type ---------- */
.eyebrow {
  font-family: var(--sans);
  font-size: 11.5px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.serif { font-family: var(--serif); }
.num { font-family: var(--serif); font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-3); }
.tiny { font-size: 12px; line-height: 1.55; }
.small { font-size: 13px; }
.strong { font-weight: 600; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }

/* ---------- layout ---------- */
.container { width: 100%; max-width: var(--max); margin: 0 auto; padding: 0 24px; }
.row { display: flex; align-items: center; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.stack { display: flex; flex-direction: column; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.hide { display: none !important; }

/* ---------- buttons ---------- */
.btn {
  --btn-bg: var(--ink);
  --btn-fg: var(--paper);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 20px;
  border: 1px solid transparent; border-radius: var(--r-pill);
  background: var(--btn-bg); color: var(--btn-fg);
  font-size: 14px; font-weight: 600; letter-spacing: 0.02em;
  transition: transform 160ms var(--ease), box-shadow 200ms var(--ease), background 200ms var(--ease), opacity 160ms;
  white-space: nowrap;
  text-align: center;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--sh-md); }
.btn:active { transform: translateY(0) scale(0.985); }
.btn[disabled] { opacity: 0.45; pointer-events: none; }
.btn svg { width: 17px; height: 17px; flex: none; }

.btn-primary {
  --btn-bg: linear-gradient(135deg, #e07a86 0%, #c9556a 100%);
  --btn-fg: #fff9f6;
  box-shadow: 0 10px 24px -14px rgba(184, 74, 93, 0.9);
}
.btn-dark { --btn-bg: var(--ink); --btn-fg: #fdf8f1; }
.btn-ghost {
  --btn-bg: transparent; --btn-fg: var(--ink);
  border-color: var(--line-strong); box-shadow: none;
}
.btn-ghost:hover { background: rgba(43, 39, 35, 0.04); box-shadow: none; }
.btn-quiet {
  --btn-bg: transparent; --btn-fg: var(--ink-2);
  min-height: 36px; padding: 0 12px; font-weight: 500; box-shadow: none;
}
.btn-quiet:hover { background: rgba(43, 39, 35, 0.05); box-shadow: none; transform: none; }
.btn-soft { --btn-bg: var(--rose-wash); --btn-fg: var(--rose-deep); border-color: rgba(217, 106, 122, 0.22); }
.btn-soft:hover { background: var(--rose-soft); box-shadow: none; }
.btn-sm { min-height: 36px; padding: 0 14px; font-size: 13px; }
.btn-lg { min-height: 52px; padding: 0 28px; font-size: 15.5px; }
.btn-block { width: 100%; }
.btn-icon { width: 38px; height: 38px; min-height: 38px; padding: 0; border-radius: 50%; }
.btn-icon svg { width: 18px; height: 18px; }

/* ---------- cards ---------- */
.card {
  background: var(--card, #fffdf9);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-sm);
}
.card-pad { padding: 22px; }
.card-tight { padding: 16px; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.card-title { font-family: var(--serif); font-size: 17px; letter-spacing: 0.02em; }
.card-title .sub { font-family: var(--sans); font-size: 12px; color: var(--ink-3); margin-left: 8px; letter-spacing: 0; }
.card-note { font-size: 12px; color: var(--ink-3); }

/* ---------- chips & badges ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 30px; padding: 0 12px; border-radius: var(--r-pill);
  border: 1px solid var(--line); background: rgba(255, 253, 249, 0.7);
  font-size: 12.5px; color: var(--ink-2);
  transition: all 160ms var(--ease);
  white-space: nowrap;
}
button.chip:hover { border-color: var(--line-strong); background: var(--card, #fffdf9); }
.chip[aria-pressed="true"], .chip.active { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.chip-rose { background: var(--rose-wash); border-color: rgba(217, 106, 122, 0.25); color: var(--rose-deep); }
.chip-gold { background: var(--gold-soft); border-color: rgba(185, 143, 82, 0.28); color: #8a6626; }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  height: 22px; padding: 0 8px; border-radius: 6px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.04em;
  background: var(--rose-wash); color: var(--rose-deep);
  white-space: nowrap;
}
.badge-gold { background: var(--gold-soft); color: #8a6626; }
.badge-sage { background: var(--sage-soft); color: #4f6247; }
.badge-ink { background: var(--ink); color: var(--paper); }
.badge-line { background: transparent; border: 1px solid var(--line-strong); color: var(--ink-3); }

.dot { width: 4px; height: 4px; border-radius: 50%; background: currentColor; opacity: 0.5; }

/* ---------- avatars ---------- */
.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--paper-3); font-size: 19px; line-height: 1;
  border: 2px solid var(--card, #fffdf9); box-shadow: var(--sh-sm); flex: none;
  overflow: hidden;
}
.avatar-lg { width: 54px; height: 54px; font-size: 26px; }
.avatar-sm { width: 28px; height: 28px; font-size: 14px; border-width: 1.5px; }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar-pair { display: inline-flex; }
.avatar-pair .avatar + .avatar { margin-left: -12px; }

.avatar-edit-row { display: flex; align-items: flex-start; gap: 14px; }
.avatar-preview .avatar { width: 64px; height: 64px; font-size: 30px; }
.avatar-edit-main { display: flex; flex-direction: column; gap: 8px; flex: 1; min-width: 0; }
.avatar-upload { align-self: flex-start; cursor: pointer; }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 7px; }
.label { font-size: 12.5px; color: var(--ink-2); font-weight: 500; letter-spacing: 0.02em; }
.hint { font-size: 12px; color: var(--ink-3); line-height: 1.5; }
.input, .textarea, .select {
  width: 100%; background: var(--card, #fffdf9);
  border: 1px solid var(--line-strong); border-radius: var(--r-md);
  padding: 11px 14px; font-size: 14.5px; color: var(--ink);
  transition: border-color 160ms, box-shadow 160ms, background 160ms;
  min-height: 44px;
}
.input::placeholder, .textarea::placeholder { color: var(--ink-4); }
.input:focus, .textarea:focus, .select:focus {
  outline: none; border-color: var(--rose);
  box-shadow: 0 0 0 3px rgba(217, 106, 122, 0.13);
  background: var(--card, #fff);
}
.textarea { resize: vertical; min-height: 96px; line-height: 1.7; }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238C8078' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px; }
.input-sm { min-height: 38px; padding: 8px 12px; font-size: 13.5px; }

.checkline { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; }
.checkline input { margin-top: 3px; accent-color: var(--rose); width: 16px; height: 16px; }

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(38, 32, 28, 0.42);
  backdrop-filter: blur(6px);
  display: grid; place-items: center; padding: 20px;
  animation: fade 200ms var(--ease);
}
.modal {
  width: min(520px, 100%); max-height: min(86vh, 780px); overflow: auto;
  background: var(--paper); border-radius: var(--r-xl);
  box-shadow: var(--sh-pop); border: 1px solid rgba(255, 255, 255, 0.5);
  padding: 26px; animation: pop 260ms var(--ease);
}
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.modal-title { font-family: var(--serif); font-size: 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }

@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(14px) scale(0.98); } }

/* ---------- toast ---------- */
.toast-layer {
  position: fixed; z-index: 120; left: 50%; bottom: 28px; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none; width: min(92vw, 480px);
}
.toast {
  display: flex; align-items: center; gap: 10px;
  background: rgba(43, 39, 35, 0.95); color: #fbf6ef;
  padding: 11px 18px; border-radius: var(--r-pill);
  font-size: 13.5px; box-shadow: var(--sh-pop);
  animation: toastIn 280ms var(--ease);
  max-width: 100%;
}
.toast svg { width: 16px; height: 16px; flex: none; }
.toast.ok svg { color: #a9d3a0; }
.toast.warn svg { color: #f0c987; }
.toast.out { animation: toastOut 220ms var(--ease) forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px) scale(0.96); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(8px) scale(0.98); } }

/* ---------- misc ---------- */
.empty {
  text-align: center; padding: 42px 20px; color: var(--ink-3);
  border: 1px dashed var(--line-strong); border-radius: var(--r-lg);
  background: rgba(255, 253, 249, 0.5);
}
.empty .emoji { font-size: 30px; display: block; margin-bottom: 10px; opacity: 0.8; }
.empty p { font-size: 13px; margin-top: 4px; }

.divider { height: 1px; background: var(--line); border: 0; margin: 18px 0; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.spin { animation: spin 900ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.skeleton {
  background: linear-gradient(100deg, var(--paper-2) 20%, #fffaf3 40%, var(--paper-2) 60%);
  background-size: 220% 100%; animation: shimmer 1.4s infinite; border-radius: 8px;
}
@keyframes shimmer { to { background-position: -120% 0; } }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(43, 39, 35, 0.16); border-radius: 99px; border: 3px solid var(--paper); }
::-webkit-scrollbar-track { background: transparent; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
