/* ========================================
   StudyLoop — CSS Variables & Base Styles
   Coffee & Cream Theme
   ======================================== */

:root {
    /*
     * Tonal hierarchy (~80% cream canvas / ~15% soft panels / ~5% rich mocha accent)
     * Large lightness gaps so neumorphic shadows read; cream-dominant, not brown-heavy.
     */
    --bg-page: #cfc0b6;
    --surface-panel: #F3F0EA;
    --surface-elevated: #ffffff;
    --surface-recess: #DDD7CF;
    --surface-chrome: #EDE9E2;
    --nav-track-bg: #E0DAD2;
    --input-fill: #eee9e3;
    --milk-foam: var(--surface-elevated);
    --cream: #E2DDD4;

    --espresso: #1A1210;
    --mocha: #5E3826;
    --mocha-hover: #4A2C1E;
    --latte: #6E625A;
    --creamy-latte: #A8988C;

    --text-main: #1A1210;
    --text-muted: #5E564E;
    --text-inverse: #FFFBF7;
    --border-coffee: #C4BBB2;
    --nav-pill-active-fg: #FFFBF7;

    --timer-ring-track: #A8988A;
    --timer-ring-progress: var(--mocha);

    /* Monochrome task / calendar stripes (depth by shade, not hue) */
    --task-stripe-1: #5E3826;
    --task-stripe-2: #7D5E4E;
    --task-stripe-3: #2A1E18;
    --task-stripe-4: #B0A099;
    --task-stripe-5: #4A3A32;
    --task-stripe-6: #8A7B72;

    /* Functional accents only (errors, success toasts, live state) */
    --accent-green: #4A6B3E;
    --accent-red: #B83228;
    --accent-amber: #B8892E;
    --accent-online: #3D8F5A;

    --glass-bg: var(--surface-elevated);
    --glass-border: rgba(90, 72, 60, 0.12);

    /* Second-layer “lift” uses a subtle dark ambient (no white highlights). */
    --neo-highlight: rgba(26, 18, 16, 0.07);
    --neo-shadow: rgba(26, 18, 16, 0.12);
    --neo-shadow-deep: rgba(26, 18, 16, 0.18);
    --neo-track: inset 5px 5px 12px var(--neo-shadow), inset -4px -4px 12px rgba(26, 18, 16, 0.06);
    --neo-pressed: inset 6px 6px 14px var(--neo-shadow-deep), inset -3px -3px 10px rgba(26, 18, 16, 0.05);

    --shadow-sm: 5px 5px 12px var(--neo-shadow), -3px -3px 10px rgba(26, 18, 16, 0.08);
    --shadow-md: 9px 9px 20px var(--neo-shadow), -4px -4px 14px rgba(26, 18, 16, 0.09);
    --shadow-lg: 14px 14px 28px var(--neo-shadow-deep), -6px -6px 16px rgba(26, 18, 16, 0.1);
    --shadow-xl: 18px 18px 36px var(--neo-shadow-deep), -8px -8px 20px rgba(26, 18, 16, 0.1);

    --radius-sm: 0.5rem;
    --radius-md: 0.75rem;
    --radius-lg: 1rem;
    --radius-xl: 1.5rem;
    --radius-2xl: 2rem;
    --radius-full: 9999px;
    --radius-input: 1.125rem;
}

:root[data-theme="dark"] {
    --bg-page: #12100E;
    --surface-panel: #1A1714;
    --surface-elevated: #242019;
    --surface-recess: #141210;
    --surface-chrome: #1C1815;
    --nav-track-bg: #252019;
    --input-fill: #181512;
    --cream: #1E1A17;
    --milk-foam: var(--surface-elevated);

    --espresso: #E8DED4;
    --mocha: #C9A88C;
    --mocha-hover: #D4B69A;
    --latte: #9A8F86;
    --creamy-latte: #5A524C;

    --text-main: #F5F0EA;
    --text-muted: #9A9088;
    --text-inverse: #14110E;
    --border-coffee: #3D3630;
    --nav-pill-active-fg: #14110E;

    --timer-ring-track: #4A423C;
    --timer-ring-progress: var(--mocha);

    --task-stripe-1: #C9A88C;
    --task-stripe-2: #9A8474;
    --task-stripe-3: #E8DED4;
    --task-stripe-4: #6B6058;
    --task-stripe-5: #7D6E62;
    --task-stripe-6: #8A7F76;

    --accent-green: #7CB868;
    --accent-red: #E57373;
    --accent-amber: #E8C547;
    --accent-online: #69F0AE;
    --glass-bg: var(--surface-elevated);
    --glass-border: rgba(255, 248, 240, 0.08);

    --neo-highlight: rgba(0, 0, 0, 0.4);
    --neo-shadow: rgba(0, 0, 0, 0.5);
    --neo-shadow-deep: rgba(0, 0, 0, 0.62);
    --neo-track: inset 4px 4px 12px var(--neo-shadow-deep), inset -3px -3px 10px rgba(0, 0, 0, 0.35);
    --neo-pressed: inset 6px 6px 14px var(--neo-shadow-deep), inset -3px -3px 8px rgba(0, 0, 0, 0.32);

    --shadow-sm: 4px 4px 12px var(--neo-shadow), -2px -2px 8px rgba(0, 0, 0, 0.35);
    --shadow-md: 8px 8px 20px var(--neo-shadow), -3px -3px 12px rgba(0, 0, 0, 0.38);
    --shadow-lg: 12px 12px 28px var(--neo-shadow-deep), -4px -4px 14px rgba(0, 0, 0, 0.42);
    --shadow-xl: 16px 16px 36px var(--neo-shadow-deep), -5px -5px 16px rgba(0, 0, 0, 0.45);
}

/* ========================================
   Reset & Base
   ======================================== */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    height: 100%;
}

body {
    font-family: 'Sora', 'Plus Jakarta Sans', system-ui, sans-serif;
    background-color: var(--bg-page);
    color: var(--text-main);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow: hidden;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="url"],
input[type="tel"],
input[type="number"],
textarea,
select {
    border-radius: var(--radius-input);
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: 'Sora', sans-serif;
    font-weight: 700;
}

/* ========================================
   Utility Classes
   ======================================== */
.font-body {
    font-family: 'Plus Jakarta Sans', sans-serif;
}

.font-display {
    font-family: 'Sora', sans-serif;
}

.text-gradient {
    color: var(--espresso);
    background: none;
    -webkit-text-fill-color: currentColor;
}

.glass {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    box-shadow: var(--shadow-md);
}

.neo-logo-tile {
    box-shadow: 6px 6px 16px rgba(61, 43, 31, 0.32), -2px -2px 8px rgba(26, 18, 16, 0.12);
}

.neo-danger-btn {
    box-shadow: 4px 4px 12px rgba(192, 57, 43, 0.38), -1px -2px 6px rgba(61, 43, 31, 0.18);
}

.neo-danger-btn:active {
    box-shadow: var(--neo-pressed);
}

/* ========================================
   Scrollbar
   ======================================== */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--creamy-latte);
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--latte);
}

/* ========================================
   Animations
   ======================================== */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes pulse-glow {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(94, 56, 38, 0.45);
    }

    50% {
        box-shadow: 0 0 0 8px rgba(94, 56, 38, 0);
    }
}

@keyframes spin-slow {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

@keyframes loading-spin {
    to {
        transform: rotate(360deg);
    }
}

.loading-ring {
    display: inline-block;
    width: 28px;
    height: 28px;
    border: 3px solid var(--border-coffee);
    border-top-color: var(--mocha);
    border-radius: 50%;
    animation: loading-spin 0.78s linear infinite;
    flex-shrink: 0;
}

.loading-ring--sm {
    width: 20px;
    height: 20px;
    border-width: 2.5px;
}

.loading-ring--md {
    width: 32px;
    height: 32px;
    border-width: 3px;
}

.loading-ring--lg {
    width: 44px;
    height: 44px;
    border-width: 4px;
}

.cal-grid-loading {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    padding: 2rem;
}

.presence-card-loading {
    position: absolute;
    inset: 0;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-xl);
    background: color-mix(in srgb, var(--milk-foam) 86%, transparent);
    pointer-events: none;
}

