/*
  SPDX-FileCopyrightText: 2026 Lukas Körber
  SPDX-License-Identifier: AGPL-3.0-only
*/

/* ============================================================================
   Quiet Focus - the StudyOS mobile surface.

   Loaded after responsive.css on purpose: the shell-level mobile rules below
   (app bar, four-tab bottom bar, page rhythm) have to win over the generic
   media-query block there, and the page rule sets keep the desktop untouched.

   Colour values live in base.css only (tools/check-contrast.py proves the
   ratios). This file references role tokens: --bg/--bg2/--bg3, --text/--text2/
   --text3, --border/--border2, --brand/--brand-card/--on-brand/--brand-text,
   --ring-track/--ring-fill, --radius-card, --radius-btn.
   ========================================================================== */

/* ── App bar (mobile only) ─────────────────────────────────────────────── */

.qf-appbar { display: none; }

/* Two wordings per primary nav entry: the page name on a desktop sidebar (学习首页/我的课表/
   学习统计/AI 学习教练, per the project glossary) and the short tab name on a phone
   (今日/课表/进度/教练). */
.nav-label-tab { display: none; }

@media (min-width: 769px) {
    /* The desktop sidebar keeps its original order even though the markup lists the four
       tabs first (that is the phone's bottom-bar order). */
    .nav-links .nav-item { order: 50; }
    .nav-links .nav-dash { order: 1; }
    .nav-links .nav-cal { order: 2; }
    .nav-links .nav-focus { order: 3; }
    .nav-links .nav-notes { order: 4; }
    .nav-links .nav-planner { order: 5; }
    .nav-links .nav-studyplan { order: 6; }
    .nav-links .nav-coach { order: 7; }
    .nav-links .nav-stats { order: 8; }
    .nav-links .nav-setup { order: 9; }
}

@media (max-width: 768px) {
    .nav-label-page { display: none; }
    .nav-label-tab { display: inline; }
}

/* ── Mobile home (desktop keeps the existing dashboard) ────────────────── */

.qf-home { display: block; }

/* ── Shared pieces of the mobile surface ──────────────────────────────── */

.qf-brand-mark {
    display: inline-grid;
    place-items: center;
    width: 26px;
    height: 26px;
    border-radius: 8px;
    background: var(--brand);
    color: var(--on-brand);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.qf-wordmark {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: var(--text);
}

.qf-icon-btn {
    display: inline-grid;
    place-items: center;
    width: 44px;
    height: 44px;
    margin-right: -10px;
    border-radius: 999px;
    color: var(--text2);
    font-size: 19px;
    line-height: 1;
}

.qf-icon-btn:hover,
.qf-icon-btn:focus-visible { color: var(--text); }

.qf-num {
    font-variant-numeric: tabular-nums;
    font-feature-settings: 'tnum' 1;
}

.qf-eyebrow {
    font-size: 12.5px;
    letter-spacing: 0.04em;
    color: var(--text3);
}

.qf-section-title {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin: 0 0 10px;
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
}

.qf-section-note {
    font-size: 12.5px;
    font-weight: 400;
    color: var(--text3);
}

.qf-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 24px;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 12px;
    color: var(--text2);
    white-space: nowrap;
}

.qf-chip.is-ok { color: var(--success); border-color: color-mix(in srgb, var(--success) 42%, transparent); }
.qf-chip.is-warn { color: var(--warning); border-color: color-mix(in srgb, var(--warning) 42%, transparent); }
.qf-chip.is-brand { color: var(--brand-text); border-color: color-mix(in srgb, var(--brand-text) 40%, transparent); }

.qf-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 0 18px;
    border-radius: var(--radius-btn);
    font: inherit;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.01em;
    color: var(--text);
    background: var(--bg3);
    border: 1px solid transparent;
    transition: var(--transition);
}

.qf-btn-primary {
    background: var(--brand);
    color: var(--on-brand);
}

.qf-btn-primary:hover { background: var(--brand-hover); color: var(--on-brand); }

