:root {
  color-scheme: light;
  --paper: #f7f1e7;
  --paper-deep: #eee4d6;
  --surface: #fffaf2;
  --ink: #201b17;
  --muted: #746b62;
  --quiet: #a59a8f;
  --line: rgba(54, 42, 33, 0.13);
  --bean: #a5413d;
  --bean-dark: #772b29;
  --white: #fffdf9;
  --shadow: 0 24px 70px rgba(62, 44, 31, 0.16);
  --topbar-height: 68px;
  --nav-height: 76px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  background: #e6ddd1;
  scroll-behavior: smooth;
  -webkit-tap-highlight-color: transparent;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background: #e6ddd1;
  color: var(--ink);
  overscroll-behavior-y: none;
}

button,
select,
textarea {
  font: inherit;
}

button {
  color: inherit;
}

button,
[role="button"] {
  touch-action: manipulation;
}

button:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(165, 65, 61, 0.28);
  outline-offset: 3px;
}

img {
  display: block;
  max-width: 100%;
}

.boot-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 16px;
  background: var(--paper);
  color: var(--muted);
  padding: 32px;
  text-align: center;
}

.boot-screen h2 {
  margin: 0;
  font-size: 22px;
  color: var(--ink);
  letter-spacing: 0.04em;
}

.boot-hint {
  margin: 0;
  font-size: 13px;
  letter-spacing: 0.06em;
}

.boot-env-select {
  font-size: 14px;
  padding: 10px 14px;
  border: 1px solid var(--muted);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  width: 100%;
  max-width: 320px;
  text-align: center;
  cursor: pointer;
}

.boot-connect-btn {
  margin-top: 8px;
  min-width: 200px;
}

.boot-error {
  margin: 0;
  font-size: 12px;
  color: #c56a5c;
  max-width: 300px;
}

.app-shell {
  position: relative;
  width: min(100%, 520px);
  min-height: 100svh;
  margin: 0 auto;
  background: var(--paper);
  box-shadow: 0 0 60px rgba(62, 44, 31, 0.12);
  overflow-x: clip;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: calc(var(--topbar-height) + env(safe-area-inset-top, 0px));
  padding: env(safe-area-inset-top, 0px) 20px 0;
  background: rgba(247, 241, 231, 0.9);
  border-bottom: 1px solid rgba(54, 42, 33, 0.06);
  backdrop-filter: blur(18px);
}

.brand-button {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.brand-button > span:last-child {
  display: grid;
  gap: 1px;
}

.brand-button strong {
  font-size: 15px;
  letter-spacing: 0.02em;
}

.brand-button small {
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.15em;
}

.bean-mark {
  position: relative;
  display: inline-block;
  width: 28px;
  height: 34px;
  border-radius: 58% 42% 54% 46% / 64% 52% 48% 36%;
  background: var(--bean);
  box-shadow: inset -5px -4px 0 rgba(91, 22, 24, 0.16);
  transform: rotate(27deg);
}

.bean-mark span {
  position: absolute;
  top: 7px;
  left: 6px;
  width: 8px;
  height: 13px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.32);
  transform: rotate(-18deg);
}

.bean-mark--large {
  width: 54px;
  height: 66px;
  animation: bean-breathe 1.7s ease-in-out infinite;
}

.server-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.04em;
}

.server-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #c69b62;
  box-shadow: 0 0 0 4px rgba(198, 155, 98, 0.13);
}

.server-badge.is-online .server-dot {
  background: #568965;
  box-shadow: 0 0 0 4px rgba(86, 137, 101, 0.13);
}

.workspace {
  min-height: calc(100svh - var(--topbar-height));
  padding-bottom: calc(var(--nav-height) + var(--safe-bottom) + 28px);
}

.view {
  min-height: calc(100svh - var(--topbar-height));
  animation: view-enter 280ms ease-out both;
}

.view[hidden] {
  display: none;
}

.hero {
  position: relative;
  min-height: clamp(510px, calc(100svh - var(--topbar-height) - 34px), 680px);
  overflow: hidden;
  border-radius: 0 0 34px 34px;
  background: #d9bf91;
  isolation: isolate;
}

.hero > img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 54% center;
  animation: hero-arrive 850ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.hero-shade {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(180deg, rgba(34, 25, 18, 0.02) 32%, rgba(31, 22, 16, 0.8) 100%);
}

