/* ==========================================================================
   Darsyar — mobile redesign (Statistics · Study Plan · Profile · bottom nav)
   Loaded last. Phones only (<= 720px, which also covers the Capacitor app);
   desktop keeps its existing layout. RTL-first, logical properties where it matters.

   Scale   : 11 label · 12 meta · 14 body · 16 inputs (prevents iOS zoom) · 18 page title
   Spacing : 4 · 8 · 12 · 16      Radii: 10 · 14 · 18      Touch target: >= 44px (hit-area), visuals may be smaller
   ========================================================================== */

:root {
    --m-r-sm: 10px; --m-r-md: 14px; --m-r-lg: 18px;
    --m-nav-h: 58px;
    --m-ease: cubic-bezier(.22, 1, .36, 1);
}
html:not(.capacitor-app) {
    --m-bg: var(--studio-bg); --m-surface: var(--studio-surface); --m-raised: var(--studio-raised);
    --m-line: var(--studio-line); --m-ink: var(--studio-ink); --m-muted: var(--studio-muted);
    --m-accent: var(--studio-accent); --m-on-accent: var(--studio-on-accent);
    --m-good: var(--studio-mint); --m-bad: var(--studio-coral); --m-warn: #b9852b;
    --m-chart: #5b8def; --m-safe-b: env(safe-area-inset-bottom, 0px); --m-header-h: 58px;
}
html:not(.capacitor-app)[data-theme="dark"] { --m-warn: #e5b955; }
html.capacitor-app {
    --android-nav-height: 58px;
    --m-bg: var(--bg-body); --m-surface: var(--bg-card); --m-raised: var(--bg-surface);
    --m-line: var(--border-subtle); --m-ink: var(--text-main); --m-muted: var(--text-muted);
    --m-accent: var(--gold-light); --m-on-accent: #111827;
    --m-good: var(--success); --m-bad: var(--danger); --m-warn: var(--warning);
    --m-chart: #5b8def; --m-safe-b: var(--android-safe-bottom); --m-header-h: calc(64px + var(--android-safe-top));
}
html.capacitor-app[data-theme="light"] { --m-accent: var(--primary-light); --m-on-accent: #fff; --m-line: rgba(15, 23, 42, .1); }

html.m-redesign .m-sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
html.m-redesign .sw-error { display: grid; justify-items: center; gap: 10px; padding: 30px 16px; text-align: center; border: 1px solid var(--studio-line); border-radius: 18px; }
html.m-redesign .m-chips { display: none; }

@keyframes m-rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes m-sheet-up { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }
@keyframes m-slide-next { from { opacity: 0; transform: translateX(-22px); } to { opacity: 1; transform: none; } }
@keyframes m-slide-prev { from { opacity: 0; transform: translateX(22px); } to { opacity: 1; transform: none; } }
@keyframes m-pop { 0% { transform: scale(1); } 40% { transform: scale(1.03); } 100% { transform: scale(1); } }
@keyframes m-check { 0% { transform: scale(.55); } 60% { transform: scale(1.18); } 100% { transform: scale(1); } }
@keyframes m-bar { from { transform: scaleY(.12); } to { transform: none; } }
@keyframes m-shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

@media (max-width: 720px) {

    /* ---------------------------------------------------------------- shell */
    html.m-redesign body :is(#view-stats, #view-schedule, #view-profile) { font-size: 14px; line-height: 1.6; color: var(--m-ink); min-width: 0; }
    html.m-redesign body .content-body { padding: 12px 12px calc(var(--m-nav-h) + var(--m-safe-b) + 22px); }
    html.m-redesign body :is(#view-stats, #view-schedule, #view-profile) :is(button, input, select, textarea) { font-family: inherit; }
    html.m-redesign body :is(#view-stats, #view-schedule, #view-profile) :is(strong, h1, h2, h3, span, small, p) { min-width: 0; }

    /* page heading */
    html.m-redesign body :is(#view-stats, #view-schedule) .section-heading-bar,
    html.m-redesign body #view-stats .sw-heading { display: flex; flex-direction: row; align-items: center; justify-content: space-between; gap: 10px; margin: 0 0 12px; }
    html.m-redesign body :is(#view-stats, #view-schedule) .section-heading-title,
    html.m-redesign body #view-stats .sw-heading h1 { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 18px; line-height: 1.4; font-weight: 800; color: var(--m-ink); }
    html.m-redesign body :is(#view-stats, #view-schedule) .section-heading-title .material-symbols-outlined { font-size: 20px; color: var(--m-accent) !important; }
    html.m-redesign body :is(#view-stats, #view-schedule) .section-heading-bar p { margin: 2px 0 0; font-size: 12px !important; line-height: 1.6; color: var(--m-muted) !important; }
    html.m-redesign body #view-stats .sw-heading :is(.sw-kicker, p) { display: none; }
    html.m-redesign body :is(#view-stats .sw-heading .sw-button, #view-stats .m-head-action, #view-schedule .schedule-print-button) {
        display: inline-flex; align-items: center; justify-content: center; gap: 6px; flex: none; min-height: 36px; padding: 0 12px;
        border: 1px solid var(--m-line); border-radius: var(--m-r-sm); background: var(--m-surface); color: var(--m-ink);
        font-size: 12px; font-weight: 600; box-shadow: none; white-space: nowrap; position: relative; transition: transform .12s, background-color .2s;
    }
    html.m-redesign body :is(#view-stats .sw-heading .sw-button, #view-stats .m-head-action, #view-schedule .schedule-print-button)::after { content: ''; position: absolute; inset: -4px; }
    html.m-redesign body #view-stats .sw-heading .sw-button .studio-icon,
    html.m-redesign body #view-stats .m-head-action .material-symbols-outlined { width: 16px; height: 16px; font-size: 18px; }
    html.m-redesign body #view-schedule .schedule-print-button { width: 38px; padding: 0; }
    html.m-redesign body #view-schedule .schedule-print-button > span:last-child { display: none; }

    /* shared press feedback */
    html.m-redesign body :is(.m-day-strip button, .m-day-add, .task-focus-button, .m-chips button, .m-more, .m-empty-cta, .sw-button, .m-head-action, .sw-segments button, .m-seg button):active { transform: scale(.96); }
    html.m-redesign body :is(.day-task-main, .manual-report-heading):active { opacity: .7; }

    /* -------------------------------------------------------- bottom nav (web) */
    html.m-redesign:not(.capacitor-app) body .studio-mobile-nav {
        height: calc(var(--m-nav-h) + env(safe-area-inset-bottom)); padding: 4px 8px env(safe-area-inset-bottom);
        border-radius: 16px 16px 0 0; background: var(--m-surface); box-shadow: 0 -2px 14px rgba(0, 0, 0, .05);
    }
    html.m-redesign:not(.capacitor-app) body .studio-mobile-nav button { position: relative; min-height: 48px; gap: 3px; font: 600 10.5px/1.2 Kalameh, sans-serif; transition: color .2s; }
    html.m-redesign:not(.capacitor-app) body .studio-mobile-nav button > * { position: relative; }
    html.m-redesign:not(.capacitor-app) body .studio-mobile-nav .studio-icon,
    html.m-redesign:not(.capacitor-app) body .studio-mobile-nav button[data-mobile-route="pomodoro"] .studio-icon { width: 21px; height: 21px; }
    html.m-redesign:not(.capacitor-app) body .studio-mobile-nav button::before {
        content: ''; position: absolute; top: 3px; width: 46px; height: 28px; border-radius: 14px;
        background: color-mix(in srgb, var(--m-accent) 15%, transparent); opacity: 0; transform: scale(.5);
        transition: transform .3s var(--m-ease), opacity .2s;
    }
    html.m-redesign:not(.capacitor-app) body .studio-mobile-nav button.active::before { opacity: 1; transform: none; }
    html.m-redesign:not(.capacitor-app) body .studio-mobile-nav button.active { color: var(--m-accent); }

    /* -------------------------------------------------------- bottom nav (app) */
    html.m-redesign.capacitor-app body .android-bottom-nav { padding: 4px 8px var(--android-safe-bottom); min-height: calc(var(--android-nav-height) + var(--android-safe-bottom)); box-shadow: 0 -2px 14px rgba(0, 0, 0, .12); backdrop-filter: none; -webkit-backdrop-filter: none; background: var(--m-surface); }
    html.m-redesign.capacitor-app body .android-nav-item { min-height: 48px; gap: 1px; border-radius: 14px; }
    html.m-redesign.capacitor-app body .android-nav-icon { font-size: 22px; }
    html.m-redesign.capacitor-app body .android-nav-label { font-size: 10.5px; }
    html.m-redesign.capacitor-app body .android-nav-item.active { background: color-mix(in srgb, var(--m-accent) 12%, transparent); color: var(--m-accent); }
    html.m-redesign.capacitor-app body .android-nav-primary .android-nav-icon { width: 38px; height: 30px; border-radius: 11px; font-size: 22px; box-shadow: none; }

    /* the keyboard must never sit on top of controls */
    html.m-kb-open body :is(.studio-mobile-nav, .android-bottom-nav) { transform: translateY(110%); visibility: hidden; transition: transform .2s, visibility .2s; }

    /* ------------------------------------------------------------- statistics */
    html.m-redesign body #view-stats .sw-stats-hero,
    html.m-redesign body #view-stats .sw-metrics article,
    html.m-redesign body #view-stats .sw-panel,
    html.m-redesign body #view-stats .m-stat,
    html.m-redesign body #view-stats .m-panel { background: var(--m-surface); border: 1px solid var(--m-line); box-shadow: none; color: var(--m-ink); }

    html.m-redesign body #view-stats .sw-stats-hero { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 14px; border-radius: var(--m-r-lg); background: color-mix(in srgb, var(--m-accent) 8%, var(--m-surface)); margin: 0; }
    html.m-redesign body #view-stats .sw-hero-main { display: grid; gap: 4px; min-width: 0; }
    html.m-redesign body #view-stats .sw-stats-hero .sw-kicker { font-size: 11.5px; color: var(--m-muted); }
    html.m-redesign body #view-stats .sw-stats-hero strong { font-size: 22px; line-height: 1.35; font-weight: 800; color: var(--m-ink); overflow-wrap: anywhere; }
    html.m-redesign body #view-stats .sw-goal { display: grid; gap: 5px; margin-top: 6px; }
    html.m-redesign body #view-stats .sw-goal small { font-size: 11px; color: var(--m-muted); }
    html.m-redesign body #view-stats :is(.sw-track) { height: 6px; border-radius: 3px; background: color-mix(in srgb, var(--m-line) 80%, transparent); overflow: hidden; }
    html.m-redesign body #view-stats .sw-track > i { display: block; height: 100%; border-radius: 3px; background: var(--m-accent); transition: width .6s var(--m-ease); }
    html.m-redesign body #view-stats .sw-streak { display: flex; flex-direction: column; align-items: center; gap: 1px; width: auto; min-width: 66px; padding: 8px 12px; border: 1px solid var(--m-line); border-radius: var(--m-r-md); background: var(--m-surface); color: var(--m-ink); }
    html.m-redesign body #view-stats .sw-streak .studio-icon { width: 18px; height: 18px; color: var(--m-warn); }
    html.m-redesign body #view-stats .sw-streak b { font-size: 20px; line-height: 1.2; }
    html.m-redesign body #view-stats .sw-streak span { font-size: 10.5px; color: var(--m-muted); white-space: nowrap; }

    html.m-redesign body #view-stats .sw-metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 8px 0; }
    html.m-redesign body #view-stats .sw-metrics article { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-width: 0; padding: 10px; border-radius: var(--m-r-md); }
    html.m-redesign body #view-stats .sw-metrics .studio-icon { width: 16px; height: 16px; margin-bottom: 3px; color: var(--m-accent); }
    html.m-redesign body #view-stats .sw-metrics span { font-size: 11px; line-height: 1.4; color: var(--m-muted); }
    html.m-redesign body #view-stats .sw-metrics strong { grid-column: auto; font-size: 14px; line-height: 1.4; font-weight: 700; overflow-wrap: anywhere; }

    html.m-redesign body #view-stats .sw-analysis-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
    html.m-redesign body #view-stats .sw-panel,
    html.m-redesign body #view-stats .m-panel { padding: 14px; border-radius: var(--m-r-lg); margin: 0 0 8px; min-width: 0; }
    html.m-redesign body #view-stats :is(.sw-panel, .m-panel) > header { display: flex; flex-direction: row; align-items: center; justify-content: space-between; gap: 10px; margin: 0 0 10px; }
    html.m-redesign body #view-stats :is(.sw-panel, .m-panel) > header :is(h2, h3) { margin: 0; font-size: 14px; line-height: 1.5; font-weight: 700; color: var(--m-ink); }
    html.m-redesign body #view-stats .sw-panel > header .sw-kicker { display: block; font-size: 10.5px; color: var(--m-muted); }
    html.m-redesign body #view-stats .sw-panel > header > .studio-icon { width: 18px; height: 18px; color: var(--m-muted); }
    html.m-redesign body #view-stats .sw-helper { margin: 0 0 8px; font-size: 11.5px; line-height: 1.7; color: var(--m-muted); }

    /* segmented controls (range + view mode) */
    html.m-redesign body :is(#view-stats .sw-segments, #view-stats .m-seg, #sf-view-modes) { display: inline-flex; gap: 2px; padding: 3px; max-width: 100%; border: 0; border-radius: 11px; background: var(--m-raised); overflow: visible; margin: 0; }
    html.m-redesign body :is(#view-stats .sw-segments button, #view-stats .m-seg button, #sf-view-modes button) {
        position: relative; min-height: 30px; padding: 0 12px; border: 0; border-radius: 8px; background: transparent; color: var(--m-muted);
        font-size: 12px; font-weight: 600; white-space: nowrap; transition: background-color .2s, color .2s, transform .12s;
    }
    html.m-redesign body :is(#view-stats .sw-segments button, #view-stats .m-seg button, #sf-view-modes button)::after { content: ''; position: absolute; inset: -7px -2px; }
    html.m-redesign body :is(#view-stats .sw-segments button, #view-stats .m-seg button, #sf-view-modes button)[aria-pressed="true"] { background: var(--m-surface); color: var(--m-ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .1); }

    /* tappable trend chart */
    html.m-redesign body #view-stats .sw-readout { display: grid; gap: 1px; min-height: 42px; margin: 0 0 10px; }
    html.m-redesign body #view-stats .sw-readout strong { font-size: 15px; line-height: 1.5; font-weight: 800; color: var(--m-ink); }
    html.m-redesign body #view-stats .sw-readout span { font-size: 11.5px; color: var(--m-muted); line-height: 1.5; }
    html.m-redesign body #view-stats .sw-chart { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px; align-items: start; }
    html.m-redesign body #view-stats .sw-axis { display: flex; flex-direction: column; justify-content: space-between; height: 108px; font-size: 10px; line-height: 1; color: var(--m-muted); text-align: end; }
    html.m-redesign body #view-stats .sw-trend { display: flex; align-items: stretch; gap: 6px; height: 128px; min-width: 0; margin: 0; padding: 0; background: none; border: 0; }
    html.m-redesign body #view-stats .sw-trend.is-month { gap: 2px; }
    html.m-redesign body #view-stats .sw-trend-day { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 0; border: 0; background: none; color: inherit; font: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; position: relative; }
    html.m-redesign body #view-stats .sw-trend-day::after { content: ''; position: absolute; inset: 0 -2px; }
    html.m-redesign body #view-stats .sw-trend-day > div { position: relative; flex: none; width: 100%; max-width: 30px; height: 108px; margin: 0; border-radius: 6px; overflow: hidden; background: color-mix(in srgb, var(--m-line) 55%, transparent); }
    html.m-redesign body #view-stats .sw-trend.is-month .sw-trend-day > div { max-width: none; border-radius: 3px; }
    html.m-redesign body #view-stats .sw-trend-day i { position: absolute; inset: auto 0 0; display: block; height: var(--level); min-height: 3px; border-radius: inherit; background: var(--m-accent); opacity: .5; transform-origin: bottom; animation: m-bar .55s var(--m-ease) both; transition: opacity .2s; }
    html.m-redesign body #view-stats .sw-trend-day.is-today i, html.m-redesign body #view-stats .sw-trend-day.is-active i { opacity: 1; }
    html.m-redesign body #view-stats .sw-trend-day.is-zero i { opacity: .25; }
    html.m-redesign body #view-stats .sw-trend-day.is-active > div { outline: 2px solid var(--m-accent); outline-offset: 1px; }
    html.m-redesign body #view-stats .sw-trend-day small { font-size: 10px; line-height: 1; color: var(--m-muted); white-space: nowrap; }
    html.m-redesign body #view-stats .sw-trend.is-month .sw-trend-day small { visibility: hidden; }
    html.m-redesign body #view-stats .sw-trend.is-month .sw-trend-day[data-tick] small { visibility: visible; }
    html.m-redesign body #view-stats .sw-trend-day.is-today small { color: var(--m-ink); font-weight: 700; }
    html.m-redesign body #view-stats .sw-time-details summary { display: flex; align-items: center; min-height: 40px; margin-top: 4px; font-size: 12px; color: var(--m-muted); cursor: pointer; }
    html.m-redesign body #view-stats .sw-time-table { max-height: 260px; overflow: auto; overscroll-behavior: contain; }
    html.m-redesign body #view-stats .sw-time-table > div { display: flex; flex-direction: row; justify-content: space-between; gap: 8px; padding: 8px 0; border-top: 1px solid var(--m-line); font-size: 12px; }
    html.m-redesign body #view-stats .sw-time-table strong { text-align: end; font-weight: 600; }

    /* subjects */
    html.m-redesign body #view-stats .sw-subjects { display: grid; gap: 12px; }
    html.m-redesign body #view-stats .sw-subjects article > div:first-child { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 6px; font-size: 13px; }
    html.m-redesign body #view-stats .sw-subjects article strong { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    html.m-redesign body #view-stats .sw-subjects article span { flex: none; font-size: 11.5px; color: var(--m-muted); }
    html.m-redesign body #view-stats .sw-subjects .sw-track > i { opacity: var(--rank, 1); }
    html.m-redesign body #view-stats .sw-stats-note { display: flex; gap: 10px; align-items: flex-start; padding: 10px 4px 0; border: 0; background: none; }
    html.m-redesign body #view-stats .sw-stats-note .studio-icon { flex: none; width: 16px; height: 16px; color: var(--m-muted); margin-top: 2px; }
    html.m-redesign body #view-stats .sw-stats-note p { margin: 0; font-size: 11.5px; line-height: 1.8; color: var(--m-muted); }

    /* empty + error states (web and app) */
    html.m-redesign body :is(#view-stats) :is(.sw-empty, .m-empty) { display: grid; justify-items: center; gap: 4px; padding: 18px 8px; text-align: center; color: var(--m-muted); }
    html.m-redesign body :is(#view-stats) :is(.sw-empty, .m-empty).hidden { display: none; }
    html.m-redesign body :is(#view-stats) :is(.sw-empty, .m-empty) .studio-icon, html.m-redesign body :is(#view-stats) .m-empty > .material-symbols-outlined { width: 30px; height: 30px; font-size: 30px; color: var(--m-muted); opacity: .8; }
    html.m-redesign body :is(#view-stats) :is(.sw-empty h3, .m-empty strong) { margin: 4px 0 0; font-size: 14px; font-weight: 700; color: var(--m-ink); }
    html.m-redesign body :is(#view-stats) :is(.sw-empty, .m-empty) p { margin: 0 0 6px; font-size: 12px; line-height: 1.7; }
    html.m-redesign body :is(#view-stats .sw-empty .sw-button, #view-stats .sw-error .sw-button, #view-stats .m-error button) { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 16px; border: 0; border-radius: var(--m-r-sm); background: var(--m-accent); color: var(--m-on-accent); font-size: 13px; font-weight: 700; }
    html.m-redesign body #view-stats .sw-error { gap: 6px; padding: 26px 16px; border-radius: var(--m-r-lg); background: var(--m-surface); border-color: var(--m-line); }
    html.m-redesign body #view-stats .sw-error h3 { margin: 4px 0 0; font-size: 15px; }
    html.m-redesign body #view-stats .sw-error p { margin: 0 0 8px; font-size: 12px; color: var(--m-muted); }
    html.m-redesign body #view-stats .sw-error .studio-icon { width: 30px; height: 30px; color: var(--m-bad); }
    html.m-redesign body #view-stats .m-error { display: flex; align-items: center; gap: 10px; padding: 12px; margin: 0 0 8px; border: 1px solid color-mix(in srgb, var(--m-bad) 40%, var(--m-line)); border-radius: var(--m-r-md); background: color-mix(in srgb, var(--m-bad) 7%, var(--m-surface)); }
    html.m-redesign body #view-stats .m-error.hidden { display: none; }
    html.m-redesign body #view-stats .m-error > .material-symbols-outlined { color: var(--m-bad); font-size: 24px; }
    html.m-redesign body #view-stats .m-error > div { flex: 1; min-width: 0; }
    html.m-redesign body #view-stats .m-error strong { font-size: 13px; }
    html.m-redesign body #view-stats .m-error p { margin: 2px 0 0; font-size: 11.5px; color: var(--m-muted); }

    /* app (Chart.js) statistics */
    html.m-redesign body #view-stats .m-stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0 0 8px; }
    html.m-redesign body #view-stats .m-stat { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 10px 12px; border-radius: var(--m-r-md); }
    html.m-redesign body #view-stats .m-stat-lead { grid-column: 1 / -1; background: color-mix(in srgb, var(--m-accent) 8%, var(--m-surface)); }
    html.m-redesign body #view-stats .m-stat-icon { display: grid; place-items: center; flex: none; width: 32px; height: 32px; border-radius: 10px; background: color-mix(in srgb, var(--m-accent) 14%, transparent); color: var(--m-accent); }
    html.m-redesign body #view-stats .m-stat-icon .material-symbols-outlined { font-size: 19px; }
    html.m-redesign body #view-stats .m-stat-icon-warm { background: color-mix(in srgb, var(--m-warn) 16%, transparent); color: var(--m-warn); }
    html.m-redesign body #view-stats .m-stat-label { font-size: 11.5px; color: var(--m-muted); line-height: 1.4; }
    html.m-redesign body #view-stats .m-stat-value { font-size: 16px; font-weight: 800; line-height: 1.4; color: var(--m-ink); }
    html.m-redesign body #view-stats .m-stat-lead .m-stat-value { font-size: 20px; }
    html.m-redesign body #view-stats .m-chart { position: relative; height: 190px; min-width: 0; }
    html.m-redesign body #view-stats .m-chart.hidden { display: none; }
    html.m-redesign body #view-stats .m-chart.m-skel { border-radius: var(--m-r-md); background: linear-gradient(100deg, var(--m-raised) 30%, color-mix(in srgb, var(--m-raised) 50%, var(--m-surface)) 50%, var(--m-raised) 70%) 0 0 / 200% 100%; animation: m-shimmer 1.4s linear infinite; }
    html.m-redesign body #view-stats .m-chart canvas { max-width: 100%; }

    /* ------------------------------------------------------------ study report */
    html.m-redesign body .manual-report-card { margin: 8px 0 0; padding: 0; border: 1px solid var(--m-line); border-radius: var(--m-r-lg); background: var(--m-surface); box-shadow: none; overflow: hidden; }
    html.m-redesign body .manual-report-heading { position: relative; display: flex; align-items: center; gap: 10px; min-height: 56px; padding: 10px 14px; margin: 0; cursor: pointer; user-select: none; -webkit-tap-highlight-color: transparent; }
    html.m-redesign body .manual-report-heading-icon { flex: none; width: auto; height: auto; background: none; font-size: 20px; color: var(--m-accent); }
    html.m-redesign body .manual-report-heading h3 { margin: 0; font-size: 14px; font-weight: 700; line-height: 1.5; color: var(--m-ink); }
    html.m-redesign body .manual-report-heading p { margin: 1px 0 0; font-size: 11px; line-height: 1.6; color: var(--m-muted); }
    html.m-redesign body .manual-report-heading > div { flex: 1; min-width: 0; }
    html.m-redesign body #report-duration-preview { width: auto; grid-column: auto; display: inline-flex; align-items: baseline; gap: 3px; flex: none; padding: 2px 10px; border-radius: 999px; background: var(--m-raised); font-size: 13px; color: var(--m-ink); }
    html.m-redesign body #report-duration-preview small { font-size: 10.5px; color: var(--m-muted); }
    html.m-redesign body .manual-report-card.m-collapsed #report-duration-preview { display: none; }
    html.m-redesign body #view-schedule .section-heading-bar p { display: none; }
    html.m-redesign body .m-chevron { display: block; flex: none; width: 8px; height: 8px; margin-inline-start: auto; border: solid var(--m-muted); border-width: 0 2px 2px 0; transform: rotate(-135deg) translate(-2px, -2px); transition: transform .28s var(--m-ease); }
    html.m-redesign body .manual-report-card.m-collapsed .m-chevron { transform: rotate(45deg); }
    html.m-redesign body .manual-report-form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 2px 14px 14px; margin: 0; }
    html.m-redesign body .manual-report-form .form-group { margin: 0; min-width: 0; }
    html.m-redesign body .manual-report-form .form-group:nth-child(2), html.m-redesign body .manual-report-form .manual-report-notes, html.m-redesign body .manual-report-form > button { grid-column: 1 / -1; }
    html.m-redesign body .manual-report-form .form-label { display: block; margin-bottom: 4px; font-size: 11.5px; font-weight: 600; color: var(--m-muted); }
    html.m-redesign body .manual-report-form :is(input, select, textarea) { width: 100%; min-height: 44px; padding: 8px 12px; border: 1px solid var(--m-line); border-radius: 12px; background: var(--m-bg); color: var(--m-ink); font-size: 16px; }
    html.m-redesign body .manual-report-form textarea { min-height: 64px; resize: none; }
    html.m-redesign body .manual-report-form > button { min-height: 46px; border: 0; border-radius: 12px; background: var(--m-accent); color: var(--m-on-accent); font-size: 14px; font-weight: 700; }
    html.m-redesign body .manual-report-card.m-collapsed .manual-report-form { display: none; }
    html.m-redesign body #manual-report-list { padding: 0 14px; }
    html.m-redesign body #manual-report-list.m-trimmed > :nth-child(n + 4) { display: none; }
    html.m-redesign body .sf-report, html.m-redesign body .manual-report-item { padding: 10px 0; gap: 10px; font-size: 13px; }
    html.m-redesign body .m-more { display: block; width: calc(100% - 28px); min-height: 44px; margin: 0 14px 6px; border: 0; background: none; color: var(--m-accent); font-size: 12.5px; font-weight: 600; }

    /* ------------------------------------------------------------- study plan */
    html.m-redesign body #view-schedule #sf-view-modes { display: grid; grid-template-columns: 1fr 1fr; width: 100%; margin: 0 0 8px; }
    html.m-redesign body #view-schedule #sf-view-modes button { min-height: 34px; font-size: 12.5px; }
    html.m-redesign body #view-schedule .schedule-admin-tools, html.m-redesign body #view-schedule .schedule-context-banner { margin: 0 0 8px; }
    html.m-redesign body #view-schedule .schedule-admin-toggle { min-height: 52px; padding: 8px 12px; border-radius: var(--m-r-md); }
    html.m-redesign body #view-schedule .schedule-days-list, html.m-redesign body #view-schedule #schedule-days-list { padding: 0; background: none; border: 0; box-shadow: none; }
    html.m-redesign body #view-schedule .schedule-days-list { margin: 0; }

    html.m-redesign body .m-day-strip { position: sticky; top: var(--m-header-h); z-index: 5; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; margin: 0 -2px 8px; padding: 4px 2px 6px; background: var(--m-bg); }
    html.m-redesign body .m-day-strip[hidden] { display: none; }
    html.m-redesign body .m-day-strip button { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-width: 0; min-height: 58px; padding: 6px 0 7px; border: 1px solid var(--m-line); border-radius: var(--m-r-md); background: var(--m-surface); color: var(--m-muted); transition: background-color .22s, color .22s, border-color .22s, transform .12s; -webkit-tap-highlight-color: transparent; }
    html.m-redesign body .m-day-strip small { font-size: 11px; line-height: 1.2; font-weight: 600; }
    html.m-redesign body .m-day-strip strong { font-size: 15px; line-height: 1.3; font-weight: 800; color: var(--m-ink); transition: color .22s; }
    html.m-redesign body .m-day-strip .is-empty strong { opacity: .4; }
    html.m-redesign body .m-chip-meter { display: block; width: 58%; height: 3px; border-radius: 2px; background: var(--m-line); overflow: hidden; }
    html.m-redesign body .m-chip-meter b { display: block; height: 100%; background: var(--m-good); transition: width .5s var(--m-ease); }
    html.m-redesign body .m-day-strip .is-today { border-color: color-mix(in srgb, var(--m-accent) 55%, var(--m-line)); }
    html.m-redesign body .m-day-strip .is-today::after { content: ''; position: absolute; top: 4px; inset-inline-end: 5px; width: 5px; height: 5px; border-radius: 50%; background: var(--m-accent); }
    html.m-redesign body .m-day-strip .is-selected { border-color: var(--m-accent); background: var(--m-accent); color: var(--m-on-accent); }
    html.m-redesign body .m-day-strip .is-selected strong { color: var(--m-on-accent); }
    html.m-redesign body .m-day-strip .is-selected .m-chip-meter { background: color-mix(in srgb, var(--m-on-accent) 25%, transparent); }
    html.m-redesign body .m-day-strip .is-selected .m-chip-meter b { background: var(--m-on-accent); }
    html.m-redesign body .m-day-strip .is-selected.is-today::after { background: var(--m-on-accent); }

    html.m-redesign body #view-schedule .schedule-day-card { display: block; padding: 12px; margin: 0 0 8px; border: 1px solid var(--m-line); border-radius: var(--m-r-lg); background: var(--m-surface); box-shadow: none; min-width: 0; }
    html.m-redesign body #view-schedule .schedule-day-card.m-day-hidden { display: none; }
    html.m-redesign body #view-schedule .schedule-day-card.is-today { border-color: color-mix(in srgb, var(--m-accent) 40%, var(--m-line)); }
    html.m-redesign body #view-schedule .schedule-day-card.m-slide-next { animation: m-slide-next .3s var(--m-ease); }
    html.m-redesign body #view-schedule .schedule-day-card.m-slide-prev { animation: m-slide-prev .3s var(--m-ease); }
    html.m-redesign body #view-schedule .schedule-day-card > header { display: flex; align-items: center; gap: 8px; margin: 0; padding: 0; border: 0; min-height: 40px; }
    html.m-redesign body #view-schedule .schedule-day-card > header > div { display: flex; align-items: center; gap: 8px; min-width: 0; }
    html.m-redesign body #view-schedule .schedule-day-index { display: none; }
    html.m-redesign body #view-schedule .schedule-day-card h3 { margin: 0; font-size: 16px; font-weight: 800; line-height: 1.4; color: var(--m-ink); }
    html.m-redesign body #view-schedule .schedule-day-card > header > span { margin-inline-start: auto; font-size: 12px; color: var(--m-muted); white-space: nowrap; }
    html.m-redesign body #view-schedule .m-day-add { position: relative; display: grid; place-items: center; flex: none; width: 36px; height: 36px; padding: 0; border: 0; border-radius: 50%; background: color-mix(in srgb, var(--m-accent) 15%, transparent); color: var(--m-accent); transition: transform .12s, background-color .2s; }
    html.m-redesign body #view-schedule .m-day-add::after { content: ''; position: absolute; inset: -4px; }
    html.m-redesign body #view-schedule .m-day-add .material-symbols-outlined { font-size: 22px; }
    html.m-redesign body #view-schedule .m-day-progress { position: relative; padding-top: 10px; margin: 2px 0 10px; }
    html.m-redesign body #view-schedule .m-day-progress[hidden] { display: none; }
    html.m-redesign body #view-schedule .m-day-progress::before { content: ''; position: absolute; top: 0; inset-inline: 0; height: 4px; border-radius: 2px; background: var(--m-line); }
    html.m-redesign body #view-schedule .m-day-progress > i { position: absolute; top: 0; inset-inline-start: 0; height: 4px; border-radius: 2px; background: var(--m-good); transition: width .6s var(--m-ease); }
    html.m-redesign body #view-schedule .m-day-progress > span { display: block; margin-top: 2px; font-size: 11px; color: var(--m-muted); }
    html.m-redesign body #view-schedule .schedule-day-card.is-complete .m-day-progress > span { color: var(--m-good); }

    html.m-redesign body #view-schedule .schedule-day-tasks { display: grid; gap: 8px; margin: 0; }
    html.m-redesign body #view-schedule .day-task { position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 10px; min-height: 58px; padding: 8px 12px; margin: 0; border: 1px solid var(--m-line); border-inline-start: 3px solid var(--task-color, var(--m-accent)); border-radius: var(--m-r-md); background: var(--m-bg); box-shadow: none; transition: opacity .3s, background-color .3s; }
    html.m-redesign body #view-schedule .day-task:has(.sf-check) { padding-inline-start: 12px; }
    html.m-redesign body #view-schedule .day-task .sf-check { position: relative; inset: auto; top: auto; flex: none; width: 26px; height: 26px; padding: 1px; border: 2px solid var(--m-muted); border-radius: 8px; background: transparent; color: var(--m-bg); transition: background-color .2s, border-color .2s; }
    html.m-redesign body #view-schedule .day-task .sf-check[aria-checked="true"] { background: var(--m-good); border-color: var(--m-good); }
    html.m-redesign body #view-schedule .day-task .sf-check svg { width: 18px; height: 18px; }
    html.m-redesign body #view-schedule .day-task-main { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; column-gap: 8px; row-gap: 1px; width: 100%; min-width: 0; min-height: 42px; padding: 0; border: 0; background: none; color: inherit; text-align: start; cursor: pointer; -webkit-tap-highlight-color: transparent; }
    html.m-redesign body #view-schedule .day-task-number { display: none; }
    html.m-redesign body #view-schedule .day-task-copy { display: contents; }
    html.m-redesign body #view-schedule .day-task-copy strong { grid-column: 1; grid-row: 1; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; overflow-wrap: anywhere; font-size: 14px; font-weight: 700; line-height: 1.55; color: var(--m-ink); }
    html.m-redesign body #view-schedule .day-task-copy small { grid-column: 1 / -1; grid-row: 2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; line-height: 1.5; color: var(--m-muted); }
    html.m-redesign body #view-schedule .day-task-copy small.is-blank { display: none; }
    html.m-redesign body #view-schedule .day-task-duration { grid-column: 2; grid-row: 1; display: inline-flex; align-items: center; gap: 3px; padding: 1px 8px; border-radius: 999px; background: var(--m-raised); font-size: 11.5px; line-height: 1.6; color: var(--m-muted); white-space: nowrap; }
    html.m-redesign body #view-schedule .day-task-duration .material-symbols-outlined { font-size: 13px; }
    html.m-redesign body #view-schedule .day-task-footer { display: flex; align-items: center; gap: 6px; padding: 0; margin: 0; border: 0; }
    html.m-redesign body #view-schedule .schedule-status { padding: 1px 8px; border-radius: 999px; font-size: 10.5px; line-height: 1.7; white-space: nowrap; border: 0; }
    html.m-redesign body #view-schedule :is(.schedule-status-pending, .schedule-status-completed) { display: none; }
    html.m-redesign body #view-schedule .schedule-status-partial { background: color-mix(in srgb, var(--m-warn) 16%, transparent); color: var(--m-warn); }
    html.m-redesign body #view-schedule .schedule-status-missed { background: color-mix(in srgb, var(--m-bad) 14%, transparent); color: var(--m-bad); }
    html.m-redesign body #view-schedule .task-focus-button { position: relative; display: grid; place-items: center; flex: none; width: 36px; height: 36px; padding: 0; border: 0; border-radius: 50%; background: var(--m-raised); color: var(--m-accent); font-size: 0; transition: transform .12s, background-color .2s; }
    html.m-redesign body #view-schedule .task-focus-button::after { content: ''; position: absolute; inset: -4px; }
    html.m-redesign body #view-schedule .task-focus-button .material-symbols-outlined { font-size: 20px; }
    html.m-redesign body #view-schedule .day-task.sf-done { opacity: .7; }
    html.m-redesign body #view-schedule .day-task.is-partial { background: color-mix(in srgb, var(--m-warn) 6%, var(--m-bg)); }
    html.m-redesign body #view-schedule .day-task.is-missed { border-inline-start-color: var(--m-bad); background: color-mix(in srgb, var(--m-bad) 6%, var(--m-bg)); }
    html.m-redesign body #view-schedule .day-task.m-just-done { animation: m-pop .5s var(--m-ease); }
    html.m-redesign body #view-schedule .day-task.m-just-done .sf-check { animation: m-check .5s var(--m-ease); }
    html.m-redesign body #view-schedule .schedule-add-task { display: none; }
    html.m-redesign body #view-schedule .day-empty { display: grid; justify-items: center; gap: 4px; padding: 22px 8px 14px; text-align: center; font-size: 13px; color: var(--m-muted); }
    html.m-redesign body #view-schedule .day-empty .material-symbols-outlined { font-size: 30px; opacity: .7; }
    html.m-redesign body #view-schedule .day-empty strong { font-size: 14px; color: var(--m-ink); }
    html.m-redesign body #view-schedule .m-empty-cta { min-height: 40px; margin-top: 6px; padding: 0 16px; border: 0; border-radius: var(--m-r-sm); background: var(--m-accent); color: var(--m-on-accent); font-size: 13px; font-weight: 700; }

    /* week overview (existing "جدول هفته" mode) — dense list, one day per card */
    html.m-redesign body #view-schedule #schedule-days-list.sf-week-grid { display: block; }
    html.m-redesign body #view-schedule .sf-week-grid .schedule-day-card { display: block; padding: 12px; }
    html.m-redesign body #view-schedule .sf-week-grid .schedule-day-card > header { display: flex; }
    html.m-redesign body #view-schedule .sf-week-grid .schedule-day-tasks { grid-template-columns: 1fr; }
    html.m-redesign body #view-schedule .sf-week-grid .day-task-copy small { display: none; }

    /* ------------------------------------------------------------ bottom sheets */
    html.m-redesign body .modal-overlay.m-sheet { padding: 0; }
    html.m-redesign body .modal-overlay.m-sheet.active { align-items: flex-end; }
    html.m-redesign body .m-sheet .modal-box { display: flex; flex-direction: column; width: 100%; max-width: none; max-height: min(90dvh, calc(var(--m-vvh, 100dvh) - 8px)); padding: 0 0 env(safe-area-inset-bottom); border: 0; border-top: 1px solid var(--m-line); border-radius: 20px 20px 0 0; background: var(--m-surface); color: var(--m-ink); animation: m-sheet-up .32s var(--m-ease); }
    html.m-redesign body .m-sheet .modal-box::before { content: ''; flex: none; width: 36px; height: 4px; margin: 8px auto 0; border-radius: 2px; background: var(--m-line); }
    html.m-redesign body .m-sheet .modal-header { flex: none; padding: 8px 16px 6px; border: 0; }
    html.m-redesign body .m-sheet .modal-title { font-size: 15px; font-weight: 800; }
    html.m-redesign body .m-sheet .modal-body { flex: 1; min-height: 0; padding: 6px 16px 10px; overflow-y: auto; overscroll-behavior: contain; }
    html.m-redesign body .m-sheet .modal-footer { position: sticky; bottom: 0; display: flex; gap: 8px; flex: none; padding: 10px 16px; border-top: 1px solid var(--m-line); background: var(--m-surface); }
    html.m-redesign body .m-sheet .modal-footer > button { flex: 1; min-height: 46px; justify-content: center; border-radius: 12px; font-size: 14px; font-weight: 700; }
    html.m-redesign body .m-sheet .modal-footer > .btn-gold { flex: 1.5; border: 0; background: var(--m-accent); color: var(--m-on-accent); box-shadow: none; }
    html.m-redesign body .m-sheet .modal-footer > .btn-primary { border: 1px solid var(--m-line); background: var(--m-raised); color: var(--m-ink); box-shadow: none; }
    html.m-redesign body .m-sheet .modal-footer > .admin-danger-button { flex: 0 0 auto; padding: 0 14px; }
    html.m-redesign body .m-sheet .modal-footer > .hidden { display: none; }
    html.m-redesign body .m-sheet .form-group { margin-bottom: 12px; }
    html.m-redesign body .m-sheet .form-label { display: block; margin-bottom: 5px; font-size: 12px; font-weight: 600; color: var(--m-muted); }
    html.m-redesign body .m-sheet .form-control { min-height: 46px; padding: 8px 12px; border-radius: 12px; font-size: 16px; }
    html.m-redesign body .m-sheet input[type="color"] { height: 46px !important; padding: 3px !important; }
    html.m-redesign body .m-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
    html.m-redesign body .m-chips button { min-height: 36px; padding: 0 14px; border: 1px solid var(--m-line); border-radius: 999px; background: var(--m-raised); color: var(--m-ink); font-size: 12.5px; font-weight: 600; transition: background-color .2s, color .2s, transform .12s; }
    html.m-redesign body .m-chips button[aria-pressed="true"] { border-color: var(--m-accent); background: var(--m-accent); color: var(--m-on-accent); }
    html.m-redesign body dialog.m-sheet-dialog[open] { width: 100%; max-width: none; margin: auto 0 0; max-height: min(90dvh, calc(var(--m-vvh, 100dvh) - 8px)); border-radius: 20px 20px 0 0; animation: m-sheet-up .32s var(--m-ease); overflow-y: auto; }
    html.m-redesign body dialog.m-sheet-dialog :is(input:not([type="checkbox"]), select) { min-height: 46px; font-size: 16px; }

    /* ------------------------------------------------------- page entrance only */
    html.m-redesign body :is(#view-stats, #view-schedule, #view-profile).m-enter > * { animation: m-rise .34s var(--m-ease) both; }
    html.m-redesign body :is(#view-stats, #view-schedule, #view-profile).m-enter > :nth-child(2) { animation-delay: 40ms; }
    html.m-redesign body :is(#view-stats, #view-schedule, #view-profile).m-enter > :nth-child(3) { animation-delay: 80ms; }
    html.m-redesign body :is(#view-stats, #view-schedule, #view-profile).m-enter > :nth-child(n+4) { animation-delay: 110ms; }

    /* very small phones (320px) */
    @media (max-width: 350px) {
        html.m-redesign body .content-body { padding-inline: 10px; }
        html.m-redesign body #view-stats .sw-stats-hero strong { font-size: 19px; }
        html.m-redesign body #view-stats .sw-metrics strong { font-size: 13px; }
        html.m-redesign body .m-day-strip { gap: 3px; }
        html.m-redesign body .m-day-strip strong { font-size: 14px; }
        html.m-redesign body #view-schedule .day-task { gap: 8px; padding-inline: 10px; }
    }
}

/* Motion preferences: the system setting or the in-app "no motion" option disables every animation above. */
@media (prefers-reduced-motion: reduce) {
    html.m-redesign body :is(#view-stats, #view-schedule, #view-profile, .m-sheet, .m-sheet-dialog) *,
    html.m-redesign body :is(.m-sheet .modal-box, dialog.m-sheet-dialog, .schedule-day-card) { animation: none !important; transition-duration: .01ms !important; }
}
html.m-redesign[data-motion="off"] body :is(#view-stats, #view-schedule, #view-profile, .m-sheet, .m-sheet-dialog) *,
html.m-redesign[data-motion="off"] body :is(.m-sheet .modal-box, dialog.m-sheet-dialog) { animation: none !important; transition-duration: .01ms !important; }
@media print { html.m-redesign .m-day-strip, html.m-redesign .m-day-add, html.m-redesign .m-chevron { display: none !important; } html.m-redesign .schedule-day-card.m-day-hidden { display: block !important; } }