.qf-btn-ghost {
    background: transparent;
    color: var(--text2);
    border-color: var(--control-border);
}

.qf-btn-ghost:hover { color: var(--text); }

.qf-btn-block { width: 100%; }
.qf-btn-lg { min-height: 52px; font-size: 16px; }
.qf-btn:disabled { color: var(--disabled-text); background: var(--bg3); border-color: var(--border); }

.qf-text-btn {
    min-height: 44px;
    padding: 0 8px;
    font: inherit;
    font-size: 13.5px;
    color: var(--text2);
}

.qf-text-btn:hover { color: var(--text); }

/* ── Mobile app bar + bottom tabs ─────────────────────────────────────── */

@media (max-width: 768px) {
    /* The shell gives the app bar the notch inset instead of the scroll container. */
    .main-content { padding-top: 0; }

    .qf-appbar {
        position: sticky;
        top: 0;
        z-index: 60;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        height: calc(48px + var(--safe-top));
        padding: var(--safe-top) 12px 0 20px;
        background: var(--bg);
        border-bottom: 1px solid transparent;
    }

    .qf-appbar-brand {
        display: inline-flex;
        align-items: center;
        gap: 9px;
        min-height: 44px;
        color: var(--text);
    }

    /* Four primary tabs only; the rest of the app lives one level deeper
       (setup top-right, the "more" row at the end of the home page). */
    .nav-item.nav-secondary { display: none; }

    .sidebar {
        height: auto;
        padding-bottom: var(--safe-bottom);
        background: color-mix(in srgb, var(--bg2) 92%, var(--bg));
        backdrop-filter: blur(12px);
    }

    .nav-links { align-items: stretch; }

    .nav-item {
        min-height: 56px;
        gap: 3px;
        padding: 8px 4px 6px;
        font-size: 11px;
        letter-spacing: 0.01em;
        color: var(--text3);
        border-radius: 0;
        background: none;
    }

    .nav-item.active { color: var(--brand-text); background: none; }
    .nav-item .nav-icon { font-size: 21px; line-height: 1; }
    .nav-item .nav-label { font-weight: 500; }
    .nav-item.nav-focus { color: var(--text3); }

    /* The current task card and the focus page use a two-column reading measure:
       a phone gets one column, everything else stays inside the page padding. */
    .qf-home { padding: 8px 20px 28px; }
    .qf-focus-page { padding: 4px 20px 32px; }
}

/* ── Home ──────────────────────────────────────────────────────────────── */

.qf-home-head { padding: 10px 0 18px; }

.qf-home-date {
    display: block;
    font-size: 12.5px;
    letter-spacing: 0.02em;
    color: var(--text3);
}

.qf-home-title {
    margin: 6px 0 4px;
    font-size: 28px;
    line-height: 1.2;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--text);
}

.qf-home-sub {
    margin: 0;
    font-size: 13px;
    line-height: 1.5;
    color: var(--text2);
}

.qf-progress {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 16px;
    margin-bottom: 18px;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
}

.qf-progress-label {
    display: block;
    font-size: 12.5px;
    color: var(--text3);
    margin-bottom: 6px;
}

.qf-progress-value {
    display: flex;
    align-items: baseline;
    gap: 6px;
    color: var(--text);
}

.qf-progress-value .qf-num { font-size: 26px; font-weight: 600; letter-spacing: -0.01em; }
.qf-progress-value .qf-unit { font-size: 13px; color: var(--text2); }

.qf-ring { flex: 0 0 auto; width: 46px; height: 46px; }
.qf-ring svg { display: block; width: 100%; height: 100%; transform: rotate(-90deg); }
.qf-ring-track { fill: none; stroke: var(--ring-track); stroke-width: 3.5; }
.qf-ring-fill { fill: none; stroke: var(--ring-fill); stroke-width: 3.5; stroke-linecap: round; }

/* Current task: the one deep, quiet focal surface of the app. */
.qf-task-card {
    position: relative;
    overflow: hidden;
    padding: 20px;
    margin-bottom: 22px;
    border-radius: var(--radius-card);
    background: var(--brand-card);
    color: var(--on-brand);
}