.hero-copy {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 2;
  display: grid;
  justify-items: start;
  gap: 12px;
  padding: 32px 24px 28px;
  color: var(--white);
  animation: hero-copy-enter 600ms 130ms ease-out both;
}

.eyebrow {
  margin: 0;
  color: var(--bean);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.hero-copy .eyebrow {
  color: rgba(255, 253, 249, 0.72);
}

.hero h1 {
  max-width: 320px;
  margin: 0;
  font-size: clamp(38px, 11vw, 54px);
  line-height: 1.05;
  letter-spacing: -0.045em;
}

.hero-description {
  max-width: 310px;
  margin: 0;
  color: rgba(255, 253, 249, 0.82);
  font-size: 14px;
  line-height: 1.7;
}

.primary-action,
.secondary-action,
.text-action,
.round-action {
  border: 0;
  cursor: pointer;
}

.primary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 18px;
  border-radius: 15px;
  background: var(--bean);
  color: var(--white);
  font-size: 14px;
  font-weight: 700;
  box-shadow: 0 10px 24px rgba(83, 26, 25, 0.2);
  transition: transform 180ms ease, background 180ms ease;
}

.primary-action:active {
  transform: scale(0.97);
}

.hero .primary-action {
  margin-top: 2px;
  background: var(--white);
  color: var(--ink);
  box-shadow: none;
}

.primary-action--full {
  width: 100%;
}

.primary-action:disabled {
  cursor: wait;
  opacity: 0.58;
}

.content-section {
  padding: 36px 20px 0;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.section-heading > div {
  display: grid;
  gap: 5px;
}

.section-heading h2,
.page-intro h1 {
  margin: 0;
  letter-spacing: -0.035em;
}

.section-heading h2 {
  font-size: 25px;
}

.text-action {
  min-height: 40px;
  padding: 0;
  background: transparent;
  color: var(--bean);
  font-size: 12px;
  font-weight: 700;
}

.vehicle-rail {
  display: grid;
  grid-auto-columns: minmax(164px, 44%);
  grid-auto-flow: column;
  gap: 12px;
  margin-right: -20px;
  padding-right: 20px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  scroll-snap-type: x mandatory;
}

.vehicle-rail::-webkit-scrollbar {
  display: none;
}

.vehicle-card {
  display: grid;
  gap: 10px;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
  scroll-snap-align: start;
  animation: card-enter 460ms var(--delay, 0ms) ease-out both;
}

.vehicle-card-image {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: 22px;
  background: var(--paper-deep);
}

.vehicle-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 350ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.vehicle-card:active .vehicle-card-image img {
  transform: scale(1.035);
}

.vehicle-card-copy {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.vehicle-card-copy strong {
  font-size: 15px;
}

.vehicle-card-copy small {
  color: var(--muted);
  font-size: 10px;
}

.memory-preview {
  padding-bottom: 34px;
}

.memory-invitation {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 88px;
  padding: 14px 0;
  border: 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.memory-invitation > span:nth-child(2) {
  display: grid;
  gap: 5px;
}

.memory-invitation strong {
  font-size: 14px;
}

.memory-invitation small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.record-orb {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border-radius: 50%;
  background: rgba(165, 65, 61, 0.1);
}

.record-orb i {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--bean);
}

.recent-memory {
  margin-top: 16px;
}

.recent-memory:empty {
  display: none;
}

.recent-memory-entry {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 12px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
}

.recent-memory-entry time {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 50%;
  background: var(--surface);
  color: var(--bean);
  font-weight: 700;
}

.page-intro {
  display: grid;
  gap: 8px;
  padding: 38px 20px 22px;
}

.page-intro h1 {
  font-size: 38px;
}

.page-intro > p:last-child,
.page-intro > div > p:last-child {
  max-width: 330px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.page-intro--with-action {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.page-intro--with-action > div {
  display: grid;
  gap: 8px;
}

.round-action {
  flex: 0 0 auto;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--bean);
  color: var(--white);
  font-size: 26px;
  box-shadow: 0 10px 28px rgba(83, 26, 25, 0.18);
}

.category-filter {
  display: flex;
  gap: 22px;
  margin: 0 20px 20px;
  padding-bottom: 10px;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
  scrollbar-width: none;
}

.category-filter::-webkit-scrollbar {
  display: none;
}

.category-filter button {
  position: relative;
  flex: 0 0 auto;
  min-height: 38px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
}

.category-filter button.is-active {
  color: var(--bean);
  font-weight: 700;
}

.category-filter button.is-active::after {
  position: absolute;
  right: 0;
  bottom: -11px;
  left: 0;
  height: 2px;
  background: var(--bean);
  content: "";
}

.vehicle-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px 12px;
  padding: 0 20px 34px;
}

.timeline {
  padding: 4px 20px 40px;
}

.timeline-entry {
  position: relative;
  display: grid;
  grid-template-columns: 58px 1fr;
  gap: 14px;
  padding-bottom: 28px;
}

.timeline-entry:not(:last-child)::before {
  position: absolute;
  top: 54px;
  bottom: 6px;
  left: 28px;
  width: 1px;
  background: var(--line);
  content: "";
}

.timeline-date {
  display: grid;
  width: 56px;
  height: 56px;
  place-content: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--paper);
  color: var(--bean);
  text-align: center;
}

.timeline-date strong {
  font-size: 17px;
  line-height: 1;
}

.timeline-date small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 9px;
}

