@media (max-width: 1120px) {
  .community-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .login-view {
    grid-template-columns: 1fr;
  }

  .login-view {
    align-content: center;
    gap: 28px;
  }

  #loginMessage {
    grid-column: 1;
    width: min(100%, 360px);
    margin-top: -8px;
  }

  .community-detail-content {
    display: block;
    overflow-x: hidden;
    overflow-y: auto;
    scrollbar-width: none;
  }

  .community-detail-profile {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    overflow: visible;
  }

  .community-comments {
    overflow: visible;
  }
}

@media (max-width: 1024px), (max-width: 1366px) and (any-pointer: coarse) {
  .community-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  :root {
    --content-top-gap: max(16px, calc(env(safe-area-inset-top, 0px) + 10px));
    --content-bottom-gap: calc(32px + env(safe-area-inset-bottom, 0px));
    --modal-edge-gap: 12px;
  }

  .app-shell {
    width: min(100% - 22px, 1180px);
    padding: var(--content-top-gap) 0 var(--content-bottom-gap);
  }

  .bottom-tabs {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .bottom-tab {
    height: 52px;
    flex-direction: column;
    gap: 2px;
    padding: 4px 8px;
    font-size: 11px;
    line-height: 1.1;
  }

  .bottom-tab svg {
    width: 20px;
    height: 20px;
  }

  html[data-environment="test"] body::before {
    top: calc(env(safe-area-inset-top, 0px) + 8px);
  }

  .topbar,
  .section-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .profile-title-row {
    gap: 10px;
  }

  .profile-avatar {
    width: 46px;
    height: 46px;
    font-size: 18px;
  }

  .history-heading-actions {
    align-items: stretch;
    justify-content: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .history-toggle-button {
    width: 100%;
  }

  .calendar-weekdays,
  .calendar-grid {
    gap: 3px;
  }

  .calendar-day {
    --calendar-day-font-size: 11px;
    border-radius: 6px;
    height: 15px;
    min-height: 15px;
  }

  button.calendar-day {
    min-height: 15px;
  }

  .calendar-day small {
    display: none;
  }

  .login-row,
  .record-row {
    flex-direction: column;
  }

  .record-fields {
    grid-template-columns: 1fr;
  }

  .account-personal-fields {
    grid-template-columns: 1fr;
  }

  .food-panel-head {
    grid-template-columns: 1fr;
  }

  .food-panel-head .record-submit-button {
    width: 100%;
  }

  .food-selection-dialog {
    padding: 18px;
  }

  .food-selection-head {
    gap: 12px;
  }

  .food-selection-head-actions {
    gap: 6px;
  }

  .food-selection-manual-button {
    padding: 0 10px;
  }

  .food-selection-head h2 {
    font-size: 22px;
  }

  .food-candidate-editor {
    grid-template-columns: 1fr;
  }

  .food-portion-control {
    grid-template-columns: 30px minmax(50px, 70px) 30px auto;
  }

  .food-portion-control small {
    grid-column: auto;
  }

  .action-zone {
    grid-template-columns: 1fr;
  }

  .ai-advice-button {
    min-height: 66px;
    margin-top: 14px;
    padding: 13px 14px;
  }

  .ai-advice-button strong {
    font-size: 17px;
  }

  .replay-launch-button {
    width: 100%;
    min-height: 52px;
  }

  .login-copy h1 {
    font-size: 46px;
  }

  .lead {
    font-size: 17px;
  }

  .chart-detail {
    left: calc(50% + 24px);
    gap: 8px;
    padding: 7px 9px;
  }

  .history-item {
    grid-template-columns: 66px minmax(0, 1fr);
  }

  .history-item.is-food {
    grid-template-columns: 66px minmax(0, 1fr);
  }

  .history-item.is-body-record,
  .history-item.is-health-record {
    grid-template-columns: 66px minmax(0, 1fr);
  }

  .history-thumb {
    width: 66px;
    height: auto;
  }

  .history-body-photo,
  .history-health-thumb {
    width: 66px;
  }

  .history-weight {
    grid-column: 2;
    margin-top: -2px;
    padding-top: 0;
    font-size: 18px;
  }

  .history-item.is-food .history-food-gallery {
    width: 66px;
  }

  .history-item.is-food .history-main {
    grid-column: 2;
  }

  .history-item.is-health-record .history-main {
    grid-column: 2;
  }

  .delete-record-button {
    width: 30px;
    height: 30px;
    min-height: 30px;
  }

  .site-footer {
    flex-direction: column;
    gap: 2px;
    margin-top: auto;
    padding-top: 16px;
  }

  .community-share-panel {
    min-height: 78px;
    align-items: flex-start;
    gap: 10px;
    padding: 13px 14px;
  }

  .community-ranking-header {
    align-items: stretch;
    flex-direction: column;
    gap: 12px;
  }

  .ranking-periods {
    width: 100%;
  }

  .ranking-period {
    padding: 0 8px;
  }

  .ranking-list {
    grid-template-columns: minmax(0, 1fr);
  }

  .ranking-item {
    grid-template-columns: 26px 40px minmax(0, 1fr) auto;
    gap: 9px;
    padding: 9px 10px;
  }

  .ranking-avatar {
    width: 40px;
    height: 40px;
  }

  .community-grid {
    grid-template-columns: 1fr;
  }

  .community-card {
    --community-media-width: 92px;
    --community-cover-height: 123px;
    --community-food-row-height: 46px;
    --community-card-content-height: calc(var(--community-cover-height) + var(--community-media-gap) + var(--community-food-row-height));
    grid-template-columns: var(--community-media-width) minmax(0, 1fr);
  }

  .community-card-media {
    width: var(--community-media-width);
  }

  .community-alias {
    font-size: 16px;
  }

  .community-weight-mini {
    width: 100%;
    min-width: 0;
    min-height: 50px;
    padding: 3px 5px;
  }

  .community-weight-mini svg {
    height: 100%;
  }

  .community-weight-mini.is-empty {
    width: 100%;
    min-width: 0;
    min-height: 50px;
    padding-inline: 6px;
    font-size: 10px;
  }

  .community-detail-backdrop {
    align-items: end;
    padding: 0;
  }

  .community-comments-backdrop {
    align-items: end;
    padding: 0;
  }

  .ai-summary-backdrop {
    align-items: end;
    padding: 0;
  }

  .community-detail-panel {
    width: 100vw;
    height: min(92dvh, 820px);
    max-height: 92dvh;
    border-right: 0;
    border-left: 0;
    border-radius: 12px 12px 0 0;
  }

  .community-comments-panel {
    width: 100vw;
    height: calc(100dvh - var(--modal-safe-top-gap) - 78px);
    max-height: calc(100dvh - var(--modal-safe-top-gap) - 78px);
    border-right: 0;
    border-left: 0;
    border-radius: 12px 12px 0 0;
  }

  .ai-summary-panel {
    width: 100vw;
    height: min(88dvh, 680px);
    border-right: 0;
    border-left: 0;
    border-radius: 12px 12px 0 0;
  }

  .community-detail-header,
  .ai-summary-header {
    padding: 10px 14px;
  }

  .community-detail-header h2,
  .ai-summary-header h2 {
    font-size: 20px;
  }

  .ai-summary-content {
    padding: 14px;
  }

  .ai-summary-output {
    min-height: 220px;
    font-size: 15px;
    line-height: 1.78;
  }

  .markdown-table-wrap table {
    min-width: 480px;
  }

  .community-detail-profile {
    grid-template-columns: minmax(92px, 34%) minmax(0, 1fr);
    gap: 10px;
    padding: 12px 14px 18px;
  }

  .community-detail-summary {
    grid-template-rows: auto auto;
  }

  .community-detail-action-row {
    grid-template-columns: minmax(92px, 34%) minmax(0, 1fr);
    gap: 10px;
  }

  .community-detail-record-area {
    gap: 12px;
    padding: 12px;
  }

  .community-detail-history-section {
    padding: 12px;
  }

  .community-detail-actions {
    height: 40px;
    justify-content: flex-end;
    margin-top: 0;
    margin-left: 0;
  }

  .community-detail-replay {
    width: 100%;
    height: 40px;
    min-height: 40px;
  }

  .community-social-button {
    flex: 0 0 40px;
    width: 40px;
    min-width: 40px;
    min-height: 40px;
    padding: 0;
    font-size: 12px;
  }

  .community-like-button.community-social-button {
    flex-basis: 62px;
    width: 62px;
    min-width: 62px;
    padding: 0 9px;
  }

  .community-comment-button {
    flex-basis: 62px;
    width: 62px;
    min-width: 62px;
  }

  .community-comments {
    padding: 10px 12px max(10px, calc(env(safe-area-inset-bottom, 0px) + 8px));
  }

  .community-comment-form {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 6px;
  }

  .community-comment-item {
    grid-template-columns: 28px minmax(0, 1fr) 40px;
    gap: 8px;
    margin-left: calc(var(--comment-depth, 0) * 12px);
  }

  .community-comment-children {
    gap: 5px;
    padding-left: 7px;
  }

  .community-comment-form button {
    min-width: 58px;
    width: auto;
    padding: 0 12px;
  }

  .community-reply-target button {
    min-width: 44px;
    min-height: 28px;
    padding: 0 10px;
  }

  .consent-dialog,
  .profile-edit-dialog {
    padding: 22px;
  }

  .consent-actions {
    grid-template-columns: 1fr;
  }

  .settings-group {
    padding: 22px 1px;
  }

  .account-management-entry {
    grid-template-columns: 52px minmax(0, 1fr) auto;
    gap: 12px;
    padding: 13px 12px;
  }

  .account-management-entry .settings-account-avatar {
    width: 52px;
    height: 52px;
    font-size: 18px;
  }

  .account-management-summary > strong {
    font-size: 19px;
  }

  .account-overview-fields {
    gap: 6px;
  }

  .account-overview-fields > span {
    padding: 7px 8px;
  }

  .settings-options,
  .native-health-sync {
    padding: 0;
  }

  .settings-option-button {
    align-items: flex-start;
    gap: 12px;
  }

  .settings-option-button .settings-status-pill {
    flex: 0 0 auto;
  }

  .settings-option-meta {
    align-items: flex-start;
  }

  .settings-footer-actions {
    padding-top: 22px;
  }

  .settings-logout-button {
    width: 100%;
  }

  .native-health-switch {
    gap: 12px;
    padding: 13px;
  }

  .native-health-detail-actions {
    display: grid;
  }

  .native-health-sync-button {
    width: 100%;
  }

  .settings-group-heading,
  .danger-zone {
    align-items: flex-start;
  }

  .profile-edit-avatar-row {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .account-binding-card {
    grid-template-columns: 34px minmax(0, 1fr);
  }

  .account-binding-card .account-binding-actions,
  .account-binding-card > .account-bind-button {
    grid-column: 1 / -1;
    justify-content: stretch;
  }

  .account-binding-actions .account-bind-button,
  .account-binding-card > .account-bind-button {
    width: 100%;
  }

  .account-profile-readonly {
    grid-template-columns: 1fr;
  }

  .profile-gender-options {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .profile-gender-options.profile-gender-scroll {
    grid-template-columns: none;
    grid-auto-flow: column;
    grid-auto-columns: minmax(132px, 1fr);
  }

  .birthday-picker-columns {
    grid-template-columns: 1fr 0.82fr 0.82fr;
  }

  .account-profile-actions {
    justify-content: stretch;
  }

  .account-profile-actions button {
    flex: 1 1 0;
  }

  .mode-selector {
    grid-template-columns: 1fr;
  }

  .privacy-audit-summary {
    grid-template-columns: 1fr;
  }

  .passkey-card {
    grid-template-columns: 1fr;
  }

  .passkey-add-button {
    width: 100%;
  }

  .danger-zone {
    flex-direction: column;
  }

  .account-delete-button,
  .withdraw-button {
    width: 100%;
  }

  .privacy-consent-dialog,
  .confirmation-dialog {
    padding: 20px;
  }

  .policy-header {
    padding: 14px;
  }

  .policy-content {
    padding: 18px 16px 28px;
  }

  .replay-modal-backdrop {
    align-items: center;
  }

  .replay-modal-panel {
    width: 80vw;
    height: 80dvh;
  }
}

@media (max-width: 380px) {
  .community-card {
    --community-media-width: 78px;
    --community-cover-height: 104px;
    --community-food-row-height: 39px;
    --community-card-content-height: calc(var(--community-cover-height) + var(--community-media-gap) + var(--community-food-row-height));
    grid-template-columns: var(--community-media-width) minmax(0, 1fr);
    gap: 10px;
  }

  .community-card-media {
    width: var(--community-media-width);
  }

  .community-weight-mini,
  .community-weight-mini.is-empty {
    min-width: 0;
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .pull-refresh,
  .app-shell,
  .chart-detail,
  .consent-backdrop,
  .consent-dialog,
  .policy-backdrop,
  .policy-panel,
  .replay-modal-backdrop,
  .replay-modal-panel,
  .ai-summary-backdrop,
  .ai-summary-panel,
  .community-detail-backdrop,
  .community-detail-panel,
  .community-comments-backdrop,
  .community-comments-panel {
    transition: none;
  }

  .ai-summary-output.is-typing::after {
    animation: none;
  }

  .community-like-button.is-just-liked .community-like-icon,
  .community-like-button.is-just-liked .community-like-icon::before,
  .community-like-button.is-just-liked .community-like-icon::after,
  .community-like-button.is-just-liked .community-like-count,
  .community-food-group {
    animation: none;
    transition: none;
  }
}

/* Final dark-mode audit layer. Keep late-added user surfaces on the same glass palette. */
@media (prefers-color-scheme: dark) {
  html[data-theme^="glass-"] {
    --dark-panel:
      linear-gradient(145deg, rgba(28, 40, 54, 0.84), rgba(14, 23, 35, 0.62)),
      radial-gradient(110% 95% at 0% 0%, rgba(216, 134, 181, 0.12), rgba(14, 23, 35, 0) 58%),
      radial-gradient(110% 95% at 100% 0%, rgba(111, 207, 226, 0.16), rgba(14, 23, 35, 0) 58%);
    --dark-panel-soft:
      linear-gradient(145deg, rgba(32, 45, 60, 0.66), rgba(16, 25, 37, 0.42)),
      radial-gradient(110% 105% at 100% 0%, rgba(111, 207, 226, 0.12), rgba(16, 25, 37, 0) 60%);
    --dark-control:
      linear-gradient(145deg, rgba(38, 53, 69, 0.78), rgba(21, 32, 45, 0.58)),
      radial-gradient(120% 110% at 100% 0%, rgba(111, 207, 226, 0.13), rgba(21, 32, 45, 0) 58%);
    --dark-control-hover:
      linear-gradient(145deg, rgba(48, 65, 82, 0.84), rgba(25, 38, 52, 0.64)),
      radial-gradient(120% 110% at 100% 0%, rgba(111, 207, 226, 0.18), rgba(25, 38, 52, 0) 58%);
    --dark-chip: rgba(107, 198, 220, 0.12);
    --dark-chip-border: rgba(139, 218, 236, 0.18);
    --dark-danger: #ff9cab;
    --dark-danger-soft: rgba(255, 114, 137, 0.14);
    --dark-warning: #e4bb72;
    --dark-warning-soft: rgba(224, 181, 110, 0.14);
    --dark-shadow: 0 30px 92px rgba(0, 0, 0, 0.34), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  }

  html[data-theme^="glass-"] .login-panel,
  html[data-theme^="glass-"] .history-section,
  html[data-theme^="glass-"] .community-share-panel,
  html[data-theme^="glass-"] .community-content-tabs,
  html[data-theme^="glass-"] .community-card,
  html[data-theme^="glass-"] .ranking-periods,
  html[data-theme^="glass-"] .ranking-item,
  html[data-theme^="glass-"] .settings-panel,
  html[data-theme^="glass-"] .settings-detail-panel,
  html[data-theme^="glass-"] .settings-group,
  html[data-theme^="glass-"] .account-profile-card,
  html[data-theme^="glass-"] .account-binding-card,
  html[data-theme^="glass-"] .passkey-card,
  html[data-theme^="glass-"] .native-health-card,
  html[data-theme^="glass-"] .native-health-switch,
  html[data-theme^="glass-"] .chart-card,
  html[data-theme^="glass-"] .calendar-card,
  html[data-theme^="glass-"] .timeline-card,
  html[data-theme^="glass-"] .record-card,
  html[data-theme^="glass-"] .capture-panel,
  html[data-theme^="glass-"] .food-record-panel,
  html[data-theme^="glass-"] .consent-dialog,
  html[data-theme^="glass-"] .community-detail-panel,
  html[data-theme^="glass-"] .community-comments-panel,
  html[data-theme^="glass-"] .ai-summary-panel,
  html[data-theme^="glass-"] .policy-panel,
  html[data-theme^="glass-"] .privacy-consent-dialog,
  html[data-theme^="glass-"] .profile-edit-dialog,
  html[data-theme^="glass-"] .confirmation-dialog,
  html[data-theme^="glass-"] .action-confirm-dialog,
  html[data-theme^="glass-"] .feedback-dialog,
  html[data-theme^="glass-"] .replay-modal-panel,
  html[data-theme^="glass-"] .food-selection-dialog,
  html[data-theme^="glass-"] .manual-food-dialog {
    border-color: var(--glass-stroke);
    background: var(--dark-panel);
    color: var(--ink);
    box-shadow: var(--dark-shadow);
  }

  html[data-theme^="glass-"] .action-confirm-dialog > p:not(.eyebrow) {
    color: var(--muted);
  }

  html[data-theme^="glass-"] .account-binding-icon,
  html[data-theme^="glass-"] .account-profile-readonly,
  html[data-theme^="glass-"] .birthday-picker,
  html[data-theme^="glass-"] .birthday-picker-column,
  html[data-theme^="glass-"] .privacy-audit-summary,
  html[data-theme^="glass-"] .privacy-audit-summary span,
  html[data-theme^="glass-"] .passkey-list-item,
  html[data-theme^="glass-"] .passkey-empty,
  html[data-theme^="glass-"] .native-health-switch,
  html[data-theme^="glass-"] .native-health-json,
  html[data-theme^="glass-"] .privacy-highlights span,
  html[data-theme^="glass-"] .passkey-prompt-visual,
  html[data-theme^="glass-"] .weight-chart,
  html[data-theme^="glass-"] .community-detail-weight-chart,
  html[data-theme^="glass-"] .calendar-grid,
  html[data-theme^="glass-"] .community-weight-mini,
  html[data-theme^="glass-"] .feedback-image-preview,
  html[data-theme^="glass-"] .food-selection-item,
  html[data-theme^="glass-"] .food-candidate-editor,
  html[data-theme^="glass-"] .food-selection-summary,
  html[data-theme^="glass-"] .food-selection-loading,
  html[data-theme^="glass-"] .food-empty-state,
  html[data-theme^="glass-"] .community-comment-bubble,
  html[data-theme^="glass-"] .community-comment-empty,
  html[data-theme^="glass-"] .markdown-table-wrap {
    border-color: rgba(255, 255, 255, 0.14);
    background: var(--dark-panel-soft);
    color: var(--ink);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
  }

  html[data-theme^="glass-"] .community-detail-header,
  html[data-theme^="glass-"] .ai-summary-header,
  html[data-theme^="glass-"] .community-comments-modal-header,
  html[data-theme^="glass-"] .community-detail-profile,
  html[data-theme^="glass-"] .community-detail-record-area,
  html[data-theme^="glass-"] .ai-summary-content {
    border-color: rgba(255, 255, 255, 0.12);
    background:
      linear-gradient(145deg, rgba(28, 40, 54, 0.64), rgba(14, 23, 35, 0.34)),
      radial-gradient(100% 120% at 0% 0%, rgba(216, 134, 181, 0.1), rgba(14, 23, 35, 0) 58%),
      radial-gradient(100% 120% at 100% 0%, rgba(111, 207, 226, 0.12), rgba(14, 23, 35, 0) 58%);
  }

  html[data-theme^="glass-"] .policy-content,
  html[data-theme^="glass-"] .history-food-mood,
  html[data-theme^="glass-"] .ai-summary-output,
  html[data-theme^="glass-"] .markdown-table-wrap,
  html[data-theme^="glass-"] .food-selection-check strong,
  html[data-theme^="glass-"] .food-selection-total,
  html[data-theme^="glass-"] .community-comment-bubble p {
    color: var(--ink);
  }

  html[data-theme^="glass-"] .history-meta,
  html[data-theme^="glass-"] .history-subtitle,
  html[data-theme^="glass-"] .settings-description,
  html[data-theme^="glass-"] .settings-option-button em,
  html[data-theme^="glass-"] .food-selection-copy,
  html[data-theme^="glass-"] .feedback-dialog label,
  html[data-theme^="glass-"] .confirmation-dialog > p:not(.danger-kicker):not(.confirmation-message),
  html[data-theme^="glass-"] .feedback-dialog > p:not(.eyebrow):not(.feedback-message),
  html[data-theme^="glass-"] .account-profile-item > span:first-child,
  html[data-theme^="glass-"] .profile-edit-avatar-row label span,
  html[data-theme^="glass-"] .native-health-json {
    color: var(--muted);
  }

  html[data-theme^="glass-"] .profile-gender-options button,
  html[data-theme^="glass-"] .birthday-picker-toggle,
  html[data-theme^="glass-"] .birthday-picker-done,
  html[data-theme^="glass-"] .birthday-picker-head button,
  html[data-theme^="glass-"] .account-profile-field input,
  html[data-theme^="glass-"] .account-profile-field select,
  html[data-theme^="glass-"] .mode-selector button,
  html[data-theme^="glass-"] .qq-sync-button,
  html[data-theme^="glass-"] .account-bind-button,
  html[data-theme^="glass-"] .profile-edit-dialog .profile-action-button,
  html[data-theme^="glass-"] .ghost-button,
  html[data-theme^="glass-"] .secondary-button,
  html[data-theme^="glass-"] .passkey-add-button,
  html[data-theme^="glass-"] .settings-logout-button,
  html[data-theme^="glass-"] .copy-phrase-button,
  html[data-theme^="glass-"] .community-social-button,
  html[data-theme^="glass-"] .community-like-button,
  html[data-theme^="glass-"] .food-selection-edit-button,
  html[data-theme^="glass-"] .food-selection-ai-button,
  html[data-theme^="glass-"] .food-portion-control button,
  html[data-theme^="glass-"] .modal-icon-button,
  html[data-theme^="glass-"] .food-selection-manual-button,
  html[data-theme^="glass-"] .feedback-upload-button {
    border-color: rgba(255, 255, 255, 0.16);
    background: var(--dark-control);
    color: var(--ink);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.11), 0 8px 22px rgba(0, 0, 0, 0.18);
  }

  html[data-theme^="glass-"] .profile-gender-options button:hover:not(:disabled),
  html[data-theme^="glass-"] .profile-gender-options button:focus-visible,
  html[data-theme^="glass-"] .birthday-picker-toggle:hover:not(:disabled),
  html[data-theme^="glass-"] .birthday-picker-toggle:focus-visible,
  html[data-theme^="glass-"] .birthday-picker-done:hover:not(:disabled),
  html[data-theme^="glass-"] .birthday-picker-done:focus-visible,
  html[data-theme^="glass-"] .birthday-picker-head button:hover:not(:disabled),
  html[data-theme^="glass-"] .birthday-picker-head button:focus-visible,
  html[data-theme^="glass-"] .account-profile-field input:focus,
  html[data-theme^="glass-"] .account-profile-field select:focus,
  html[data-theme^="glass-"] .mode-selector button:hover:not(:disabled),
  html[data-theme^="glass-"] .mode-selector button:focus-visible,
  html[data-theme^="glass-"] .qq-sync-button:hover:not(:disabled),
  html[data-theme^="glass-"] .qq-sync-button:focus-visible,
  html[data-theme^="glass-"] .account-bind-button:hover:not(:disabled),
  html[data-theme^="glass-"] .account-bind-button:focus-visible,
  html[data-theme^="glass-"] .profile-edit-dialog .profile-action-button:hover:not(:disabled),
  html[data-theme^="glass-"] .profile-edit-dialog .profile-action-button:focus-visible,
  html[data-theme^="glass-"] .ghost-button:hover:not(:disabled),
  html[data-theme^="glass-"] .ghost-button:focus-visible,
  html[data-theme^="glass-"] .secondary-button:hover:not(:disabled),
  html[data-theme^="glass-"] .secondary-button:focus-visible,
  html[data-theme^="glass-"] .passkey-add-button:hover:not(:disabled),
  html[data-theme^="glass-"] .passkey-add-button:focus-visible,
  html[data-theme^="glass-"] .settings-logout-button:hover:not(:disabled),
  html[data-theme^="glass-"] .settings-logout-button:focus-visible,
  html[data-theme^="glass-"] .copy-phrase-button:hover:not(:disabled),
  html[data-theme^="glass-"] .copy-phrase-button:focus-visible,
  html[data-theme^="glass-"] .community-social-button:hover:not(:disabled),
  html[data-theme^="glass-"] .community-social-button:focus-visible,
  html[data-theme^="glass-"] .community-like-button:hover:not(:disabled),
  html[data-theme^="glass-"] .community-like-button:focus-visible,
  html[data-theme^="glass-"] .food-selection-edit-button:hover:not(:disabled),
  html[data-theme^="glass-"] .food-selection-edit-button:focus-visible,
  html[data-theme^="glass-"] .food-selection-ai-button:hover:not(:disabled),
  html[data-theme^="glass-"] .food-selection-ai-button:focus-visible,
  html[data-theme^="glass-"] .food-portion-control button:hover:not(:disabled),
  html[data-theme^="glass-"] .food-portion-control button:focus-visible,
  html[data-theme^="glass-"] .modal-icon-button:hover:not(:disabled),
  html[data-theme^="glass-"] .modal-icon-button:focus-visible,
  html[data-theme^="glass-"] .food-selection-manual-button:hover:not(:disabled),
  html[data-theme^="glass-"] .food-selection-manual-button:focus-visible,
  html[data-theme^="glass-"] .feedback-upload-button:hover:not(:disabled),
  html[data-theme^="glass-"] .feedback-upload-button:focus-visible {
    border-color: rgba(189, 239, 255, 0.28);
    background: var(--dark-control-hover);
    color: var(--ink);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.16), 0 12px 30px rgba(0, 0, 0, 0.24);
  }

  html[data-theme^="glass-"] .profile-gender-options button:active:not(:disabled),
  html[data-theme^="glass-"] .birthday-picker-toggle:active:not(:disabled),
  html[data-theme^="glass-"] .birthday-picker-done:active:not(:disabled),
  html[data-theme^="glass-"] .birthday-picker-head button:active:not(:disabled),
  html[data-theme^="glass-"] .mode-selector button:active:not(:disabled),
  html[data-theme^="glass-"] .qq-sync-button:active:not(:disabled),
  html[data-theme^="glass-"] .account-bind-button:active:not(:disabled),
  html[data-theme^="glass-"] .profile-edit-dialog .profile-action-button:active:not(:disabled),
  html[data-theme^="glass-"] .ghost-button:active:not(:disabled),
  html[data-theme^="glass-"] .secondary-button:active:not(:disabled),
  html[data-theme^="glass-"] .passkey-add-button:active:not(:disabled),
  html[data-theme^="glass-"] .settings-logout-button:active:not(:disabled),
  html[data-theme^="glass-"] .copy-phrase-button:active:not(:disabled),
  html[data-theme^="glass-"] .community-social-button:active:not(:disabled),
  html[data-theme^="glass-"] .community-like-button:active:not(:disabled),
  html[data-theme^="glass-"] .food-selection-edit-button:active:not(:disabled),
  html[data-theme^="glass-"] .food-selection-ai-button:active:not(:disabled),
  html[data-theme^="glass-"] .food-portion-control button:active:not(:disabled),
  html[data-theme^="glass-"] .modal-icon-button:active:not(:disabled),
  html[data-theme^="glass-"] .food-selection-manual-button:active:not(:disabled),
  html[data-theme^="glass-"] .feedback-upload-button:active:not(:disabled) {
    background: rgba(22, 34, 48, 0.84);
    box-shadow: inset 0 1px 10px rgba(0, 0, 0, 0.2);
  }

  html[data-theme^="glass-"] .profile-gender-options button.is-active,
  html[data-theme^="glass-"] .mode-selector button.is-active,
  html[data-theme^="glass-"] .mode-selector button.is-active:hover:not(:disabled),
  html[data-theme^="glass-"] .mode-selector button.is-active:focus-visible,
  html[data-theme^="glass-"] .birthday-picker-column button.is-selected,
  html[data-theme^="glass-"] .food-selection-item.is-selected {
    border-color: rgba(189, 239, 255, 0.38);
    background:
      linear-gradient(145deg, rgba(54, 75, 92, 0.72), rgba(21, 34, 48, 0.5)),
      radial-gradient(110% 110% at 100% 0%, rgba(111, 207, 226, 0.22), rgba(21, 34, 48, 0) 58%);
    color: var(--primary);
    box-shadow: inset 0 0 0 1px rgba(189, 239, 255, 0.12), 0 0 0 3px rgba(111, 207, 226, 0.08);
  }

  html[data-theme^="glass-"] .birthday-picker-column button,
  html[data-theme^="glass-"] .document-link,
  html[data-theme^="glass-"] .consent-document-row button,
  html[data-theme^="glass-"] .settings-back-button,
  html[data-theme^="glass-"] .passkey-delete-button {
    background: transparent;
    box-shadow: none;
  }

  html[data-theme^="glass-"] .birthday-picker-column button:hover:not(:disabled),
  html[data-theme^="glass-"] .birthday-picker-column button:focus-visible {
    background: rgba(255, 255, 255, 0.08);
    color: var(--primary);
  }

  html[data-theme^="glass-"] .document-link,
  html[data-theme^="glass-"] .document-link:hover:not(:disabled),
  html[data-theme^="glass-"] .document-link:focus-visible,
  html[data-theme^="glass-"] .document-link:active:not(:disabled),
  html[data-theme^="glass-"] .consent-document-row button,
  html[data-theme^="glass-"] .consent-document-row button:hover:not(:disabled),
  html[data-theme^="glass-"] .consent-document-row button:focus-visible,
  html[data-theme^="glass-"] .consent-document-row button:active:not(:disabled),
  html[data-theme^="glass-"] .settings-back-button,
  html[data-theme^="glass-"] .settings-back-button:hover:not(:disabled),
  html[data-theme^="glass-"] .settings-back-button:focus-visible,
  html[data-theme^="glass-"] .settings-back-button:active:not(:disabled) {
    color: var(--primary);
  }

  html[data-theme^="glass-"] .account-personal-fields input,
  html[data-theme^="glass-"] .account-personal-fields select,
  html[data-theme^="glass-"] .feedback-dialog textarea,
  html[data-theme^="glass-"] .confirmation-dialog input,
  html[data-theme^="glass-"] .food-candidate-editor input,
  html[data-theme^="glass-"] .food-portion-control input,
  html[data-theme^="glass-"] .manual-food-field input,
  html[data-theme^="glass-"] .community-comment-form input,
  html[data-theme^="glass-"] .community-comment-form textarea {
    border-color: rgba(255, 255, 255, 0.16);
    background: rgba(12, 20, 31, 0.66);
    color: var(--ink);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
  }

  html[data-theme^="glass-"] .account-personal-fields input:focus,
  html[data-theme^="glass-"] .account-personal-fields select:focus,
  html[data-theme^="glass-"] .feedback-dialog textarea:focus,
  html[data-theme^="glass-"] .confirmation-dialog input:focus,
  html[data-theme^="glass-"] .food-candidate-editor input:focus,
  html[data-theme^="glass-"] .food-portion-control input:focus,
  html[data-theme^="glass-"] .manual-food-field input:focus,
  html[data-theme^="glass-"] .community-comment-form input:focus,
  html[data-theme^="glass-"] .community-comment-form textarea:focus {
    border-color: rgba(189, 239, 255, 0.34);
    background: rgba(15, 25, 38, 0.78);
    box-shadow: 0 0 0 3px rgba(111, 207, 226, 0.14), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  }

  html[data-theme^="glass-"] input::placeholder,
  html[data-theme^="glass-"] textarea::placeholder {
    color: rgba(183, 198, 209, 0.58);
  }

  html[data-theme^="glass-"] .withdraw-button,
  html[data-theme^="glass-"] .account-delete-button,
  html[data-theme^="glass-"] .danger-confirm-button {
    border-color: rgba(255, 156, 171, 0.28);
    background:
      linear-gradient(145deg, rgba(82, 36, 52, 0.64), rgba(40, 24, 35, 0.48)),
      radial-gradient(110% 120% at 100% 0%, rgba(255, 156, 171, 0.16), rgba(40, 24, 35, 0) 58%);
    color: var(--dark-danger);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 8px 20px rgba(0, 0, 0, 0.2);
  }

  html[data-theme^="glass-"] .withdraw-button:hover:not(:disabled),
  html[data-theme^="glass-"] .account-delete-button:hover:not(:disabled),
  html[data-theme^="glass-"] .account-delete-button:focus-visible,
  html[data-theme^="glass-"] .danger-confirm-button:hover:not(:disabled),
  html[data-theme^="glass-"] .danger-confirm-button:focus-visible {
    background:
      linear-gradient(145deg, rgba(94, 42, 59, 0.74), rgba(46, 26, 38, 0.58)),
      radial-gradient(110% 120% at 100% 0%, rgba(255, 156, 171, 0.22), rgba(46, 26, 38, 0) 58%);
  }

  html[data-theme^="glass-"] .passkey-delete-button,
  html[data-theme^="glass-"] .passkey-delete-button:hover:not(:disabled),
  html[data-theme^="glass-"] .passkey-delete-button:focus-visible,
  html[data-theme^="glass-"] .passkey-delete-button:active:not(:disabled) {
    color: var(--dark-danger);
  }

  html[data-theme^="glass-"] .copy-phrase-button.is-copied {
    border-color: rgba(111, 207, 226, 0.32);
    background: rgba(111, 207, 226, 0.14);
    color: var(--primary);
  }

  html[data-theme^="glass-"] .copy-phrase-button.is-copy-failed,
  html[data-theme^="glass-"] .account-status-notice {
    border-color: rgba(255, 156, 171, 0.28);
    background: var(--dark-danger-soft);
    color: var(--dark-danger);
  }

  html[data-theme^="glass-"] .account-status-notice[data-status="frozen"] {
    border-color: rgba(228, 187, 114, 0.28);
    background: var(--dark-warning-soft);
    color: var(--dark-warning);
  }

  html[data-theme^="glass-"] .chart-y-axis {
    border-right-color: rgba(255, 255, 255, 0.14);
    background: transparent;
    color: rgba(222, 236, 242, 0.62);
    box-shadow: none;
  }

  html[data-theme^="glass-"] .chart-detail {
    border-color: rgba(255, 255, 255, 0.16);
    background: var(--dark-panel-soft);
    color: var(--ink);
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  }

  html[data-theme^="glass-"] .calendar-day {
    color: rgba(238, 248, 251, 0.86);
  }

  html[data-theme^="glass-"] .calendar-day.is-empty {
    border-color: rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.04);
    color: rgba(167, 182, 195, 0.48);
  }

  html[data-theme^="glass-"] .community-detail-cover,
  html[data-theme^="glass-"] .history-thumb,
  html[data-theme^="glass-"] .history-body-photo,
  html[data-theme^="glass-"] .history-health-thumb,
  html[data-theme^="glass-"] .history-food-gallery,
  html[data-theme^="glass-"] .history-food-gallery.is-empty,
  html[data-theme^="glass-"] .history-food-track img {
    background: rgba(139, 218, 236, 0.1);
    color: #9eddea;
  }

  html[data-theme^="glass-"] .community-detail-history-section,
  html[data-theme^="glass-"] .history-item,
  html[data-theme^="glass-"] .food-history-card,
  html[data-theme^="glass-"] .history-food-entry,
  html[data-theme^="glass-"] .history-health-entry,
  html[data-theme^="glass-"] .history-food-list > span {
    border-color: rgba(255, 255, 255, 0.14);
    background: var(--dark-panel-soft);
  }

  html[data-theme^="glass-"] .history-food-summary span,
  html[data-theme^="glass-"] .food-nutrition-grid span,
  html[data-theme^="glass-"] .food-selection-nutrition span,
  html[data-theme^="glass-"] .history-food-nutrition span,
  html[data-theme^="glass-"] .food-selection-data span {
    border-color: var(--dark-chip-border);
    background: var(--dark-chip);
    color: rgba(225, 242, 248, 0.86);
  }

  html[data-theme^="glass-"] .ai-summary-output code {
    background: rgba(111, 207, 226, 0.14);
    color: #b9eef8;
  }

  html[data-theme^="glass-"] .ai-summary-output blockquote {
    border-left-color: rgba(236, 161, 198, 0.36);
    background: rgba(236, 161, 198, 0.1);
  }

  html[data-theme^="glass-"] .markdown-table-wrap th {
    background: rgba(111, 207, 226, 0.12);
    color: #b9eef8;
  }

  html[data-theme^="glass-"] .food-selection-loading .food-selection-spinner {
    border-color: rgba(189, 239, 255, 0.16);
    border-top-color: var(--primary);
  }

  html[data-theme^="glass-"] .food-selection-ai-button {
    background:
      linear-gradient(135deg, rgba(70, 56, 96, 0.66), rgba(31, 65, 82, 0.52)),
      radial-gradient(110% 120% at 100% 0%, rgba(157, 218, 255, 0.16), rgba(31, 65, 82, 0) 58%);
  }

  html[data-theme^="glass-"] .community-food-dots span {
    background: rgba(139, 218, 236, 0.24);
  }

  html[data-theme^="glass-"] .community-food-dots span.is-active {
    background: rgba(236, 161, 198, 0.74);
  }

  html[data-theme^="glass-"] .community-like-button.is-liked {
    background:
      linear-gradient(145deg, rgba(78, 58, 34, 0.62), rgba(36, 29, 23, 0.46)),
      radial-gradient(120% 120% at 100% 0%, rgba(255, 214, 123, 0.18), rgba(36, 29, 23, 0) 58%);
  }

  html[data-theme^="glass-"] .community-comment-item.is-own .community-comment-bubble {
    border-color: rgba(139, 218, 236, 0.18);
    background: rgba(111, 207, 226, 0.12);
  }

  html[data-theme^="glass-"] .community-comment-empty-icon {
    background: rgba(111, 207, 226, 0.12);
    color: var(--primary);
  }
}

/* Dark palette polish. The red-blue glass theme needs darker glass layers, not milky panels. */
@media (prefers-color-scheme: dark) {
  html[data-theme^="glass-"] {
    --dark-panel:
      linear-gradient(145deg, rgba(18, 29, 43, 0.86), rgba(7, 14, 25, 0.74)),
      radial-gradient(115% 95% at 0% 0%, rgba(216, 134, 181, 0.08), rgba(7, 14, 25, 0) 58%),
      radial-gradient(115% 95% at 100% 0%, rgba(111, 207, 226, 0.11), rgba(7, 14, 25, 0) 58%);
    --dark-panel-soft:
      linear-gradient(145deg, rgba(22, 35, 50, 0.64), rgba(8, 16, 28, 0.54)),
      radial-gradient(110% 105% at 100% 0%, rgba(111, 207, 226, 0.08), rgba(8, 16, 28, 0) 60%);
    --dark-panel-faint: linear-gradient(145deg, rgba(21, 34, 48, 0.46), rgba(7, 14, 25, 0.38));
    --dark-control:
      linear-gradient(145deg, rgba(26, 41, 58, 0.78), rgba(10, 20, 34, 0.68)),
      radial-gradient(120% 110% at 100% 0%, rgba(111, 207, 226, 0.1), rgba(10, 20, 34, 0) 58%);
    --dark-control-hover:
      linear-gradient(145deg, rgba(33, 50, 68, 0.86), rgba(13, 24, 39, 0.74)),
      radial-gradient(120% 110% at 100% 0%, rgba(111, 207, 226, 0.15), rgba(13, 24, 39, 0) 58%);
    --dark-selected:
      linear-gradient(145deg, rgba(36, 72, 90, 0.7), rgba(14, 29, 45, 0.64)),
      radial-gradient(115% 110% at 100% 0%, rgba(131, 211, 229, 0.22), rgba(14, 29, 45, 0) 58%);
    --dark-border: rgba(163, 219, 234, 0.2);
    --dark-border-strong: rgba(190, 239, 250, 0.34);
    --dark-border-soft: rgba(255, 255, 255, 0.1);
    --dark-text-muted: rgba(214, 229, 237, 0.7);
    --dark-text-faint: rgba(190, 206, 217, 0.52);
    --dark-shadow: 0 26px 82px rgba(0, 0, 0, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.08);
    --chart-grid: rgba(196, 228, 238, 0.13);
    --chart-axis: rgba(199, 231, 241, 0.18);
    --chart-empty: rgba(117, 195, 213, 0.18);
    --chart-prediction: #c8baff;
    --chart-prediction-soft: rgba(200, 186, 255, 0.18);
    --chart-prediction-glow: rgba(200, 186, 255, 0.24);
    --calendar-loss: #78c6d9;
    --calendar-gain: #df91aa;
    --calendar-neutral: rgba(255, 255, 255, 0.055);
    --calendar-selected-bg: rgba(189, 239, 255, 0.08);
    --calorie-gold: #d9ad65;
    --calorie-gold-soft: rgba(217, 173, 101, 0.14);
  }

  html[data-theme^="glass-"] .history-section,
  html[data-theme^="glass-"] .community-share-panel,
  html[data-theme^="glass-"] .community-card,
  html[data-theme^="glass-"] .ranking-item,
  html[data-theme^="glass-"] .settings-panel,
  html[data-theme^="glass-"] .settings-detail-panel,
  html[data-theme^="glass-"] .settings-group,
  html[data-theme^="glass-"] .account-profile-card,
  html[data-theme^="glass-"] .account-binding-card,
  html[data-theme^="glass-"] .passkey-card,
  html[data-theme^="glass-"] .native-health-card,
  html[data-theme^="glass-"] .chart-card,
  html[data-theme^="glass-"] .calendar-card,
  html[data-theme^="glass-"] .timeline-card,
  html[data-theme^="glass-"] .record-card,
  html[data-theme^="glass-"] .capture-panel,
  html[data-theme^="glass-"] .food-record-panel,
  html[data-theme^="glass-"] .consent-dialog,
  html[data-theme^="glass-"] .community-detail-panel,
  html[data-theme^="glass-"] .community-comments-panel,
  html[data-theme^="glass-"] .ai-summary-panel,
  html[data-theme^="glass-"] .policy-panel,
  html[data-theme^="glass-"] .privacy-consent-dialog,
  html[data-theme^="glass-"] .profile-edit-dialog,
  html[data-theme^="glass-"] .confirmation-dialog,
  html[data-theme^="glass-"] .feedback-dialog,
  html[data-theme^="glass-"] .replay-modal-panel,
  html[data-theme^="glass-"] .food-selection-dialog,
  html[data-theme^="glass-"] .manual-food-dialog {
    border-color: var(--dark-border);
    background: var(--dark-panel);
    color: var(--ink);
    box-shadow: var(--dark-shadow);
  }

  html[data-theme^="glass-"] .community-detail-header,
  html[data-theme^="glass-"] .community-detail-profile,
  html[data-theme^="glass-"] .community-detail-record-area,
  html[data-theme^="glass-"] .community-comments-modal-header,
  html[data-theme^="glass-"] .ai-summary-header,
  html[data-theme^="glass-"] .ai-summary-content {
    border-color: var(--dark-border-soft);
    background:
      linear-gradient(145deg, rgba(21, 34, 49, 0.72), rgba(8, 16, 28, 0.58)),
      radial-gradient(100% 120% at 0% 0%, rgba(216, 134, 181, 0.07), rgba(8, 16, 28, 0) 58%),
      radial-gradient(100% 120% at 100% 0%, rgba(111, 207, 226, 0.09), rgba(8, 16, 28, 0) 58%);
    color: var(--ink);
  }

  html[data-theme^="glass-"] .community-content-tabs,
  html[data-theme^="glass-"] .ranking-periods {
    border-color: var(--dark-border-soft);
    background: rgba(7, 14, 25, 0.42);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
  }

  html[data-theme^="glass-"] .community-content-tab:not(.is-active),
  html[data-theme^="glass-"] .community-content-tab:not(.is-active):hover:not(:disabled),
  html[data-theme^="glass-"] .community-content-tab:not(.is-active):focus-visible,
  html[data-theme^="glass-"] .community-content-tab:not(.is-active):active:not(:disabled),
  html[data-theme^="glass-"] .ranking-period:not(.is-active),
  html[data-theme^="glass-"] .ranking-period:not(.is-active):hover:not(:disabled),
  html[data-theme^="glass-"] .ranking-period:not(.is-active):focus-visible,
  html[data-theme^="glass-"] .ranking-period:not(.is-active):active:not(:disabled) {
    border-color: transparent;
    background: transparent;
    color: rgba(214, 229, 237, 0.54);
    box-shadow: none;
  }

  html[data-theme^="glass-"] .community-content-tab.is-active,
  html[data-theme^="glass-"] .community-content-tab.is-active:hover:not(:disabled),
  html[data-theme^="glass-"] .community-content-tab.is-active:focus-visible,
  html[data-theme^="glass-"] .ranking-period.is-active,
  html[data-theme^="glass-"] .ranking-period.is-active:hover:not(:disabled),
  html[data-theme^="glass-"] .ranking-period.is-active:focus-visible {
    border-color: var(--dark-border-strong);
    background: var(--dark-selected);
    color: #bdefff;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 10px 26px rgba(0, 0, 0, 0.18);
  }

  html[data-theme^="glass-"] .weight-chart,
  html[data-theme^="glass-"] .community-detail-weight-chart,
  html[data-theme^="glass-"] .community-detail-trend,
  html[data-theme^="glass-"] .weight-calendar,
  html[data-theme^="glass-"] .weight-goal-chart,
  html[data-theme^="glass-"] .community-weight-mini,
  html[data-theme^="glass-"] .history-item,
  html[data-theme^="glass-"] .food-history-card,
  html[data-theme^="glass-"] .history-food-entry,
  html[data-theme^="glass-"] .history-health-entry,
  html[data-theme^="glass-"] .history-food-list > span,
  html[data-theme^="glass-"] .record-entry-button,
  html[data-theme^="glass-"] .replay-launch-button,
  html[data-theme^="glass-"] .community-detail-replay,
  html[data-theme^="glass-"] .community-comment-empty,
  html[data-theme^="glass-"] .community-comment-bubble,
  html[data-theme^="glass-"] .food-selection-item,
  html[data-theme^="glass-"] .food-selection-summary,
  html[data-theme^="glass-"] .food-candidate-editor,
  html[data-theme^="glass-"] .food-empty-state,
  html[data-theme^="glass-"] .markdown-table-wrap {
    border-color: var(--dark-border);
    background: var(--dark-panel-soft);
    color: var(--ink);
    box-shadow: 0 16px 44px rgba(0, 0, 0, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  }

  html[data-theme^="glass-"] .goal-chart-metric {
    color: rgba(221, 237, 243, 0.72);
  }

  html[data-theme^="glass-"] .goal-chart-head span,
  html[data-theme^="glass-"] .goal-chart-head strong small {
    color: var(--dark-text-muted);
  }

  html[data-theme^="glass-"] .goal-chart-head strong,
  html[data-theme^="glass-"] .goal-chart-point-label {
    color: var(--ink);
    fill: var(--ink);
  }

  html[data-theme^="glass-"] .goal-chart-point circle {
    stroke: rgba(244, 251, 253, 0.86);
  }

  html[data-theme^="glass-"] .calendar-grid {
    border: 0;
    background: transparent;
    box-shadow: none;
  }

  html[data-theme^="glass-"] .calendar-detail,
  html[data-theme^="glass-"] .chart-detail {
    border-color: var(--dark-border-strong);
    background:
      linear-gradient(145deg, rgba(30, 45, 61, 0.9), rgba(11, 21, 35, 0.84)),
      radial-gradient(100% 120% at 100% 0%, rgba(111, 207, 226, 0.14), rgba(11, 21, 35, 0) 58%);
    color: var(--dark-text-muted);
    box-shadow: 0 16px 42px rgba(0, 0, 0, 0.34), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  }

  html[data-theme^="glass-"] .chart-detail-date,
  html[data-theme^="glass-"] .calendar-detail-date {
    color: #f4fbfd;
  }

  html[data-theme^="glass-"] .chart-detail strong,
  html[data-theme^="glass-"] .calendar-detail strong {
    color: #bdefff;
  }

  html[data-theme^="glass-"] .account-profile-field input {
    color-scheme: dark;
    caret-color: var(--primary);
  }

  html[data-theme^="glass-"] .account-profile-field input::placeholder {
    color: var(--dark-text-faint);
  }

  html[data-theme^="glass-"] .account-profile-field input[type="date"]::-webkit-date-and-time-value {
    color: var(--ink);
  }

  html[data-theme^="glass-"] .account-profile-field input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(1) saturate(0.9) opacity(0.78);
  }

  html[data-theme^="glass-"] .chart-detail.is-prediction {
    border-color: var(--chart-prediction-soft);
    box-shadow:
      0 18px 46px rgba(0, 0, 0, 0.28),
      0 0 30px var(--chart-prediction-soft),
      inset 0 1px 0 rgba(255, 255, 255, 0.12);
  }

  html[data-theme^="glass-"] .chart-detail.is-prediction strong {
    color: var(--chart-prediction);
  }

  html[data-theme^="glass-"] .chart-y-axis {
    border-right-color: var(--dark-border-soft);
    background:
      linear-gradient(180deg, rgba(12, 22, 35, 0.68), rgba(7, 14, 25, 0.48)),
      radial-gradient(120% 100% at 0% 0%, rgba(111, 207, 226, 0.06), rgba(7, 14, 25, 0) 58%);
    color: var(--dark-text-muted);
    box-shadow: none;
  }

  html[data-theme^="glass-"] .chart-day-label,
  html[data-theme^="glass-"] .community-detail-trend-day-label {
    fill: var(--dark-text-muted);
  }

  html[data-theme^="glass-"] .calendar-weekdays,
  html[data-theme^="glass-"] .calendar-head span,
  html[data-theme^="glass-"] .community-card-time,
  html[data-theme^="glass-"] .community-detail-latest,
  html[data-theme^="glass-"] .history-note,
  html[data-theme^="glass-"] .history-meta,
  html[data-theme^="glass-"] .history-subtitle,
  html[data-theme^="glass-"] .history-food-entry > span,
  html[data-theme^="glass-"] .history-health-entry > span,
  html[data-theme^="glass-"] .history-food-list em,
  html[data-theme^="glass-"] .community-card-footer,
  html[data-theme^="glass-"] .community-card-date,
  html[data-theme^="glass-"] .community-card-meta,
  html[data-theme^="glass-"] .settings-description {
    color: var(--dark-text-muted);
  }

  html[data-theme^="glass-"] .calendar-head strong,
  html[data-theme^="glass-"] .history-time,
  html[data-theme^="glass-"] .history-food-entry > strong,
  html[data-theme^="glass-"] .history-health-entry > strong,
  html[data-theme^="glass-"] .record-entry-button strong,
  html[data-theme^="glass-"] .replay-launch-button,
  html[data-theme^="glass-"] .community-detail-header h2,
  html[data-theme^="glass-"] .community-comments-modal-header h2 {
    color: var(--ink);
  }

  html[data-theme^="glass-"] .history-mood,
  html[data-theme^="glass-"] .history-food-mood,
  html[data-theme^="glass-"] .community-card-mood,
  html[data-theme^="glass-"] .community-detail-mood {
    color: rgba(239, 248, 251, 0.88);
  }

  html[data-theme^="glass-"] .history-weight,
  html[data-theme^="glass-"] .history-weight-summary strong,
  html[data-theme^="glass-"] .community-self-badge,
  html[data-theme^="glass-"] .community-card-records {
    color: #78cfe2;
  }

  html[data-theme^="glass-"] .history-weight-summary strong {
    background: rgba(117, 195, 213, 0.14);
  }

  html[data-theme^="glass-"] .history-food-summary:not(.history-health-summary) strong,
  html[data-theme^="glass-"] .history-food-calories {
    color: var(--calorie-gold);
  }

  html[data-theme^="glass-"] .history-food-summary:not(.history-health-summary) strong {
    background: var(--calorie-gold-soft);
  }

  html[data-theme^="glass-"] .history-health-summary strong {
    color: #b7b0ff;
  }

  html[data-theme^="glass-"] .history-workout-summary strong {
    color: #e3bd70;
  }

  html[data-theme^="glass-"] .history-food-summary span,
  html[data-theme^="glass-"] .food-nutrition-grid span,
  html[data-theme^="glass-"] .food-selection-nutrition span,
  html[data-theme^="glass-"] .history-food-nutrition span,
  html[data-theme^="glass-"] .food-selection-data span {
    border-color: rgba(142, 216, 234, 0.2);
    background: rgba(117, 195, 213, 0.13);
    color: rgba(224, 244, 249, 0.9);
  }

  html[data-theme^="glass-"] .calendar-day,
  html[data-theme^="glass-"] button.calendar-day {
    border-color: rgba(163, 219, 234, 0.13);
    background: var(--day-color, var(--calendar-neutral));
    color: rgba(236, 246, 249, 0.84);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
  }

  html[data-theme^="glass-"] button.calendar-day:hover:not(:disabled),
  html[data-theme^="glass-"] button.calendar-day:focus-visible,
  html[data-theme^="glass-"] button.calendar-day:active:not(:disabled) {
    border-color: rgba(190, 239, 250, 0.32);
    background: var(--day-color, var(--calendar-neutral));
    color: rgba(246, 252, 253, 0.92);
    box-shadow: 0 0 0 1px rgba(190, 239, 250, 0.14), 0 0 12px rgba(111, 207, 226, 0.1);
  }

  html[data-theme^="glass-"] .calendar-day.is-selected,
  html[data-theme^="glass-"] button.calendar-day.is-selected:hover:not(:disabled),
  html[data-theme^="glass-"] button.calendar-day.is-selected:focus-visible,
  html[data-theme^="glass-"] button.calendar-day.is-selected:active:not(:disabled) {
    border-color: rgba(190, 239, 250, 0.58);
    background: var(--day-color, var(--calendar-selected-bg));
    color: #f6fcfd;
    box-shadow: 0 0 0 1px rgba(190, 239, 250, 0.24), 0 0 14px rgba(111, 207, 226, 0.13);
  }

  html[data-theme^="glass-"] .calendar-day.is-up {
    border-color: rgba(223, 145, 170, 0.32);
    background: color-mix(in srgb, var(--day-color) 48%, rgba(8, 16, 28, 0.68));
    color: #ffe1e8;
  }

  html[data-theme^="glass-"] .calendar-day.is-down {
    border-color: rgba(120, 198, 217, 0.34);
    background: color-mix(in srgb, var(--day-color) 48%, rgba(8, 16, 28, 0.68));
    color: #def8ff;
  }

  html[data-theme^="glass-"] .calendar-day.is-empty {
    border-color: rgba(255, 255, 255, 0.065);
    background: rgba(255, 255, 255, 0.035);
    color: rgba(188, 205, 216, 0.42);
  }

  html[data-theme^="glass-"] .record-entry-button small,
  html[data-theme^="glass-"] .history-loader,
  html[data-theme^="glass-"] .chart-empty,
  html[data-theme^="glass-"] .calendar-empty {
    color: var(--dark-text-muted);
  }

  html[data-theme^="glass-"] .community-detail-close,
  html[data-theme^="glass-"] .community-comments-close,
  html[data-theme^="glass-"] .community-social-button,
  html[data-theme^="glass-"] .community-like-button,
  html[data-theme^="glass-"] .history-toggle-button,
  html[data-theme^="glass-"] .account-profile-field input,
  html[data-theme^="glass-"] .ghost-button,
  html[data-theme^="glass-"] .secondary-button,
  html[data-theme^="glass-"] .passkey-add-button,
  html[data-theme^="glass-"] .settings-logout-button,
  html[data-theme^="glass-"] .feedback-upload-button,
  html[data-theme^="glass-"] .food-selection-edit-button,
  html[data-theme^="glass-"] .food-selection-ai-button,
  html[data-theme^="glass-"] .food-selection-manual-button,
  html[data-theme^="glass-"] .modal-icon-button {
    border-color: var(--dark-border);
    background: var(--dark-control);
    color: var(--ink);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 8px 22px rgba(0, 0, 0, 0.18);
  }

  html[data-theme^="glass-"] .community-detail-close:hover:not(:disabled),
  html[data-theme^="glass-"] .community-detail-close:focus-visible,
  html[data-theme^="glass-"] .community-comments-close:hover:not(:disabled),
  html[data-theme^="glass-"] .community-comments-close:focus-visible,
  html[data-theme^="glass-"] .community-social-button:hover:not(:disabled),
  html[data-theme^="glass-"] .community-social-button:focus-visible,
  html[data-theme^="glass-"] .community-like-button:hover:not(:disabled),
  html[data-theme^="glass-"] .community-like-button:focus-visible,
  html[data-theme^="glass-"] .history-toggle-button:hover:not(:disabled),
  html[data-theme^="glass-"] .history-toggle-button:focus-visible,
  html[data-theme^="glass-"] .account-profile-field input:focus,
  html[data-theme^="glass-"] .ghost-button:hover:not(:disabled),
  html[data-theme^="glass-"] .ghost-button:focus-visible,
  html[data-theme^="glass-"] .secondary-button:hover:not(:disabled),
  html[data-theme^="glass-"] .secondary-button:focus-visible,
  html[data-theme^="glass-"] .passkey-add-button:hover:not(:disabled),
  html[data-theme^="glass-"] .passkey-add-button:focus-visible,
  html[data-theme^="glass-"] .settings-logout-button:hover:not(:disabled),
  html[data-theme^="glass-"] .settings-logout-button:focus-visible,
  html[data-theme^="glass-"] .feedback-upload-button:hover:not(:disabled),
  html[data-theme^="glass-"] .feedback-upload-button:focus-visible,
  html[data-theme^="glass-"] .food-selection-edit-button:hover:not(:disabled),
  html[data-theme^="glass-"] .food-selection-edit-button:focus-visible,
  html[data-theme^="glass-"] .food-selection-ai-button:hover:not(:disabled),
  html[data-theme^="glass-"] .food-selection-ai-button:focus-visible,
  html[data-theme^="glass-"] .food-selection-manual-button:hover:not(:disabled),
  html[data-theme^="glass-"] .food-selection-manual-button:focus-visible,
  html[data-theme^="glass-"] .modal-icon-button:hover:not(:disabled),
  html[data-theme^="glass-"] .modal-icon-button:focus-visible {
    border-color: var(--dark-border-strong);
    background: var(--dark-control-hover);
    color: var(--ink);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14), 0 12px 30px rgba(0, 0, 0, 0.24);
  }

  html[data-theme^="glass-"] .community-like-button.is-liked {
    border-color: rgba(237, 191, 105, 0.34);
    background:
      linear-gradient(145deg, rgba(72, 51, 28, 0.66), rgba(26, 23, 19, 0.54)),
      radial-gradient(120% 120% at 100% 0%, rgba(255, 214, 123, 0.18), rgba(26, 23, 19, 0) 58%);
    color: #e9b955;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 10px 24px rgba(0, 0, 0, 0.2);
  }

  html[data-theme^="glass-"] .community-like-button.is-liked:hover:not(:disabled),
  html[data-theme^="glass-"] .community-like-button.is-liked:focus-visible {
    border-color: rgba(246, 208, 126, 0.46);
    background:
      linear-gradient(145deg, rgba(82, 58, 31, 0.74), rgba(32, 27, 21, 0.62)),
      radial-gradient(120% 120% at 100% 0%, rgba(255, 214, 123, 0.23), rgba(32, 27, 21, 0) 58%);
    color: #f2c769;
  }

  html[data-theme^="glass-"] .delete-record-button,
  html[data-theme^="glass-"] .delete-record-button:focus:not(:focus-visible),
  html[data-theme^="glass-"] .food-delete-button,
  html[data-theme^="glass-"] .food-delete-button:focus:not(:focus-visible) {
    border-color: transparent;
    background: transparent;
    color: #ff91a3;
    box-shadow: none;
  }

  html[data-theme^="glass-"] .delete-record-button:hover:not(:disabled),
  html[data-theme^="glass-"] .delete-record-button:focus-visible,
  html[data-theme^="glass-"] .delete-record-button:active:not(:disabled),
  html[data-theme^="glass-"] .food-delete-button:hover:not(:disabled),
  html[data-theme^="glass-"] .food-delete-button:focus-visible,
  html[data-theme^="glass-"] .food-delete-button:active:not(:disabled) {
    background: transparent;
    color: #ff9cab;
    box-shadow: none;
  }

  html[data-theme^="glass-"] .community-detail-cover,
  html[data-theme^="glass-"] .history-thumb,
  html[data-theme^="glass-"] .history-body-photo,
  html[data-theme^="glass-"] .history-health-thumb,
  html[data-theme^="glass-"] .history-food-gallery,
  html[data-theme^="glass-"] .history-food-gallery.is-empty,
  html[data-theme^="glass-"] .history-food-track img {
    background: rgba(117, 195, 213, 0.11);
    color: #aeeaf5;
  }

  html[data-theme^="glass-"] .history-health-thumb {
    border-color: rgba(124, 220, 239, 0.16);
    background:
      linear-gradient(145deg, rgba(23, 38, 57, 0.88), rgba(18, 27, 43, 0.92));
    color: #aebcff;
  }

  html[data-theme^="glass-"] .history-health-thumb.is-workout {
    border-color: rgba(255, 128, 158, 0.16);
    background:
      linear-gradient(145deg, rgba(50, 33, 45, 0.88), rgba(18, 31, 43, 0.92));
  }

  html[data-theme^="glass-"] .history-health-icon-image {
    filter: drop-shadow(0 6px 11px rgba(0, 0, 0, 0.24));
  }

  html[data-theme^="glass-"] .history-health-thumb-label {
    color: rgba(232, 248, 252, 0.78);
  }

  html[data-theme^="glass-"] .bottom-tabs {
    border-top-color: rgba(255, 255, 255, 0.08);
    background:
      linear-gradient(180deg, rgba(12, 20, 32, 0) 0%, rgba(12, 20, 32, 0.58) 34%, rgba(8, 15, 26, 0.86) 100%),
      radial-gradient(110% 120% at 0% 0%, rgba(216, 134, 181, 0.12), rgba(8, 15, 26, 0) 58%),
      radial-gradient(110% 120% at 100% 0%, rgba(111, 207, 226, 0.16), rgba(8, 15, 26, 0) 58%);
  }
}

/* Dark cleanup for settings and AI advice surfaces. Keep wrappers invisible; only real controls get glass. */
@media (prefers-color-scheme: dark) {
  html[data-theme^="glass-"] .settings-content {
    border-top-color: rgba(163, 219, 234, 0.16);
    background: transparent;
  }

  html[data-theme^="glass-"] .settings-panel,
  html[data-theme^="glass-"] .settings-detail-panel,
  html[data-theme^="glass-"] .settings-panel > .settings-group,
  html[data-theme^="glass-"] .settings-panel > .native-health-sync,
  html[data-theme^="glass-"] .settings-panel > .settings-footer-actions {
    border-color: transparent;
    background: transparent;
    box-shadow: none;
  }

  html[data-theme^="glass-"] .settings-panel > .settings-group {
    border-bottom-color: rgba(163, 219, 234, 0.12);
  }

  html[data-theme^="glass-"] .settings-panel > .settings-options,
  html[data-theme^="glass-"] .settings-panel > .native-health-sync {
    border-bottom-color: transparent;
  }

  html[data-theme^="glass-"] .settings-group-heading,
  html[data-theme^="glass-"] .account-info-row,
  html[data-theme^="glass-"] .danger-zone {
    color: var(--ink);
  }

  html[data-theme^="glass-"] .settings-option-button,
  html[data-theme^="glass-"] .native-health-sync .settings-option-button {
    border: 1px solid var(--dark-border);
    background: var(--dark-panel-soft);
    color: var(--ink);
    box-shadow: 0 14px 38px rgba(0, 0, 0, 0.16), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  }

  html[data-theme^="glass-"] .settings-option-button:hover:not(:disabled),
  html[data-theme^="glass-"] .settings-option-button:focus-visible,
  html[data-theme^="glass-"] .settings-option-button:active:not(:disabled) {
    border-color: var(--dark-border-strong);
    background: var(--dark-control-hover);
    color: var(--ink);
    box-shadow: 0 16px 44px rgba(0, 0, 0, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  }

  html[data-theme^="glass-"] .settings-option-button small,
  html[data-theme^="glass-"] .settings-kicker {
    color: #83d3e5;
  }

  html[data-theme^="glass-"] .settings-option-button em,
  html[data-theme^="glass-"] .settings-option-arrow,
  html[data-theme^="glass-"] .settings-account-text small,
  html[data-theme^="glass-"] .settings-account-text em {
    color: var(--dark-text-muted);
  }

  html[data-theme^="glass-"] .account-management-entry {
    border-color: var(--dark-border);
    background: var(--dark-panel-soft);
    color: var(--ink);
    box-shadow: 0 16px 44px rgba(0, 0, 0, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  }

  html[data-theme^="glass-"] .account-management-entry:hover:not(:disabled),
  html[data-theme^="glass-"] .account-management-entry:focus-visible {
    border-color: var(--dark-border-strong);
    background: var(--dark-control-hover);
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.24), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  }

  html[data-theme^="glass-"] .account-management-summary > strong,
  html[data-theme^="glass-"] .account-profile-item strong {
    color: var(--ink);
  }

  html[data-theme^="glass-"] .account-overview-fields > span {
    border-color: var(--dark-border-soft);
    background: var(--dark-control);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  }

  html[data-theme^="glass-"] .account-overview-fields small {
    color: var(--primary);
  }

  html[data-theme^="glass-"] .account-overview-fields em,
  html[data-theme^="glass-"] .account-management-entry .settings-option-arrow {
    color: var(--dark-text-muted);
  }

  html[data-theme^="glass-"] .ai-advice-button {
    border-color: var(--dark-border);
    background:
      linear-gradient(145deg, rgba(20, 33, 49, 0.82), rgba(8, 16, 28, 0.68)),
      radial-gradient(115% 110% at 0% 0%, rgba(216, 134, 181, 0.12), rgba(8, 16, 28, 0) 58%),
      radial-gradient(115% 110% at 100% 0%, rgba(111, 207, 226, 0.18), rgba(8, 16, 28, 0) 58%);
    color: var(--ink);
    box-shadow: var(--dark-shadow);
  }

  html[data-theme^="glass-"] .ai-advice-button:hover:not(:disabled),
  html[data-theme^="glass-"] .ai-advice-button:focus-visible,
  html[data-theme^="glass-"] .ai-advice-button:active:not(:disabled) {
    border-color: var(--dark-border-strong);
    background:
      linear-gradient(145deg, rgba(27, 43, 62, 0.88), rgba(10, 20, 34, 0.74)),
      radial-gradient(115% 110% at 0% 0%, rgba(216, 134, 181, 0.15), rgba(10, 20, 34, 0) 58%),
      radial-gradient(115% 110% at 100% 0%, rgba(111, 207, 226, 0.22), rgba(10, 20, 34, 0) 58%);
    color: var(--ink);
  }

  html[data-theme^="glass-"] .ai-advice-button small {
    color: #83d3e5;
  }

  html[data-theme^="glass-"] .ai-advice-button em {
    color: var(--dark-text-muted);
  }

  html[data-theme^="glass-"] .ai-advice-action {
    border-color: rgba(190, 239, 250, 0.28);
    background:
      linear-gradient(145deg, rgba(36, 72, 90, 0.62), rgba(13, 27, 43, 0.56)),
      radial-gradient(120% 110% at 100% 0%, rgba(131, 211, 229, 0.18), rgba(13, 27, 43, 0) 58%);
    color: #bdefff;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
  }
}

/* Dark history chips: food calories stay warm, body weight stays cool. */
@media (prefers-color-scheme: dark) {
  html[data-theme^="glass-"] .history-food-summary:not(.history-weight-summary):not(.history-health-summary) strong {
    border: 1px solid rgba(229, 184, 104, 0.2);
    background:
      linear-gradient(145deg, rgba(84, 58, 28, 0.5), rgba(39, 31, 22, 0.42)),
      radial-gradient(120% 120% at 100% 0%, rgba(229, 184, 104, 0.18), rgba(39, 31, 22, 0) 58%);
    color: #e2b463;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07);
  }

  html[data-theme^="glass-"] .history-weight-summary strong,
  html[data-theme^="glass-"] .history-food-summary.history-weight-summary strong {
    border: 1px solid rgba(148, 226, 255, 0.24);
    background:
      linear-gradient(145deg, rgba(31, 73, 96, 0.54), rgba(15, 36, 56, 0.46)),
      radial-gradient(120% 120% at 100% 0%, rgba(111, 207, 226, 0.22), rgba(15, 36, 56, 0) 58%);
    color: #a8ecff;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  }
}

/* Dark pull-to-refresh surface. */
@media (prefers-color-scheme: dark) {
  html[data-theme^="glass-"] .pull-refresh {
    border-color: rgba(148, 226, 255, 0.24);
    background:
      linear-gradient(145deg, rgba(20, 33, 49, 0.86), rgba(8, 16, 28, 0.72)),
      radial-gradient(120% 110% at 0% 0%, rgba(216, 134, 181, 0.1), rgba(8, 16, 28, 0) 58%),
      radial-gradient(120% 110% at 100% 0%, rgba(111, 207, 226, 0.2), rgba(8, 16, 28, 0) 58%);
    color: #a8ecff;
    box-shadow: 0 14px 36px rgba(0, 0, 0, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.1);
    -webkit-backdrop-filter: blur(18px) saturate(1.12);
    backdrop-filter: blur(18px) saturate(1.12);
  }

  html[data-theme^="glass-"] .pull-refresh-icon {
    color: #82dff1;
    filter: drop-shadow(0 0 8px rgba(130, 223, 241, 0.16));
  }

  html[data-theme^="glass-"] body.is-pull-ready .pull-refresh,
  html[data-theme^="glass-"] body.is-refreshing .pull-refresh {
    border-color: rgba(190, 239, 250, 0.38);
    background:
      linear-gradient(145deg, rgba(28, 47, 66, 0.9), rgba(10, 20, 34, 0.78)),
      radial-gradient(120% 110% at 0% 0%, rgba(216, 134, 181, 0.13), rgba(10, 20, 34, 0) 58%),
      radial-gradient(120% 110% at 100% 0%, rgba(111, 207, 226, 0.25), rgba(10, 20, 34, 0) 58%);
    box-shadow: 0 16px 42px rgba(0, 0, 0, 0.38), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  }
}

/* Community share controls and empty states. */
html[data-theme^="glass-"] .community-empty {
  border-color: rgba(123, 198, 220, 0.2);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.52), rgba(255, 255, 255, 0.24)),
    radial-gradient(110% 120% at 0% 0%, rgba(255, 218, 246, 0.2), rgba(255, 255, 255, 0) 56%),
    radial-gradient(110% 120% at 100% 0%, rgba(183, 238, 255, 0.28), rgba(255, 255, 255, 0) 56%);
  color: rgba(91, 113, 126, 0.72);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.58), 0 18px 46px rgba(80, 102, 119, 0.1);
  -webkit-backdrop-filter: blur(22px) saturate(1.18);
  backdrop-filter: blur(22px) saturate(1.18);
}