.qf-task-card.is-empty { background: var(--bg2); border: 1px solid var(--border); color: var(--text); }

.qf-task-eyebrow {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12.5px;
    letter-spacing: 0.04em;
    color: color-mix(in srgb, var(--on-brand) 72%, transparent);
}

.qf-task-card.is-empty .qf-task-eyebrow { color: var(--text3); }

.qf-task-status {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 22px;
    padding: 0 9px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--on-brand) 14%, transparent);
    color: var(--on-brand);
    font-size: 11.5px;
    letter-spacing: 0.02em;
}

.qf-task-status-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--brand-text);
}

.qf-task-subject {
    margin-top: 12px;
    font-size: 13.5px;
    color: color-mix(in srgb, var(--on-brand) 82%, transparent);
}

.qf-task-title {
    margin: 6px 0 10px;
    font-size: 20px;
    line-height: 1.35;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--on-brand);
}

.qf-task-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 14px;
    font-size: 12.5px;
    color: color-mix(in srgb, var(--on-brand) 70%, transparent);
}

.qf-task-next {
    display: flex;
    gap: 8px;
    margin: 14px 0 16px;
    font-size: 14px;
    line-height: 1.5;
    color: color-mix(in srgb, var(--on-brand) 92%, transparent);
}

.qf-task-next b {
    flex: 0 0 auto;
    font-weight: 600;
    color: var(--on-brand-accent);
}

.qf-task-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

/* Inside the forest card the primary action inverts: light fill, brand text. */
.qf-task-card .qf-btn-primary {
    flex: 1 1 auto;
    min-width: 140px;
    background: var(--on-brand);
    color: var(--brand);
}

.qf-task-card .qf-btn-primary:hover { background: #ffffff; color: var(--brand); }
.qf-task-card .qf-text-btn { color: color-mix(in srgb, var(--on-brand) 78%, transparent); }
.qf-task-card .qf-text-btn:hover { color: var(--on-brand); }
.qf-task-card .qf-task-elapsed { color: var(--on-brand-accent); }

.qf-task-elapsed {
    font-family: var(--font-mono);
    font-size: 21px;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.02em;
    color: var(--text);
}

.qf-task-hint {
    margin-top: 12px;
    font-size: 12.5px;
    line-height: 1.5;
    color: color-mix(in srgb, var(--on-brand) 70%, transparent);
}

.qf-task-card.is-empty .qf-task-hint { color: var(--text2); }

/* ── Today timeline ───────────────────────────────────────────────────── */

.qf-timeline { margin-bottom: 22px; }

.qf-timeline ol { list-style: none; margin: 0; padding: 0; }

.qf-tl-row {
    position: relative;
    display: grid;
    grid-template-columns: 46px 16px minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 48px;
    padding: 6px 0;
    border: 0;
    border-bottom: 1px solid var(--border);
    background: none;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.qf-tl-row:last-child { border-bottom: 0; }

.qf-tl-row:hover { background: color-mix(in srgb, var(--text) 4%, transparent); }

.qf-tl-time {
    font-size: 12.5px;
    font-variant-numeric: tabular-nums;
    color: var(--text3);
}

.qf-tl-dot {
    width: 7px;
    height: 7px;
    margin: 0 auto;
    border-radius: 50%;
    border: 1.5px solid var(--control-border);
}

.qf-tl-body { min-width: 0; display: flex; flex-direction: column; gap: 1px; }

.qf-tl-subject { font-size: 11.5px; color: var(--text3); letter-spacing: 0.02em; }

.qf-tl-title {
    font-size: 14.5px;
    line-height: 1.35;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.qf-tl-min {
    font-size: 12.5px;
    font-variant-numeric: tabular-nums;
    color: var(--text3);
}

.qf-tl-row.is-done .qf-tl-title,
.qf-tl-row.is-done .qf-tl-subject { color: var(--muted-text); }
.qf-tl-row.is-done .qf-tl-dot { border-color: var(--success); background: var(--success); }
.qf-tl-row.is-done .qf-tl-min { color: var(--muted-text); }

.qf-tl-row.is-current .qf-tl-dot { border-color: var(--brand-text); background: var(--brand-text); }
.qf-tl-row.is-current .qf-tl-title { color: var(--brand-text); font-weight: 600; }
.qf-tl-row.is-current .qf-tl-time { color: var(--brand-text); }

.qf-tl-row.is-partial .qf-tl-dot { border-color: var(--warning); background: var(--warning); }
.qf-tl-row.is-partial .qf-tl-title { color: var(--warning); }

.qf-tl-row.is-skipped { opacity: 1; }
.qf-tl-row.is-skipped .qf-tl-title,
.qf-tl-row.is-skipped .qf-tl-subject { color: var(--disabled-text); }

.qf-tl-flag { font-size: 11px; color: var(--text3); }

/* ── Secondary entries ("more") ────────────────────────────────────────── */

.qf-more {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 18px;
    padding-top: 6px;
    border-top: 1px solid var(--border);
}

.qf-more a {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    font-size: 13px;
    color: var(--text2);
}

.qf-more a:hover { color: var(--text); }

/* ── Focus page (/today) ───────────────────────────────────────────────── */

.qf-focus-page {
    max-width: 640px;
    margin: 0 auto;
}

.qf-focus-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 4px 0 14px;
}

.qf-back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 44px;
    padding-right: 8px;
    font-size: 14px;
    color: var(--text2);
}

.qf-back:hover { color: var(--text); }

.qf-focus-title h1 {
    margin: 8px 0 6px;
    font-size: 26px;
    line-height: 1.3;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--text);
}