.timeline-content {
  min-width: 0;
  padding-top: 4px;
}

.timeline-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 10px;
  margin-bottom: 7px;
  color: var(--quiet);
  font-size: 10px;
}

.timeline-content h3 {
  margin: 0 0 6px;
  font-size: 16px;
}

.timeline-content p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
  white-space: pre-wrap;
}

.timeline-content audio {
  width: 100%;
  height: 38px;
  margin-top: 12px;
}

.empty-state {
  display: grid;
  justify-items: center;
  gap: 12px;
  padding: 58px 24px;
  text-align: center;
}

.empty-state .record-orb {
  width: 72px;
  height: 72px;
}

.empty-state h2,
.empty-state p {
  margin: 0;
}

.empty-state h2 {
  font-size: 22px;
}

.empty-state p {
  max-width: 270px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}

.family-panel {
  padding: 6px 20px 30px;
}

.panel-label {
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.14em;
}

.family-list {
  display: grid;
}

.family-person {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 12px;
  min-height: 70px;
  border-bottom: 1px solid rgba(54, 42, 33, 0.08);
}

.family-avatar {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 50%;
  background: var(--paper-deep);
  color: var(--bean);
  font-size: 13px;
  font-weight: 700;
}

.family-person > span:nth-child(2) {
  display: grid;
  gap: 3px;
}

.family-person strong {
  font-size: 13px;
}

.family-person small,
.family-role {
  color: var(--muted);
  font-size: 10px;
}

.server-details {
  display: grid;
  margin: 0;
}

.server-details > div {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 20px;
  min-height: 54px;
  padding: 17px 0;
  border-bottom: 1px solid rgba(54, 42, 33, 0.08);
}

.server-details dt {
  color: var(--muted);
  font-size: 11px;
}

.server-details dd {
  max-width: 65%;
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  text-align: right;
  overflow-wrap: anywhere;
}

.native-server-settings {
  width: 100%;
  margin-top: 14px;
}

.privacy-note {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 13px;
  margin: 0 20px 34px;
  padding: 16px;
  border-radius: 18px;
  background: rgba(165, 65, 61, 0.07);
  color: var(--bean-dark);
}

.privacy-note > span {
  font-size: 19px;
}

.privacy-note strong {
  font-size: 12px;
}

.privacy-note p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.6;
}

.bottom-nav {
  position: fixed;
  right: max(0px, calc((100vw - 520px) / 2));
  bottom: 0;
  left: max(0px, calc((100vw - 520px) / 2));
  z-index: 35;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  height: calc(var(--nav-height) + var(--safe-bottom));
  padding: 7px 12px var(--safe-bottom);
  background: rgba(255, 250, 242, 0.93);
  border-top: 1px solid rgba(54, 42, 33, 0.08);
  backdrop-filter: blur(22px);
}

.bottom-nav button {
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 3px;
  min-width: 0;
  min-height: 54px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--quiet);
  font-size: 10px;
  cursor: pointer;
}

.bottom-nav button.is-active {
  color: var(--bean);
  font-weight: 700;
}

.nav-icon {
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  font-size: 18px;
  line-height: 1;
  transition: transform 180ms ease;
}

.bottom-nav button.is-active .nav-icon {
  transform: translateY(-2px);
}

.sheet {
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  overflow: hidden;
}

