/* Bounded content, quick preferences and stable controls across languages and text sizes. */
html:root[data-theme] body .content { min-width:0;overflow-x:clip; }
html:root[data-theme] body :is(.view-section,.hero-grid,.meal-card,.meal-card>*,.meal-card h4,.meal-card p,.workout-row>*,.draft-item,.draft-item>*,.modal-head>div,.calorie-copy) { min-width:0;max-width:100%;overflow-wrap:anywhere; }
html:root[data-theme] body :is(.hero-grid,.form-grid,.program-grid) { min-width:0; }
html:root[data-theme] body .hero-grid { align-items:start; }
html:root[data-theme] body .calorie-card { align-self:start; }
html:root[data-theme] body .sidebar { height:100dvh;min-height:100vh;overflow-y:auto; }
html:root[data-theme] body .sidebar { gap:0; }
html:root[data-theme] body .sidebar :is(.logo,nav,.sidebar-workout,.sidebar-foot) { flex-shrink:0; }
html:root[data-theme] body .sidebar-workout { margin-top:auto;min-height:60px; }
html:root[data-theme] body .sidebar-foot { margin-top:14px;padding-top:14px;display:flex;flex-direction:column;align-items:stretch;gap:8px; }
html:root[data-theme] body .sidebar-foot .text-button { width:100%;min-height:44px;white-space:nowrap;text-align:start; }
html:root[data-theme] body .mobile-brand-row { display:none; }
html:root[data-theme] body .topbar-actions { display:flex;align-items:center;flex:0 0 auto;gap:10px; }
html:root[data-theme] body .topbar .page-heading { min-width:0; }
html:root[data-theme] body .top-start { display:flex;align-items:center;justify-content:center;min-height:44px;max-width:220px;gap:8px;margin:0; }
html:root[data-theme] body .top-start>span { flex:0 0 28px;width:28px;height:28px;display:grid;place-items:center; }
html:root[data-theme] body .top-start>b { min-width:0;font-size:.8rem;line-height:1.35;text-align:start; }
html:root[data-theme] body .quick-preferences { display:flex;align-items:center;gap:4px;width:max-content;max-width:100%; }
html:root[data-theme] body .quick-language { position:relative;display:flex;align-items:center;justify-content:center;gap:5px;width:56px;min-height:44px;margin:0;border:1px solid var(--m-line);border-radius:9px;background:var(--m-surface);color:var(--m-muted);font-size:.75rem; }
html:root[data-theme] body .quick-language>b { font-size:.75rem;letter-spacing:.03em; }
html:root[data-theme] body .preference-chevron { width:5px;height:5px;border-right:1.5px solid currentColor;border-bottom:1.5px solid currentColor;transform:rotate(45deg);margin-top:-3px; }
html:root[data-theme] body .quick-language>select { position:absolute;inset:-1px;width:calc(100% + 2px);height:calc(100% + 2px);min-width:0;margin:0;opacity:0;cursor:pointer; }
html:root[data-theme] body #profileThemeButton { display:grid;place-items:center;width:44px;height:44px;padding:10px;margin:0;border:1px solid var(--m-line);border-radius:9px;background:var(--m-surface);color:var(--m-muted); }
html:root[data-theme] body #profileThemeButton>svg { width:20px;height:20px;fill:none;stroke:currentColor;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round; }
html:root[data-theme] body #profileThemeButton[aria-pressed="false"] .theme-moon,
html:root[data-theme] body #profileThemeButton[aria-pressed="true"] .theme-sun { display:none; }
html:root[data-theme] body :is(.quick-language:focus-within,#profileThemeButton:focus-visible) { outline:2px solid var(--m-accent);outline-offset:3px; }
.preference-sr { position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap;border:0; }
html:root[data-theme] body #profileSection .profile-save-bar { grid-column:1/-1;display:flex;align-items:center;justify-content:flex-end;gap:16px;width:100%;min-height:72px;top:12px;bottom:auto;padding:12px 16px;border-radius:12px; }
html:root[data-theme] body .profile-save-bar .success-message { flex:1;min-width:0;margin:0; }
html:root[data-theme] body .profile-save-bar button { flex:0 0 auto;min-width:180px;min-height:44px;width:auto;margin:0; }
html:root[data-theme] body .modal-head { gap:16px; }
html:root[data-theme] body .modal-head>.icon-button { display:grid;place-items:center;flex:0 0 44px;width:44px;height:44px;min-height:44px;max-width:44px;padding:0;border-radius:50%;line-height:1; }
html:root[data-theme] body .auth-card .detail-hint { font-size:.875rem;line-height:1.6;color:var(--m-muted); }
html:root[data-theme] body .brand-panel::after { display:none; }
html:root[data-theme] body .auth-proof { max-width:min(100%,250px); }
html:root[data-theme] body .bar { min-height:5px; }
@media(max-width:1100px) {
 html:root[data-theme] body .topbar { flex-wrap:wrap;gap:12px; }
 html:root[data-theme] body .topbar-actions { flex-wrap:nowrap; }
}
@media(max-width:820px) {
 html:root[data-theme] body .content { padding-bottom:calc(var(--navigation-height,140px) + 28px); }
 html:root[data-theme] body .mobile-brand-row { display:flex;align-items:center;justify-content:space-between;gap:8px;margin-bottom:18px; }
 html:root[data-theme] body .mobile-brand-row .mobile-brand { display:flex;margin:0;flex:0 1 auto;min-width:0; }
 html:root[data-theme] body .topbar { align-items:center;flex-wrap:nowrap;gap:8px; }
 html:root[data-theme] body .topbar-actions { display:flex;gap:4px; }
 html:root[data-theme] body .topbar .page-heading { flex:1;min-width:0; }
 html:root[data-theme] body .quick-preferences { flex:0 0 auto;gap:4px; }
 html:root[data-theme] body .topbar .avatar { display:none; }
 html:root[data-theme] body .topbar h1 { overflow-wrap:anywhere;line-height:1.15; }
 html:root[data-theme] body .floating-add { position:static;inset:auto;display:inline-flex;flex:0 0 44px;width:44px;height:44px;padding:0;align-items:center;justify-content:center; }
 html:root[data-theme] body .floating-add span { width:auto;height:auto; }
 html:root[data-theme] body .topbar .top-start { display:none; }
 html:root[data-theme] body .toast { bottom:calc(var(--navigation-height,140px) + 12px);inset-inline:16px;max-width:calc(100vw - 32px);overflow-wrap:anywhere;text-align:center; }
 html:root[data-theme] body #profileSection .profile-save-bar { position:static;flex-wrap:wrap;gap:8px; }
 html:root[data-theme] body .profile-save-bar button { flex:1 0 100%;min-width:0;width:100%; }
}
@media(prefers-reduced-motion:reduce) { html:root[data-theme] body .toast { transition:none; } }

html:root[data-theme] body .settings-card:has(#textSizeSelect) { display:flex;align-items:center;flex-wrap:wrap;gap:24px; }
html:root[data-theme] body .settings-card:has(#textSizeSelect) h3 { margin:0; }
html:root[data-theme] body .settings-card:has(#textSizeSelect) .language-field { margin:0; }
html:root[data-theme] body #profileSection>.profile-save-bar { margin-block:12px; }

/* Dark tiles retain their individual accent without a solid brown/green block. */
html:root[data-theme="dark"] body .macro-card { background:color-mix(in srgb,var(--m-surface) 90%,var(--macro-color)); }
html:root[data-theme="dark"] body main #todaySection .coach-card.scene-ready::after { opacity:.88; }

html:root[data-theme] body .profile-save-bar .success-message:empty { display:none; }

/* Compact localized input methods; Arabic Label stays legible without widening the dialog. */
#methodRow { display:grid;grid-template-columns:repeat(4,minmax(0,1fr)); }
#methodRow button { min-width:0;padding-inline:8px; }
#methodRow button span { white-space:nowrap; }
html[lang="ar"] #methodRow button { font-size:.85rem;gap:4px; }

@media(max-width:520px){#methodRow{grid-template-columns:repeat(2,minmax(0,1fr));}}

/* Diary previews keep the original note intact; logical padding also works in RTL. */
.wellbeing-note { padding:14px 16px;min-width:0; }
.wellbeing-note .diary-preview { margin-block:10px;white-space:pre-wrap;overflow-wrap:anywhere; }
.diary-count { display:block;text-align:end;font-variant-numeric:tabular-nums; }
.diary-count.over-limit { font-weight:700; }
