:root {
  --brand: #4f46e5;
  --brand-2: #7c3aed;
  --brand-soft: #eef0ff;
  --danger: #e5484d;
  --danger-soft: #fff0f0;
  --ok: #17994f;

  --bg: #f5f5f8;
  --surface: #ffffff;
  --line: #e8e8ef;
  --text: #1b1b25;
  --text-2: #5c5c70;
  --text-3: #9494a6;

  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --shadow: 0 1px 2px rgba(24, 24, 40, .05), 0 8px 24px rgba(24, 24, 40, .06);
  --shadow-up: 0 -6px 24px rgba(24, 24, 40, .08);
  --safe-b: env(safe-area-inset-bottom, 0px);

  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif;
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

body { min-height: 100vh; }

button, input, textarea, select {
  font-family: inherit;
  font-size: 16px; /* 小于 16px 会让 iOS Safari 聚焦时自动放大页面 */
  color: inherit;
}

button { cursor: pointer; border: none; background: none; padding: 0; }

a { color: var(--brand); text-decoration: none; }

.hidden { display: none !important; }

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

.app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  height: 52px;
  padding: 0 16px;
  background: rgba(245, 245, 248, .88);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}

.topbar h1 {
  flex: 1;
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: .01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar .icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  margin-left: -6px;
  border-radius: 50%;
  color: var(--text-2);
}
.topbar .icon-btn:active { background: rgba(0, 0, 0, .05); }
.topbar .text-btn { color: var(--text-2); font-size: 14px; padding: 6px 4px; }

.view { flex: 1; padding: 16px 16px calc(96px + var(--safe-b)); }

/* ---------- 通用组件 ---------- */

.card {
  background: var(--surface);
  border-radius: var(--r-md);
  box-shadow: var(--shadow);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 50px;
  border-radius: var(--r-md);
  background: var(--brand);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  transition: transform .12s ease, opacity .12s ease;
}
.btn:active { transform: scale(.985); }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn.ghost { background: var(--surface); color: var(--text); border: 1px solid var(--line); }
.btn.danger-text { background: transparent; color: var(--danger); font-weight: 500; height: 44px; }
.btn.sm { height: 40px; width: auto; padding: 0 16px; font-size: 15px; border-radius: var(--r-sm); }

.field { margin-bottom: 16px; }
.field label {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-2);
}
.field .hint { font-weight: 400; color: var(--text-3); }

.input, .textarea {
  width: 100%;
  padding: 13px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.input:focus, .textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, .12);
}
.textarea { min-height: 88px; resize: vertical; line-height: 1.6; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(28px + var(--safe-b));
  transform: translateX(-50%) translateY(12px);
  max-width: 84vw;
  padding: 11px 18px;
  border-radius: 999px;
  background: rgba(27, 27, 37, .93);
  color: #fff;
  font-size: 14px;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  z-index: 200;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.empty {
  padding: 72px 24px;
  text-align: center;
  color: var(--text-3);
}
.empty .big { font-size: 42px; margin-bottom: 12px; }
.empty p { margin: 6px 0; font-size: 15px; }

.spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(255, 255, 255, .35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 登录 ---------- */

.auth {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 32px 24px calc(40px + var(--safe-b));
  max-width: 420px;
  margin: 0 auto;
}
.brand { text-align: center; margin-bottom: 32px; }
.brand .logo {
  width: 68px; height: 68px;
  margin: 0 auto 16px;
  border-radius: 22px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 10px 28px rgba(79, 70, 229, .3);
}
.brand h1 { margin: 0 0 6px; font-size: 26px; font-weight: 700; letter-spacing: .04em; }
.brand p { margin: 0; color: var(--text-3); font-size: 14px; }

.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  margin-bottom: 20px;
  background: #ececf2;
  border-radius: 12px;
}
.tabs button {
  flex: 1;
  height: 38px;
  border-radius: 9px;
  font-size: 15px;
  font-weight: 500;
  color: var(--text-2);
}
.tabs button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.08); }

.auth-tip {
  margin: 18px 0 0;
  font-size: 13px;
  color: var(--text-3);
  text-align: center;
}

.form-error {
  margin: 0 0 14px;
  padding: 10px 14px;
  border-radius: var(--r-sm);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 14px;
}

/* ---------- 打卡列表 ---------- */

.list-meta {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin: 4px 2px 14px;
  font-size: 13px;
  color: var(--text-3);
}
.list-meta b { font-size: 20px; font-weight: 700; color: var(--text); }

.checkin-list { display: flex; flex-direction: column; gap: 10px; }

.checkin-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 14px 16px;
  background: var(--surface);
  border-radius: var(--r-md);
  box-shadow: var(--shadow);
  transition: transform .12s ease;
}
.checkin-item:active { transform: scale(.99); }
.checkin-item .row { display: flex; align-items: center; gap: 10px; }
.checkin-item .title {
  flex: 1;
  font-size: 16px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.checkin-item .note {
  margin-top: 6px;
  font-size: 14px;
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.checkin-item .sub {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
  font-size: 13px;
  color: var(--text-3);
}
.checkin-item .dur {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--brand);
  font-variant-numeric: tabular-nums;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 12px;
  font-weight: 500;
}

.fab-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 30;
  padding: 12px 16px calc(12px + var(--safe-b));
  background: linear-gradient(to top, var(--bg) 62%, rgba(245, 245, 248, 0));
  pointer-events: none;
}
.fab-bar .inner { max-width: 560px; margin: 0 auto; pointer-events: auto; }
.fab-bar .btn { box-shadow: 0 8px 22px rgba(79, 70, 229, .32); }