.sheet::backdrop {
  background: rgba(29, 23, 19, 0.48);
  backdrop-filter: blur(4px);
}

.sheet[open] {
  display: grid;
  align-items: end;
  justify-items: center;
}

.sheet-surface {
  position: relative;
  width: min(100%, 520px);
  max-height: calc(100svh - 22px);
  overflow-y: auto;
  border-radius: 30px 30px 0 0;
  background: var(--surface);
  box-shadow: var(--shadow);
  animation: sheet-rise 320ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.sheet-close {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 5;
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 253, 249, 0.9);
  color: var(--ink);
  font-size: 24px;
  box-shadow: 0 8px 20px rgba(50, 35, 23, 0.12);
  cursor: pointer;
}

/* --- Vehicle Detail Page --- */

.detail-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 52px;
  padding: 0 12px;
}

.back-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: var(--paper-deep);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.detail-counter {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.detail-image-wrapper {
  position: relative;
  aspect-ratio: 1.08;
  overflow: hidden;
  background: var(--paper-deep);
  touch-action: pan-y;
  user-select: none;
}

.detail-image-wrapper img,
.detail-image-wrapper video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* 图片作封面层，视频就绪后淡入覆盖 */
.detail-image-wrapper img {
  z-index: 1;
}

.detail-image-wrapper video {
  z-index: 2;
  opacity: 0;
  transition: opacity 0.35s ease;
}

.detail-image-wrapper video.is-ready {
  opacity: 1;
}

/* 加载遮罩：等视频和声音都就绪后一起揭开 */
.detail-loading {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(247, 241, 231, 0.78);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  opacity: 1;
  transition: opacity 0.25s ease;
}

.detail-loading.is-hidden {
  opacity: 0;
  pointer-events: none;
}

.detail-loading-spinner {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid rgba(60, 49, 43, 0.14);
  border-top-color: var(--accent, #c9713f);
  animation: detail-spin 0.8s linear infinite;
}

@keyframes detail-spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .detail-loading-spinner {
    animation-duration: 2.4s;
  }
}

/* 手机不允许带声音自动播放时，先静音播画面并提示点一下开声音 */
.detail-sound-hint {
  position: absolute;
  left: 50%;
  bottom: 14px;
  z-index: 4;
  transform: translateX(-50%);
  padding: 9px 18px;
  border: 0;
  border-radius: 999px;
  background: rgba(60, 49, 43, 0.84);
  color: #fff;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  opacity: 1;
  transition: opacity 0.25s ease;
}

.detail-sound-hint.is-hidden {
  opacity: 0;
  pointer-events: none;
}

.detail-body {
  display: grid;
  gap: 12px;
  padding: 24px 20px calc(var(--nav-height) + var(--safe-bottom) + 24px);
}

.detail-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.detail-title-row h2 {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-size: 28px;
  letter-spacing: -0.04em;
}

.mini-icon-btn {
  flex: 0 0 auto;
  display: grid;
  width: 57px;
  height: 57px;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--paper-deep);
  font-size: 27px;
  line-height: 1;
  cursor: pointer;
  transition: background 180ms ease;
}

.mini-icon-btn:active {
  background: var(--paper);
}

.detail-body h2 {
  margin: 0;
  font-size: 28px;
  letter-spacing: -0.04em;
}

.mini-icon-btn.is-recording {
  animation: recording-pulse 1.2s ease-out infinite;
  background: rgba(165, 65, 61, 0.15);
  color: var(--bean);
}

