* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #fff6ec;            /* 奶油底色 */
  --card: #ffffff;
  --primary: #ff8a5c;       /* 蜜桃橘 */
  --primary-dark: #f2703f;
  --primary-soft: #ffe3d3;
  --text: #4a3f35;          /* 暖棕 */
  --text-light: #a08c7d;
  --border: #f3e4d3;
  --pos: #3bae8a;
  --neg: #ef6461;
  --radius: 20px;
  --shadow: 0 4px 16px rgba(122, 86, 58, .08);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

button { font-family: inherit; }
button:active { transform: scale(.96); }

/* ---------- 顶栏 ---------- */

.topbar {
  background: linear-gradient(135deg, #ffb37b, #ff8a5c);
  color: #fff;
  padding: 30px 20px 24px;
  text-align: center;
  border-radius: 0 0 28px 28px;
}
.topbar h1 { font-size: 23px; font-weight: 800; }
.subtitle { margin-top: 6px; font-size: 13px; opacity: .92; }

.topbar-ledger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 18px 16px;
  text-align: left;
}
.topbar-ledger h1 {
  font-size: 18px;
  flex: 1;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.back {
  color: #fff;
  text-decoration: none;
  font-size: 15px;
  white-space: nowrap;
}
.topbar-actions { display: flex; gap: 4px; }
.icon-btn {
  background: rgba(255, 255, 255, .18);
  border: none;
  border-radius: 50%;
  width: 34px;
  height: 34px;
  font-size: 15px;
  cursor: pointer;
}

/* ---------- 布局 ---------- */

.container {
  max-width: 560px;
  margin: 0 auto;
  padding: 16px 16px 60px;
}

.empty { text-align: center; padding: 56px 0 28px; }
.empty-icon { font-size: 56px; margin-bottom: 12px; }
.empty p { font-size: 16px; }
.hint { color: var(--text-light); font-size: 13px; }
.center { text-align: center; padding: 12px 0; }

/* ---------- 首屏主按钮 ---------- */

.hero {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 18px;
  margin-bottom: 14px;
  text-align: center;
}
.hero-text { font-size: 14.5px; color: var(--text-light); margin-bottom: 14px; }
.hero-text b { color: var(--text); font-size: 17px; margin: 0 2px; }
.btn-hero {
  display: block;
  width: 100%;
  background: linear-gradient(135deg, #ffb37b, var(--primary));
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 16px;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 2px;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(255, 138, 92, .4);
  transition: transform .12s;
}

.migrate-card {
  background: var(--primary-soft);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
  font-size: 14px;
  line-height: 1.6;
}
.migrate-card .btn-small {
  margin-top: 12px;
  padding: 8px 16px;
  font-size: 14px;
}

/* ---------- 账本卡片 ---------- */

.ledger-grid { display: flex; flex-direction: column; gap: 12px; margin-bottom: 20px; }
.ledger-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  text-decoration: none;
  color: inherit;
  transition: transform .12s;
}
.ledger-card:active { transform: scale(.98); }
.ledger-emoji {
  font-size: 26px;
  background: var(--primary-soft);
  border-radius: 16px;
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.ledger-info { flex: 1; min-width: 0; }
.ledger-name { font-size: 16px; font-weight: 700; }
.ledger-meta { font-size: 13px; color: var(--text-light); margin-top: 3px; }
.chevron { font-size: 22px; color: var(--text-light); }

/* ---------- 账目明细（主体） ---------- */

.expense-list {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 14px;
}
.expense-list h3 { font-size: 16px; margin-bottom: 6px; }

.expense-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px dashed var(--border);
}
.expense-item:first-of-type { border-top: none; }
.expense-cat { font-size: 24px; }
.expense-main { flex: 1; min-width: 0; }
.expense-title { font-size: 15px; font-weight: 600; }
.expense-meta { font-size: 12.5px; color: var(--text-light); margin-top: 3px; }
.expense-right { text-align: right; }
.expense-amount { font-size: 15px; font-weight: 800; }
.expense-item.transfer { opacity: .75; }
.expense-item.transfer .expense-amount { color: var(--pos); }
.link-btn {
  background: none; border: none;
  color: var(--text-light);
  font-size: 12.5px;
  cursor: pointer;
  padding: 2px 0;
}
.link-btn:hover { color: var(--neg); }

/* ---------- 最后来算钱（弱化的收尾区） ---------- */

.settle-area {
  background: transparent;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}
.settle-area h3 { font-size: 15px; margin-bottom: 10px; color: var(--text-light); }

.settle-target {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding-bottom: 10px;
}

.balance-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
}
.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
  flex-shrink: 0;
}
.member-name { flex: 1; font-size: 14.5px; }
.balance { font-size: 13.5px; color: var(--text-light); }
.balance.pos { color: var(--pos); font-weight: 700; }
.balance.neg { color: var(--neg); font-weight: 700; }