html[data-theme^="glass-"] .share-switch-track {
  width: 52px;
  height: 30px;
  border: 0;
  padding: 3px;
  background: #d6e1e7;
  box-shadow: none;
  transition: background 180ms ease, transform 160ms ease;
}

html[data-theme^="glass-"] .share-switch-track span {
  width: 24px;
  height: 24px;
  background: #ffffff;
  box-shadow: none;
}

html[data-theme^="glass-"] .share-switch input:checked + .share-switch-track {
  background: #7ccdde;
}

html[data-theme^="glass-"] .share-switch input:checked + .share-switch-track span {
  transform: translateX(22px);
}

html[data-theme^="glass-"] .share-switch input:checked + .share-switch-track + .share-switch-text {
  color: #3e8293;
}

html[data-theme^="glass-"] .share-switch input:focus-visible + .share-switch-track {
  outline-color: rgba(117, 195, 213, 0.24);
}

@media (prefers-color-scheme: dark) {
  html[data-theme^="glass-"] .community-empty {
    border-color: rgba(148, 226, 255, 0.2);
    background:
      linear-gradient(145deg, rgba(20, 33, 49, 0.72), rgba(8, 16, 28, 0.58)),
      radial-gradient(110% 120% at 0% 0%, rgba(216, 134, 181, 0.06), rgba(8, 16, 28, 0) 58%),
      radial-gradient(110% 120% at 100% 0%, rgba(111, 207, 226, 0.1), rgba(8, 16, 28, 0) 58%);
    color: rgba(214, 229, 237, 0.62);
    box-shadow: 0 16px 44px rgba(0, 0, 0, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.07);
  }

  html[data-theme^="glass-"] .share-switch-track {
    background: #40515a;
    box-shadow: none;
  }

  html[data-theme^="glass-"] .share-switch-track span {
    background: #eff7fa;
    box-shadow: none;
  }

  html[data-theme^="glass-"] .share-switch input:checked + .share-switch-track {
    background: #5bc4d8;
  }

  html[data-theme^="glass-"] .share-switch input:checked + .share-switch-track + .share-switch-text {
    color: #a8ecff;
  }

  html[data-theme^="glass-"] .share-switch input:disabled + .share-switch-track,
  html[data-theme^="glass-"] .share-switch input:disabled ~ .share-switch-text {
    opacity: 0.62;
  }
}