.presence-card-loading.hidden {
    display: none !important;
}

:root[data-theme="dark"] .presence-card-loading {
    background: color-mix(in srgb, var(--milk-foam) 88%, transparent);
}

.animate-fade-in-up {
    animation: fadeInUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.animate-fade-in {
    animation: fadeIn 0.4s ease both;
}

.animate-pulse-glow {
    animation: pulse-dot-soft 2s ease-in-out infinite;
}

/* ========================================
   Card Styles
   ======================================== */
.card {
    background: var(--milk-foam);
    border: none;
    border-radius: var(--radius-xl);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
    box-shadow: var(--shadow-lg);
}

.card-elevated {
    background: var(--milk-foam);
    border: none;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
}

/* ========================================
   App header (true center nav)
   ======================================== */
#app-header.app-header {
    display: grid;
    align-items: center;
    column-gap: 0.75rem;
    row-gap: 0.35rem;
}

.app-header__brand {
    justify-self: start;
    min-width: 0;
}

.app-header__nav {
    justify-self: center;
    width: 100%;
    min-width: 0;
    display: flex;
    justify-content: center;
}

.app-header__nav .nav-pill-group {
    flex-wrap: nowrap;
}

.app-header__actions {
    justify-self: end;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

@media (max-width: 768px) {
    #app-header.app-header {
        grid-template-columns: 1fr auto;
    }
}

@media (min-width: 769px) {
    #app-header.app-header {
        /* Center column grows so nav pills are not squeezed (e.g. “Marketplace”). */
        grid-template-columns: auto minmax(0, 1fr) auto;
    }
}

#app-header.app-header {
    background: var(--surface-chrome) !important;
    border-bottom: none !important;
    box-shadow: 0 4px 14px rgba(26, 18, 16, 0.14), 0 2px 6px rgba(26, 18, 16, 0.08);
}

:root[data-theme="dark"] #app-header.app-header {
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.55), 0 2px 8px rgba(0, 0, 0, 0.35);
}

.dashboard-footer-progress {
    background: #af9f94;
    border-top: none;
    box-shadow: 0 -6px 18px rgba(26, 18, 16, 0.14), 0 2px 8px rgba(26, 18, 16, 0.08);
}

:root[data-theme="dark"] .dashboard-footer-progress {
    background: #0c0a08;
    box-shadow: 0 -6px 20px rgba(0, 0, 0, 0.55), 0 2px 8px rgba(0, 0, 0, 0.35);
}

.app-mob-nav {
    background: var(--surface-chrome);
    border-top: none;
    box-shadow: 0 -6px 20px rgba(26, 18, 16, 0.14), 0 -2px 8px rgba(26, 18, 16, 0.08);
}

:root[data-theme="dark"] .app-mob-nav {
    box-shadow: 0 -6px 22px rgba(0, 0, 0, 0.55), 0 -2px 8px rgba(0, 0, 0, 0.35);
}

#settings-btn {
    border: none !important;
    box-shadow: var(--shadow-sm);
}

#settings-btn .material-symbols-outlined {
    display: block;
    transition: transform 0.2s ease;
}

#settings-btn:hover .material-symbols-outlined {
    transform: rotate(180deg);
    transition: transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#header-avatar {
    border: none !important;
    box-shadow: var(--shadow-md);
}

#mob-chat-btn {
    box-shadow: 5px 5px 14px rgba(61, 43, 31, 0.38), -2px -2px 8px rgba(26, 18, 16, 0.14) !important;
}

.mob-nav-pill-group {
    --nav-pad: 5px;
    position: relative;
    display: flex;
    flex: 1;
    min-width: 0;
    align-items: stretch;
    padding: var(--nav-pad);
    border-radius: var(--radius-full);
    background: var(--nav-track-bg);
    box-shadow: var(--neo-track);
    gap: 2px;
}

.mob-nav-pill-group .nav-pill-slider {
    z-index: 0;
}

.mob-nav-btn {
    position: relative;
    z-index: 1;
    flex: 1 1 0;
    min-width: 0;
    background: transparent;
    border: none;
    cursor: pointer;
    color: rgba(26, 18, 16, 0.48);
    transition: color 0.25s ease;
}

.mob-nav-btn.active {
    color: var(--nav-pill-active-fg);
}

:root[data-theme="dark"] .mob-nav-btn {
    color: rgba(240, 232, 223, 0.45);
}

:root[data-theme="dark"] .mob-nav-btn.active {
    color: var(--nav-pill-active-fg);
}

.marketplace-soon-card {
    max-width: 22rem;
    text-align: center;
    padding: 2.5rem 2rem;
}

.marketplace-soon-card .marketplace-soon-icon {
    font-size: 3rem;
    color: var(--mocha);
    margin-bottom: 1rem;
}

/* ========================================
   Statistics page polish
   ======================================== */
.stats-page {
    position: relative;
    gap: 1.75rem;
}

/* Per-card loading on Statistics (see .stat-card-loading) */
.stats-card-host {
    position: relative;
}

.stat-card-loading {
    position: absolute;
    inset: 0;
    z-index: 8;
    display: flex;
    align-items: center;
    justify-content: center;
    background: color-mix(in srgb, var(--milk-foam) 88%, transparent);
    border-radius: inherit;
    pointer-events: none;
}

.stat-card-loading.hidden {
    display: none !important;
}

:root[data-theme="dark"] .stat-card-loading {
    background: color-mix(in srgb, var(--surface-elevated) 90%, transparent);
}

.stats-focus-logs-host {
    position: relative;
}

.stats-focus-logs-host .stat-card-loading {
    border-radius: var(--radius-lg);
}

@media (min-width: 1024px) {
    .stats-page {
        gap: 2rem;
    }
}

.stats-page-hero {
    margin-bottom: 0.25rem;
}

/* This Week metrics: one row, four equal columns */
.stats-week-metrics {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.35rem 0.65rem;
    align-items: start;
}

.stats-week-metric-cell {
    min-width: 0;
}

.stats-week-metric-label {
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 0.2rem;
    line-height: 1.2;
}

.stats-week-metric-value {
    font-size: 1.25rem;
    font-weight: 800;
    line-height: 1.15;
}

.stats-week-metric-sub {
    font-size: 8px;
    font-weight: 700;
    color: var(--text-muted);
    margin-top: 0.15rem;
    line-height: 1.2;
}

.stats-week-best-hour {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.08rem;
    min-width: 0;
}

.stats-week-best-hour-main {
    font-size: 0.8125rem;
    font-weight: 800;
    color: var(--mocha);
    line-height: 1.2;
    letter-spacing: -0.02em;
}

.stats-week-best-hour-sub {
    font-size: 0.625rem;
    font-weight: 600;
    color: var(--text-muted);
    line-height: 1.25;
}

.stats-week-best-hour-sub.hidden {
    display: none !important;
}

.stat-today-total {
    font-size: 0.7rem;
    letter-spacing: 0.02em;
}

@media (max-width: 380px) {
    .stats-week-metrics {
        gap: 0.25rem 0.35rem;
    }

    .stats-week-metric-value {
        font-size: 1.05rem;
    }

    .stats-week-metric-label {
        font-size: 8px;
    }

    .stats-week-best-hour-main {
        font-size: 0.75rem;
    }

    .stats-week-best-hour-sub {
        font-size: 0.5625rem;
    }
}