.settle-list { border-top: 1px dashed var(--border); margin-top: 8px; padding-top: 6px; }
.settle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  font-size: 14px;
}
.settle-row span:first-child { flex: 1; }
.settle-amount { font-weight: 800; color: var(--primary-dark); }
.btn-paid {
  background: var(--primary-soft);
  color: var(--primary-dark);
  border: none;
  border-radius: 999px;
  padding: 6px 13px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.all-clear { text-align: center; font-size: 15px; padding: 10px 0 4px; }
.rate-note {
  font-size: 12px;
  color: var(--text-light);
  margin-top: 10px;
  line-height: 1.6;
}

/* ---------- 头像马卡龙色 ---------- */

.c0 { background: #ffd6cc; color: #c4553b; }
.c1 { background: #cdeedd; color: #2e8b6a; }
.c2 { background: #d4defc; color: #4a63b8; }
.c3 { background: #ffe8b3; color: #a97b12; }
.c4 { background: #f8d0e0; color: #b04a77; }
.c5 { background: #d8f0c8; color: #5a8f3a; }
.c6 { background: #cfe9f5; color: #3a7d9c; }
.c7 { background: #eadcf8; color: #7a4ab0; }

/* ---------- 按钮 ---------- */

.btn-primary {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 13px 22px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(255, 138, 92, .35);
}
.btn-primary:active { background: var(--primary-dark); }
.btn-block { display: block; width: 100%; }
.btn-ghost {
  background: none;
  border: 1.5px solid var(--border);
  border-radius: 999px;
  padding: 9px 16px;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
}
.btn-wide { flex: 1; }

/* ---------- 弹窗 ---------- */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(74, 63, 53, .45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
}
.dialog {
  background: var(--card);
  border-radius: 24px 24px 0 0;
  padding: 22px 20px calc(22px + env(safe-area-inset-bottom));
  width: 100%;
  max-width: 560px;
  max-height: 88vh;
  overflow-y: auto;
}
@media (min-width: 600px) {
  .overlay { align-items: center; }
  .dialog { border-radius: 24px; }
}
.dialog h2 { font-size: 18px; margin-bottom: 16px; }

/* ---------- 记一笔：金额优先 ---------- */

.amount-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0 4px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 14px;
}
.amount-row:focus-within { border-bottom-color: var(--primary); }
.currency-tag {
  font-size: 22px;
  font-weight: 800;
  color: var(--primary-dark);
  background: var(--primary-soft);
  border-radius: 12px;
  padding: 8px 12px;
  flex-shrink: 0;
}
.cur-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}
.amount-input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  font-size: 44px;
  font-weight: 800;
  color: var(--text);
  background: transparent;
  text-align: right;
  padding: 0;
}
.amount-input::placeholder { color: #ead9c8; }

.title-input {
  width: 100%;
  border: none;
  border-bottom: 1.5px solid var(--border);
  padding: 10px 2px;
  font-size: 16px;
  outline: none;
  background: transparent;
  margin-bottom: 16px;
  color: var(--text);
}
.title-input:focus { border-bottom-color: var(--primary); }

.field { display: block; margin-bottom: 14px; }
.field > span {
  display: block;
  font-size: 13px;
  color: var(--text-light);
  margin-bottom: 7px;
}
.field input[type="text"] {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 11px 12px;
  font-size: 15px;
  background: var(--bg);
  outline: none;
  color: var(--text);
}
.field input:focus { border-color: var(--primary); background: #fff; }

.emoji-row { display: flex; flex-wrap: wrap; gap: 8px; }
.emoji-btn {
  font-size: 20px;
  background: var(--bg);
  border: 2px solid transparent;
  border-radius: 12px;
  padding: 6px 10px;
  cursor: pointer;
}
.emoji-btn.active { border-color: var(--primary); background: var(--primary-soft); }
.chip {
  background: var(--bg);
  border: 1.5px solid transparent;
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 14px;
  cursor: pointer;
  color: var(--text);
}
.chip.active {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-weight: 700;
}
.chip-sm { padding: 5px 11px; font-size: 13px; background: var(--card); }

/* 圆圈选人 */
.avatar-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  padding: 6px 0 2px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.avatar-pick {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  cursor: pointer;
}
.pick-circle {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  font-weight: 700;
  transition: all .15s;
  position: relative;
  border: 2px solid transparent;
}
.avatar-pick:not(.active) .pick-circle {
  background: var(--bg) !important;
  color: var(--text-light) !important;
  border: 2px dashed var(--border);
  filter: grayscale(1);
}
.avatar-pick.active .pick-circle {
  box-shadow: 0 3px 10px rgba(122, 86, 58, .2);
}
.avatar-pick.active .pick-circle::after {
  content: '✓';
  position: absolute;
  right: -3px;
  bottom: -3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .2);
}
.pick-name { font-size: 12.5px; color: var(--text); }
.avatar-pick:not(.active) .pick-name { color: var(--text-light); }

.date-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
}
.date-row input[type="date"] {
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 6px 10px;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  outline: none;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 60px;
  transform: translateX(-50%);
  background: rgba(74, 63, 53, .93);
  color: #fff;
  font-size: 14px;
  padding: 10px 18px;
  border-radius: 999px;
  z-index: 100;
  white-space: nowrap;
  animation: toast-in .2s ease-out;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(8px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}
