:root {
  --bg: #f5f6fb;
  --card: #ffffff;
  --text: #1c1b2e;
  --muted: #6b6a85;
  --line: #e7e7f1;
  --primary: #5b5bd6;
  --primary-2: #7c6cff;
  --danger: #d9485f;
  --ok: #17a673;
  --radius: 18px;
  --shadow: 0 10px 30px rgba(31, 30, 70, 0.08);
}

* {
  box-sizing: border-box;
}

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

body {
  min-height: 100dvh;
  background:
    radial-gradient(1200px 600px at 10% -10%, #e9e6ff 0%, transparent 60%),
    radial-gradient(900px 500px at 110% 0%, #e0f2ff 0%, transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
}

.app {
  max-width: 520px;
  margin: 0 auto;
  padding: calc(16px + env(safe-area-inset-top)) 18px
    calc(24px + env(safe-area-inset-bottom));
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 18px;
}

.brand-icon {
  width: 32px;
  height: 32px;
  border-radius: 9px;
}

.brand-sub {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--muted);
  text-transform: uppercase;
  margin-top: 4px;
}

.topbar-actions {
  display: flex;
  gap: 8px;
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.view {
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: fade-in 0.25s ease;
}

@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.hero h1 {
  margin: 8px 0 8px;
  font-size: 28px;
  line-height: 1.25;
  letter-spacing: -0.02em;
}

.hero p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.tabs {
  display: flex;
  gap: 6px;
  padding: 5px;
  margin-bottom: 18px;
  background: #f1f1f9;
  border-radius: 12px;
}

.tab {
  flex: 1;
  padding: 10px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.tab.is-active {
  background: #fff;
  color: var(--text);
  box-shadow: 0 2px 8px rgba(31, 30, 70, 0.08);
}

.form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.field input {
  width: 100%;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfbfe;
  font: inherit;
  font-size: 16px;
  color: var(--text);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  -webkit-appearance: none;
}

.field input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(91, 91, 214, 0.14);
}

.error {
  margin: 0;
  color: var(--danger);
  font-size: 13px;
  line-height: 1.5;
}

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
  text-align: center;
}

.btn {
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 12px 16px;
  font: inherit;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  transition: transform 0.12s, opacity 0.2s, background 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.btn:active {
  transform: scale(0.985);
}

.btn:disabled {
  opacity: 0.6;
  cursor: default;
}

.btn-block {
  width: 100%;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary-2), var(--primary));
  color: #fff;
  box-shadow: 0 8px 20px rgba(91, 91, 214, 0.28);
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.7);
  border-color: var(--line);
  color: var(--muted);
  font-size: 13px;
  padding: 8px 12px;
}

.btn-soft {
  background: #f0efff;
  color: var(--primary);
  font-size: 14px;
  padding: 9px 16px;
}

.btn-danger {
  background: #fff0f2;
  color: var(--danger);
}

.user-card {
  display: flex;
  align-items: center;
  gap: 14px;
}

.user-meta {
  min-width: 0;
}