.stats-kpi-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-full);
    background: rgba(94, 56, 38, 0.08);
    color: var(--mocha);
    border: 1px solid rgba(94, 56, 38, 0.14);
}

:root[data-theme="dark"] .stats-kpi-badge {
    background: rgba(201, 168, 140, 0.12);
    color: var(--mocha);
    border-color: rgba(201, 168, 140, 0.22);
}

.stats-highlight-card {
    box-shadow: var(--shadow-lg);
}

.stats-chart-card {
    box-shadow: var(--shadow-md);
}

.stats-card-head {
    padding-bottom: 0.85rem;
    margin-bottom: 0.25rem;
    border-bottom: 1px solid var(--border-coffee);
}

.stats-weekly-copy {
    align-self: center;
}

.stats-weekly-divider {
    border-color: rgba(111, 78, 55, 0.12);
}

:root[data-theme="dark"] .stats-weekly-divider {
    border-color: rgba(230, 213, 195, 0.12);
}

@media (max-width: 1023px) {
    .stats-weekly-copy {
        padding-bottom: 1rem;
        border-bottom: 1px solid rgba(111, 78, 55, 0.1);
        border-right: none !important;
        padding-right: 0 !important;
    }
}

:root[data-theme="dark"] .stats-weekly-copy {
    border-bottom-color: rgba(230, 213, 195, 0.1);
}

.stats-nudge {
    background: rgba(230, 213, 195, 0.35);
    border: 1px solid rgba(111, 78, 55, 0.14);
    line-height: 1.55;
}

:root[data-theme="dark"] .stats-nudge {
    background: rgba(74, 64, 56, 0.45);
    border-color: rgba(230, 213, 195, 0.12);
}

.start-hour-persona-badge {
    background: var(--milk-foam);
    border: 1px solid rgba(111, 78, 55, 0.18);
    box-shadow: var(--shadow-sm);
    letter-spacing: 0.08em;
}

:root[data-theme="dark"] .start-hour-persona-badge {
    background: rgba(45, 38, 32, 0.9);
    border-color: rgba(230, 213, 195, 0.15);
}

.start-hour-bars-panel {
    max-width: 42rem;
    margin-left: auto;
    margin-right: auto;
    padding: 0.5rem 0.25rem 0;
}

.stats-focus-logs .stats-logs-head {
    margin-bottom: 0.25rem;
}

#stats-view .session-item {
    box-shadow: var(--shadow-sm);
}

#stats-view .session-item:hover {
    box-shadow: var(--shadow-md);
}

:root[data-theme="dark"] #stats-view .session-item {
    box-shadow: var(--shadow-sm);
}

/* ========================================
   Pill Inputs & Buttons
   ======================================== */
.pill-input {
    width: 100%;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-input);
    border: none;
    background: var(--input-fill);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-main);
    outline: none;
    box-shadow: var(--neo-pressed);
    transition: box-shadow 0.2s;
}

.pill-input:focus {
    box-shadow: var(--neo-track), 0 0 0 2px rgba(111, 78, 55, 0.18);
}

.pill-input::placeholder {
    color: var(--latte);
}

.pill-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 2rem;
    border-radius: var(--radius-full);
    font-weight: 700;
    font-size: 0.8rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.pill-btn:active {
    transform: scale(0.97);
}

.pill-btn-primary {
    background: var(--mocha);
    color: var(--text-inverse);
    box-shadow: 4px 4px 14px rgba(26, 18, 16, 0.28), -2px -2px 10px var(--neo-highlight);
}

.pill-btn-primary:hover {
    background: var(--mocha-hover);
}

.pill-btn-primary:active {
    box-shadow: var(--neo-pressed);
}

.pill-btn-outline {
    background: var(--milk-foam);
    color: var(--mocha);
    border: none;
    box-shadow: var(--shadow-sm);
}

.pill-btn-outline:hover {
    background: var(--surface-recess);
}

.pill-btn-outline:active {
    box-shadow: var(--neo-pressed);
}

/* ========================================
   Timer Ring
   ======================================== */
.timer-ring-container svg {
    transform: rotate(-90deg);
}

.timer-ring-bg {
    stroke: var(--timer-ring-track);
    stroke-opacity: 1;
}

.timer-ring-progress {
    stroke: var(--timer-ring-progress);
    transition: stroke-dashoffset 1s linear;
}

.timer-ring-progress.studying {
    stroke: var(--mocha);
}

/* ========================================
   Presence Dot
   ======================================== */
.presence-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid var(--milk-foam);
    position: absolute;
    bottom: 2px;
    right: 2px;
}

.presence-dot.online {
    background: var(--accent-online);
}

.presence-dot.offline {
    background: var(--latte);
}

.presence-dot.studying {
    background: var(--accent-online);
    animation: pulse-dot-soft 2s ease-in-out infinite;
}

/* ========================================
   Chat Bubbles
   ======================================== */
.chat-bubble {
    max-width: 85%;
    padding: 0.75rem 1.25rem;
    font-size: 0.8125rem;
    font-weight: 500;
    line-height: 1.6;
    border-radius: var(--radius-xl);
    word-break: break-word;
}

.chat-bubble.incoming {
    background: var(--surface-panel);
    color: var(--text-main);
    border-bottom-left-radius: 6px;
    align-self: flex-start;
    box-shadow: var(--shadow-sm);
    border: none;
}

.chat-bubble.outgoing {
    background: var(--mocha);
    color: var(--milk-foam);
    border-bottom-right-radius: 6px;
    align-self: flex-end;
    box-shadow: var(--shadow-sm);
}

.chat-msg--out {
    align-items: flex-end;
}

.chat-msg--in {
    align-items: flex-start;
}

.chat-msg__time {
    font-size: 0.625rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    margin-top: 0.35rem;
    padding: 0 0.35rem;
    text-transform: uppercase;
}

/* ========================================
   Focus page: presence column, timer, chat
   ======================================== */
.focus-app {
    background: var(--bg-page);
}

.presence-column {
    background: var(--surface-panel);
}

@media (min-width: 1024px) {
    .presence-column {
        background: var(--surface-panel);
    }
}

.presence-column__head {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0 0.15rem 0.25rem;
}

.presence-column__icon {
    font-size: 1.35rem;
    color: var(--mocha);
    opacity: 0.9;
    margin-top: 0.1rem;
}

.presence-column__title {
    font-size: 0.625rem;
    font-weight: 800;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--text-main);
}

.presence-column__sub {
    font-size: 0.6875rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-top: 0.15rem;
    letter-spacing: 0.02em;
}

.presence-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1.15rem 1rem 1.25rem;
    border-radius: var(--radius-xl);
    border: none;
    background: var(--milk-foam);
    box-shadow: var(--shadow-md);
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.presence-card:hover {
    box-shadow: var(--shadow-lg);
}

.presence-card--me {
    background: var(--milk-foam);
}

.presence-card--partner {
    position: relative;
    background: var(--milk-foam);
}

.presence-card--waiting {
    opacity: 0.94;
}

.presence-card--waiting .presence-card__avatar--partner {
    opacity: 0.88;
}

.presence-card--linked {
    opacity: 1;
}

.presence-card__avatar-wrap {
    position: relative;
    flex-shrink: 0;
}

.presence-card__avatar {
    width: 5rem;
    height: 5rem;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 800;
    line-height: 1;
}

.presence-card__avatar--self {
    background: var(--milk-foam);
    color: var(--mocha);
    border: 3px solid var(--mocha);
    box-shadow: var(--shadow-sm);
}

.presence-card__avatar--partner {
    background: var(--creamy-latte);
    color: var(--mocha);
    border: 2px solid var(--border-coffee);
    box-shadow: var(--shadow-sm);
}

.presence-card__body {
    text-align: center;
    width: 100%;
    min-width: 0;
}