.qf-focus-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 12px;
    margin: 0;
    font-size: 13px;
    color: var(--text2);
}

/* Thin-line ring with a tick scale around the digits. */
.qf-timer {
    position: relative;
    width: min(264px, 76vw);
    aspect-ratio: 1;
    margin: 22px auto 8px;
    display: grid;
    place-items: center;
}

.qf-timer-ticks,
.qf-timer-progress {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    pointer-events: none;
}

.qf-timer-ticks {
    background: repeating-conic-gradient(
        from -0.35deg,
        var(--border2) 0deg 0.7deg,
        transparent 0.7deg 6deg);
    -webkit-mask: radial-gradient(circle, transparent 0 46%, #000 46% 47.5%, transparent 47.5%);
    mask: radial-gradient(circle, transparent 0 46%, #000 46% 47.5%, transparent 47.5%);
}

.qf-timer-progress { transform: rotate(-90deg); }
.qf-timer-progress circle { fill: none; stroke-linecap: round; }
.qf-timer-progress .qf-timer-track { stroke: color-mix(in srgb, var(--ring-track) 60%, transparent); stroke-width: 1.5; }
.qf-timer-progress .qf-timer-fill { stroke: var(--ring-fill); stroke-width: 2.5; }

.qf-timer-value {
    position: relative;
    z-index: 1;
    text-align: center;
}

.qf-timer-digits {
    display: block;
    font-family: var(--font-mono);
    font-size: clamp(44px, 13vw, 56px);
    line-height: 1;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.01em;
    color: var(--text);
}

.qf-timer-paused .qf-timer-digits { color: var(--text2); }

.qf-timer-caption {
    display: block;
    margin-top: 10px;
    font-size: 12.5px;
    letter-spacing: 0.02em;
    color: var(--text3);
}

.qf-focus-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 6px 0 6px;
}

.qf-focus-controls .qf-btn { flex: 1 1 0; }

.qf-focus-goal {
    margin: 10px 0 0;
    text-align: center;
    font-size: 12.5px;
    color: var(--text3);
}

/* ── Learning steps ───────────────────────────────────────────────────── */

.qf-section { padding: 22px 0 4px; border-top: 1px solid var(--border); margin-top: 22px; }

.qf-steps { list-style: none; margin: 0; padding: 0; counter-reset: qf-step; }

.qf-step {
    position: relative;
    display: grid;
    grid-template-columns: 26px minmax(0, 1fr);
    gap: 12px;
    padding: 9px 0;
    font-size: 14.5px;
    line-height: 1.55;
    color: var(--text2);
}

.qf-step-no {
    display: grid;
    place-items: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 1px solid var(--border2);
    font-size: 11.5px;
    font-variant-numeric: tabular-nums;
    color: var(--text3);
}

.qf-step.is-first { color: var(--text); }
.qf-step.is-first .qf-step-no { border-color: var(--brand-text); color: var(--brand-text); }

.qf-steps-note {
    margin: 6px 0 0;
    font-size: 12px;
    line-height: 1.55;
    color: var(--text3);
}

/* ── Resource rows ────────────────────────────────────────────────────── */

.qf-asset {
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    min-height: 52px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

.qf-asset:last-child { border-bottom: 0; }

.qf-asset-icon {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: var(--bg3);
    font-size: 13px;
    color: var(--text2);
}

.qf-asset-body { min-width: 0; }

.qf-asset-name {
    display: block;
    font-size: 14.5px;
    line-height: 1.35;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.qf-asset-meta {
    display: block;
    margin-top: 2px;
    font-size: 12px;
    line-height: 1.4;
    color: var(--text3);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.qf-asset-action {
    min-height: 40px;
    padding: 0 14px;
    border-radius: 12px;
    border: 1px solid var(--control-border);
    background: transparent;
    color: var(--text);
    font: inherit;
    font-size: 13px;
}

.qf-asset-action:hover { border-color: var(--text3); }

.qf-asset.is-unbound .qf-asset-name { color: var(--text2); }

.qf-asset-bind {
    grid-column: 1 / -1;
    display: grid;
    gap: 8px;
    padding: 10px 0 4px;
}

.qf-asset-bind input,
.qf-asset-bind select {
    width: 100%;
    min-height: 42px;
    padding: 8px 12px;
    border-radius: 12px;
    border: 1px solid var(--control-border);
    background: var(--bg);
    color: var(--text);
    font: inherit;
    font-size: 14px;
}

.qf-locked {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding: 14px;
    border: 1px dashed var(--border2);
    border-radius: var(--radius-btn);
    font-size: 13.5px;
    line-height: 1.5;
    color: var(--text2);
}

/* ── Today mode (reduced / minimum / rest / shift) ────────────────────── */

.qf-mode-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.qf-mode-opt {
    min-height: 36px;
    padding: 0 14px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text2);
    font: inherit;
    font-size: 13px;
}

.qf-mode-opt.is-active {
    border-color: var(--brand-text);
    color: var(--brand-text);
    background: var(--brand-soft);
}

.qf-mode-shift {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.qf-mode-shift input {
    width: 88px;
    min-height: 40px;
    padding: 6px 10px;
    border-radius: 12px;
    border: 1px solid var(--control-border);
    background: var(--bg);
    color: var(--text);
    font: inherit;
    font-size: 14px;
}

/* ── Record sheet (bottom sheet on a phone) ───────────────────────────── */

.qf-sheet-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1200;
    background: color-mix(in srgb, #000000 55%, transparent);
}

.qf-sheet {
    position: fixed;
    z-index: 1201;
    left: 0;
    right: 0;
    bottom: 0;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 20px 20px calc(20px + var(--safe-bottom));
    border-radius: 22px 22px 0 0;
    background: var(--bg2);
    border-top: 1px solid var(--border);
    overscroll-behavior: contain;
}

/* The form scrolls inside the sheet; the two save actions stay visible at its bottom. */
.qf-sheet-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
}

.qf-sheet-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 4px;
}

.qf-sheet-title { margin: 0; font-size: 18px; font-weight: 600; color: var(--text); }

.qf-sheet-hint {
    margin: 6px 0 14px;
    font-size: 12.5px;
    line-height: 1.5;
    color: var(--text3);
}

.qf-field-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
    gap: 12px;
    margin-bottom: 14px;
}

.qf-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.qf-field.wide { grid-column: 1 / -1; }

.qf-field label { font-size: 12.5px; color: var(--text3); }

.qf-field input,
.qf-field textarea {
    min-height: 44px;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid var(--control-border);
    background: var(--bg);
    color: var(--text);
    font: inherit;
    font-size: 15px;
    font-variant-numeric: tabular-nums;
}

.qf-field textarea { min-height: 76px; resize: vertical; line-height: 1.5; }

.qf-sheet-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 0 0 auto;
    padding-top: 12px;
    margin-top: 4px;
}