/* Community comments use their own surface tokens so modal, empty state and
   sent/received bubbles stay readable across light and dark shells. */
html[data-theme^="glass-"] {
  --comment-content-bg:
    linear-gradient(180deg, rgba(250, 254, 255, 0.42), rgba(247, 252, 255, 0.3)),
    radial-gradient(95% 70% at 100% 0%, rgba(184, 238, 255, 0.18), rgba(255, 255, 255, 0) 62%);
  --comment-bubble-bg:
    linear-gradient(145deg, rgba(255, 255, 255, 0.62), rgba(246, 252, 255, 0.42));
  --comment-own-bubble-bg:
    linear-gradient(145deg, rgba(229, 247, 251, 0.7), rgba(245, 252, 255, 0.48));
  --comment-bubble-border: rgba(255, 255, 255, 0.6);
  --comment-own-bubble-border: rgba(105, 183, 207, 0.22);
  --comment-bubble-text: #172029;
  --comment-meta-text: rgba(102, 116, 128, 0.78);
  --comment-empty-bg:
    linear-gradient(145deg, rgba(255, 255, 255, 0.48), rgba(246, 252, 255, 0.28));
  --comment-empty-border: rgba(123, 198, 220, 0.2);
  --comment-empty-icon-bg: rgba(229, 247, 251, 0.72);
  --comment-input-bg:
    linear-gradient(145deg, rgba(255, 255, 255, 0.7), rgba(244, 252, 255, 0.44));
  --comment-input-border: rgba(255, 255, 255, 0.68);
  --comment-input-text: #172029;
  --comment-input-placeholder: rgba(102, 116, 128, 0.62);
  --comment-send-bg:
    linear-gradient(145deg, rgba(255, 255, 255, 0.78), rgba(244, 252, 255, 0.48));
  --comment-send-border: rgba(255, 255, 255, 0.64);
  --comment-send-text: #172029;
}