.presence-card__name {
    font-size: 1rem;
    font-weight: 800;
    color: var(--text-main);
    letter-spacing: -0.02em;
}

.presence-card__name--muted {
    color: var(--text-muted);
}

.presence-card__status {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-top: 0.4rem;
    padding: 0.28rem 0.75rem;
    border-radius: var(--radius-full);
    font-size: 0.5625rem;
    font-weight: 800;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-muted);
    background: var(--surface-panel);
    border: 1px solid var(--border-coffee);
}

.presence-card--me .presence-card__status {
    background: var(--surface-recess);
}

#my-status-pill,
#partner-status-text {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.presence-card__status--plain {
    border: none;
    background: transparent;
    padding-left: 0;
    padding-right: 0;
    letter-spacing: 0.12em;
}

.presence-card__timer {
    font-size: 1.5rem;
    font-weight: 800;
    margin-top: 0.65rem;
    color: var(--espresso);
    letter-spacing: -0.03em;
    line-height: 1.1;
}

.presence-card__timer--muted {
    color: var(--text-muted);
    font-size: 1.35rem;
}

.presence-card__hint {
    font-size: 0.625rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-top: 0.35rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.presence-card__meta {
    font-size: 0.625rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-top: 0.45rem;
}

.presence-card__badge {
    font-size: 0.5625rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--latte);
    margin-top: 0.35rem;
}

.presence-quote {
    margin-top: auto;
    padding: 1rem 1.1rem;
    border-radius: var(--radius-lg);
    border: none;
    background: var(--surface-recess);
    box-shadow: var(--neo-pressed);
}

.presence-quote__text {
    font-size: 0.75rem;
    font-style: italic;
    font-weight: 500;
    line-height: 1.55;
    color: var(--text-muted);
    text-align: center;
}

.focus-stage {
    background: var(--surface-elevated);
}

@media (min-width: 1024px) {
    .focus-stage {
        border-left: 1px solid var(--border-coffee);
        border-right: 1px solid var(--border-coffee);
        margin: 0 -1px;
    }
}

.marketplace-view-root {
    background: var(--bg-page);
    min-height: min(70vh, 28rem);
}

.focus-timer-ring__svg {
    filter: drop-shadow(0 10px 28px rgba(26, 18, 16, 0.12));
}

.focus-subject-chip {
    background: var(--espresso);
    color: var(--text-inverse);
    box-shadow: 3px 3px 12px rgba(26, 18, 16, 0.35), -2px -2px 8px var(--neo-highlight);
}

.focus-subject-input:focus {
    border-color: var(--mocha);
}

.subject-dropdown-panel {
    background: var(--milk-foam);
    border: none;
    box-shadow: var(--shadow-lg);
}

.subject-dropdown-row {
    display: flex;
    align-items: stretch;
    gap: 0;
    border-bottom: 1px solid rgba(111, 78, 55, 0.08);
}

.subject-dropdown-row:last-child {
    border-bottom: none;
}

.subject-dropdown-pick {
    flex: 1;
    min-width: 0;
    text-align: left;
    padding: 0.65rem 0.75rem 0.65rem 1.25rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-main);
    border: none;
    background: transparent;
    cursor: pointer;
    transition: background 0.15s ease;
}

.subject-dropdown-pick:hover {
    background: var(--creamy-latte);
}

.subject-dropdown-remove {
    flex-shrink: 0;
    width: 2.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: var(--latte);
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    transition: background 0.15s ease, color 0.15s ease;
}

.subject-dropdown-remove:hover {
    color: var(--accent-red);
    background: rgba(192, 57, 43, 0.08);
}

.focus-btn-start {
    box-shadow: 5px 5px 14px rgba(61, 43, 31, 0.34), -2px -2px 8px rgba(26, 18, 16, 0.12);
}

.focus-btn-stop {
    min-width: 3.25rem;
}

/* Chat shell */
.chat-shell {
    background: var(--surface-panel);
    box-shadow: -8px 0 24px var(--neo-shadow), 4px 0 16px var(--neo-highlight);
}

.chat-shell__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 1rem 1.15rem;
    flex-shrink: 0;
    border-bottom: 1px solid var(--border-coffee);
    background: var(--surface-elevated);
    box-shadow: 0 4px 12px var(--neo-shadow);
}

.chat-shell__brand {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    min-width: 0;
}

.chat-shell__brand-icon {
    font-size: 1.35rem;
    color: var(--mocha);
}

.chat-shell__title {
    font-size: 0.6875rem;
    font-weight: 800;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--text-main);
}

.chat-shell__subtitle {
    font-size: 0.625rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-top: 0.1rem;
    letter-spacing: 0.03em;
}

.chat-live-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.3rem 0.65rem;
    border-radius: var(--radius-full);
    background: var(--cream);
    border: none;
    box-shadow: var(--neo-pressed);
}

.chat-live-pill__dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--mocha);
    animation: pulse-dot-soft 2.2s ease-in-out infinite;
}

.chat-live-pill__label {
    font-size: 0.5625rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.chat-shell__close {
    color: var(--text-muted);
    border: 1px solid transparent;
    transition: background 0.15s, color 0.15s;
}

.chat-shell__close:hover {
    background: rgba(230, 213, 195, 0.35);
    color: var(--text-main);
}

.chat-shell__messages {
    background: var(--bg-page);
    scrollbar-width: thin;
    scrollbar-color: var(--border-coffee) transparent;
}

.chat-empty-hint {
    text-align: center;
    font-size: 0.8125rem;
    font-weight: 500;
    line-height: 1.55;
    color: var(--text-muted);
    padding: 2.5rem 1.25rem;
    max-width: 16rem;
    margin: 0 auto;
}

.chat-shell__footer {
    flex-shrink: 0;
    padding: 0.85rem 1rem 1rem;
    border-top: 1px solid var(--border-coffee);
    background: var(--surface-elevated);
}

.chat-composer {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.35rem 0.35rem 1rem;
    border-radius: var(--radius-full);
    border: none;
    background: var(--input-fill);
    box-shadow: var(--neo-pressed);
    transition: box-shadow 0.2s;
}

.chat-composer:focus-within {
    box-shadow: var(--neo-track), 0 0 0 2px rgba(111, 78, 55, 0.2);
}

.chat-composer__input {
    flex: 1;
    min-width: 0;
    border: none;
    background: transparent;
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--text-main);
    outline: none;
    padding: 0.5rem 0;
    font-family: inherit;
}

.chat-composer__input::placeholder {
    color: var(--latte);
    font-size: 0.8rem;
}

.chat-composer__send {
    flex-shrink: 0;
    width: 2.5rem;
    height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: var(--radius-full);
    cursor: pointer;
    background: var(--mocha);
    color: var(--text-inverse);
    transition: background 0.2s, transform 0.15s, box-shadow 0.15s;
    box-shadow: 3px 3px 8px rgba(61, 43, 31, 0.32), -1px -2px 6px rgba(26, 18, 16, 0.14);
}

.chat-composer__send:hover {
    background: var(--mocha-hover);
}

.chat-composer__send:active {
    transform: scale(0.96);
    box-shadow: var(--neo-pressed);
}

:root[data-theme="dark"] .chat-composer__send {
    box-shadow: 4px 4px 12px rgba(0, 0, 0, 0.55), -2px -2px 8px rgba(0, 0, 0, 0.35);
}

:root[data-theme="dark"] .presence-quote {
    background: var(--surface-recess);
    box-shadow: var(--neo-pressed);
}

:root[data-theme="dark"] .chat-shell__header {
    background: var(--surface-elevated);
}

:root[data-theme="dark"] .chat-shell__messages {
    background: var(--bg-page);
}

:root[data-theme="dark"] .chat-live-pill {
    background: var(--surface-recess);
    box-shadow: var(--neo-pressed);
}