.qf-sheet-actions .qf-btn { width: 100%; }

.qf-msg { font-size: 13px; line-height: 1.5; margin: 10px 0 0; }
.qf-msg.is-ok { color: var(--success); }
.qf-msg.is-error { color: var(--danger); }

/* ── Desktop: the mobile-only pieces stay out, the focus page gets a column ─ */

@media (min-width: 769px) {
    .qf-home { display: none; }
    .qf-focus-page { padding: 8px 0 40px; }
    .qf-sheet {
        left: 50%;
        right: auto;
        bottom: auto;
        top: 50%;
        width: min(560px, calc(100vw - 48px));
        max-height: 86vh;
        transform: translate(-50%, -50%);
        border: 1px solid var(--border);
        border-radius: var(--radius-card);
        padding: 24px;
    }
    .qf-sheet-actions { flex-direction: row; }
    .qf-sheet-actions .qf-btn { width: auto; flex: 1 1 0; }
}

/* ── The legacy dashboard is replaced on a phone, kept on a desktop ────── */

@media (max-width: 768px) {
    .dashboard { display: none; }
}

/* The V5 dashboard hero stays as the desktop card; the phone uses .qf-task-card. */
@media (max-width: 768px) {
    .fab-dial { right: 14px; }

    /* The speed dial is chrome, not content: it takes the product identity instead of the
       personal accent, so it stops competing with the forest card and the tab bar. */
    .fab-main {
        background: var(--brand);
        color: var(--on-brand);
        width: 48px;
        height: 48px;
    }

    .fab-main:hover { background: var(--brand-hover); color: var(--on-brand); }
}