.inline-recorder {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 16px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.inline-recorder strong {
  font-size: 12px;
}

.inline-recorder time {
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.inline-recorder audio {
  width: 100%;
  height: 40px;
  margin-top: 4px;
}

.inline-recorder .file-fallback {
  min-height: 40px;
  margin-top: 4px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--white);
  color: var(--bean);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.detail-body .primary-action--full {
  margin-top: 8px;
}

.vehicle-sheet-image {
  position: relative;
  aspect-ratio: 1.08;
  overflow: hidden;
  background: var(--paper-deep);
  touch-action: pan-y;
  user-select: none;
}

.vehicle-sheet-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.nav-arrow {
  position: absolute;
  top: 50%;
  z-index: 5;
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 253, 249, 0.82);
  color: var(--ink);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  transform: translateY(-50%);
  box-shadow: 0 4px 14px rgba(50, 35, 23, 0.1);
  transition: background 180ms ease, transform 180ms ease;
}

.nav-arrow:active {
  background: rgba(255, 253, 249, 0.95);
  transform: translateY(-50%) scale(0.93);
}

.nav-arrow--prev {
  left: 10px;
}

.nav-arrow--next {
  right: 10px;
}

.nav-counter {
  position: absolute;
  bottom: 10px;
  right: 12px;
  z-index: 2;
  padding: 4px 10px;
  border-radius: 10px;
  background: rgba(32, 27, 23, 0.55);
  color: var(--white);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.vehicle-sheet-body {
  display: grid;
  gap: 12px;
  padding: 24px 20px calc(24px + var(--safe-bottom));
}

.vehicle-sheet-body h2,
.memory-sheet-header h2 {
  margin: 0;
  font-size: 32px;
  letter-spacing: -0.04em;
}

.vehicle-description {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.8;
}

.fact-line {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  margin-top: 2px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: var(--bean);
}

.fact-line p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.7;
}

.sheet-actions {
  display: grid;
  grid-template-columns: 0.9fr 1.25fr;
  gap: 10px;
  margin-top: 8px;
}

.secondary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 14px;
  border-radius: 15px;
  background: var(--paper-deep);
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}

.memory-sheet {
  padding: 28px 20px calc(24px + var(--safe-bottom));
}

.memory-sheet-header {
  display: grid;
  gap: 8px;
  margin-bottom: 22px;
  padding-right: 42px;
}

.memory-sheet-header p:last-child {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.field-label {
  display: block;
  margin: 16px 0 8px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.09em;
}

select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--white);
  color: var(--ink);
}

select {
  min-height: 48px;
  padding: 0 13px;
}

textarea {
  min-height: 90px;
  padding: 13px;
  line-height: 1.6;
  resize: vertical;
}

.recorder {
  display: grid;
  justify-items: center;
  gap: 8px;
  margin: 18px 0 6px;
  padding: 24px 16px 18px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.record-button {
  position: relative;
  display: grid;
  width: 74px;
  height: 74px;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: rgba(165, 65, 61, 0.12);
  cursor: pointer;
}

.record-button span {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bean);
  transition: border-radius 180ms ease, transform 180ms ease;
}

.recorder.is-recording .record-button {
  animation: recording-pulse 1.2s ease-out infinite;
}

.recorder.is-recording .record-button span {
  border-radius: 7px;
  transform: scale(0.75);
}

.recorder strong {
  margin-top: 4px;
  font-size: 12px;
}

.recorder time {
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.recorder audio {
  width: 100%;
  height: 40px;
  margin-top: 8px;
}

.file-fallback {
  min-height: 44px;
  margin-top: 6px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--white);
  color: var(--bean);
  font-size: 12px;
  font-weight: 700;
}

.memory-sheet .primary-action--full {
  margin-top: 20px;
}

.clarity-options {
  display: flex;
  gap: 8px;
}

.clarity-chip {
  flex: 1 1 0;
  min-width: 0;
  min-height: 46px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--white);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: background 160ms ease, color 160ms ease, border-color 160ms ease;
}

.clarity-chip.is-selected {
  border-color: transparent;
  color: var(--white);
}

.clarity-chip--great.is-selected {
  background: #568965;
}

.clarity-chip--good.is-selected {
  background: #c69b62;
}

.clarity-chip--practice.is-selected {
  background: #d57b42;
}

.clarity-line {
  margin-bottom: 8px;
}

.clarity-tag {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
}

.clarity-tag--great {
  background: rgba(86, 137, 101, 0.16);
  color: #3f6b4d;
}

.clarity-tag--good {
  background: rgba(198, 155, 98, 0.2);
  color: #856021;
}

.clarity-tag--practice {
  background: rgba(213, 123, 66, 0.16);
  color: #a85423;
}

.detail-memories {
  margin-top: 10px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.detail-memory-list {
  display: grid;
  gap: 14px;
  margin-top: 14px;
}

.detail-memory-item {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--white);
}

.detail-memory-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  color: var(--quiet);
  font-size: 10px;
}

.detail-memory-item p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
  white-space: pre-wrap;
}

.detail-memory-item audio {
  width: 100%;
  height: 38px;
}