:root[data-theme="dark"] .focus-stage {
    background: var(--surface-elevated);
}

/* ========================================
   Heatmap
   ======================================== */
.heatmap-cell {
    aspect-ratio: 1;
    border-radius: 3px;
    transition: transform 0.1s ease;
}

.heatmap-cell:hover {
    transform: scale(1.2);
}

.hm-0 {
    background: rgba(94, 56, 38, 0.07);
}

.hm-1 {
    background: rgba(94, 56, 38, 0.2);
}

.hm-2 {
    background: rgba(94, 56, 38, 0.4);
}

.hm-3 {
    background: rgba(94, 56, 38, 0.62);
}

.hm-4 {
    background: rgba(94, 56, 38, 0.88);
}

:root[data-theme="dark"] .hm-0 {
    background: rgba(201, 168, 140, 0.08);
}

:root[data-theme="dark"] .hm-1 {
    background: rgba(201, 168, 140, 0.22);
}

:root[data-theme="dark"] .hm-2 {
    background: rgba(201, 168, 140, 0.42);
}

:root[data-theme="dark"] .hm-3 {
    background: rgba(201, 168, 140, 0.62);
}

:root[data-theme="dark"] .hm-4 {
    background: rgba(201, 168, 140, 0.88);
}

/* ========================================
   Stats: weekly summary + start-hour chart
   ======================================== */
.weekly-summary-card {
    background: var(--surface-elevated);
    border: none;
    box-shadow: var(--shadow-lg);
}

:root[data-theme="dark"] .weekly-summary-card {
    background: var(--surface-elevated);
    box-shadow: var(--shadow-lg);
}

.start-hour-bars-track {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 2px;
}

.start-hour-bars {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 2px;
    min-width: min(100%, 720px);
    height: 140px;
    margin: 0 auto;
}

.start-hour-bar-col {
    flex: 1;
    min-width: 0;
    max-width: 36px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    height: 100%;
}

.start-hour-bar {
    width: 100%;
    min-height: 2px;
    border-radius: 3px 3px 1px 1px;
    background: var(--latte);
    transition: background 0.15s ease, box-shadow 0.15s ease;
}

.start-hour-bar.is-peak {
    background: var(--mocha);
    box-shadow: 0 0 0 1px rgba(111, 78, 55, 0.35);
}

:root[data-theme="dark"] .start-hour-bar {
    background: rgba(201, 168, 140, 0.35);
}

:root[data-theme="dark"] .start-hour-bar.is-peak {
    background: rgba(201, 168, 140, 0.72);
    box-shadow: 0 0 0 1px rgba(201, 168, 140, 0.45);
}

.start-hour-tick {
    font-size: 0.5625rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    line-height: 1.15;
    margin-top: 8px;
    color: var(--text-main);
    opacity: 0.72;
    text-align: center;
    width: 100%;
    white-space: nowrap;
    letter-spacing: 0.02em;
}

@media (min-width: 640px) {
    .start-hour-tick {
        font-size: 0.625rem;
    }
}

@media (min-width: 900px) {
    .start-hour-bar-col {
        max-width: 40px;
    }
}

/* ========================================
   Calendar view
   ======================================== */
.cal-month-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
}

.cal-dow {
    text-align: center;
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    padding: 0.35rem 0;
    color: var(--text-muted);
}

.cal-cell {
    aspect-ratio: 1;
    min-height: 0;
    border-radius: var(--radius-md);
    border: none;
    background: var(--surface-panel);
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 4px 2px;
    transition: background 0.15s, box-shadow 0.15s, transform 0.1s;
}

.cal-cell:hover {
    box-shadow: var(--shadow-md);
}

.cal-cell.other-month {
    opacity: 0.38;
}

.cal-cell.today {
    box-shadow: var(--shadow-sm), 0 0 0 2px var(--mocha);
}

.cal-cell.selected {
    background: var(--creamy-latte);
    box-shadow: var(--shadow-md), 0 0 0 2px var(--espresso);
}

:root[data-theme="dark"] .cal-cell.selected {
    background: var(--creamy-latte);
}

:root[data-theme="dark"] .cal-cell.selected .cal-cell-num {
    color: var(--text-inverse);
}

.cal-cell-num {
    font-size: 11px;
    font-weight: 800;
    color: var(--text-main);
    line-height: 1.2;
}

.cal-cell-dots {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    justify-content: center;
    margin-top: 2px;
    max-width: 100%;
    padding: 0 1px;
}

.cal-dot {
    width: 5px;
    height: 5px;
    border-radius: 9999px;
    flex-shrink: 0;
}

.cal-more {
    font-size: 7px;
    font-weight: 800;
    color: var(--text-muted);
    line-height: 1;
}

.cal-task-color-opt {
    width: 22px;
    height: 22px;
    border-radius: 9999px;
    border: 2px solid transparent;
    cursor: pointer;
    flex-shrink: 0;
}

.cal-task-color-opt.active {
    border-color: var(--espresso);
    box-shadow: 0 0 0 2px var(--milk-foam);
}

.cal-day-panel {
    border-radius: var(--radius-lg);
    border: none;
    background: var(--surface-elevated);
    box-shadow: var(--shadow-md);
    padding: 1rem 1.1rem;
}

.cal-task-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 0.5rem;
    border-radius: var(--radius-sm);
    border: none;
    background: var(--surface-recess);
    margin-bottom: 0.4rem;
    box-shadow: var(--neo-pressed);
}

.cal-task-row.done {
    opacity: 0.65;
}

.cal-task-stripe {
    width: 4px;
    align-self: stretch;
    min-height: 28px;
    border-radius: 2px;
    flex-shrink: 0;
}

/* ========================================
   SVG Chart Colors
   ======================================== */
.chart-mocha {
    stroke: var(--mocha);
}

.chart-latte {
    stroke: var(--latte);
}

.chart-espresso {
    stroke: var(--espresso);
}

.chart-creamy {
    stroke: var(--creamy-latte);
}

/* ========================================
   Nav Pill Toggle  
   ======================================== */
.nav-pill-group {
    --nav-pad: 5px;
    position: relative;
    display: flex;
    align-items: stretch;
    flex-wrap: nowrap;
    width: max-content;
    max-width: 100%;
    background: var(--nav-track-bg);
    padding: var(--nav-pad);
    border-radius: var(--radius-full);
    border: none;
    box-shadow: var(--neo-track);
    gap: 2px;
}

.nav-pill-slider {
    position: absolute;
    left: 0;
    top: 0;
    width: 0;
    height: 0;
    border-radius: var(--radius-full);
    background: var(--mocha);
    box-shadow: 3px 3px 12px rgba(26, 18, 16, 0.28), -1px -1px 8px var(--neo-highlight);
    z-index: 0;
    pointer-events: none;
    transition:
        left 0.38s cubic-bezier(0.22, 1, 0.32, 1),
        top 0.38s cubic-bezier(0.22, 1, 0.32, 1),
        width 0.38s cubic-bezier(0.22, 1, 0.32, 1),
        height 0.38s cubic-bezier(0.22, 1, 0.32, 1);
}

:root[data-theme="dark"] .nav-pill-slider {
    box-shadow: 3px 3px 12px rgba(0, 0, 0, 0.5), -1px -1px 5px rgba(0, 0, 0, 0.35);
}

.nav-pill {
    position: relative;
    z-index: 1;
    flex: 0 0 auto;
    white-space: nowrap;
    padding: 0.5rem 1rem;
    font-size: 0.72rem;
    font-weight: 700;
    border-radius: var(--radius-full);
    cursor: pointer;
    color: var(--text-main);
    border: none;
    background: transparent;
    transition: color 0.25s ease;
}