.user-name {
  margin: 0;
  font-size: 17px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.avatar {
  flex: none;
  width: 46px;
  height: 46px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 800;
  font-size: 20px;
  background: linear-gradient(135deg, #8b7bff, #5b5bd6);
}

.avatar-lg {
  width: 56px;
  height: 56px;
  font-size: 24px;
  border-radius: 16px;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.section-intro h2 {
  margin: 6px 0 6px;
  font-size: 20px;
  letter-spacing: -0.01em;
}

.section-intro p {
  margin: 0;
}

.actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.action-card {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
  text-align: left;
  font: inherit;
  color: var(--text);
  cursor: pointer;
  transition: transform 0.12s, border-color 0.2s;
}

.action-card:active {
  transform: scale(0.99);
  border-color: #cfcdf7;
}

.action-icon {
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 20px;
  color: var(--primary);
  background: #f0efff;
}

.action-text {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.action-text strong {
  font-size: 16px;
}

.action-text small {
  color: var(--muted);
  font-size: 13px;
}

.code-panel {
  text-align: center;
}

.code-value {
  margin: 10px 0 14px;
  font-family: "SF Mono", "Roboto Mono", Menlo, Consolas, monospace;
  font-size: clamp(26px, 8vw, 34px);
  font-weight: 800;
  letter-spacing: 0.14em;
  color: var(--primary);
  padding-left: 0.14em;
  white-space: nowrap;
}

.code-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.paired-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: center;
}

.pair-line {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  text-align: left;
}

.pair-meta {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.paired-note {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 13px;
}

.footer {
  text-align: center;
  padding-top: 8px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(28px + env(safe-area-inset-bottom));
  transform: translate(-50%, 16px);
  max-width: calc(100vw - 40px);
  padding: 11px 18px;
  border-radius: 999px;
  background: rgba(28, 27, 46, 0.92);
  color: #fff;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 10;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

[hidden] {
  display: none !important;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101018;
    --card: #191925;
    --text: #f2f1fa;
    --muted: #a5a3bd;
    --line: #2a2a3d;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  }

  body {
    background:
      radial-gradient(1200px 600px at 10% -10%, #241f45 0%, transparent 60%),
      radial-gradient(900px 500px at 110% 0%, #102a3d 0%, transparent 55%),
      var(--bg);
  }

  .tabs {
    background: #14141f;
  }

  .tab.is-active {
    background: #232333;
    color: var(--text);
  }

  .field input {
    background: #12121b;
  }

  .btn-ghost {
    background: rgba(25, 25, 37, 0.7);
  }

  .btn-soft,
  .action-icon {
    background: #232343;
  }

  .btn-danger {
    background: #2a1a20;
  }
}

/* ---------- 应用主界面 ---------- */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

#app-shell {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  gap: 12px;
}

.tab-views {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.tab-view {
  display: flex;
  flex-direction: column;
  gap: 14px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-bottom: 6px;
}

.tab-chat {
  overflow: hidden;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.section-head h2,
.section-head h3 {
  margin: 0;
  font-size: 19px;
  letter-spacing: -0.01em;
}

.section-head h3 {
  font-size: 16px;
}

.tabbar {
  display: flex;
  gap: 4px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.tabbar button {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 4px;
  border: 0;
  border-radius: 13px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.tabbar button.is-active {
  background: #f0efff;
  color: var(--primary);
}

.tab-icon {
  font-size: 17px;
  line-height: 1;
}

/* ---------- 聊天列表 ---------- */
.chat-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.contact-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.contact {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card);
  box-shadow: var(--shadow);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: transform 0.12s;
}

.contact:active {
  transform: scale(0.995);
}

.contact-avatar {
  position: relative;
  display: flex;
  flex: none;
}

.contact-main {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  min-width: 0;
}

.contact-name {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 15px;
  font-weight: 700;
}

.contact-preview {
  overflow: hidden;
  color: var(--muted);
  font-size: 12.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.contact-time {
  flex: none;
  color: var(--muted);
  font-size: 11px;
}

.online-dot {
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 11px;
  height: 11px;
  border: 2px solid var(--card);
  border-radius: 50%;
  background: #2fbf71;
}

.tag {
  padding: 2px 7px;
  border-radius: 999px;
  background: #f0efff;
  color: var(--primary);
  font-size: 10px;
  font-weight: 700;
}

.unread {
  flex: none;
  display: grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}

.avatar-sm {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  font-size: 16px;
}

.requests {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.requests:empty {
  display: none;
}

.request-card {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
}

.request-text {
  flex: 1;
  font-size: 13px;
  line-height: 1.4;
}

.request-card .btn {
  padding: 7px 12px;
  font-size: 13px;
}

/* ---------- 会话 ---------- */
.conversation {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
  min-height: 0;
}

.conversation-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.conversation-meta {
  display: flex;
  flex-direction: column;
  gap: 1px;
  flex: 1;
  min-width: 0;
}

.conversation-meta strong {
  overflow: hidden;
  font-size: 16px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#peer-status.is-online {
  color: #2fbf71;
}

.conversation-actions {
  display: flex;
  gap: 6px;
}

.icon-btn {
  flex: none;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  color: var(--text);
  font-family: inherit;
  font-size: 17px;
  cursor: pointer;
}

.icon-btn:active {
  transform: scale(0.96);
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 4px 2px;
}

.msg {
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-width: 78%;
}

.msg-in {
  align-self: flex-start;
  align-items: flex-start;
}

.msg-out {
  align-self: flex-end;
  align-items: flex-end;
}

.bubble {
  max-width: 100%;
  padding: 9px 13px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card);
  box-shadow: 0 2px 8px rgba(31, 30, 70, 0.04);
  font-size: 15px;
  line-height: 1.45;
  word-break: break-word;
}

.msg-out .bubble {
  border-color: transparent;
  background: linear-gradient(135deg, var(--primary-2), var(--primary));
  color: #fff;
}

.bubble audio {
  display: block;
  width: 210px;
  max-width: 100%;
  height: 36px;
  margin: 2px 0;
}

.msg-time {
  color: var(--muted);
  font-size: 10px;
}

.msg-out .msg-time {
  text-align: right;
}

.composer {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 2px;
}

.composer-input {
  flex: 1;
  min-width: 0;
  height: 44px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  color: var(--text);
  font: inherit;
  font-size: 16px;
  outline: none;
}

.composer-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(91, 91, 214, 0.14);
}

.mic.is-recording {
  border-color: #ffc9d4;
  background: #ffe8ee;
  color: var(--danger);
}

.recording-hint {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 8px);
  padding: 6px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--danger);
  font-size: 12px;
  text-align: center;
}

.empty-hint {
  padding: 16px 0;
  text-align: center;
}

.form.compact {
  padding: 14px;
}

/* ---------- 位置 ---------- */
.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  cursor: pointer;
}

.switch-text {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.switch {
  flex: none;
  position: relative;
  width: 48px;
  height: 28px;
  margin: 0;
  border-radius: 999px;
  background: #d8d7e6;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  transition: background 0.2s;
}

.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s;
}

.switch:checked {
  background: var(--primary);
}

.switch:checked::after {
  transform: translateX(20px);
}

.radar-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

#radar {
  display: block;
  width: min(100%, 300px);
  aspect-ratio: 1;
}

.location-info {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.location-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
}

.location-row > span:last-child {
  overflow: hidden;
  color: var(--text);
  font-size: 13px;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* ---------- 日程 ---------- */
.calendar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  padding-bottom: 6px;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.day-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

.day-cell.is-outside {
  color: #c5c4d6;
}

.day-cell.is-today {
  background: #f0efff;
}

.day-cell.is-selected {
  background: var(--primary);
  color: #fff;
}

.day-number {
  font-size: 13px;
}

.day-dots {
  display: flex;
  gap: 2px;
}

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

.event-list {
  display: flex;
  flex-direction: column;
}

.event-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 11px 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.event-row:last-child {
  border-bottom: 0;
}

.event-time {
  flex: none;
  min-width: 92px;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.event-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.event-main strong {
  font-size: 14px;
}

.event-main small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- 我的 ---------- */
.friends-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 6px;
}

.friend-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
}

.friend-name {
  flex: 1;
  font-size: 14px;
}

.danger-text {
  color: var(--danger);
  font-size: 13px;
  padding: 7px 12px;
}

/* ---------- 弹出层 ---------- */
.sheet {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
  background: rgba(20, 19, 40, 0.45);
}

.sheet-card {
  width: 100%;
  max-width: 520px;
  max-height: 86dvh;
  overflow-y: auto;
  padding: 18px;
  border-radius: 22px;
  background: var(--card);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.28);
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.sheet-head h3 {
  margin: 0;
  font-size: 18px;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.sheet-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 4px;
}

/* ---------- 通话 ---------- */
.call-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: #141327;
  color: #fff;
}

.call-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
  max-width: 420px;
}

.call-card h3 {
  margin: 0;
  font-size: 22px;
}

.call-card .muted {
  color: rgba(255, 255, 255, 0.65);
}

.call-remote {
  width: 100%;
  max-height: 52dvh;
  border-radius: 18px;
  background: #000;
  object-fit: cover;
}

.call-local {
  position: absolute;
  top: 120px;
  right: 10px;
  width: 92px;
  height: 124px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 14px;
  background: #000;
  object-fit: cover;
}

.call-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 8px;
}

.call-actions .btn-danger {
  background: #ff4d6a;
  color: #fff;
}

.call-actions .btn-soft {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}

body.call-open {
  overflow: hidden;
}

/* ---------- 深色模式补充 ---------- */
@media (prefers-color-scheme: dark) {
  .tabbar {
    background: rgba(25, 25, 37, 0.92);
  }

  .tabbar button.is-active,
  .tag,
  .day-cell.is-today {
    background: #232343;
  }

  .recording-hint {
    background: rgba(20, 20, 32, 0.92);
  }

  .sheet-card {
    background: #191925;
  }
}


/* ---------- 配对提示 ---------- */
.pairing-prompt {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.pairing-prompt-text {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.pairing-prompt .btn {
  flex: none;
}

/* ---------- 相册 ---------- */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.photo-tile {
  padding: 0;
  border: 0;
  border-radius: 12px;
  overflow: hidden;
  aspect-ratio: 1;
  background: #ececf6;
  cursor: pointer;
}

.photo-tile img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-viewer {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  background: rgba(10, 10, 20, 0.95);
}

.photo-viewer-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  color: #fff;
}

.photo-viewer-bar .muted {
  flex: 1;
  min-width: 140px;
  color: rgba(255, 255, 255, 0.65);
}

#photo-image {
  flex: 1;
  min-height: 0;
  width: 100%;
  object-fit: contain;
}

body.viewer-open {
  overflow: hidden;
}

/* ---------- 地图 ---------- */
.map-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
}

.map-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.map-select {
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  color: var(--text);
  font: inherit;
  font-size: 13px;
}

.map {
  height: 320px;
  border-radius: 14px;
  overflow: hidden;
  background: #eef0f7;
}

.map-icon {
  border: 0;
  background: transparent;
}

.map-dot {
  display: block;
  width: 20px;
  height: 20px;
  border: 3px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(91, 91, 214, 0.35), 0 4px 10px rgba(0, 0, 0, 0.2);
}

.map-dot-me {
  background: #5b5bd6;
}

.map-dot-partner {
  background: #d9485f;
}

.leaflet-container {
  font: inherit;
  font-size: 12px;
}

.leaflet-control-attribution {
  font-size: 10px;
}

/* ---------- 工具类 ---------- */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

@media (prefers-color-scheme: dark) {
  .photo-tile {
    background: #232333;
  }

  .map {
    background: #1a1a28;
  }

  .map-select {
    background: #232333;
  }

  .leaflet-container {
    background: #1a1a28;
  }
}


/* ---------- 色色打卡悬浮球 ---------- */
.checkin-ball {
  position: fixed;
  right: 16px;
  bottom: calc(96px + env(safe-area-inset-bottom));
  z-index: 25;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  width: 64px;
  height: 64px;
  border: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ff9db6, #ff4d79);
  color: #fff;
  box-shadow: 0 10px 24px rgba(255, 77, 121, 0.45);
  cursor: pointer;
  font: inherit;
}

.checkin-ball:active {
  transform: scale(0.96);
}

.checkin-ball-heart {
  font-size: 24px;
  line-height: 1;
}

.checkin-ball-timer {
  font-size: 10px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

.checkin-ball.is-active {
  animation: checkin-pulse 1.6s ease-in-out infinite;
}

@keyframes checkin-pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(255, 77, 121, 0.5), 0 10px 24px rgba(255, 77, 121, 0.45);
  }
  50% {
    box-shadow: 0 0 0 14px rgba(255, 77, 121, 0), 0 10px 24px rgba(255, 77, 121, 0.45);
  }
}