html[data-theme^="glass-"] .community-comments-content {
  background: var(--comment-content-bg);
}

html[data-theme^="glass-"] .community-comments-panel .community-comments,
html[data-theme^="glass-"] .community-comments {
  background: transparent;
  color: var(--ink);
}

html[data-theme^="glass-"] .community-comment-bubble {
  border-color: var(--comment-bubble-border);
  background: var(--comment-bubble-bg);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.56), 0 8px 22px rgba(80, 102, 119, 0.08);
}

html[data-theme^="glass-"] .community-comment-item.is-own .community-comment-bubble {
  border-color: var(--comment-own-bubble-border);
  background: var(--comment-own-bubble-bg);
}

html[data-theme^="glass-"] .community-comment-meta strong,
html[data-theme^="glass-"] .community-comment-bubble p,
html[data-theme^="glass-"] .community-comment-empty strong {
  color: var(--comment-bubble-text);
}

html[data-theme^="glass-"] .community-comment-meta time,
html[data-theme^="glass-"] .community-comment-empty,
html[data-theme^="glass-"] .community-comment-empty small {
  color: var(--comment-meta-text);
}

html[data-theme^="glass-"] .community-reply-target {
  border-color: rgba(255, 255, 255, 0.42);
  background: rgba(229, 247, 251, 0.3);
  color: var(--primary-strong);
}

