:root {
  --bg: #f5faf6;
  --card: #ffffff;
  --ink: #2c3b35;
  --muted: #8b9d95;
  --line: #eaf2ed;
  --mint: #6fc2a0;
  --mint-deep: #4e9e82;
  --mint-soft: #eaf7f0;
  --danger: #d46a6a;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

[hidden] {
  display: none !important;
}

body {
  min-height: 100vh;
  background:
    radial-gradient(1200px 600px at 15% -10%, #e9f7f0 0%, rgba(233, 247, 240, 0) 60%),
    radial-gradient(900px 500px at 100% 0%, #fdf8ee 0%, rgba(253, 248, 238, 0) 55%),
    var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Helvetica, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button {
  font-family: inherit;
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
  color: inherit;
}

.app {
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  padding: 14px 16px calc(140px + env(safe-area-inset-bottom));
}

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 2px 16px;
}

.brand {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.pill {
  padding: 7px 14px;
  border-radius: 999px;
  background: #fff;
  color: var(--mint-deep);
  font-size: 12px;
  box-shadow: 0 4px 14px rgba(78, 158, 130, 0.14);
}

/* ---------- 加载 ---------- */
.loading {
  display: flex;
  justify-content: center;
  padding-top: 120px;
}

.loading span {
  width: 9px;
  height: 9px;
  margin: 0 4px;
  border-radius: 50%;
  background: #9ad8be;
  animation: blink 1.2s infinite ease-in-out;
}

.loading span:nth-child(2) { animation-delay: 0.2s; }
.loading span:nth-child(3) { animation-delay: 0.4s; }

@keyframes blink {
  0%, 80%, 100% { opacity: 0.25; transform: scale(0.85); }
  40% { opacity: 1; transform: scale(1); }
}

/* ---------- 创建 / 加入 ---------- */
.card {
  background: var(--card);
  border-radius: 22px;
  box-shadow: 0 14px 40px rgba(44, 59, 53, 0.07);
}

.onboard {
  margin-top: 36px;
  padding: 36px 26px 28px;
  text-align: center;
}

.onboard-emoji {
  font-size: 56px;
  line-height: 1;
}

.onboard-title {
  margin: 12px 0 0;
  font-size: 23px;
  font-weight: 800;
  letter-spacing: 1px;
}

.onboard-desc {
  margin: 8px 0 0;
  font-size: 13px;
  line-height: 1.75;
  color: var(--muted);
}

.field {
  width: 100%;
  margin-top: 16px;
  padding: 15px 16px;
  border: 1px solid transparent;
  border-radius: 14px;
  background: #f5faf7;
  font-size: 16px;
  color: var(--ink);
  outline: none;
}

.field:focus {
  border-color: #b9e2cd;
  background: #fff;
}

.field-code {
  letter-spacing: 5px;
  font-weight: 700;
  text-transform: uppercase;
}

.field::placeholder {
  color: #b4c2ba;
  letter-spacing: 0;
  font-weight: 400;
}

.primary {
  width: 100%;
  margin-top: 18px;
  padding: 15px 18px;
  border-radius: 15px;
  background: linear-gradient(135deg, #7fcfaa, #4e9e82);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 1px;
  box-shadow: 0 10px 22px rgba(78, 158, 130, 0.28);
}

.primary:active {
  transform: translateY(1px);
}

.primary:disabled {
  opacity: 0.6;
}

.onboard-tip {
  margin: 16px 0 0;
  font-size: 11px;
  color: #aebdb5;
}

/* ---------- 顶部卡片 ---------- */
.hero {
  margin-top: 2px;
  padding: 20px 18px 16px;
  border-radius: 22px;
  background: linear-gradient(135deg, #e9f7f0 0%, #f7fcf9 62%, #fdf8ee 100%);
}

.hero-date {
  font-size: 12px;
  letter-spacing: 1.5px;
  color: var(--muted);
}

.hero-status {
  margin-top: 5px;
  font-size: 21px;
  font-weight: 800;
  line-height: 1.35;
  letter-spacing: 0.5px;
}

.hero-meta {
  display: flex;
  align-items: center;
  margin-top: 15px;
}

.meta-item {
  display: flex;
  align-items: baseline;
}

.meta-num {
  font-size: 25px;
  font-weight: 800;
  color: var(--mint-deep);
  line-height: 1;
}

.meta-label {
  margin-left: 4px;
  font-size: 12px;
  color: var(--muted);
}

.meta-line {
  width: 1px;
  height: 18px;
  margin: 0 14px;
  background: #ddebe3;
}

.meta-spacer {
  flex: 1;
}

/* ---------- 列表 ---------- */
.group {
  margin-top: 20px;
}

.group-head {
  display: flex;
  align-items: baseline;
  padding: 0 6px 8px;
}

.group-label {
  font-size: 14px;
  font-weight: 700;
}

.group-week {
  margin-left: 6px;
  font-size: 11px;
  color: #a5b5ad;
}

.group-count {
  margin-left: auto;
  font-size: 11px;
  color: #a5b5ad;
}

.group .card {
  padding: 2px 16px;
  border-radius: 18px;
}

.row {
  display: flex;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid #eef5f0;
  user-select: none;
  -webkit-user-select: none;
}

.row:last-child {
  border-bottom: none;
}

.row:active {
  opacity: 0.65;
}

.row-time {
  display: flex;
  flex-direction: column;
  width: 56px;
  flex: none;
}

.time {
  font-size: 16px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.time-hint {
  margin-top: 2px;
  font-size: 10px;
  color: #a5b5ad;
}

.row-tags {
  flex: 1;
  display: flex;
  align-items: center;
  overflow: hidden;
}

.tag {
  margin-right: 7px;
  padding: 4px 9px;
  border-radius: 7px;
  font-size: 11px;
  line-height: 1.4;
  white-space: nowrap;
}

.amount-1 { background: #f0f8f3; color: #6b9e87; }
.amount-2 { background: #e4f3ea; color: #4e9e82; }
.amount-3 { background: #d6ecdf; color: #3e8a6e; }
.amount-4 { background: #c9e5d5; color: #2f7359; }

.shape-1 { background: #eef5fb; color: #5d8cae; }
.shape-2 { background: #fdf3e7; color: #b8873f; }
.shape-3 { background: #eef1fb; color: #6b79b8; }

.who {
  max-width: 84px;
  margin-left: 6px;
  font-size: 11px;
  color: #a5b5ad;
  text-align: right;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.who-mine {
  color: var(--mint-deep);
  font-weight: 700;
}

.hint {
  margin-top: 18px;
  text-align: center;
  font-size: 11px;
  color: #b4c2ba;
}

.empty {
  margin-top: 70px;
  text-align: center;
  color: var(--muted);
}

.empty-emoji {
  font-size: 52px;
  line-height: 1;
}

.empty p {
  margin: 8px 0 0;
  font-size: 13px;
  line-height: 1.7;
}

/* ---------- 悬浮按钮 ---------- */
.fab {
  position: fixed;
  right: max(20px, calc((100vw - 520px) / 2 + 20px));
  bottom: calc(26px + env(safe-area-inset-bottom));
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #7fcfaa, #4e9e82);
  color: #fff;
  font-size: 34px;
  font-weight: 300;
  line-height: 1;
  padding-bottom: 4px;
  box-shadow: 0 12px 26px rgba(78, 158, 130, 0.38);
  z-index: 20;
}

.fab:active {
  transform: scale(0.95);
}

/* ---------- 遮罩 & 面板 ---------- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(28, 42, 36, 0.35);
  z-index: 30;
}

.sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: 100%;
  max-width: 520px;
  max-height: 88vh;
  overflow-y: auto;
  z-index: 31;
  padding: 10px 18px calc(26px + env(safe-area-inset-bottom));
  background: #fff;
  border-radius: 22px 22px 0 0;
  box-shadow: 0 -12px 34px rgba(28, 42, 36, 0.16);
}

.handle {
  width: 38px;
  height: 4px;
  margin: 0 auto 12px;
  border-radius: 999px;
  background: #e6eee9;
}

.sheet-title {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
  text-align: center;
}

.pick-row {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.pick {
  flex: 1;
  padding: 10px 12px;
  border-radius: 12px;
  background: #f5faf7;
}

.pick-label {
  display: block;
  font-size: 11px;
  color: var(--muted);
}

.pick-value {
  display: block;
  width: 100%;
  margin-top: 3px;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  outline: none;
}

.section-label {
  margin: 16px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  margin-top: 8px;
}

.chip {
  margin: 0 8px 8px 0;
  padding: 9px 18px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: #f4f9f6;
  color: #6c8379;
  font-size: 14px;
}

.chip.on {
  background: var(--mint-soft);
  border-color: #9ad8be;
  color: var(--mint-deep);
  font-weight: 700;
}

.sheet-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.sheet-actions .ghost {
  flex: 0 0 34%;
  margin-top: 0;
}

.sheet-actions .primary {
  flex: 1;
  margin-top: 0;
}

.ghost {
  margin-top: 14px;
  padding: 15px 18px;
  border-radius: 15px;
  background: #f1f9f5;
  color: var(--mint-deep);
  font-size: 15px;
  font-weight: 600;
}

.ghost.wide {
  width: 100%;
}

.invite-code {
  margin: 18px 0 6px;
  text-align: center;
  font-size: 34px;
  font-weight: 800;
  letter-spacing: 8px;
  color: var(--mint-deep);
}

.invite-desc {
  margin: 0;
  text-align: center;
  font-size: 12px;
  line-height: 1.75;
  color: var(--muted);
}

.invite-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}

.invite-actions .ghost,
.invite-actions .primary {
  flex: 1;
  margin-top: 0;
}

.sheet-links {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 18px;
}

.text-btn {
  padding: 8px 10px;
  font-size: 12px;
  color: #a5b5ad;
}

.text-btn:active {
  color: var(--mint-deep);
}

.close-btn {
  display: block;
  margin: 4px auto 0;
}

.dot {
  margin: 0 4px;
  color: #c9d6cf;
}

.menu-item {
  display: block;
  width: 100%;
  margin-top: 12px;
  padding: 15px;
  border-radius: 14px;
  background: #f5faf7;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
}

.menu-item.danger {
  color: var(--danger);
}

/* ---------- 对话框 ---------- */
.dialog {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: calc(100% - 56px);
  max-width: 330px;
  z-index: 41;
  padding: 22px 20px 16px;
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 24px 60px rgba(28, 42, 36, 0.24);
}

.dialog h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 800;
  text-align: center;
}

.dialog p {
  margin: 10px 0 0;
  font-size: 14px;
  line-height: 1.7;
  color: #5f7169;
  text-align: center;
}

.dialog-input {
  width: 100%;
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px solid #e3efe8;
  border-radius: 12px;
  background: #f7fbf8;
  font-family: inherit;
  font-size: 16px;
  outline: none;
}

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

.dialog-actions button {
  flex: 1;
  padding: 12px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
}

.dialog-actions .cancel {
  background: #f2f6f3;
  color: #7c8f87;
}

.dialog-actions .ok {
  background: linear-gradient(135deg, #7fcfaa, #4e9e82);
  color: #fff;
}

.dialog-actions .ok.danger {
  background: linear-gradient(135deg, #e08080, #d46a6a);
}

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 50;
  max-width: 80vw;
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(44, 59, 53, 0.9);
  color: #fff;
  font-size: 13px;
  text-align: center;
  animation: toast-in 0.18s ease-out;
}

@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 6px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

@media (min-width: 600px) {
  .app {
    padding-top: 26px;
  }
  .topbar {
    padding-bottom: 18px;
  }
  .hero {
    padding: 24px 22px 18px;
  }
  .hero-status {
    font-size: 24px;
  }
}