/* ---------- 日程里的打卡记录 ---------- */
.checkin-row {
  border-left: 3px solid #ff8aa4;
  padding-left: 10px;
}

.checkin-row .event-main strong {
  color: #d9485f;
}

.day-dot.is-checkin {
  background: #ff5c80;
  opacity: 1;
}


/* ---------- 悬浮球：常驻 / 拖动 / 互动 ---------- */
.checkin-ball {
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, #8b7bff, #5b5bd6);
  box-shadow: 0 10px 24px rgba(91, 91, 214, 0.42);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: grab;
  transition: background 0.25s, box-shadow 0.25s;
}

.checkin-ball:active {
  cursor: grabbing;
}

.checkin-ball.is-checkin {
  background: radial-gradient(circle at 35% 30%, #ff9db6, #ff4d79);
  box-shadow: 0 10px 24px rgba(255, 77, 121, 0.45);
}

.checkin-ball.anim-shake {
  animation: ball-shake 0.7s ease;
}

.checkin-ball.anim-flash {
  animation: ball-flash 0.7s ease;
}

.checkin-ball.anim-bounce {
  animation: ball-bounce 0.7s ease;
}

.checkin-ball.anim-heartbeat {
  animation: ball-heartbeat 0.8s ease;
}

@keyframes ball-shake {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  15% { transform: translate(-5px, 2px) rotate(-9deg); }
  30% { transform: translate(5px, -2px) rotate(9deg); }
  45% { transform: translate(-5px, 2px) rotate(-7deg); }
  60% { transform: translate(5px, -2px) rotate(7deg); }
  75% { transform: translate(-3px, 1px) rotate(-3deg); }
}

@keyframes ball-flash {
  0%, 100% { filter: none; }
  20% { filter: brightness(1.9) saturate(1.5); }
  40% { filter: none; }
  60% { filter: brightness(1.9) saturate(1.5); }
  80% { filter: none; }
}

@keyframes ball-bounce {
  0%, 100% { transform: translateY(0); }
  30% { transform: translateY(-16px); }
  50% { transform: translateY(0); }
  65% { transform: translateY(-8px); }
  80% { transform: translateY(0); }
}

@keyframes ball-heartbeat {
  0%, 100% { transform: scale(1); }
  15% { transform: scale(1.16); }
  30% { transform: scale(1); }
  45% { transform: scale(1.12); }
  60% { transform: scale(1); }
}

/* 悬浮球气泡 */
.ball-bubble {
  position: fixed;
  z-index: 26;
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-width: 220px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 10px 30px rgba(31, 30, 70, 0.18);
  color: var(--text);
  font-size: 14px;
  line-height: 1.4;
  word-break: break-word;
  pointer-events: none;
  animation: bubble-in 0.2s ease;
}

.ball-bubble small {
  color: var(--muted);
  font-size: 10px;
  text-align: right;
}

@keyframes bubble-in {
  from {
    opacity: 0;
    transform: translateY(5px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@media (prefers-color-scheme: dark) {
  .ball-bubble {
    background: rgba(32, 32, 48, 0.98);
  }
}


/* ---------- 悬浮球留言卡片 ---------- */
.checkin-ball {
  width: 68px;
  height: 68px;
}

.ball-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  display: grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border: 2px solid #fff;
  border-radius: 999px;
  background: #ff3b5c;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
}

.ball-cards {
  position: fixed;
  z-index: 24;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 214px;
  max-height: 45vh;
  overflow-y: auto;
  padding: 6px;
  border-radius: 16px;
  background: rgba(245, 246, 251, 0.55);
  box-shadow: 0 12px 32px rgba(31, 30, 70, 0.12);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.ball-card {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 4px 14px rgba(31, 30, 70, 0.08);
  animation: card-in 0.22s ease;
  user-select: none;
  -webkit-user-select: none;
  touch-action: pan-y;
}

.ball-card-text {
  margin: 0;
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
  word-break: break-word;
}

.ball-card-meta {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 10px;
  text-align: right;
}

.ball-cards-hint {
  padding: 2px 4px 4px;
  color: var(--muted);
  font-size: 10px;
  text-align: center;
}

@keyframes card-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ---------- 更大的动作幅度 ---------- */
.checkin-ball.anim-shake {
  animation: ball-shake 0.9s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

.checkin-ball.anim-flash {
  animation: ball-flash 1.1s ease;
}

.checkin-ball.anim-bounce {
  animation: ball-bounce 1.2s ease;
}

.checkin-ball.anim-heartbeat {
  animation: ball-heartbeat 0.95s ease;
}

@keyframes ball-shake {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  10% { transform: translate(-16px, 6px) rotate(-22deg); }
  25% { transform: translate(16px, -6px) rotate(22deg); }
  40% { transform: translate(-14px, 5px) rotate(-18deg); }
  55% { transform: translate(14px, -5px) rotate(18deg); }
  70% { transform: translate(-10px, 3px) rotate(-12deg); }
  85% { transform: translate(10px, -3px) rotate(12deg); }
}

@keyframes ball-flash {
  0%, 100% { filter: none; transform: scale(1); }
  14% { filter: brightness(4) saturate(2.4); transform: scale(1.1); }
  28% { filter: none; transform: scale(1); }
  42% { filter: brightness(4) saturate(2.4); transform: scale(1.1); }
  56% { filter: none; transform: scale(1); }
  70% { filter: brightness(3.4) saturate(2); transform: scale(1.07); }
  84% { filter: none; transform: scale(1); }
}

@keyframes ball-bounce {
  0%, 100% { transform: scale(1); }
  16% { transform: scale(1.28); }
  33% { transform: scale(1); }
  50% { transform: scale(1.28); }
  66% { transform: scale(1); }
  83% { transform: scale(1.28); }
}

@keyframes ball-heartbeat {
  0%, 100% { transform: scale(1); }
  12% { transform: scale(1.55); }
  24% { transform: scale(1); }
  36% { transform: scale(1.4); }
  50% { transform: scale(1); }
  62% { transform: scale(1.25); }
  74% { transform: scale(1); }
}

/* ---------- 地图状态 ---------- */
.map-wrap {
  position: relative;
}

.map-status {
  position: absolute;
  inset: 0;
  z-index: 500;
  display: grid;
  place-items: center;
  padding: 16px;
  border-radius: 14px;
  background: rgba(245, 246, 251, 0.86);
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.map-status[hidden] {
  display: none;
}

.map-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.map-actions .btn {
  padding: 6px 10px;
  font-size: 12px;
}

@media (prefers-color-scheme: dark) {
  .ball-cards {
    background: rgba(20, 20, 32, 0.6);
  }

  .ball-card {
    background: rgba(32, 32, 48, 0.98);
  }

  .map-status {
    background: rgba(26, 26, 40, 0.88);
  }
}


/* ---------- 悬浮球自定义外观 ---------- */
.checkin-ball {
  overflow: hidden;
  transition: background 0.25s, box-shadow 0.25s, opacity 0.2s;
}

.checkin-ball.is-snapping {
  transition: left 0.3s cubic-bezier(0.2, 0.9, 0.3, 1), top 0.3s cubic-bezier(0.2, 0.9, 0.3, 1),
    background 0.25s, box-shadow 0.25s, opacity 0.2s;
}

.checkin-ball[data-shape="circle"] {
  border-radius: 50%;
}

.checkin-ball[data-shape="rounded"] {
  border-radius: 20px;
}

.checkin-ball[data-shape="original"] {
  border-radius: 0;
}

.checkin-ball.has-image {
  background: transparent;
  box-shadow: 0 10px 24px rgba(31, 30, 70, 0.18);
}

.checkin-ball.has-image[data-shape="original"] {
  overflow: visible;
  box-shadow: none;
}

.ball-custom-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

.checkin-ball[data-shape="original"] .ball-custom-image {
  object-fit: contain;
}

/* 设置项 */
.card > .field {
  margin-top: 12px;
}

.range {
  width: 100%;
  accent-color: var(--primary);
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.ball-image-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.ball-image-preview {
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 12px;
  object-fit: cover;
  background: #f2f2f8;
}

/* ---------- 登录设备 ---------- */
.session-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}

.session-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.session-row:last-child {
  border-bottom: 0;
}

.session-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.session-info strong {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
}

.session-row .btn {
  flex: none;
  padding: 6px 10px;
  font-size: 12px;
}

/* ---------- 卡片：自适应大小 / 滑动删除 / 颜色 ---------- */
.ball-cards {
  width: max-content;
  max-width: min(300px, 84vw);
  padding: 9px;
  align-items: flex-end;
}

.ball-card-shell {
  position: relative;
  width: fit-content;
  max-width: 100%;
  border-radius: 14px;
  overflow: hidden;
  flex: none;
}

.ball-card {
  position: relative;
  z-index: 1;
  width: fit-content;
  min-width: 108px;
  max-width: 270px;
  padding: 14px 16px;
  transform: translateX(var(--swipe, 0px));
  transition: transform 0.18s ease;
  touch-action: pan-y;
}

.ball-card-text {
  color: inherit;
  font-size: 16px;
}

.ball-card-meta {
  color: inherit;
  opacity: 0.7;
}

.ball-card-delete {
  position: absolute;
  top: 0;
  bottom: 0;
  z-index: 0;
  display: none;
  width: 76px;
  border: 0;
  background: #ff4d6a;
  color: #fff;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.ball-card-shell.swipe-left .ball-card-delete,
.ball-card-shell.open-left .ball-card-delete {
  display: block;
  right: 0;
}

.ball-card-shell.swipe-right .ball-card-delete,
.ball-card-shell.open-right .ball-card-delete {
  display: block;
  left: 0;
}


/* ---------- 闲置吸附：变淡变小，操作时恢复 ---------- */
.checkin-ball {
  transition: background 0.25s, box-shadow 0.25s, opacity 0.42s ease,
    scale 0.42s cubic-bezier(0.2, 0.9, 0.3, 1);
}

.checkin-ball.is-docked {
  opacity: var(--dock-opacity, 0.3);
  scale: 0.7;
}

.checkin-ball.is-snapping {
  transition: left 0.34s cubic-bezier(0.2, 0.9, 0.3, 1),
    top 0.34s cubic-bezier(0.2, 0.9, 0.3, 1), background 0.25s, box-shadow 0.25s,
    opacity 0.42s ease, scale 0.42s cubic-bezier(0.2, 0.9, 0.3, 1);
}


/* ---------- 悬浮球大小可调 ---------- */
.checkin-ball {
  width: var(--ball-size, 68px);
  height: var(--ball-size, 68px);
}

.checkin-ball-heart {
  font-size: calc(var(--ball-size, 68px) * 0.36);
}

.checkin-ball.is-docked {
  scale: var(--dock-scale, 0.7);
}


/* ---------- 卡片鲜艳配色 / 加粗 / 逐条弹出 ---------- */
.checkin-ball {
  z-index: 1200;
}

.ball-cards {
  z-index: 1190;
}

.toast {
  z-index: 1300;
}

.ball-card {
  transition: background-color 0.3s ease, color 0.3s ease, transform 0.18s ease;
  animation: card-pop 0.32s cubic-bezier(0.2, 0.9, 0.25, 1.1) backwards;
  animation-delay: calc(var(--i, 0) * 45ms);
}

.ball-card-text {
  font-size: 15px;
  font-weight: 700;
}

.ball-card-meta {
  font-weight: 600;
}

@keyframes card-pop {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.82);
  }
  to {
    opacity: 1;
    transform: none;
  }
}


/* toast 不遮挡悬浮球，但仍在卡片之上 */
.toast {
  z-index: 1195;
}


/* 卡片逐条弹出：间隔更从容、过渡更柔和 */
.ball-card {
  animation-duration: 0.44s;
  animation-timing-function: cubic-bezier(0.22, 0.9, 0.28, 1.06);
  animation-delay: calc(var(--i, 0) * 90ms);
}

.ball-cards {
  gap: 10px;
}


/* ---------- 底部可折叠的定位校准 ---------- */
details.collapsible {
  padding: 0;
}

details.collapsible > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 16px 18px;
  list-style: none;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

details.collapsible > summary::-webkit-details-marker {
  display: none;
}

details.collapsible > summary small {
  font-weight: 400;
}

details.collapsible > summary::after {
  content: "▾";
  color: var(--muted);
  font-weight: 400;
  transition: transform 0.2s ease;
}

details.collapsible[open] > summary::after {
  transform: rotate(180deg);
}

details.collapsible .details-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 0 18px 16px;
}


.auto-share-row {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}


/* ---------- 气泡消息 ---------- */
.ball-bubble {
  position: fixed;
  z-index: 1210;
  max-width: min(72vw, 260px);
  padding: 10px 14px;
  border-radius: 14px;
  background: var(--surface, #ffffff);
  color: var(--text, #1c1b2e);
  border: 1px solid var(--line, #e5e4ef);
  box-shadow: 0 8px 24px rgba(28, 27, 46, 0.16);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  text-align: center;
  transform: translateX(-50%);
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}

.ball-bubble.is-visible {
  opacity: 1;
}

.ball-bubble::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -7px;
  width: 12px;
  height: 12px;
  background: inherit;
  border-right: 1px solid var(--line, #e5e4ef);
  border-bottom: 1px solid var(--line, #e5e4ef);
  transform: translateX(-50%) rotate(45deg);
}

/* ---------- 日历今天/月视图 ---------- */
#calendar-view-toggle {
  margin-left: auto;
  white-space: nowrap;
}

.calendar-head {
  gap: 8px;
}

@media (max-width: 360px) {
  #calendar-view-toggle {
    font-size: 12px;
    padding: 4px 8px;
  }
}


/* ---------- 悬浮球渐变 / 环状配色 ---------- */
.checkin-ball {
  background:
    radial-gradient(circle at 30% 24%, rgba(255, 255, 255, 0.55), transparent 42%),
    linear-gradient(135deg, var(--ball-a, #8b7bff), var(--ball-b, #ff8fb1));
  box-shadow: 0 12px 28px rgba(60, 40, 120, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.checkin-ball,
.checkin-ball * {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.checkin-ball.is-checkin {
  background:
    radial-gradient(circle at 30% 24%, rgba(255, 255, 255, 0.5), transparent 42%),
    linear-gradient(135deg, #ff9db6, #ff4d79);
  box-shadow: 0 12px 28px rgba(255, 77, 121, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.checkin-ball[data-style="ring"]:not(.is-checkin) {
  background: conic-gradient(from 220deg, var(--ball-a), var(--ball-b), var(--ball-a));
  box-shadow: 0 10px 26px rgba(60, 40, 120, 0.28);
  -webkit-mask: radial-gradient(circle at 50% 50%, transparent 0 52%, #000 53%);
  mask: radial-gradient(circle at 50% 50%, transparent 0 52%, #000 53%);
}

.checkin-ball[data-style="ring"]:not(.is-checkin)::before {
  display: none;
}

.checkin-ball.has-image {
  background: transparent;
  box-shadow: 0 10px 24px rgba(31, 30, 70, 0.18);
}

.checkin-ball.has-image::before {
  display: none;
}

.ball-custom-image {
  z-index: 1;
}

.checkin-ball-timer {
  position: relative;
  z-index: 2;
}

.ball-badge {
  z-index: 3;
}

.ball-color-row {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

.ball-color-row label {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
}

.ball-color-row input[type="color"] {
  width: 40px;
  height: 28px;
  padding: 0;
  border: 0;
  background: transparent;
}


/* ---------- 设置里的球体配色预览 ---------- */
.ball-color-preview-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 10px 0 4px;
}

.ball-color-preview {
  position: relative;
  flex: none;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 30% 24%, rgba(255, 255, 255, 0.55), transparent 42%),
    linear-gradient(135deg, var(--ball-a, #8b7bff), var(--ball-b, #ff8fb1));
  box-shadow: 0 10px 22px rgba(60, 40, 120, 0.3);
}

.ball-color-preview[data-style="ring"] {
  background: conic-gradient(from 220deg, var(--ball-a), var(--ball-b), var(--ball-a));
  -webkit-mask: radial-gradient(circle at 50% 50%, transparent 0 52%, #000 53%);
  mask: radial-gradient(circle at 50% 50%, transparent 0 52%, #000 53%);
}

.ball-color-preview[data-style="ring"]::before {
  display: none;
}


/* ---------- 打卡模式：悬浮球铺开在屏幕中央 ---------- */
.checkin-ball.is-checkin {
  left: 50% !important;
  right: auto !important;
  bottom: auto !important;
  top: 58% !important;
  width: min(56vw, 220px) !important;
  height: min(56vw, 220px) !important;
  transform: translate(-50%, -50%) !important;
  border-radius: 50% !important;
  opacity: 1 !important;
  scale: 1 !important;
  z-index: 1198 !important;
  pointer-events: none;
  background:
    radial-gradient(circle at 30% 24%, rgba(255, 255, 255, 0.5), transparent 42%),
    linear-gradient(135deg, #ff9db6, #ff4d79) !important;
  box-shadow: 0 26px 70px rgba(255, 77, 121, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.checkin-ball.is-checkin .checkin-ball-timer {
  font-size: clamp(28px, 9vw, 46px);
  font-weight: 800;
  letter-spacing: 0.03em;
  text-shadow: 0 2px 12px rgba(120, 20, 50, 0.25);
}

.checkin-ball.is-checkin.anim-shake,
.checkin-ball.is-checkin.anim-bounce,
.checkin-ball.is-checkin.anim-heartbeat,
.checkin-ball.is-checkin.anim-flash {
  animation: none;
}

/* 打卡时页面内容仍可点击，开关不会被球挡住 */
.checkin-ball.is-checkin::before {
  display: none;
}


@media (max-height: 720px) {
  .checkin-ball.is-checkin {
    top: 61% !important;
    width: min(50vw, 190px) !important;
    height: min(50vw, 190px) !important;
  }
}


/* ---------- 色色打卡：计时中 ---------- */
.checkin-ball.is-checkin-active {
  left: 0 !important;
  right: auto !important;
  bottom: auto !important;
  top: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  transform: none !important;
  border-radius: 0 !important;
  opacity: 1 !important;
  scale: 1 !important;
  z-index: 1290 !important;
  pointer-events: auto;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  background:
    radial-gradient(circle at 50% 38%, rgba(255, 77, 121, 0.22), transparent 55%),
    radial-gradient(circle at 12% 86%, rgba(255, 77, 121, 0.12), transparent 42%),
    #08060c !important;
  box-shadow: none !important;
  transition: left 0.5s cubic-bezier(0.2, 0.8, 0.2, 1), top 0.5s cubic-bezier(0.2, 0.8, 0.2, 1),
    width 0.5s cubic-bezier(0.2, 0.8, 0.2, 1), height 0.5s cubic-bezier(0.2, 0.8, 0.2, 1),
    border-radius 0.5s cubic-bezier(0.2, 0.8, 0.2, 1), background 0.35s ease;
}

.checkin-ball.is-checkin-closing {
  transition: left 0.5s cubic-bezier(0.2, 0.8, 0.2, 1), top 0.5s cubic-bezier(0.2, 0.8, 0.2, 1),
    width 0.5s cubic-bezier(0.2, 0.8, 0.2, 1), height 0.5s cubic-bezier(0.2, 0.8, 0.2, 1),
    border-radius 0.5s cubic-bezier(0.2, 0.8, 0.2, 1), background 0.35s ease;
}

.checkin-ball.is-checkin-active .checkin-ball-timer {
  font-size: clamp(64px, 21vw, 140px);
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0.02em;
  color: #ffffff;
  text-shadow: 0 0 36px rgba(255, 77, 121, 0.45);
  font-variant-numeric: tabular-nums;
  position: relative;
  z-index: 2;
}

.checkin-ball.is-checkin-active .ball-badge {
  display: none;
}

.checkin-decor {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.checkin-decor[hidden] {
  display: none;
}

.checkin-heart {
  position: absolute;
  color: rgba(255, 143, 177, 0.58);
  text-shadow: 0 0 26px rgba(255, 77, 121, 0.5);
  animation: checkin-heart-float 6.5s ease-in-out infinite;
}

.checkin-heart.h1 { top: 9%; left: 9%; font-size: 54px; animation-delay: -1.2s; }
.checkin-heart.h2 { top: 16%; right: 11%; font-size: 34px; animation-delay: -3.4s; }
.checkin-heart.h3 { bottom: 18%; left: 14%; font-size: 30px; animation-delay: -2.1s; }
.checkin-heart.h4 { bottom: 10%; right: 10%; font-size: 48px; animation-delay: -4.5s; }
.checkin-heart.h5 { top: 45%; right: 7%; font-size: 22px; animation-delay: -0.6s; }

@keyframes checkin-heart-float {
  0%, 100% { transform: translateY(0) rotate(-6deg) scale(1); opacity: 0.55; }
  50% { transform: translateY(-18px) rotate(6deg) scale(1.08); opacity: 0.85; }
}

.checkin-active-label {
  position: relative;
  z-index: 2;
  color: #ff9db6;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.24em;
}

.checkin-active-label[hidden] {
  display: none;
}

.checkin-close {
  display: none;
  min-width: min(72vw, 300px);
  padding: 16px 30px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, #ff8fb1, #ff3d77);
  color: #ffffff;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.04em;
  box-shadow: 0 14px 34px rgba(255, 61, 119, 0.38);
  position: relative;
  z-index: 2;
}

.checkin-close:not([hidden]) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.checkin-ball.is-checkin-active .checkin-close {
  display: inline-flex;
}

/* 卡片离球稍远，气泡字体略小、贴近球 */
.ball-bubble {
  max-width: min(62vw, 210px);
  padding: 8px 12px;
  font-size: 13px;
}


.checkin-ball.is-checkin-active {
  height: 100dvh !important;
}

/* ---------- 全屏色色打卡：黑底发光爱心 ---------- */
.checkin-ball.is-checkin-active {
  display: block !important;
  background: #000000 !important;
  padding: 0 !important;
}

.checkin-ball.is-checkin-active .checkin-decor {
  display: flex;
}

.checkin-decor {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  pointer-events: none;
}

.checkin-decor::before {
  content: "";
  position: absolute;
  width: min(94vw, 620px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 45, 120, 0.32), transparent 62%);
  filter: blur(30px);
}

.checkin-heart-art {
  position: relative;
  width: min(88vw, 560px);
  height: auto;
  filter: drop-shadow(0 0 22px rgba(255, 45, 120, 0.55)) drop-shadow(0 0 90px rgba(255, 45, 120, 0.4));
  animation: checkin-heart-beat 3.4s ease-in-out infinite;
}

@keyframes checkin-heart-beat {
  0%, 100% { transform: scale(1); }
  14% { transform: scale(1.035); }
  28% { transform: scale(1); }
  42% { transform: scale(1.02); }
  56% { transform: scale(1); }
}

.checkin-ball.is-checkin-active .checkin-active-label {
  position: absolute;
  top: 15%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  color: rgba(255, 157, 192, 0.85);
  font-size: 14px;
  letter-spacing: 0.26em;
  white-space: nowrap;
}

.checkin-ball.is-checkin-active .checkin-ball-timer {
  position: absolute;
  top: 46%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 3;
  font-size: clamp(56px, 18vw, 120px);
  line-height: 1;
  color: #ffffff;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.45), 0 0 34px rgba(255, 45, 120, 0.35);
}

.checkin-ball.is-checkin-active .checkin-close {
  position: absolute;
  top: 71%;
  left: 50%;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: min(70vw, 300px);
  padding: 16px 32px;
  border: 1.5px solid rgba(255, 143, 177, 0.75);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.35);
  color: #ff9dc0;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0.04em;
  box-shadow: 0 0 30px rgba(255, 45, 120, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 4;
}

@media (max-height: 640px) {
  .checkin-ball.is-checkin-active .checkin-active-label {
    top: 10%;
  }

  .checkin-ball.is-checkin-active .checkin-close {
    top: 76%;
    padding: 14px 28px;
    font-size: 17px;
  }
}


/* ---------- 计时中：悬浮球变成小爱心 ---------- */
.checkin-ball.is-checkin-running {
  background: transparent !important;
  box-shadow: none !important;
  border-radius: 50%;
  overflow: visible;
  opacity: 1 !important;
  scale: 1 !important;
  z-index: 1200 !important;
  pointer-events: auto;
}

.checkin-ball.is-checkin-running.is-active {
  animation: none;
}

.checkin-ball.is-checkin-running .ball-custom-image {
  display: none;
}

.checkin-ball.is-checkin-running .checkin-decor {
  display: flex;
  overflow: visible;
}

.checkin-ball.is-checkin-running .checkin-decor::before {
  width: 130%;
  filter: blur(10px);
  background: radial-gradient(circle, rgba(255, 45, 120, 0.4), transparent 65%);
}

.checkin-ball.is-checkin-running .checkin-heart-art {
  width: 94%;
  filter: drop-shadow(0 0 8px rgba(255, 45, 120, 0.7)) drop-shadow(0 0 22px rgba(255, 45, 120, 0.45));
}

.checkin-ball.is-checkin-running .checkin-ball-timer {
  position: absolute;
  left: 50%;
  bottom: 1px;
  transform: translateX(-50%);
  z-index: 3;
  padding: 1px 5px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.5);
  color: #ffffff;
  font-size: 10px;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: 0.02em;
  text-shadow: none;
}

.checkin-ball.is-checkin-running .checkin-active-label,
.checkin-ball.is-checkin-running .checkin-close {
  display: none !important;
}


/* 圆角爱心 + 心电图 */
.checkin-heart-art {
  overflow: visible;
}

.checkin-heart-shape {
  stroke-linejoin: round;
}

.checkin-ecg-base {
  fill: none;
  stroke: rgba(255, 255, 255, 0.42);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.checkin-ecg-pulse {
  fill: none;
  stroke: #ffffff;
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 16 84;
  animation: checkin-ecg-sweep 1.8s linear infinite;
  filter: drop-shadow(0 0 4px rgba(255, 255, 255, 0.8));
}

@keyframes checkin-ecg-sweep {
  from { stroke-dashoffset: 100; }
  to { stroke-dashoffset: 0; }
}

.checkin-ball.is-checkin-running .checkin-heart-art {
  animation: checkin-heart-beat 1.8s ease-in-out infinite;
}


/* ---------- 原生 App 内隐藏网页悬浮球 ---------- */
body.native-app #checkin-ball,
body.native-app #ball-bubble,
body.native-app #ball-cards {
  display: none !important;
}

/* ---------- 底部导航固定 ---------- */
.tab-view {
  position: relative;
  z-index: 0;
  padding-bottom: calc(96px + env(safe-area-inset-bottom));
}

.tabbar {
  position: fixed;
  left: 50%;
  right: auto;
  bottom: calc(10px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(calc(100vw - 24px), 520px);
  margin: 0;
  z-index: 25;
}

@media (min-width: 560px) {
  .tabbar {
    width: 520px;
  }
}


/* 旧浏览器 fallback */
.tab-view {
  padding-bottom: 96px;
  padding-bottom: calc(96px + env(safe-area-inset-bottom));
}

.tabbar {
  bottom: 10px;
  bottom: calc(10px + env(safe-area-inset-bottom));
}

body.native-app .brand { display: none !important; }

.checkin-count-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.checkin-count-row p { margin: 0; }

.checkin-count-row { display: flex; align-items: center; justify-content: flex-start; gap: 12px; }
.checkin-count-value {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 76px; height: 46px; padding: 0 18px;
  border-radius: 14px; color: #fff; font-size: 24px; font-weight: 800;
  background: linear-gradient(135deg, #ff4d8d, #8b5cf6);
  box-shadow: 0 8px 20px rgba(255, 77, 141, 0.35);
}
.checkin-plus-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 60px; height: 46px; padding: 0 16px;
  border: 0; border-radius: 14px; color: #fff; font-size: 20px; font-weight: 800;
  background: linear-gradient(135deg, #ffb800, #ff5f6d);
  box-shadow: 0 8px 20px rgba(255, 128, 64, 0.35);
  cursor: pointer;
}
.checkin-plus-btn:active { transform: scale(0.96); }

.checkin-count-value, .checkin-adjust-input {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 64px; height: 40px; padding: 0 12px;
  border-radius: 12px; border: 1px solid #ddd6ff;
  background: #f0edff; color: var(--text);
  font-size: 15px; font-weight: 700; box-shadow: none;
}
.checkin-adjust-input {
  width: 64px; text-align: center; outline: none;
}
.checkin-adjust-input::placeholder { color: #9a93b8; opacity: 1; }

.checkin-count-value {
  min-width: 76px; height: 46px; padding: 0 18px;
  border-radius: 14px; border: 0; color: #fff; font-size: 24px;
  background: linear-gradient(135deg, #ff4d8d, #8b5cf6);
  box-shadow: 0 8px 20px rgba(255, 77, 141, 0.35);
}
.checkin-plus-btn {
  min-width: 60px; height: 46px; padding: 0 16px;
  border: 0; border-radius: 14px; color: #fff; font-size: 20px; font-weight: 800;
  background: linear-gradient(135deg, #ffb800, #ff5f6d);
  box-shadow: 0 8px 20px rgba(255, 128, 64, 0.35);
  cursor: pointer;
}

.checkin-count-value, .checkin-adjust-input {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 64px; height: 40px; padding: 0 12px;
  border-radius: 12px; border: 1px solid #ddd6ff;
  background: #f0edff; color: var(--text);
  font-size: 15px; font-weight: 700; box-shadow: none;
}
.checkin-adjust-input { width: 64px; text-align: center; outline: none; }
.checkin-adjust-input::placeholder { color: #9a93b8; opacity: 1; }
.checkin-plus-btn { display: none !important; }