/* ── Calendar (day view): compact header, one scrolling filter row ─────── */

@media (max-width: 768px) {
    .calendar-page { padding: 10px 0 8px 12px; }

    .cal-header {
        gap: 6px;
        padding-right: 12px;
        align-items: center;
    }

    /* The date label gets its own line instead of being squeezed by the five controls. */
    .cal-header h2 {
        order: -1;
        flex: 1 1 100%;
        font-size: 1.15rem;
        line-height: 1.35;
        margin-bottom: 2px;
    }

    .cal-header .btn-nav {
        min-width: 40px;
        min-height: 40px;
        padding: 0 8px;
    }

    .cal-view-switch { margin-left: auto; }
    .cal-view-opt { min-height: 40px; padding: 0 12px; font-size: 0.8rem; }
    .cal-header .btn-today { min-height: 40px; padding: 0 12px; font-size: 0.8rem; }
    .cal-header .cal-new-session { min-height: 40px; padding: 0 12px; font-size: 0.8rem; }

    .cal-import-row {
        flex-wrap: nowrap;
        overflow-x: auto;
        gap: 6px;
        padding-right: 12px;
        padding-bottom: 2px;
    }

    .cal-import-row .btn-secondary {
        flex: 0 0 auto;
        min-height: 40px;
        padding: 0 10px;
        font-size: 0.76rem;
        white-space: nowrap;
    }

    .cal-filter-row { padding-right: 12px; gap: 8px; }

    .cal-filter-pills {
        flex-wrap: nowrap;
        overflow-x: auto;
        gap: 6px;
        padding-bottom: 4px;
    }

    .cal-filter-pill {
        flex: 0 0 auto;
        min-height: 36px;
        padding: 0 10px;
        font-size: 0.78rem;
    }

    .cal-filter-pill .cp-name {
        max-width: 7.5em;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .cal-filter-pill .pill-tag { display: none; }
}