/* ---------- 详情 ---------- */

.detail-head { margin-bottom: 16px; }
.detail-head h2 { margin: 0 0 8px; font-size: 21px; line-height: 1.35; font-weight: 650; }
.detail-head .meta { font-size: 13px; color: var(--text-3); }

.section { margin-top: 22px; }
.section > h3 {
  margin: 0 0 10px 2px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-3);
  letter-spacing: .06em;
}
.note-box {
  padding: 14px 16px;
  background: var(--surface);
  border-radius: var(--r-md);
  box-shadow: var(--shadow);
  font-size: 15px;
  color: var(--text-2);
  white-space: pre-wrap;
  word-break: break-word;
}

.share-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface);
  border-radius: var(--r-md);
  box-shadow: var(--shadow);
  margin-bottom: 8px;
}
.share-row .info { flex: 1; min-width: 0; }
.share-row .link {
  font-size: 13px;
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.share-row .state { margin-top: 4px; font-size: 12px; color: var(--text-3); }
.share-row .state.dead { color: var(--text-3); text-decoration: none; }
.share-row.expired .link { color: var(--text-3); text-decoration: line-through; }
.share-row .acts { display: flex; gap: 6px; flex-shrink: 0; }
.mini-btn {
  padding: 7px 11px;
  border-radius: 8px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 13px;
  font-weight: 500;
}
.mini-btn.gray { background: #f0f0f5; color: var(--text-2); }

/* ---------- 录音 ---------- */

.recorder {
  padding: 22px 16px 18px;
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  text-align: center;
}

.rec-timer {
  font-size: 34px;
  font-weight: 300;
  font-variant-numeric: tabular-nums;
  letter-spacing: .04em;
  color: var(--text);
}
.rec-status { margin-top: 2px; font-size: 13px; color: var(--text-3); height: 20px; }
.rec-status .dot {
  display: inline-block;
  width: 7px; height: 7px;
  margin-right: 5px;
  border-radius: 50%;
  background: var(--danger);
  vertical-align: middle;
  animation: blink 1.2s ease-in-out infinite;
}
@keyframes blink { 50% { opacity: .25; } }

.wave {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: 56px;
  margin: 14px 0 18px;
}
.wave i {
  display: block;
  width: 4px;
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(180deg, var(--brand), var(--brand-2));
  opacity: .85;
  transition: height .08s linear;
}

.rec-controls { display: flex; align-items: center; justify-content: center; gap: 26px; }

.rec-main {
  position: relative;
  width: 74px; height: 74px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 22px rgba(79, 70, 229, .34);
  transition: transform .12s ease;
}
.rec-main:active { transform: scale(.95); }
.rec-main.recording { background: linear-gradient(135deg, #f0575b, var(--danger)); box-shadow: 0 8px 22px rgba(229, 72, 77, .34); }
.rec-main.recording::after {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid rgba(229, 72, 77, .35);
  animation: pulse 1.8s ease-out infinite;
}
@keyframes pulse {
  0% { transform: scale(1); opacity: .8; }
  100% { transform: scale(1.28); opacity: 0; }
}

.rec-side {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  width: 56px;
  color: var(--text-2);
  font-size: 12px;
}
.rec-side .circle {
  width: 46px; height: 46px;
  border-radius: 50%;
  background: #f1f1f6;
  display: flex; align-items: center; justify-content: center;
}
.rec-side:active .circle { background: #e6e6ee; }
.rec-side[disabled] { opacity: .35; }

.rec-error {
  margin-top: 14px;
  padding: 10px 14px;
  border-radius: var(--r-sm);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 13px;
  text-align: left;
  line-height: 1.5;
}

.progress {
  height: 4px;
  margin-top: 14px;
  border-radius: 2px;
  background: var(--line);
  overflow: hidden;
}
.progress i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--brand), var(--brand-2));
  transition: width .2s ease;
}

/* ---------- 底部弹层 ---------- */

.sheet-mask {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(20, 20, 30, .42);
  opacity: 0;
  transition: opacity .22s ease;
}
.sheet-mask.show { opacity: 1; }

.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  max-width: 560px;
  margin: 0 auto;
  z-index: 101;
  max-height: 88vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 8px 20px calc(24px + var(--safe-b));
  background: var(--surface);
  border-radius: 22px 22px 0 0;
  box-shadow: var(--shadow-up);
  transform: translateY(100%);
  transition: transform .28s cubic-bezier(.32, .72, 0, 1);
}
.sheet.show { transform: translateY(0); }
.sheet .grabber {
  width: 38px; height: 4px;
  margin: 0 auto 14px;
  border-radius: 2px;
  background: #dcdce4;
}
.sheet h3 { margin: 0 0 16px; font-size: 18px; font-weight: 650; text-align: center; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips button {
  padding: 9px 16px;
  border-radius: 999px;
  background: #f1f1f6;
  color: var(--text-2);
  font-size: 14px;
  transition: background .15s ease;
}
.chips button.on { background: var(--brand); color: #fff; font-weight: 500; }

/* 微信分享卡片预览 */
.wx-card {
  display: flex;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: #fafafc;
}
.wx-card .thumb {
  width: 56px; height: 56px;
  border-radius: 6px;
  flex-shrink: 0;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  object-fit: cover;
}
.wx-card .t {
  font-size: 14px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.wx-card .d { margin-top: 4px; font-size: 12px; color: var(--text-3); }

.link-box {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  margin-bottom: 12px;
  background: #f6f6fa;
  border-radius: var(--r-sm);
}
.link-box code {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  color: var(--text-2);
  word-break: break-all;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