html[data-theme^="glass-"] .community-reply-target button,
html[data-theme^="glass-"] .community-comment-reply {
  color: var(--primary-strong);
  border-color: transparent;
  background: transparent;
  box-shadow: none;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

html[data-theme^="glass-"] .community-comment-children {
  border-color: rgba(119, 189, 210, 0.24);
}

html[data-theme^="glass-"] .community-comment-avatar.is-deleted,
html[data-theme^="glass-"] .community-comment-item.is-deleted .community-comment-bubble {
  border-color: rgba(255, 255, 255, 0.34);
  background: rgba(255, 255, 255, 0.2);
}

html[data-theme^="glass-"] .community-comment-bubble .community-comment-reply-context {
  color: var(--primary-strong);
}

html[data-theme^="glass-"] .community-comment-bubble .community-comment-deleted {
  color: var(--comment-meta-text);
}

html[data-theme^="glass-"] .community-comment-empty {
  border-color: var(--comment-empty-border);
  background: var(--comment-empty-bg);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.42), 0 14px 34px rgba(80, 102, 119, 0.08);
}

html[data-theme^="glass-"] .community-comment-empty-icon {
  background: var(--comment-empty-icon-bg);
  color: var(--primary-strong);
}

html[data-theme^="glass-"] .community-comment-form input {
  border-color: var(--comment-input-border);
  background: var(--comment-input-bg);
  color: var(--comment-input-text);
}