.nav-pill.active {
    color: var(--nav-pill-active-fg);
    background: transparent;
    box-shadow: none;
}

.nav-pill:not(.active) {
    color: rgba(26, 18, 16, 0.48);
}

:root[data-theme="dark"] .nav-pill:not(.active) {
    color: rgba(245, 240, 234, 0.42);
}

.nav-pill:hover:not(.active) {
    color: var(--text-main);
}

:root[data-theme="dark"] .nav-pill:hover:not(.active) {
    color: var(--text-main);
}

/* ========================================
   Stats Tab Toggle
   ======================================== */
.stats-toggle {
    display: flex;
    background: var(--nav-track-bg);
    padding: 4px;
    border-radius: var(--radius-full);
    border: none;
    box-shadow: var(--neo-track);
}

.stats-toggle label {
    flex: 1;
    text-align: center;
    padding: 0.5rem 1.25rem;
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    border-radius: var(--radius-full);
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.2s;
}

.stats-toggle label:has(input:checked) {
    background: var(--surface-elevated);
    color: var(--text-main);
    box-shadow: var(--shadow-sm);
}

.stats-toggle input {
    display: none;
}

/* ========================================
   Session Log Item
   ======================================== */
.session-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    background: var(--milk-foam);
    border: none;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s;
}

.session-item:hover {
    box-shadow: var(--shadow-md);
}

/* ========================================
   Auth Card
   ======================================== */
.auth-card {
    background: var(--milk-foam);
    border: none;
    border-radius: var(--radius-2xl);
    box-shadow: var(--shadow-xl);
    padding: 2.5rem;
    max-width: 420px;
    width: 100%;
}

.auth-input {
    width: 100%;
    padding: 0.875rem 1.25rem;
    border: none;
    border-radius: var(--radius-input);
    background: var(--input-fill);
    font-size: 0.875rem;
    color: var(--text-main);
    outline: none;
    box-shadow: var(--neo-pressed);
    transition: box-shadow 0.2s;
}

.auth-input:focus {
    box-shadow: var(--neo-track), 0 0 0 2px rgba(111, 78, 55, 0.18);
}

.auth-input::placeholder {
    color: var(--latte);
}

/* ========================================
   Footer Progress Bar (Dashboard)
   ======================================== */
.goal-bar-track {
    width: 100%;
    height: 10px;
    background: var(--surface-recess);
    border-radius: var(--radius-full);
    overflow: hidden;
    border: none;
    box-shadow: var(--neo-pressed);
}

.goal-bar-fill {
    height: 100%;
    background: var(--mocha);
    border-radius: var(--radius-full);
    transition: width 1s ease;
    position: relative;
    box-shadow: 2px 0 6px rgba(61, 43, 31, 0.15);
}

/* Dashboard footer: desktop = in flow; mobile = fixed above bottom nav */
@media (min-width: 769px) {
    .dashboard-footer-progress {
        position: relative;
    }
}

/* ========================================
   Responsive Helpers
   ======================================== */
@media (max-width: 768px) {
    .hide-mobile {
        display: none !important;
    }
}

@media (min-width: 769px) {
    .hide-desktop {
        display: none !important;
    }
}

/* ========================================
   TABLET (769px – 1024px)
   ======================================== */
@media (min-width: 769px) and (max-width: 1024px) {
    #app-header.app-header {
        padding-left: 1.25rem;
        padding-right: 1.25rem;
        column-gap: 0.5rem;
    }

    .nav-pill {
        padding: 0.45rem 1rem;
        font-size: 0.72rem;
    }

    #dashboard-view > aside:first-child {
        width: 15.5rem !important;
        min-width: 13rem;
        padding: 1rem !important;
    }

    #dashboard-view > aside:first-child .presence-card__avatar {
        width: 52px !important;
        height: 52px !important;
        font-size: 1.1rem !important;
    }

    #dashboard-view > section {
        padding: 1.5rem 1rem !important;
    }

    #dashboard-view > section .focus-timer-ring__svg {
        width: clamp(220px, 42vw, 260px) !important;
        height: clamp(220px, 42vw, 260px) !important;
    }

    #timer-display {
        font-size: clamp(2.5rem, 7vw, 3.5rem) !important;
    }

    #chat-panel {
        width: 15rem !important;
        min-width: 12rem;
    }

    #stats-view,
    #calendar-view {
        padding: 1.5rem 1.25rem !important;
    }

    #calendar-view .grid.grid-cols-1.xl\:grid-cols-3 {
        gap: 1.25rem;
    }

    .cal-cell {
        min-height: 44px;
    }

    #cal-grid {
        grid-auto-rows: minmax(44px, 1fr) !important;
    }

    .session-item {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .session-item .text-right {
        width: 100%;
        text-align: left !important;
        padding-left: 3.25rem;
    }
}

/* ========================================
   MOBILE RESPONSIVE OVERHAUL
   ======================================== */

