/*
 * Canonical mobile layout for LifeMap.
 * Keep mobile density and responsive behavior here instead of adding another
 * override to the legacy desktop/reference stylesheet.
 */

.trace-more {
  display: none;
}

@media (max-width: 880px) {
  html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
  }

  body {
    min-width: 0;
    padding-bottom: 0;
    overflow-x: clip;
    background: var(--journal-paper, #fbfaf6);
  }

  .page {
    min-height: 0;
  }

  .topbar {
    position: relative;
    height: 64px;
    border-bottom: 1px solid #e1e3dc;
    background: rgba(251, 250, 246, 0.98);
  }

  .nav {
    height: 64px;
    padding: 0 16px;
  }

  .brand-reference {
    width: 132px;
    height: auto;
  }

  .avatar-reference {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
  }

  .avatar-reference img {
    width: 36px;
    height: 36px;
  }

  .hero {
    width: 100%;
    padding: 0 16px 80px;
  }

  .hero-copy {
    padding: 16px 0 10px;
  }

  .mobile-page-kicker {
    font-size: 24px;
    line-height: 1.25;
  }

  .mobile-map-date {
    margin-top: 3px;
    font-size: 12px;
    line-height: 1.5;
  }

  .map-shell {
    overflow: visible;
  }

  body .map-board {
    height: 450px;
    border-radius: 8px;
    box-shadow: 0 10px 24px rgba(74, 70, 53, 0.1);
  }

  .map-board picture {
    inset: 58px 0 0;
  }

  .mobile-route-label {
    top: 70px;
    left: 12px;
    max-width: 176px;
    padding: 8px 10px;
  }

  .mobile-route-label span {
    font-size: 10px;
  }

  .mobile-route-label strong {
    font-size: 12px;
    line-height: 1.35;
  }

  .mobile-map-focus {
    min-height: 54px;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
    padding: 10px 12px;
    border-radius: 8px;
    box-shadow: none;
    text-align: left;
  }

  .mobile-map-focus > span {
    display: none;
  }

  .mobile-map-focus strong {
    min-width: 0;
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", sans-serif;
    font-size: 13px;
    line-height: 1.4;
    overflow-wrap: anywhere;
  }

  .mobile-map-focus::after {
    content: "查看地标";
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 0 10px;
    border-radius: 6px;
    color: #ffffff;
    background: var(--state-color, var(--journal-green));
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
  }

  .mobile-node-panel {
    width: 100%;
    padding: 18px 16px 80px;
  }

  .mobile-panel-head {
    gap: 4px;
  }

  .mobile-panel-head > span {
    font-size: 12px;
    line-height: 1.4;
  }

  .mobile-panel-head h2 {
    margin: 0;
    font-size: 24px;
    line-height: 1.3;
  }

  .mobile-panel-head p {
    display: none;
  }

  .mobile-group-rail {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
    margin: 14px 0 0;
    padding: 0;
    overflow: visible;
  }

  .mobile-group-tab {
    min-width: 0;
    min-height: 48px;
    display: grid;
    place-items: center;
    padding: 6px 3px;
    border: 1px solid #dfe3db;
    border-radius: 8px;
    box-shadow: none;
    text-align: center;
  }

  .mobile-group-tab.active {
    border-color: color-mix(in srgb, var(--state-color) 42%, #dfe3db);
    background: var(--state-surface);
    box-shadow: none;
  }

  .mobile-group-tab strong {
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", sans-serif;
    font-size: 12px;
    line-height: 1.25;
    overflow-wrap: anywhere;
  }

  .mobile-group-tab span {
    display: none;
  }

  .mobile-node-rail {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin: 10px 0 0;
    padding: 0;
    overflow: visible;
  }

  .mobile-node-tab {
    min-width: 0;
    min-height: 84px;
    display: grid;
    grid-template-columns: 1fr;
    justify-items: center;
    align-content: center;
    gap: 6px;
    padding: 9px 4px;
    border: 1px solid #e1e4de;
    border-radius: 8px;
    box-shadow: none;
    text-align: center;
  }

  .mobile-node-tab.active {
    border-color: color-mix(in srgb, var(--accent) 42%, #dfe3db);
    box-shadow: none;
  }

  .mobile-node-icon {
    width: 34px;
    height: 34px;
    margin: 0;
    border-radius: 8px;
  }

  .mobile-node-icon svg {
    width: 19px;
    height: 19px;
  }

  .mobile-node-copy {
    min-width: 0;
    width: 100%;
    display: block;
  }

  .mobile-node-copy strong {
    display: block;
    font-size: 12px;
    line-height: 1.3;
    overflow-wrap: anywhere;
  }

  .mobile-node-copy small {
    display: none;
  }

  .mobile-node-detail {
    width: 100%;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 7px 12px;
    margin-top: 12px;
    padding: 14px;
    border-radius: 8px;
    box-shadow: none;
  }

  .mobile-node-detail .state-pill {
    grid-column: 1 / -1;
    width: max-content;
    max-width: 100%;
    margin: 0;
    font-size: 11px;
    overflow-wrap: anywhere;
  }

  .mobile-node-detail > div {
    grid-column: 1;
    min-width: 0;
  }

  .mobile-node-detail strong {
    font-size: 18px;
    line-height: 1.3;
  }

  .mobile-node-detail span {
    margin-top: 2px;
    font-size: 12px;
    line-height: 1.45;
  }

  .mobile-node-detail .app-entry-action {
    grid-column: 2;
    grid-row: 2;
    min-height: 40px;
    margin: 0;
    padding: 8px 11px;
    border-radius: 6px;
    font-size: 12px;
  }

  .mobile-node-detail p {
    grid-column: 1 / -1;
    margin: 2px 0 0;
    font-size: 13px;
    line-height: 1.55;
  }

  .mobile-node-detail .app-entry-meta {
    display: none;
  }

  .report {
    width: 100%;
    padding: 18px 16px 80px;
  }

  .journal-today-head {
    gap: 4px;
    padding-bottom: 10px;
  }

  .journal-today-head > span {
    font-size: 12px;
    line-height: 1.4;
  }

  .journal-today-head h2 {
    max-width: 100%;
    font-size: 24px;
    line-height: 1.3;
    overflow-wrap: anywhere;
  }

  .journal-today-head time {
    font-size: 12px;
    line-height: 1.5;
  }

  .journal-today-head p {
    margin-top: 3px;
    font-size: 13px;
    line-height: 1.55;
  }

  .trace-timeline::before {
    left: 37px;
    top: 16px;
    bottom: 18px;
  }

  .trace-timeline li {
    grid-template-columns: 36px minmax(0, 1fr) 62px;
    gap: 8px;
    min-height: 92px;
    padding: 10px 0;
  }

  .trace-timeline li:nth-child(n + 4) {
    display: none;
  }

  .report.show-all-traces .trace-timeline li:nth-child(n + 4) {
    display: grid;
  }

  .trace-timeline li::before {
    left: 33px;
    width: 8px;
    height: 8px;
  }

  .trace-timeline time {
    padding-top: 3px;
    font-size: 11px;
  }

  .trace-timeline img {
    width: 62px;
    height: 62px;
    border-width: 3px;
    border-radius: 6px;
  }

  .trace-timeline div {
    min-width: 0;
    padding-left: 5px;
  }

  .trace-timeline strong,
  .trace-timeline span,
  .trace-timeline small {
    max-width: 100%;
    overflow-wrap: anywhere;
  }

  .trace-timeline strong {
    font-size: 15px;
    line-height: 1.4;
  }

  .trace-timeline span {
    margin-top: 2px;
    font-size: 12px;
    line-height: 1.45;
  }

  .trace-timeline small {
    margin-top: 3px;
    font-size: 10px;
    line-height: 1.4;
  }

  .trace-more {
    width: 100%;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 10px;
    border: 1px solid #d9ded5;
    border-radius: 8px;
    color: var(--journal-green);
    background: #f7f8f3;
    font-size: 13px;
    font-weight: 700;
  }

  .trace-more[hidden] {
    display: none;
  }

  .journal-reflection {
    margin-top: 14px;
    padding: 12px 13px;
    border-radius: 0 6px 6px 0;
    font-size: 13px;
    line-height: 1.65;
  }

  .future.mine {
    width: 100%;
    padding: 18px 16px 80px;
  }

  .mine-panel {
    gap: 15px;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }

  .mine-head {
    gap: 10px;
  }

  .mine-avatar {
    width: 44px;
    height: 44px;
    font-size: 16px;
    box-shadow: none;
  }

  .mine-head h2 {
    font-size: 20px;
  }

  .mine-head p {
    margin-top: 3px;
    font-size: 12px;
    line-height: 1.45;
  }

  .mine-stats {
    gap: 0;
    border-top: 1px solid #e0e4dd;
    border-bottom: 1px solid #e0e4dd;
  }

  .mine-stats div {
    padding: 11px 4px;
    border: 0;
    border-right: 1px solid #e0e4dd;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    text-align: center;
  }

  .mine-stats div:last-child {
    border-right: 0;
  }

  .mine-stats span {
    font-size: 11px;
  }

  .mine-stats strong {
    margin-top: 3px;
    font-size: 19px;
  }

  .mine-section {
    gap: 9px;
  }

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

  .achievement-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .achievement-grid article {
    min-height: 96px;
    gap: 5px;
    padding: 11px;
    border-radius: 8px;
    box-shadow: none;
  }

  .achievement-grid svg {
    width: 22px;
    height: 22px;
  }

  .achievement-grid strong {
    font-size: 13px;
  }

  .achievement-grid span {
    font-size: 11px;
    line-height: 1.45;
  }

  .trail-list {
    gap: 7px;
  }

  .trail-list li {
    grid-template-columns: 46px minmax(0, 1fr);
    gap: 9px;
    min-height: 44px;
    padding: 9px 10px;
    border-radius: 8px;
  }

  .trail-list span {
    font-size: 11px;
  }

  .trail-list strong {
    min-width: 0;
    font-size: 12px;
    line-height: 1.45;
    overflow-wrap: anywhere;
  }

  body:not([data-mobile-view="profile"]) .site-footer {
    display: none;
  }

  body[data-mobile-view="profile"] .site-footer {
    width: calc(100% - 32px);
    min-height: 0;
    gap: 6px;
    margin: 8px 16px 0;
    padding: 12px 0 calc(80px + env(safe-area-inset-bottom));
    font-size: 10px;
    line-height: 1.5;
  }

  .footer-records {
    gap: 4px 8px;
  }

  .mobile-switcher {
    left: 12px;
    right: 12px;
    bottom: max(8px, env(safe-area-inset-bottom));
    height: 60px;
    min-height: 60px;
    padding: 4px;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(44, 52, 45, 0.13);
  }

  .mobile-switcher button {
    min-height: 52px;
    gap: 2px;
    border-radius: 6px;
    font-size: 11px;
  }

  .mobile-switcher button.active {
    background: #eef5ec;
    box-shadow: none;
  }

  .mobile-switcher button:focus-visible {
    outline: 2px solid var(--journal-green);
    outline-offset: -2px;
    box-shadow: none;
  }

  .mobile-switcher svg {
    width: 18px;
    height: 18px;
  }
}

@media (max-width: 360px) {
  .hero,
  .mobile-node-panel,
  .report,
  .future.mine {
    padding-left: 12px;
    padding-right: 12px;
  }

  .mobile-group-tab strong,
  .mobile-node-copy strong {
    font-size: 11px;
  }

  .trace-timeline li {
    grid-template-columns: 34px minmax(0, 1fr) 56px;
    gap: 6px;
  }

  .trace-timeline img {
    width: 56px;
    height: 56px;
  }
}