html[data-theme^="glass-"] .community-comment-form input::placeholder {
  color: var(--comment-input-placeholder);
}

html[data-theme^="glass-"] .community-comment-form button {
  border-color: var(--comment-send-border);
  background: var(--comment-send-bg);
  color: var(--comment-send-text);
}

html[data-theme^="glass-"] .community-comment-form input:focus {
  border-color: rgba(119, 189, 210, 0.5);
  background: var(--comment-input-bg);
  color: var(--comment-input-text);
  box-shadow:
    0 0 0 3px rgba(103, 174, 190, 0.12),
    0 14px 34px rgba(78, 127, 150, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.78);
}

@media (prefers-color-scheme: dark) {
  html[data-theme^="glass-"] {
    --comment-content-bg:
      linear-gradient(180deg, rgba(10, 18, 30, 0.82), rgba(7, 13, 23, 0.72)),
      radial-gradient(88% 74% at 0% 0%, rgba(216, 134, 181, 0.06), rgba(7, 13, 23, 0) 62%),
      radial-gradient(92% 78% at 100% 0%, rgba(111, 207, 226, 0.08), rgba(7, 13, 23, 0) 64%);
    --comment-bubble-bg:
      linear-gradient(145deg, rgba(22, 35, 50, 0.78), rgba(10, 18, 31, 0.68));
    --comment-own-bubble-bg:
      linear-gradient(145deg, rgba(22, 59, 74, 0.74), rgba(12, 27, 42, 0.72));
    --comment-bubble-border: rgba(189, 239, 255, 0.14);
    --comment-own-bubble-border: rgba(139, 218, 236, 0.22);
    --comment-bubble-text: rgba(244, 250, 253, 0.94);
    --comment-meta-text: rgba(183, 198, 209, 0.62);
    --comment-empty-bg:
      linear-gradient(145deg, rgba(19, 31, 45, 0.7), rgba(8, 15, 26, 0.56));
    --comment-empty-border: rgba(139, 218, 236, 0.16);
    --comment-empty-icon-bg: rgba(111, 207, 226, 0.12);
    --comment-input-bg:
      linear-gradient(145deg, rgba(29, 43, 59, 0.86), rgba(12, 22, 36, 0.78));
    --comment-input-border: rgba(189, 239, 255, 0.18);
    --comment-input-text: rgba(244, 250, 253, 0.94);
    --comment-input-placeholder: rgba(183, 198, 209, 0.5);
    --comment-send-bg:
      linear-gradient(145deg, rgba(35, 52, 68, 0.9), rgba(17, 29, 45, 0.84));
    --comment-send-border: rgba(189, 239, 255, 0.18);
    --comment-send-text: rgba(244, 250, 253, 0.96);
  }

  html[data-theme^="glass-"] .community-comments-content {
    background: var(--comment-content-bg);
  }

  html[data-theme^="glass-"] .community-comments-panel .community-comments,
  html[data-theme^="glass-"] .community-comments {
    background: transparent;
  }

  html[data-theme^="glass-"] .community-comment-bubble,
  html[data-theme^="glass-"] .community-comment-empty {
    box-shadow: 0 14px 38px rgba(0, 0, 0, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  }

  html[data-theme^="glass-"] .community-comment-form input:focus {
    border-color: rgba(139, 218, 236, 0.34);
    box-shadow:
      0 0 0 3px rgba(111, 207, 226, 0.12),
      0 12px 28px rgba(0, 0, 0, 0.18),
      inset 0 1px 0 rgba(255, 255, 255, 0.1);
  }
}

html[data-theme^="glass-"] .community-comment-bubble,
html[data-theme^="glass-"] .community-comment-item.is-own .community-comment-bubble {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
}

html[data-theme^="glass-"] .community-comment-meta strong {
  color: var(--comment-meta-text);
}

html[data-theme^="glass-"] .community-comment-footer,
html[data-theme^="glass-"] .community-comment-footer time,
html[data-theme^="glass-"] .community-comment-like,
html[data-theme^="glass-"] .community-comment-more {
  color: var(--comment-meta-text);
  border-color: transparent;
  background: transparent;
  box-shadow: none;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

html[data-theme^="glass-"] .community-comment-like:hover:not(:disabled),
html[data-theme^="glass-"] .community-comment-like:focus-visible,
html[data-theme^="glass-"] .community-comment-more:hover:not(:disabled),
html[data-theme^="glass-"] .community-comment-more:focus-visible {
  background: transparent;
  color: var(--primary);
  box-shadow: none;
}

html[data-theme^="glass-"] .community-comment-like.is-liked {
  color: #ff5d7f;
}

html[data-theme^="glass-"] .community-comment-like.is-liked:hover:not(:disabled),
html[data-theme^="glass-"] .community-comment-like.is-liked:focus-visible,
html[data-theme^="glass-"] .community-comment-like.is-liked:active:not(:disabled) {
  background: transparent;
  color: #ff5d7f;
  box-shadow: none;
}

html[data-theme^="glass-"] .community-comment-menu {
  border-color: rgba(189, 239, 255, 0.16);
  background:
    linear-gradient(145deg, rgba(24, 38, 54, 0.96), rgba(9, 18, 31, 0.94));
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

html[data-theme^="glass-"] .community-comment-menu button {
  color: var(--ink);
}

html[data-theme^="glass-"] .community-comment-menu button:hover:not(:disabled),
html[data-theme^="glass-"] .community-comment-menu button:focus-visible {
  background: rgba(111, 207, 226, 0.1);
  color: var(--primary);
}

html[data-theme^="glass-"] .community-member-more-wrap .community-member-more-menu {
  border-color: var(--dark-border-strong);
  background: var(--dark-control);
  box-shadow: 0 22px 52px rgba(0, 0, 0, 0.36), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

html[data-theme^="glass-"] .community-member-more-wrap .community-member-more-menu button {
  color: var(--ink);
}

html[data-theme^="glass-"] .community-member-more-wrap .community-member-more-menu button:hover:not(:disabled),
html[data-theme^="glass-"] .community-member-more-wrap .community-member-more-menu button:focus-visible {
  background: var(--dark-control-hover);
  color: #bdefff;
}

@media (prefers-color-scheme: dark) {
  html[data-theme^="glass-"] .community-comment-bubble,
  html[data-theme^="glass-"] .community-comment-item.is-own .community-comment-bubble {
    box-shadow: none;
  }

  html[data-theme^="glass-"] .food-result-item {
    border-color: var(--dark-border, rgba(163, 219, 234, 0.2));
    background:
      linear-gradient(145deg, rgba(28, 42, 57, 0.72), rgba(12, 22, 36, 0.56)),
      radial-gradient(110% 100% at 100% 0%, rgba(111, 207, 226, 0.1), rgba(12, 22, 36, 0) 58%);
    color: var(--ink);
    box-shadow: 0 16px 44px rgba(0, 0, 0, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  }

  html[data-theme^="glass-"] .food-result-item p,
  html[data-theme^="glass-"] .food-result-item span,
  html[data-theme^="glass-"] .food-result-item small,
  html[data-theme^="glass-"] .food-result-metrics,
  html[data-theme^="glass-"] .food-result-metrics span {
    color: var(--dark-text-muted, rgba(214, 229, 237, 0.7));
  }

  html[data-theme^="glass-"] .food-result-item strong,
  html[data-theme^="glass-"] .food-nutrition-grid b {
    color: var(--ink);
  }

  html[data-theme^="glass-"] .food-result-metrics strong {
    color: var(--primary);
  }

  html[data-theme^="glass-"] .food-source-badge {
    border-color: rgba(190, 239, 250, 0.32);
    background:
      linear-gradient(145deg, rgba(38, 67, 82, 0.9), rgba(13, 28, 43, 0.84)),
      radial-gradient(110% 100% at 100% 0%, rgba(111, 207, 226, 0.2), rgba(13, 28, 43, 0) 58%);
    color: #dff9ff;
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.24), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  }
}