/* ---- Mobile: Global ---- */
@media (max-width: 768px) {
    body {
        overflow: hidden;
    }

    /* Header: tighter on mobile */
    #app-header.app-header {
        padding: 0.6rem 1rem;
    }

    #app-header.app-header h1 {
        font-size: 0.95rem;
    }

    /* Progress strip above bottom nav */
    .dashboard-footer-progress {
        position: fixed;
        left: 0;
        right: 0;
        bottom: calc(52px + env(safe-area-inset-bottom, 0px));
        padding: 0.45rem 1rem !important;
        box-shadow: 0 -4px 16px rgba(26, 18, 16, 0.14), 0 2px 6px rgba(26, 18, 16, 0.08);
    }

    :root[data-theme="dark"] .dashboard-footer-progress {
        box-shadow: 0 -4px 18px rgba(0, 0, 0, 0.5), 0 2px 6px rgba(0, 0, 0, 0.35);
    }

    .dashboard-footer-progress .goal-bar-track {
        height: 8px;
    }

    /* Main: room for bottom nav + progress footer */
    #app-shell > main {
        padding-bottom: calc(118px + env(safe-area-inset-bottom, 0px));
    }

    /* ---- Dashboard View: Mobile ---- */
    #dashboard-view {
        flex-direction: column !important;
        height: auto !important;
        min-height: 100%;
    }

    /* Sidebar: Compact horizontal presence on mobile */
    #dashboard-view > aside:first-child {
        width: 100% !important;
        padding: 0.75rem 1rem !important;
        flex-direction: row !important;
        gap: 0.75rem !important;
        border-right: none !important;
        border-bottom: 1.5px solid var(--border-coffee);
        overflow-x: auto;
        overflow-y: hidden;
        flex-shrink: 0 !important;
    }

    #dashboard-view > aside:first-child > .presence-column__head {
        display: none !important;
    }

    /* Presence cards: horizontal compact */
    #dashboard-view > aside:first-child > article.presence-card {
        flex-direction: row !important;
        align-items: center !important;
        padding: 0.55rem 0.75rem !important;
        gap: 0.65rem !important;
        min-width: 0;
        flex: 1;
        border-radius: var(--radius-lg) !important;
    }

    #dashboard-view > aside:first-child .presence-card__avatar-wrap {
        flex-shrink: 0;
    }

    #dashboard-view > aside:first-child .presence-card__avatar {
        width: 40px !important;
        height: 40px !important;
        font-size: 1rem !important;
    }

    #dashboard-view > aside:first-child .presence-card .presence-dot {
        width: 8px;
        height: 8px;
        bottom: 0;
        right: 0;
    }

    #dashboard-view > aside:first-child .presence-card__body {
        text-align: left !important;
        min-width: 0;
        flex: 1;
    }

    #dashboard-view > aside:first-child .presence-card__name {
        font-size: 0.8rem !important;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        margin-top: 0 !important;
    }

    /* Status pill: inline */
    #my-status-pill,
    #partner-status-text {
        font-size: 8px !important;
        padding: 1px 8px !important;
        margin-top: 2px !important;
    }

    /* Timer text in card: smaller */
    #my-card-timer,
    #partner-card-timer {
        font-size: 1rem !important;
        margin-top: 2px !important;
    }

    #partner-card-today {
        font-size: 9px !important;
        margin-top: 4px !important;
    }

    #partner-tab-status {
        font-size: 7px !important;
        margin-top: 2px !important;
    }

    /* ---- Timer Section: Mobile ---- */
    #dashboard-view > section.focus-stage {
        padding: 1.5rem 1rem !important;
        border: none !important;
        margin: 0 !important;
        flex: 1;
        justify-content: flex-start !important;
        padding-top: 1rem !important;
    }

    #dashboard-view > section .focus-stage__inner {
        gap: 1.25rem !important;
    }

    /* Timer ring: scale down */
    #dashboard-view > section .focus-timer-ring__svg {
        width: 200px !important;
        height: 200px !important;
    }

    #timer-display {
        font-size: 2.75rem !important;
    }

    #timer-subject-badge {
        font-size: 8px !important;
        padding: 0.25rem 0.85rem !important;
        margin-top: 0.35rem !important;
    }

    /* Subject input */
    #subject-input-wrapper {
        max-width: 100% !important;
    }

    .pill-input {
        padding: 0.65rem 1rem 0.65rem 2.75rem !important;
        font-size: 0.8rem !important;
    }

    .pill-btn {
        padding: 0.65rem 1.25rem !important;
        font-size: 0.7rem !important;
    }

    /* ---- Chat Panel: Mobile ---- */
    #chat-panel {
        border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    }

    /* ---- Stats / Calendar: Mobile ---- */
    #stats-view,
    #calendar-view {
        padding: 1.25rem 1rem !important;
        padding-bottom: 80px !important;
    }

    #stats-view > div {
        gap: 1.25rem !important;
    }

    /* Stats header */
    #stats-view h1 {
        font-size: 1.5rem !important;
        margin-bottom: 0.25rem !important;
    }

    /* Stats toggle */
    .stats-toggle {
        max-width: 100% !important;
    }

    .stats-toggle label {
        padding: 0.4rem 0.75rem;
        font-size: 0.65rem;
    }

    /* KPI Cards: stack single column */
    #stats-view .grid.grid-cols-1.md\:grid-cols-2.xl\:grid-cols-4 {
        grid-template-columns: 1fr !important;
        gap: 0.75rem !important;
    }

    /* KPI compact on mobile */
    .card-elevated {
        border-radius: var(--radius-lg) !important;
    }

    #stats-view .card-elevated {
        padding: 1rem 1.25rem !important;
    }

    #stats-view .card-elevated .text-4xl {
        font-size: 1.75rem !important;
    }

    /* Charts grid: single column */
    #stats-view .grid.grid-cols-1.lg\:grid-cols-2 {
        grid-template-columns: 1fr !important;
        gap: 0.75rem !important;
    }

    /* Subject chart: stack on mobile */
    #subject-chart-content {
        flex-direction: column !important;
        gap: 1.25rem !important;
    }

    #subject-chart-content .relative {
        width: 120px !important;
        height: 120px !important;
    }

    /* Heatmap: smaller cells */
    #heatmap-grid {
        gap: 3px !important;
    }

    .start-hour-bars {
        height: 120px;
        min-width: 100%;
    }

    #weekly-summary-card .stats-week-metric-value {
        font-size: 1.2rem !important;
    }

    /* Focus logs: tighter */
    .session-item {
        padding: 0.75rem 1rem;
        flex-wrap: wrap;
        gap: 0.35rem;
    }

    .session-item > div:first-child {
        min-width: 0;
        flex: 1;
    }

    .session-item .text-right {
        width: 100%;
        text-align: left !important;
        padding-left: 3rem;
    }

    .session-item .w-11 {
        width: 2rem !important;
        height: 2rem !important;
    }

    .session-item .w-11 .material-symbols-outlined {
        font-size: 1rem;
    }

    .session-item .font-bold.text-sm {
        font-size: 0.8rem !important;
    }

    /* Focus logs bottom padding */
    #stats-view .flex.flex-col.gap-4.pb-24 {
        padding-bottom: 2rem !important;
    }

    /* ---- Mobile Bottom Nav ---- */
    #app-shell > nav.hide-desktop {
        padding: 0.5rem 1rem calc(0.5rem + env(safe-area-inset-bottom, 0px));
        gap: 0;
    }

    .mob-nav-btn {
        padding: 0.25rem 0.5rem;
    }

    .mob-nav-btn .material-symbols-outlined {
        font-size: 1.25rem;
    }

    .mob-nav-btn .text-\[9px\] {
        font-size: 8px;
    }

    /* Chat FAB */
    #mob-chat-btn {
        width: 44px !important;
        height: 44px !important;
        margin-top: -1.25rem !important;
    }

    /* ---- Todo Widget: Mobile ---- */
    #todo-widget {
        width: 240px;
        bottom: 70px;
        left: 10px;
        font-size: 0.75rem;
    }

    /* ---- Settings Modal: Mobile ---- */
    .settings-card {
        padding: 1.5rem !important;
        max-width: calc(100% - 1.5rem) !important;
        max-height: calc(100vh - 2rem) !important;
        border-radius: var(--radius-xl) !important;
    }

    .settings-card h2 {
        font-size: 1.1rem !important;
    }

    .settings-section {
        padding: 0.85rem !important;
    }

    .settings-input {
        padding: 0.6rem 0.85rem !important;
        font-size: 0.8rem !important;
    }

    .settings-stepper-btn {
        width: 32px !important;
        height: 32px !important;
    }

    #settings-goal-value {
        font-size: 1.75rem !important;
    }

    .settings-action-btn {
        padding: 0.7rem 1rem !important;
        font-size: 0.8rem !important;
    }

    /* Auth card mobile */
    .auth-card {
        padding: 1.75rem;
        max-width: calc(100% - 2rem);
    }

    /* Delete confirmation modal */
    #delete-confirm-modal > div:last-child {
        max-width: calc(100% - 1.5rem) !important;
        padding: 1.5rem !important;
    }
}

/* ---- Small phones (< 380px) ---- */
@media (max-width: 380px) {
    #dashboard-view > section .focus-timer-ring__svg {
        width: 170px !important;
        height: 170px !important;
    }

    #timer-display {
        font-size: 2.25rem !important;
    }

    #my-card-timer,
    #partner-card-timer {
        font-size: 0.85rem !important;
    }

    #dashboard-view > aside:first-child .presence-card__avatar {
        width: 34px !important;
        height: 34px !important;
        font-size: 0.85rem !important;
    }

    #stats-view h1 {
        font-size: 1.25rem !important;
    }

    #stats-view .card-elevated .text-4xl,
    #stats-view .card-elevated .text-4xl {
        font-size: 1.5rem !important;
    }
}

/* ---- Tablet (769px - 1024px) ---- */
@media (min-width: 769px) and (max-width: 1024px) {
    /* Tighter sidebar */
    #dashboard-view > aside:first-child {
        width: 220px !important;
        padding: 1rem !important;
    }

    /* Smaller avatars */
    #dashboard-view > aside:first-child .presence-card__avatar {
        width: 56px !important;
        height: 56px !important;
        font-size: 1.25rem !important;
    }

    /* Chat panel */
    #chat-panel {
        width: 260px !important;
    }

    /* Timer */
    #dashboard-view > section .focus-timer-ring__svg {
        width: 240px !important;
        height: 240px !important;
    }

    #timer-display {
        font-size: 3.5rem !important;
    }

    /* Stats KPI */
    #stats-view {
        padding: 1.5rem 2rem !important;
    }
}

