/* 同调鸟 AttunBird · 移动端 PWA 样式
 * 视觉参考 attunbird-home-ui-v2.png / record-discuss-ui.png
 * 米白底 + 深墨蓝主卡 + 品牌赭红 + 三鸟色
 */

:root {
  /* 底色 */
  --paper: #F7F4ED;
  --paper-2: #EFE9DC;
  --card: #FFFFFF;
  --line: rgba(20, 32, 28, 0.08);
  --ink: #1F2933;
  --ink-2: #3D4A56;
  --muted: #8A8A82;

  /* 品牌 */
  --bird: #D63A2F;
  --bird-deep: #A82C24;
  --leaf: #2F6F5E;
  --blue: #1E4A72;
  --blue-light: #3D6F9E;
  --yellow: #9A6B00;

  /* 鸟卡片色 */
  --red-bird: #E24A3C;
  --blue-bird: #3D6F9E;
  --yellow-bird: #C49023;

  --shadow: 0 8px 24px rgba(20, 32, 28, 0.06);
  --shadow-md: 0 12px 32px rgba(20, 32, 28, 0.10);

  --tabbar-h: 64px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "PingFang SC", "Songti SC", serif;
  color: var(--ink);
  background:
    radial-gradient(800px 400px at 10% -10%, #FBF7EE 0%, transparent 60%),
    linear-gradient(180deg, var(--paper) 0%, var(--paper-2) 100%);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ===== 顶栏 ===== */
.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px 10px;
  position: relative;
  z-index: 10;
  flex: 0 0 auto;
  background: linear-gradient(180deg, var(--paper) 0%, rgba(247,244,237,0.6) 100%);
  backdrop-filter: blur(8px);
}
.brand { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.brand-logo {
  width: 40px; height: 40px; border-radius: 50%;
  object-fit: cover;
  background: var(--paper);
  box-shadow: 0 4px 12px rgba(20,32,28,0.12);
  flex-shrink: 0;
}
.brand-text { min-width: 0; }
.brand-name {
  font-family: "Songti SC", "STKaiti", serif;
  font-weight: 700; font-size: 18px; letter-spacing: -0.01em;
  white-space: nowrap;
}
.brand-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }
.top-btn {
  position: relative;
  width: 38px; height: 38px;
  border-radius: 12px;
  background: transparent;
  border: 0;
  color: var(--ink-2);
  display: grid; place-items: center;
  cursor: pointer;
}
.top-btn:active { background: rgba(20,32,28,0.05); }
.badge {
  position: absolute; top: 4px; right: 4px;
  min-width: 16px; height: 16px; border-radius: 999px;
  background: var(--bird);
  color: #fff; font-size: 10px; font-weight: 700;
  display: grid; place-items: center; padding: 0 4px;
  box-shadow: 0 0 0 2px var(--paper);
}

/* ===== 主区 + view 切换 ===== */
#app { flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 4px 16px calc(var(--tabbar-h) + var(--safe-bottom) + 12px); }
.view { display: none; }
.view.active { display: block; animation: fadein 0.18s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ===== 通用卡 ===== */
.card {
  background: var(--card);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.card-ico {
  width: 32px; height: 32px; border-radius: 10px;
  display: grid; place-items: center;
  color: var(--ink-2);
  background: rgba(61,74,86,0.06);
}
.card-ico.ico-red { color: var(--bird); background: rgba(214,58,47,0.10); }
.card-ico.ico-ink { color: var(--ink-2); background: rgba(61,74,86,0.06); }
.card-title { font-size: 16px; font-weight: 600; flex: 1; }
.card-add {
  width: 28px; height: 28px; border-radius: 50%;
  border: 0; background: rgba(61,74,86,0.06);
  color: var(--ink-2); font-size: 18px; line-height: 1;
  display: grid; place-items: center;
  cursor: pointer; flex-shrink: 0;
}
.card-add:active { background: rgba(61,74,86,0.12); transform: scale(0.94); }

/* ===== 今日深色卡 ===== */
.hero-card {
  display: flex; align-items: center; gap: 12px;
  background: linear-gradient(135deg, #3D4A56 0%, #2A333D 100%);
  color: #fff;
  border-radius: 14px;
  padding: 16px;
  margin: 4px 0 14px;
  box-shadow: 0 10px 28px rgba(61,74,86,0.20);
}
.hero-icon {
  width: 40px; height: 40px; border-radius: 12px;
  background: rgba(255,255,255,0.12);
  display: grid; place-items: center; flex-shrink: 0;
}
.hero-body { flex: 1; min-width: 0; }
.hero-title { font-size: 16px; font-weight: 600; }
.hero-sub { font-size: 12px; opacity: 0.78; margin-top: 2px; }
.hero-arrow { flex-shrink: 0; opacity: 0.7; }

/* ===== 提醒列表 ===== */
.remind-list, .schedule-list { list-style: none; padding: 0; margin: 0; }
.remind-list li.empty, .schedule-list li.empty {
  list-style: none;
  color: var(--muted); font-size: 13px;
  padding: 8px 0;
}
.remind-list li {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 0;
  font-size: 14px;
}
.remind-list li + li { border-top: 1px solid var(--line); }
.bullet {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--bird); flex-shrink: 0;
}
.bullet.muted { background: var(--muted); opacity: 0.5; }
.remind-text { flex: 1; }
.tag {
  font-size: 11px; padding: 2px 6px; border-radius: 4px;
  font-weight: 600;
}
.tag-high { background: rgba(214,58,47,0.10); color: var(--bird-deep); }

/* ===== 日程列表 ===== */
.schedule-list li {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 0;
  font-size: 14px;
  cursor: pointer;
}
.schedule-list li + li { border-top: 1px solid var(--line); }
.time {
  color: var(--ink-2); font-weight: 600;
  font-variant-numeric: tabular-nums;
  min-width: 80px;
}
.event { flex: 1; }

/* ===== 社区动态（三鸟） ===== */
.bird-list { list-style: none; padding: 0; margin: 0; }
.bird-list li {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 0;
  cursor: pointer;
}
.bird-list li + li { border-top: 1px solid var(--line); }
.bird-list li:active { background: rgba(20,32,28,0.03); }
.bird-mark {
  width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center;
  color: #fff; font-weight: 700; font-size: 13px;
  font-family: "Songti SC", serif;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0,0,0,0.10);
}
.bird-mark.red { background: var(--red-bird); }
.bird-mark.blue { background: var(--blue-bird); }
.bird-mark.yellow { background: var(--yellow-bird); }
.bird-name { flex: 1; font-size: 15px; }
.bird-count { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.bird-arrow { color: var(--muted); font-size: 18px; }

/* ===== 页面标题 ===== */
.page-title {
  font-family: "Songti SC", "STKaiti", serif;
  font-size: 24px; font-weight: 700;
  margin: 8px 0 4px;
  color: var(--ink);
}
.page-sub { font-size: 13px; color: var(--muted); margin-bottom: 16px; }
.section-label { font-size: 12px; color: var(--muted); margin: 16px 4px 8px; font-weight: 500; }
.hint-line { font-size: 12px; color: var(--muted); text-align: center; padding: 16px 0; }

/* ===== 记录页 ===== */
.compose-card {
  background: var(--card);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 8px;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}
.compose-card textarea {
  width: 100%;
  border: 0; outline: 0; resize: none;
  font: inherit; font-size: 15px; line-height: 1.5;
  color: var(--ink);
  background: transparent;
  padding: 0;
  min-height: 80px;
}
.compose-card textarea::placeholder { color: #B8B0A0; }
.compose-bar { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 0; border-radius: 999px;
  padding: 8px 18px; font-size: 14px; font-weight: 500;
  cursor: pointer; font-family: inherit;
}
.btn:active { transform: scale(0.96); }
.btn-ghost {
  background: rgba(61,74,86,0.06);
  color: var(--ink-2);
}
.btn-primary {
  background: linear-gradient(135deg, var(--ink-2) 0%, #2A333D 100%);
  color: #fff;
  box-shadow: 0 4px 12px rgba(61,74,86,0.20);
}

/* ===== 记录列表行 ===== */
#recordList { padding-bottom: 96px; }
.card.row {
  display: flex; gap: 12px;
  padding: 14px 16px;
  cursor: pointer;
}
.card.row + .card.row { margin-top: 0; }
.dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--bird); margin-top: 8px; flex-shrink: 0;
}
.dot.muted { background: var(--muted); opacity: 0.5; }
.row-title { font-size: 15px; font-weight: 500; }
.row-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.row-meta { font-size: 11px; color: var(--muted); margin-top: 4px; }

/* ===== 讨论页聊天 ===== */
.chat { padding-bottom: 16px; }
.msg { display: flex; margin-bottom: 12px; }
.msg.user { justify-content: flex-end; }
.msg.ai { justify-content: flex-start; }
.bubble {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 15px; line-height: 1.5;
  word-wrap: break-word;
}
.msg.user .bubble {
  background: linear-gradient(135deg, var(--ink-2) 0%, #2A333D 100%);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.msg.ai .bubble {
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--line);
  border-bottom-left-radius: 4px;
  box-shadow: var(--shadow);
}

.discuss-bar {
  position: fixed;
  left: 0; right: 0;
  bottom: calc(var(--tabbar-h) + var(--safe-bottom));
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px;
  background: rgba(247,244,237,0.95);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  z-index: 5;
}
.discuss-bar[hidden] { display: none; }
.discuss-bar input {
  flex: 1;
  border: 0; outline: 0;
  background: var(--card);
  border-radius: 999px;
  padding: 10px 16px;
  font: inherit; font-size: 14px;
  color: var(--ink);
  box-shadow: 0 2px 8px rgba(20,32,28,0.06);
}
.discuss-bar input::placeholder { color: #B8B0A0; }

/* ===== 记录页底部语音输入条（固定底部，仅 record 视图） ===== */
.record-bar {
  position: fixed;
  left: 0; right: 0;
  bottom: calc(var(--tabbar-h) + var(--safe-bottom));
  display: flex; align-items: flex-end; gap: 8px;
  padding: 10px 12px;
  background: rgba(247,244,237,0.95);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  z-index: 5;
}
.record-bar[hidden] { display: none; }
.record-bar textarea {
  flex: 1;
  border: 0; outline: 0;
  background: var(--card);
  border-radius: 16px;
  padding: 10px 14px;
  font: inherit; font-size: 15px; line-height: 1.4;
  color: var(--ink);
  resize: none;
  max-height: 88px;
  box-shadow: 0 2px 8px rgba(20,32,28,0.06);
}
.record-bar textarea::placeholder { color: #B8B0A0; }
.save-round {
  width: 40px; height: 40px; border-radius: 50%;
  border: 0; cursor: pointer; flex-shrink: 0;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--ink-2) 0%, #2A333D 100%);
  color: #fff;
  box-shadow: 0 4px 12px rgba(61,74,86,0.20);
}
.save-round:active { transform: scale(0.94); }
.send-btn, .mic-mini {
  width: 40px; height: 40px; border-radius: 50%;
  border: 0; cursor: pointer;
  display: grid; place-items: center;
  flex-shrink: 0;
}
.send-btn {
  background: linear-gradient(135deg, var(--ink-2) 0%, #2A333D 100%);
  color: #fff;
  box-shadow: 0 4px 12px rgba(61,74,86,0.20);
}
.mic-mini {
  background: var(--card);
  color: var(--ink-2);
  box-shadow: 0 2px 8px rgba(20,32,28,0.06);
}

/* ===== 浮起麦克风（首页专用） ===== */
.fab {
  position: fixed;
  right: 20px;
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 24px);
  width: 56px; height: 56px;
  border-radius: 50%;
  border: 0;
  background: linear-gradient(135deg, var(--ink-2) 0%, #2A333D 100%);
  color: #fff;
  display: grid; place-items: center;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(61,74,86,0.30);
  z-index: 8;
  transition: transform 0.15s;
}
.fab:active { transform: scale(0.92); }
.fab[hidden] { display: none; }

/* ===== 录音中状态 ===== */
@keyframes recpulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(192, 57, 43, 0.45); }
  50% { box-shadow: 0 0 0 9px rgba(192, 57, 43, 0); }
}
#voiceBtn.recording, .mic-mini.recording, #fabMic.recording {
  background: #C0392B !important;
  color: #fff !important;
  animation: recpulse 1.3s infinite;
}

/* ===== 底栏 4 tab ===== */
.tabbar {
  position: relative;
  flex: 0 0 auto;
  height: calc(var(--tabbar-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  display: flex;
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  z-index: 9;
}
.tab {
  flex: 1;
  border: 0; background: transparent;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px;
  color: var(--muted);
  font: inherit; font-size: 11px;
  cursor: pointer;
  padding: 6px 0;
  position: relative;
}
.tab.active { color: var(--ink-2); }
.tab.active::after {
  content: ''; position: absolute; bottom: 4px;
  width: 18px; height: 2px; border-radius: 2px;
  background: var(--ink-2);
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  background: rgba(31,41,51,0.92);
  color: #fff;
  font-size: 14px;
  padding: 10px 18px;
  border-radius: 10px;
  z-index: 100;
  pointer-events: none;
  animation: toastIn 0.2s ease;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, calc(-50% + 6px)); } }

/* ===== 横屏/小屏安全 ===== */
@media (max-width: 360px) {
  .brand-name { font-size: 16px; }
  .page-title { font-size: 22px; }
  .hero-title { font-size: 15px; }
}

/* ===== 鸟社区弹层（底栏 sheet） ===== */
.sheet {
  position: fixed; inset: 0;
  z-index: 50;
  display: flex; align-items: flex-end;
}
.sheet[hidden] { display: none; }
.sheet-mask {
  position: absolute; inset: 0;
  background: rgba(20,32,28,0.42);
  backdrop-filter: blur(2px);
  animation: fadein 0.18s ease;
}
.sheet-body {
  position: relative;
  width: 100%;
  max-height: 70vh;
  background: var(--paper);
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -8px 24px rgba(20,32,28,0.18);
  display: flex; flex-direction: column;
  padding-bottom: var(--safe-bottom);
  animation: sheetUp 0.22s ease;
}
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: none; } }
.sheet-head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--line);
}
.sheet-mark {
  width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center;
  color: #fff; font-weight: 700; font-size: 13px;
  font-family: "Songti SC", serif;
  box-shadow: 0 2px 6px rgba(0,0,0,0.10);
}
.sheet-mark.red { background: var(--red-bird); }
.sheet-mark.blue { background: var(--blue-bird); }
.sheet-mark.yellow { background: var(--yellow-bird); }
.sheet-title { font-size: 16px; font-weight: 600; flex: 1; }
.sheet-close {
  width: 32px; height: 32px; border-radius: 50%;
  border: 0; background: rgba(61,74,86,0.06);
  color: var(--ink-2); font-size: 20px; line-height: 1;
  cursor: pointer;
}
.sheet-posts {
  list-style: none; padding: 8px 16px 16px; margin: 0;
  overflow-y: auto;
  max-height: calc(70vh - 60px);
}
.sheet-posts li {
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
  line-height: 1.55;
}
.sheet-posts li:last-child { border-bottom: 0; }
.sheet-post-meta {
  font-size: 12px; color: var(--muted);
  margin-bottom: 4px;
}