.detail-memory-empty {
  margin: 14px 0 0;
  color: var(--quiet);
  font-size: 12px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: calc(var(--nav-height) + var(--safe-bottom) + 16px);
  left: 20px;
  z-index: 80;
  max-width: 440px;
  margin: auto;
  padding: 13px 16px;
  border-radius: 14px;
  background: #2b2520;
  color: var(--white);
  font-size: 12px;
  line-height: 1.5;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@keyframes bean-breathe {
  0%, 100% { transform: rotate(27deg) scale(1); }
  50% { transform: rotate(27deg) scale(1.07); }
}

@keyframes hero-arrive {
  from { opacity: 0; transform: scale(1.08); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes hero-copy-enter {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes card-enter {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes view-enter {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes sheet-rise {
  from { opacity: 0; transform: translateY(44px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes recording-pulse {
  0% { box-shadow: 0 0 0 0 rgba(165, 65, 61, 0.2); }
  100% { box-shadow: 0 0 0 22px rgba(165, 65, 61, 0); }
}

@media (min-width: 560px) {
  body {
    padding: 18px 0;
  }

  .app-shell {
    min-height: calc(100svh - 36px);
    border-radius: 30px;
    overflow: hidden;
  }

  .topbar {
    top: 18px;
  }

  .bottom-nav {
    bottom: 18px;
    border-radius: 0 0 30px 30px;
  }
}

@media (max-width: 360px) {
  .hero-copy {
    padding-inline: 18px;
  }

  .content-section,
  .page-intro,
  .vehicle-grid,
  .timeline,
  .family-panel {
    padding-right: 16px;
    padding-left: 16px;
  }

  .vehicle-grid {
    gap: 20px 10px;
  }
}

/* ---------- 相册 ---------- */

.view-photos {
  padding-bottom: calc(var(--nav-height) + var(--safe-bottom) + 24px);
}

.photos-topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  padding: 28px 20px 14px;
}

.photos-title {
  margin: 4px 0 0;
  font-size: 26px;
  letter-spacing: -0.01em;
}

.photos-upload-btn {
  flex: none;
  min-height: 44px;
  padding: 0 16px;
}

.photos-notice {
  margin: 0 20px 12px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(165, 65, 61, 0.08);
  color: var(--bean-dark);
  font-size: 13px;
  line-height: 1.6;
}

.photos-notice.is-hidden {
  display: none;
}

.photo-timeline {
  padding: 0 14px;
}

.photo-month-divider {
  position: sticky;
  top: 0;
  z-index: 3;
  margin: 22px 0 10px;
  padding: 8px 4px;
  background: linear-gradient(180deg, rgba(247, 241, 231, 0.97) 62%, rgba(247, 241, 231, 0));
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.photo-month-divider span {
  color: var(--quiet);
  font-weight: 500;
}

/* 自适应列宽：手机上 3 列，宽屏铺更多，不用写断点 */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 8px;
}

.photo-card {
  position: relative;
  overflow: hidden;
  /* 固定成正方形：图片没加载出来时也不会把版面顶来顶去 */
  aspect-ratio: 1 / 1;
  padding: 0;
  border: 0;
  border-radius: 14px;
  background: var(--paper-deep);
  cursor: pointer;
}

.photo-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 260ms ease;
}

.photo-card:active img {
  transform: scale(1.04);
}

.photo-card-badge {
  position: absolute;
  right: 6px;
  top: 6px;
  display: grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 11px;
  background: rgba(32, 27, 23, 0.72);
  color: var(--white);
  font-size: 11px;
}

.photo-card-badge--failed {
  background: rgba(165, 65, 61, 0.86);
}

.photo-card-spinner {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(32, 27, 23, 0.42);
}

.photo-sentinel {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 22px 0 8px;
  color: var(--quiet);
  font-size: 13px;
}

.photo-sentinel[hidden] {
  display: none;
}

/* 传照片 */

.photo-upload-sheet {
  display: grid;
  gap: 14px;
  /* 之前只有 display/gap，没有 padding：内容贴着屏幕左右边缘，
     底部又被安全区（刘海屏/手势条）压住 ⇒ 手机上标题被切、最后一行看不全 */
  padding: 26px 20px max(18px, var(--safe-bottom));
  max-height: min(86svh, calc(100svh - 22px));
}

@media (max-width: 420px) {
  .photo-upload-sheet {
    gap: 12px;
    padding: 22px 16px max(16px, var(--safe-bottom));
  }

  .photo-upload-sheet h2 {
    font-size: 21px;
    line-height: 1.25;
  }
}

.upload-hint {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}

.upload-progress {
  overflow: hidden;
  height: 8px;
  border-radius: 4px;
  background: var(--paper-deep);
}

.upload-progress-bar {
  width: 0;
  height: 100%;
  border-radius: 4px;
  background: var(--bean);
  transition: width 240ms ease;
}

.upload-progress-text {
  margin: 0;
  color: var(--ink, var(--muted));
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.upload-list {
  display: grid;
  max-height: 32svh;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  gap: 6px;
  list-style: none;
}

.upload-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--paper);
  font-size: 12.5px;
  min-height: 40px;
}

.upload-item-name {
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-item-state {
  flex: none;
  color: var(--quiet);
}

.upload-item--done .upload-item-state {
  color: #4b7a4f;
}

.upload-item--failed .upload-item-state {
  color: var(--bean);
}

.upload-retry {
  flex: none;
  padding: 4px 10px;
  border: 0;
  border-radius: 9px;
  background: var(--bean);
  color: var(--white);
  font-size: 12px;
  cursor: pointer;
}

/* 看大图 */

.photo-viewer {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: #17130f;
  color: rgba(255, 253, 249, 0.92);
}

.photo-viewer.is-hidden {
  display: none;
}

.viewer-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: max(10px, env(safe-area-inset-top)) 14px 10px;
}

.viewer-icon-btn {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 253, 249, 0.12);
  color: inherit;
  font-size: 22px;
  cursor: pointer;
}

.viewer-spacer {
  width: 40px;
}

.viewer-counter {
  font-size: 13px;
  letter-spacing: 0.08em;
}

.viewer-stage {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 4px;
  min-height: 0;
  padding: 0 4px;
}

.viewer-frame {
  display: grid;
  min-width: 0;
  min-height: 0;
  place-items: center;
  gap: 10px;
}

.viewer-frame img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 12px;
  object-fit: contain;
}

/* 原图和插画并排对比；窄屏自动改成上下摞 */
.viewer-frame--compare {
  grid-template-columns: 1fr 1fr;
  align-items: center;
}

.viewer-frame--compare img {
  max-height: 46vh;
}

.viewer-label {
  margin: 0;
  color: rgba(255, 253, 249, 0.5);
  font-size: 11px;
  text-align: center;
  letter-spacing: 0.1em;
}

.photo-viewer .nav-arrow {
  position: static;
  flex: none;
}

.viewer-info {
  display: grid;
  gap: 10px;
  padding: 14px 18px max(18px, env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(23, 19, 15, 0) 0%, rgba(23, 19, 15, 0.92) 34%);
}

.viewer-date {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
}

.viewer-caption {
  margin: 0;
  color: rgba(255, 253, 249, 0.62);
  font-size: 13px;
  line-height: 1.6;
}

.viewer-caption:empty {
  display: none;
}

.viewer-stylize {
  display: grid;
  gap: 8px;
  padding-top: 4px;
  border-top: 1px solid rgba(255, 253, 249, 0.12);
}

.viewer-stylize.is-hidden {
  display: none;
}

.viewer-stylize-label {
  color: rgba(255, 253, 249, 0.5);
  font-size: 11px;
  letter-spacing: 0.12em;
}

.viewer-styles {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.style-chip {
  padding: 8px 13px;
  border: 1px solid rgba(255, 253, 249, 0.22);
  border-radius: 999px;
  background: transparent;
  color: rgba(255, 253, 249, 0.8);
  font-size: 12px;
  cursor: pointer;
}

.style-chip.is-active {
  border-color: transparent;
  background: var(--bean);
  color: var(--white);
  font-weight: 700;
}

.photo-viewer .secondary-action {
  justify-self: start;
  min-height: 42px;
  padding: 0 16px;
  border-radius: 13px;
  background: rgba(255, 253, 249, 0.14);
  color: var(--white);
  font-size: 13px;
  font-weight: 700;
}

.photo-viewer .secondary-action:disabled {
  cursor: wait;
  opacity: 0.6;
}

.viewer-ai-note {
  margin: 0;
  color: rgba(255, 253, 249, 0.55);
  font-size: 12px;
  line-height: 1.6;
}

.viewer-ai-note:empty {
  display: none;
}

@media (max-width: 520px) {
  .viewer-frame--compare {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .viewer-frame--compare img {
    max-height: 24vh;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
