/* Layout polish only. Stored records and synchronization are unchanged. */
@media screen {
  .main-content, .main-shell, .view, .card { min-width: 0; }
  .modal-head, .modal-foot { flex-shrink: 0; }
  .modal-body { min-height: 0; overscroll-behavior: contain; }
  .avatar-bubble { left: auto; right: 0; transform: none; }
  .avatar-bubble::after { left: auto; right: 18px; }
}

@media screen and (min-width: 721px) {
  .card { box-shadow: var(--shadow-sm); }
  .page-lead, .guide-step p, .modal-section-note, .field-help { font-size: 12px; }
  .btn { min-height: 36px; }
  .modal-body { scrollbar-gutter: stable; }
}

@media screen and (max-width: 720px) {
  :root { --phone-nav-height: calc(64px + env(safe-area-inset-bottom, 0px)); }
  body::after { opacity: .055; }
  .main-content {
    padding: 16px 16px calc(var(--phone-nav-height) + 96px);
  }
  .topbar { min-height: 64px; padding: 8px 12px; gap: 4px; }
  .topbar-left, .topbar-controls { gap: 0; }
  .topbar .icon-btn, .date-nav .icon-btn { width: 40px; height: 44px; }
  .date-nav { padding: 0; }
  .date-jump { min-height: 44px; padding: 0 4px; font-size: 12px; }
  .topbar-controls { flex-wrap: wrap; }
  .main-content .page-head-actions { flex-wrap: wrap; gap: 8px; }
  .page-head > div:first-child { flex: 0 1 auto; width: 100%; }
  .page-head-actions:empty { display: none; }
  .page-title { font-size: 28px; line-height: 1.35; }
  .page-lead { font-size: 14px; line-height: 1.75; }

  .today-hero { padding: 24px 20px; border-radius: 22px; }
  .hero-main { padding-right: 0; }
  .hero-eyebrow { padding-right: 48px; font-size: 10px; letter-spacing: .08em; }
  .hero-greeting { padding-right: 0; margin-top: 22px; font-size: 30px; line-height: 1.45; overflow-wrap: anywhere; }
  .hero-greeting em { display: inline; }
  .hero-sub { padding-right: 0; margin-top: 10px; font-size: 14px; }
  .hero-side { top: 20px; right: 18px; }
  .hero-daynum { font-size: 38px; }
  .hero-badges { gap: 8px; margin-top: 20px; padding-right: 20px; }
  .hero-badge, .hero-meta-link { font-size: 12px; }
  .today-grid, .today-main, .today-side { gap: 16px; }
  .guide-card { margin-top: 16px; padding: 18px; }
  .guide-steps { gap: 14px; }
  .guide-step p { font-size: 13px; line-height: 1.8; }
  .guide-step strong { font-size: 14px; }
  .guide-foot { flex-wrap: wrap; gap: 10px; }

  .btn { min-height: 44px; padding: 9px 14px; font-size: 14px; }
  .input, .select, .textarea, .main-content input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
  .main-content textarea, .main-content select, .modal input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
  .modal textarea, .modal select { min-height: 44px; max-width: 100%; font-size: 16px; }
  .field-label, .field-help, .modal-sub, .modal-section-note,
  .todo-card-foot, .todo-toolbar, .guide-foot, .empty-note, .empty-text,
  .life-stat-note, .advice-body p, .weight-chart-note, .feed-note-content,
  .meal-entry-name, .plan-entry-name, .reading-note-text { font-size: 13px; line-height: 1.75; }
  .main-content small, .modal-body small { font-size: 12px; }
  .todo-action, .record-action, .meal-edit, .meal-delete, .plan-entry-edit, .plan-entry-delete,
  .expense-actions button, .habit-edit { min-width: 36px; min-height: 40px; }
  .todo-item { gap: 8px; }
  .todo-content, .todo-copy, .expense-copy, .meal-entry-name { min-width: 0; overflow-wrap: anywhere; }
  .todo-check, .plan-check, .hour-done, .habit-check { flex-shrink: 0; }
  .life-grid, .today-main .life-strip .life-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
  .life-stat { min-width: 0; padding: 14px; }
  .life-stat-note { white-space: normal; }
  .calendar-side, .diary-side, .reflection-side, .records-side, .finance-side,
  .habit-side, .feeds-side { flex-direction: column; }
  .meal-groups { grid-template-columns: 1fr; }
  .meal-form, .weight-form { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
  .meal-form .btn, .weight-form .btn { grid-column: 1 / -1; }
  .meal-form .meal-kcal-input { grid-column: auto; }
  .diary-content { font-size: 16px; line-height: 1.9; }
  .diary-meta-row, .diary-inline-tools, .weather-row { flex-wrap: wrap; gap: 8px; }
  .weather-btn, .diary-tool-btn { min-height: 40px; }
  .calendar-day { min-width: 0; min-height: 58px; }
  .calendar-day-tag, .calendar-day-note { font-size: 10px; }
  .calendar-weekdays, .calendar-legend { font-size: 11px; }
  .habit-row {
    grid-template-columns: 14px 32px minmax(0, 1fr) 40px;
    grid-template-areas: "drag icon info edit" "progress progress progress progress" "value value value value";
    gap: 8px; padding: 14px 0;
  }
  .habit-row > .drag-handle { grid-area: drag; }
  .habit-info strong { font-size: 14px; white-space: normal; }
  .habit-info .habit-kind-badge { display: inline-flex; width: auto; margin-left: 6px; padding: 1px 6px; font-size: 10px; vertical-align: middle; }
  .habit-info > span { font-size: 12px; line-height: 1.8; overflow-wrap: anywhere; }
  .habit-value-control { flex-wrap: wrap; justify-content: flex-start; gap: 5px; }
  .habit-step, .habit-star, .habit-skip, .habit-value-control .habit-check { width: 36px; height: 44px; border-radius: 9px; }
  .habit-value-input { width: 52px; height: 44px; border-radius: 9px; }
  .habit-progress-copy { display: block; font-size: 12px; }
  .habit-renew { grid-area: value; justify-self: start; }
  .habit-week-legend { flex-wrap: wrap; font-size: 11px; }
  .habit-month-card { padding: 16px 14px; }
  .habit-week-scroll, .weight-table-wrap { max-width: 100%; overflow-x: auto; }
  .three-fields { grid-template-columns: 1fr; }
  .body-tabs { display: flex; flex-wrap: wrap; gap: 6px; border-radius: 16px; }
  .body-tab { flex: 1 1 calc(33.33% - 6px); min-width: 0; min-height: 44px; font-size: 12px; }
  .timeline-page .review-card-head, .timeline-page .review-card-head > div { flex-wrap: wrap; }

  .mobile-tabbar { min-height: 0; padding: 4px 5px calc(4px + env(safe-area-inset-bottom, 0px)); background: var(--surface); }
  .mobile-tab { height: 46px; min-height: 44px; gap: 3px; font-size: 11px; border-radius: 12px; }
  .mobile-tab span { line-height: 1.2; }
  .mobile-tab .icon { width: 22px; height: 22px; }
  .mobile-tab.is-active { background: var(--accent-wash); color: var(--accent-deep); }
  /* Dock utility buttons together, clear of the reading area and navigation. */
  .fab, .avatar-fab, .flower-fab, .calc-fab {
    position: fixed; top: auto !important; left: auto !important;
    bottom: calc(var(--phone-nav-height) + 12px) !important;
    transform: none !important; width: 44px; height: 44px; z-index: 90;
  }
  .fab { right: 18px !important; z-index: 89; }
  .flower-fab { right: 74px !important; }
  .calc-fab { right: 130px !important; }
  .avatar-fab { right: 186px !important; }
  .fab::before { content: ""; position: absolute; z-index: -1; right: -8px; top: -8px; width: 228px; height: 60px; border: 1px solid var(--line-soft); border-radius: 30px; background: var(--surface); box-shadow: var(--shadow-md); pointer-events: none; }
  .fab-main, .avatar-main, .flower-main, .calc-main { width: 44px; height: 44px; box-shadow: none; cursor: pointer; }
  .flower-main { transform: none; }
  .flower-main svg { width: 38px; height: 38px; }
  .avatar-bubble { display: none; }
  .fab-panel { top: auto; bottom: calc(var(--phone-nav-height) + 84px); right: 12px; width: min(360px, calc(100vw - 24px)); max-height: calc(100dvh - var(--phone-nav-height) - 170px); transform: none; padding: 16px; border-radius: 20px; }
  .fab-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .fab-item { min-height: 48px; font-size: 13px; }
  .fab-hide { width: 40px; height: 40px; }
  .calc-panel, .calc-panel.opens-down { position: fixed; top: auto; bottom: calc(var(--phone-nav-height) + 84px); right: 12px; width: min(300px, calc(100vw - 24px)); max-height: calc(100dvh - var(--phone-nav-height) - 170px); }
  .calc-keys button { min-height: 44px; font-size: 16px; }
  .toast-region { bottom: calc(var(--phone-nav-height) + 84px); }
  body.modal-open :is(.fab, .avatar-fab, .flower-fab, .calc-fab, .fab-panel) { visibility: hidden; }

  .modal-layer { padding-top: env(safe-area-inset-top, 0px); }
  .modal, .modal.is-wide, .modal.is-small { width: 100%; max-height: calc(100dvh - 16px - env(safe-area-inset-top, 0px)); border-radius: 24px 24px 0 0; }
  .modal-head { padding: 20px 18px 14px; }
  .modal-close { width: 44px; height: 44px; flex-shrink: 0; }
  .modal-body { padding: 18px; overflow-x: hidden; }
  .modal-foot { flex-wrap: wrap; padding: 12px 18px calc(16px + env(safe-area-inset-bottom, 0px)); }
  .modal-foot .btn { flex: 1 1 auto; }
}

@media screen and (max-width: 360px) {
  .topbar { padding-inline: 6px; }
  .topbar .icon-btn, .date-nav .icon-btn { width: 36px; }
  .date-jump { font-size: 11px; padding-inline: 2px; }
  .main-content { padding-inline: 12px; }
  .hero-greeting { font-size: 27px; }
  .fab-grid, .finance-metrics { grid-template-columns: 1fr; }
}

/* Keep long user text inside its own card instead of widening the page. */
.seg-row,.seg-copy,.sleep-row,.sleep-copy,.glucose-row,.glucose-row-main,
.record-day-group,.record-day-items,.record-item,.memo-card,.memo-content,
.hobby-log-row,.hobby-log-copy,.ls-packing-group,.ls-packing-row,
.diary-history-list,.diary-history-item,.co-heatmap-scroll,.heatmap-wrap {
  min-width:0;
  max-width:100%;
  box-sizing:border-box;
}
.seg-row { align-items:flex-start; }
.seg-copy { flex-wrap:wrap; }
.seg-copy strong,.seg-extra,.sleep-copy strong,.sleep-copy span,
.glucose-row-main strong,.glucose-row-main span,.record-title,.memo-title,
.memo-content,.hobby-log-copy strong,.hobby-log-copy span,
.ls-packing-row strong,.ls-packing-row small {
  min-width:0;
  overflow-wrap:anywhere;
  word-break:normal;
}
.seg-actions,.sleep-actions,.hobby-log-actions { flex:none; }
.diary-history-title { display:block; max-width:100%; }
.co-heatmap-scroll,.heatmap-wrap { overflow-x:auto; }
.heatmap-weeks { flex:0 0 auto; }

/* 移动端紧凑化：减少图标底框与空态的留白（2.40.17） */
@media (max-width: 760px) {
  .today-main { gap: 14px; }
  .card { padding: 16px 15px; }

  .empty-state { padding: 12px 4px; gap: 6px; }
  .todo-empty .empty-icon,
  .empty-icon {
    width: 52px;
    height: 52px;
    min-width: 52px;
    border-radius: 50%;
  }
  .empty-icon svg { width: 22px; height: 22px; }
  .empty-state strong { font-size: 15px; }
  .empty-state p { font-size: 12.5px; line-height: 1.55; margin: 2px 0 8px; }

  .todo-suggestions { gap: 6px; margin-top: 6px; }
  .todo-suggestion {
    min-height: 38px;
    padding: 7px 10px;
    font-size: 12.5px;
    border-radius: 10px;
  }

  .du-choice-five,
  .du-choice-grid,
  .du-status-grid {
    grid-template-columns: repeat(auto-fit, minmax(50px, 1fr)) !important;
    gap: 5px !important;
    margin: 9px 0 14px;
  }
  .du-choice {
    min-height: 50px !important;
    padding: 5px 3px !important;
    gap: 3px !important;
    border-radius: 10px;
  }
  .du-choice-icon,
  .du-choice-icon > span { width: 22px; height: 22px; font-size: 18px; }
  .du-choice-icon .icon,
  .du-choice-icon .weather-glyph { width: 18px; height: 18px; }
  .du-choice-label { font-size: 11.5px !important; line-height: 1.25 !important; }

  .icon-btn.wf-small,
  .record-action.ui-icon-only { width: 31px; height: 31px; min-width: 31px; }

  .card-title { font-size: 16px; }
  .wf-home-section { margin-top: 12px; }
}

/* 待办卡片：多选按钮与完成计数同一行（2.40.21） */
.todo-head-tools { display: inline-flex; align-items: center; gap: 6px; flex: none; }
.todo-multi-btn { width: 28px !important; height: 28px !important; min-width: 28px !important; padding: 0; }
.todo-multi-btn .icon { width: 15px; height: 15px; }
@media (max-width: 760px) {
  .todo-head-tools { gap: 5px; }
  .todo-multi-btn { width: 26px !important; height: 26px !important; min-width: 26px !important; }\n  .todo-card-head .card-head { gap: 8px; }
}

/* 待办卡片头：多选按钮收窄，说明文字单行（2.40.23） */
.todo-card .todo-multi-btn { width: 26px !important; height: 26px !important; min-width: 26px !important; flex: 0 0 26px !important; padding: 0 !important; border-radius: 8px; }
.todo-card .todo-multi-btn .icon { width: 14px; height: 14px; }
.todo-card .card-note { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

/* 页级工具（模板/导出）统一上移到顶栏右上角，与设置图标同排 */
.wf-page-tools.is-moved-out { display: none !important; }
.page-header-tools { display: inline-flex; align-items: center; gap: 6px; margin-right: 2px; flex: none; }
.page-header-tools .icon-btn,
.page-header-tools .ui-icon-only { width: 30px !important; height: 30px !important; min-width: 30px !important; flex: 0 0 30px !important; padding: 0 !important; }
.topbar-controls { flex-wrap: nowrap; }
@media (max-width: 760px) {
  .page-header-tools { gap: 5px; margin-right: 1px; }
  .page-header-tools .icon-btn,
  .page-header-tools .ui-icon-only { width: 28px !important; height: 28px !important; min-width: 28px !important; flex: 0 0 28px !important; }
}

.wf-page-tools.is-moved-out,
.wf-page-tools.wf-actions.is-moved-out,
.wf-page-tools.wf-actions.is-moved-out * { display: none !important; height: 0 !important; min-height: 0 !important; }