/* ===== 右侧抽屉（点 logo 打开） ===== */
.brand { cursor: pointer; }
.brand:active { opacity: 0.7; }

.drawer {
  position: fixed; inset: 0;
  z-index: 60;
  display: flex; justify-content: flex-end;
}
.drawer[hidden] { display: none; }
.drawer-mask {
  position: absolute; inset: 0;
  background: rgba(20, 32, 28, 0.42);
  backdrop-filter: blur(2px);
  animation: fadein 0.18s ease;
}
.drawer-body {
  position: relative;
  width: 82%; max-width: 340px;
  height: 100%;
  background: var(--paper);
  box-shadow: -8px 0 32px rgba(20, 32, 28, 0.18);
  padding: calc(env(safe-area-inset-top, 0px) + 18px) 20px 24px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex; flex-direction: column;
  animation: drawerIn 0.24s ease;
}
@keyframes drawerIn { from { transform: translateX(100%); } to { transform: none; } }
.drawer-close {
  position: absolute; top: 14px; right: 14px;
  width: 32px; height: 32px; border-radius: 50%;
  border: 0; background: rgba(61,74,86,0.06);
  color: var(--ink-2); font-size: 22px; line-height: 1;
  cursor: pointer; flex-shrink: 0;
}
.drawer-close:active { background: rgba(61,74,86,0.12); }
.drawer-brand { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 4px 0 18px; }
.drawer-logo {
  width: 72px; height: 72px; border-radius: 50%;
  object-fit: cover; background: var(--card);
  box-shadow: 0 6px 18px rgba(20,32,28,0.14);
}
.drawer-name {
  font-family: "Songti SC", "STKaiti", serif;
  font-weight: 700; font-size: 20px; margin-top: 12px;
  letter-spacing: -0.01em;
}
.drawer-sub { font-size: 12px; color: var(--muted); margin-top: 4px; }
.drawer-row {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 14px; margin-bottom: 10px;
}
.drawer-label { font-size: 14px; color: var(--ink-2); }
.drawer-value {
  font-size: 15px; font-weight: 700; color: var(--bird-deep);
  font-variant-numeric: tabular-nums;
}
.drawer-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; border: 0; border-radius: 12px;
  padding: 12px; font: inherit; font-size: 15px; font-weight: 500;
  cursor: pointer;
  background: linear-gradient(135deg, var(--ink-2) 0%, #2A333D 100%);
  color: #fff;
  box-shadow: 0 4px 12px rgba(61,74,86,0.20);
}
.drawer-btn:active { transform: scale(0.98); }
.drawer-btn.busy { opacity: 0.7; }
.drawer-status {
  font-size: 13px; color: var(--muted);
  text-align: center; min-height: 18px;
  margin: 10px 2px 2px;
}
.drawer-status.ok { color: var(--leaf); }
.drawer-status.new { color: var(--bird-deep); font-weight: 600; }
.drawer-sep { height: 1px; background: var(--line); margin: 14px 0 12px; }
.drawer-section-title {
  font-size: 13px; font-weight: 600; color: var(--ink-2);
  margin-bottom: 10px;
}
.changelog { list-style: none; padding: 0; margin: 0; }
.changelog li {
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.changelog li:last-child { border-bottom: 0; }
.cl-head {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 4px;
}
.cl-ver {
  font-size: 13px; font-weight: 700; color: var(--bird-deep);
  font-variant-numeric: tabular-nums;
}
.cl-date { font-size: 12px; color: var(--muted); }
.cl-desc { font-size: 13px; color: var(--ink); line-height: 1.55; }