/* ========================================
   Draggable To-Do Widget
   ======================================== */
#todo-widget {
    position: fixed;
    bottom: 80px;
    left: 20px;
    width: 280px;
    background: var(--milk-foam);
    border: none;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    z-index: 100;
    overflow: hidden;
    font-family: 'Plus Jakarta Sans', sans-serif;
    animation: fadeInUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.todo-drag-handle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: var(--surface-panel);
    border-bottom: 1px solid var(--border-coffee);
    cursor: grab;
    user-select: none;
    box-shadow: 0 4px 10px var(--neo-shadow);
}

.todo-drag-handle:active {
    cursor: grabbing;
}

#todo-body {
    padding: 0.75rem 1rem 1rem;
    max-height: 300px;
    overflow-y: auto;
}

#todo-list {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.todo-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.35rem;
    padding: 0.5rem 0.5rem 0.5rem 0.25rem;
    border-radius: var(--radius-sm);
    transition: background 0.15s;
}

.todo-color-stripe {
    width: 3px;
    align-self: stretch;
    min-height: 22px;
    border-radius: 2px;
    flex-shrink: 0;
}

.todo-item:hover {
    background: rgba(230, 213, 195, 0.2);
}

.todo-item.done .todo-text {
    text-decoration: line-through;
    color: var(--text-muted);
    opacity: 0.6;
}

.todo-checkbox {
    appearance: none;
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    flex-shrink: 0;
    position: relative;
    transition: all 0.2s;
    box-shadow: var(--neo-pressed);
    background: var(--input-fill);
}

.todo-checkbox:checked {
    background: var(--mocha);
    box-shadow: 2px 2px 6px rgba(61, 43, 31, 0.3), -1px -1px 4px rgba(26, 18, 16, 0.18);
}

.todo-checkbox:checked::after {
    content: '';
    position: absolute;
    left: 4px;
    top: 1px;
    width: 5px;
    height: 8px;
    border: solid var(--milk-foam);
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.todo-text {
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: all 0.2s;
}

.todo-delete {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--latte);
    opacity: 0;
    transition: all 0.15s;
    flex-shrink: 0;
    padding: 2px;
    border-radius: 4px;
}

.todo-item:hover .todo-delete,
.cal-task-row:hover .todo-delete {
    opacity: 1;
}

.todo-delete:hover {
    color: var(--accent-red);
    background: rgba(192, 57, 43, 0.08);
}

.todo-input {
    flex: 1;
    padding: 0.45rem 0.65rem;
    border: none;
    border-radius: var(--radius-input);
    font-size: 0.65rem;
    font-weight: 500;
    color: var(--text-main);
    background: var(--input-fill);
    outline: none;
    transition: box-shadow 0.2s;
    box-shadow: var(--neo-pressed);
}

.todo-input:focus {
    box-shadow: var(--neo-track), 0 0 0 2px rgba(111, 78, 55, 0.18);
}

.todo-input::placeholder {
    color: var(--latte);
    font-size: 0.78rem;
}

.todo-add-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    background: var(--mocha);
    color: var(--milk-foam);
    transition: background 0.2s, box-shadow 0.15s;
    flex-shrink: 0;
    box-shadow: 3px 3px 8px rgba(61, 43, 31, 0.32), -1px -2px 5px rgba(26, 18, 16, 0.12);
}

.todo-add-btn:hover {
    background: var(--mocha-hover);
}

/* ========================================
   Settings Modal
   ======================================== */
.settings-card {
    background: var(--milk-foam);
    border: none;
    border-radius: var(--radius-2xl);
    box-shadow: var(--shadow-xl);
    padding: 2.5rem;
    max-width: 480px;
    width: calc(100% - 2rem);
    max-height: calc(100vh - 4rem);
    overflow-y: auto;
    font-family: 'Plus Jakarta Sans', sans-serif;
}

.settings-section {
    padding: 1.25rem;
    border-radius: var(--radius-xl);
    background: var(--surface-panel);
    border: none;
    box-shadow: var(--neo-pressed);
}

.settings-section-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-coffee);
}

.settings-label {
    display: block;
    font-size: 0.6rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.settings-input {
    width: 100%;
    padding: 0.7rem 1rem;
    border: none;
    border-radius: var(--radius-input);
    background: var(--input-fill);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-main);
    outline: none;
    transition: box-shadow 0.2s;
    font-family: 'Plus Jakarta Sans', sans-serif;
    box-shadow: var(--neo-pressed);
}

.settings-input:focus {
    box-shadow: var(--neo-track), 0 0 0 2px rgba(111, 78, 55, 0.18);
}

.settings-input::placeholder {
    color: var(--latte);
    font-weight: 500;
}

.settings-save-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.6rem 0.9rem;
    border-radius: var(--radius-md);
    border: none;
    background: var(--mocha);
    color: var(--text-inverse);
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
    box-shadow: 3px 3px 12px rgba(26, 18, 16, 0.26), -2px -2px 8px var(--neo-highlight);
}

.settings-save-btn:hover {
    background: var(--mocha-hover);
}

.settings-save-btn:active {
    transform: scale(0.95);
}

.settings-save-btn.saved {
    background: var(--accent-green);
}

.settings-stepper-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    border: none;
    background: var(--milk-foam);
    color: var(--mocha);
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: var(--shadow-sm);
}

.settings-stepper-btn:hover {
    background: var(--creamy-latte);
}

.settings-stepper-btn:active {
    transform: scale(0.92);
    box-shadow: var(--neo-pressed);
}

.settings-action-btn {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.85rem 1.25rem;
    border-radius: var(--radius-lg);
    border: none;
    background: var(--milk-foam);
    color: var(--text-main);
    font-size: 0.85rem;
    font-weight: 700;
    font-family: 'Plus Jakarta Sans', sans-serif;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: var(--shadow-sm);
}

.settings-action-btn:hover {
    background: var(--creamy-latte);
}

.settings-action-btn:active {
    transform: scale(0.98);
}

.settings-danger-btn {
    color: var(--accent-red);
}

.settings-appearance-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.settings-dark-switch {
    position: relative;
    flex-shrink: 0;
    width: 2.75rem;
    height: 1.5rem;
    cursor: pointer;
    margin-top: 0.15rem;
}

.settings-dark-input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    margin: 0;
    pointer-events: none;
}

.settings-dark-track {
    display: block;
    width: 2.75rem;
    height: 1.5rem;
    border-radius: var(--radius-full);
    background: var(--cream);
    box-shadow: var(--neo-pressed);
    transition: background 0.2s, box-shadow 0.2s;
    position: relative;
}

.settings-dark-track::after {
    content: '';
    position: absolute;
    width: 1.1rem;
    height: 1.1rem;
    border-radius: 50%;
    background: var(--milk-foam);
    top: 2px;
    left: 2px;
    transition: transform 0.2s ease;
    box-shadow: var(--shadow-sm);
}

.settings-dark-input:checked + .settings-dark-track {
    background: var(--mocha);
    box-shadow: var(--shadow-sm);
}

.settings-dark-input:checked + .settings-dark-track::after {
    transform: translateX(1.2rem);
}

.settings-dark-input:focus-visible + .settings-dark-track {
    box-shadow: var(--neo-track), 0 0 0 2px rgba(111, 78, 55, 0.25);
}

.settings-goal-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
}

.settings-goal-steppers {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1 1 auto;
    min-width: 0;
}

.settings-goal-save {
    flex: 0 1 auto;
    margin-left: auto;
}

@media (max-width: 440px) {
    .settings-goal-save {
        flex: 1 1 100%;
        margin-left: 0;
        justify-content: center;
    }
}

.settings-danger-btn:hover {
    background: rgba(192, 57, 43, 0.06);
    border-color: var(--accent-red);
}