/* Shared user-panel shell. Loaded after page styles and preferences. */
:root {
    --panel-topbar-height: 78px;
    --panel-gutter: 24px;
    --panel-mobile-gutter: 12px;
    --header-height: var(--panel-topbar-height);
}

body { color: var(--text-body); background: var(--color-bg); font-size: var(--font-size-md); }
:is(.dashboard-main,.schedule-main,.tasks-page,.habits-page,.projects-page,.categories-page,.settings-page,.notes-page) {
    min-width: 0;
    background: var(--color-bg);
    color: var(--text-body);
}
.panel-topbar {
    box-sizing: border-box;
    position: sticky;
    inset-block-start: 0;
    z-index: 80;
    width: 100%;
    height: var(--panel-topbar-height);
    min-height: var(--panel-topbar-height);
    padding: 10px var(--panel-gutter);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    border-bottom: 1px solid var(--color-border);
    background: color-mix(in srgb,var(--color-bg) 96%,transparent);
    backdrop-filter: blur(10px);
    color: var(--text-body);
}
.panel-topbar :is(h1,.dashboard-title,.tasks-topbar__heading h1,.schedule-header__identity h1) {
    color: var(--text-heading);
}
.panel-topbar__identity,.panel-topbar__actions { min-width: 0; display: flex; align-items: center; gap: 12px; }
.panel-topbar__identity > div { min-width: 0; display: flex; flex-direction: column; line-height: 1.5; }
.panel-topbar__identity h1 { margin: 0; font-size: var(--type-16); font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.panel-topbar__identity > div > span { color: var(--text-muted); font-size: var(--type-10); }
.panel-topbar__icon { width: 42px; height: 42px; flex: 0 0 42px; display: grid; place-items: center; border-radius: 11px; color: var(--color-primary); background: var(--color-primary-light); }
.panel-topbar__icon svg,.projects-topbar__icon svg,.schedule-header__icon svg { width: 21px; height: 21px; }
.panel-topbar .notification.icon-button { position: relative; width: 42px; height: 42px; min-width: 42px; min-height: 42px; flex: 0 0 42px; display: grid; place-items: center; padding: 0; border: 1px solid var(--color-border); border-radius: 11px; background: var(--color-surface); color: var(--color-primary); }
.panel-topbar .notification.icon-button svg { width: 22px; height: 22px; }
.panel-topbar .mobile-menu { display: none; }
.panel-topbar .mobile-menu svg { width: 20px; height: 20px; }
.categories-page,.settings-page { box-sizing: border-box; padding: 0 var(--panel-gutter) 90px; }
.categories-header.panel-topbar,.settings-header.panel-topbar { max-width: none; margin: 0 calc(-1 * var(--panel-gutter)) 24px; width: calc(100% + 2 * var(--panel-gutter)); }
.categories-header.panel-topbar > .panel-topbar__identity > div > span,.settings-header.panel-topbar > .panel-topbar__identity > div > span { color: var(--text-muted); font-size: var(--type-10); font-weight: 400; }
.categories-header.panel-topbar h1,.settings-header.panel-topbar h1 { margin: 0; font-size: var(--type-16); }
.categories-header.panel-topbar .panel-topbar__actions { gap: 12px; }
.projects-header.projects-topbar.panel-topbar,.tasks-topbar.panel-topbar,.habits-topbar.panel-topbar,.topbar.panel-topbar,.schedule-header.panel-topbar { height: var(--panel-topbar-height); min-height: var(--panel-topbar-height); padding: 10px var(--panel-gutter); background: color-mix(in srgb,var(--color-bg) 96%,transparent); border-bottom-color: var(--color-border); }
.habits-topbar.panel-topbar { margin-inline: calc(-1 * var(--panel-gutter)); width: calc(100% + 2 * var(--panel-gutter)); }
.projects-topbar__icon { font-size: 0; background: var(--color-primary-light); }
.schedule-header__icon { width: 42px; height: 42px; border-radius: 11px; }
.dashboard-main .board { padding-inline: var(--panel-gutter); }
.schedule-content { padding-inline: var(--panel-gutter); }
.habits-page { padding-inline: var(--panel-gutter); }
.projects-content { padding-inline: var(--panel-gutter); }
.task-stats { padding-inline: var(--panel-gutter); }
.tasks-toolbar,.tasks-list { padding-inline: var(--panel-gutter); }

/* The dashboard date control is the size and color reference on all three pages. */
.panel-date-topbar :is(.toolbar-right,.schedule-toolbar) { min-width: 0; }
.panel-date-topbar :is(.date-navigation,.schedule-toolbar .date-navigation) { height: 40px; border: 1px solid var(--color-border); border-radius: 10px; background: var(--color-surface); }
.panel-date-topbar .date-nav-button { width: 38px; height: 38px; flex: 0 0 38px; color: var(--text-body); background: transparent; }
.panel-date-topbar .date-nav-button svg { width: 17px; height: 17px; }
.panel-date-topbar .current-date { min-width: 215px; height: 38px; padding-inline: 10px; border-inline: 1px solid var(--color-border-light); color: var(--text-heading); background: transparent; }
.panel-date-topbar .current-date strong { font-size: var(--type-10); color: var(--text-heading); }
.panel-date-topbar .today-button { min-height: 38px; color: var(--color-primary); background: var(--color-primary-light); font-size: var(--type-10); }
.panel-date-topbar .schedule-date-picker { width: min(336px,calc(100vw - 20px)); max-height: calc(100dvh - 95px); overflow-y: auto; border-color: var(--color-border); background: var(--color-surface); color: var(--text-body); }
.panel-date-topbar :is(.schedule-date-picker__title,.calendar-year-title) { color: var(--text-heading); font-size: var(--type-11); }
.panel-date-topbar :is(.calendar-weekdays,.calendar-day,.calendar-month) { font-size: var(--type-10); }
.panel-date-topbar .schedule-date-picker { padding: 16px 16px 18px; border-radius: 20px; box-shadow: 0 18px 45px rgba(28,36,74,.12),0 3px 10px rgba(28,36,74,.05); }
.panel-date-topbar :is(.schedule-date-picker__header,.calendar-year-navigation) { min-height: 42px; display: grid; grid-template-columns: 38px minmax(0,1fr) 38px; align-items: center; gap: 8px; }
.panel-date-topbar .schedule-date-picker__title { min-height: 36px; padding: 5px 10px; border: 0; border-radius: 8px; background: transparent; font-weight: 800; }
.panel-date-topbar :is(.calendar-nav-button,.calendar-year-button) { width: 38px; height: 38px; padding: 0; display: grid; place-items: center; border: 0; border-radius: 9px; background: var(--color-surface-soft); color: var(--text-body); }
.panel-date-topbar :is(.calendar-nav-button,.calendar-year-button) svg { width: 15px; height: 15px; }
.panel-date-topbar .calendar-year-navigation { direction: ltr; }
.panel-date-topbar .calendar-year-title { direction: rtl; text-align: center; font-weight: 850; }
.panel-date-topbar .calendar-months { margin-top: 18px; display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 10px; }
.panel-date-topbar .calendar-month { min-width: 0; height: 46px; padding: 0 7px; display: grid; place-items: center; border: 1px solid var(--color-border-light); border-radius: 10px; background: var(--color-surface-soft); color: var(--text-body); font-weight: 700; }
.panel-date-topbar .calendar-month.is-selected { border-color: transparent; background: linear-gradient(135deg,var(--color-primary),var(--color-secondary,#6b63ff)); color: var(--on-accent); }
.panel-date-topbar .calendar-weekdays { margin: 14px 0 7px; }
.panel-date-topbar .calendar-weekdays span { height: 28px; display: grid; place-items: center; color: var(--text-heading); font-weight: 800; }
.panel-date-topbar .calendar-days { row-gap: 3px; }
.panel-date-topbar :is(.calendar-day,.calendar-day-empty) { width: 34px; height: 34px; justify-self: center; }
.panel-date-topbar .calendar-day { display: grid; place-items: center; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--text-body); font-weight: 600; }
.panel-date-topbar .calendar-day.is-selected { background: linear-gradient(135deg,var(--color-primary),var(--color-secondary,#6b63ff)); color: var(--on-accent); box-shadow: 0 5px 12px rgba(91,82,238,.22); }
.panel-date-topbar .calendar-day.is-today:not(.is-selected) { color: var(--color-primary); font-weight: 900; box-shadow: none; }
.panel-date-topbar :is(.calendar-today,.calendar-month-cancel) { width: 100%; height: 42px; margin-top: 15px; border: 0; border-radius: 10px; background: var(--color-primary-light); color: var(--color-primary); font-weight: 800; }

/* One theme and typography source for every surface, including the dashboard. */
:is(.dashboard-main,.schedule-main,.tasks-page,.habits-page,.projects-page,.categories-page,.settings-page,.notes-page) :is(.card,.project-card,.category-card,.settings-card,.habit-card,.task-card) { background-color: var(--color-surface); border-color: var(--color-border); }
.dashboard-main .card { color: var(--text-body); }
.dashboard-main :is(.topbar,.card,.schedule-date-picker) { color: var(--text-body); }
.dashboard-main :is(.card h2,.card h3,.card strong) { color: var(--text-heading); }
.schedule-main { --schedule-bg: var(--color-bg); --schedule-card: var(--color-surface); --schedule-text: var(--text-body); --schedule-border: var(--color-border); }
.sidebar .nav-item__icon svg,.mobile-bottom-nav svg,.mobile-create-sheet__actions svg,.sidebar-user__more svg { width: 21px; height: 21px; display: block; flex: 0 0 auto; }
.mobile-create-sheet__actions svg { width: 20px; height: 20px; }

.panel-theme-switch { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 12px; cursor: pointer; font-size: var(--type-11); }
.panel-theme-switch input { position: absolute; width: 42px; height: 24px; inset-inline-end: 0; opacity: 0; cursor: pointer; }
.panel-theme-switch__slider { position: relative; display: block; width: 42px; height: 24px; flex: 0 0 42px; border-radius: 99px; background: var(--color-border); transition: background .2s ease; }
.panel-theme-switch__slider::after { content: ''; position: absolute; inset-block-start: 3px; inset-inline-start: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--color-surface); box-shadow: 0 1px 4px rgba(0,0,0,.2); transition: transform .2s ease; }
.panel-theme-switch input:checked + .panel-theme-switch__slider { background: var(--color-primary); }
.panel-theme-switch input:checked + .panel-theme-switch__slider::after { transform: translateX(-18px); }
.panel-theme-switch input:focus-visible + .panel-theme-switch__slider { outline: 3px solid var(--color-primary); outline-offset: 3px; }
.panel-theme-switch input:disabled + .panel-theme-switch__slider { opacity: .6; cursor: wait; }
.sidebar-theme-switch { margin-bottom: 12px; padding: 4px 8px; color: var(--sidebar-text); }
.settings-theme-footer { max-width: 900px; margin: 20px auto 0; padding: 17px 20px; border: 1px solid var(--color-border); border-radius: 14px; background: var(--color-surface); }
.settings-theme-footer__hint { display: block; margin-top: 6px; color: var(--text-muted); font-size: var(--type-9); }

@media (max-width: 1100px) {
    :root { --panel-gutter: 18px; }
}
@media (max-width: 900px) {
    .panel-topbar .mobile-menu { width: 40px; height: 40px; min-width: 40px; min-height: 40px; display: grid; place-items: center; padding: 0; border: 1px solid var(--color-border); border-radius: 10px; background: var(--color-surface); color: var(--text-body); }
}
@media (max-width: 768px) {
    :root { --panel-topbar-height: 58px; --panel-gutter: var(--panel-mobile-gutter); }
    .panel-topbar,.projects-header.projects-topbar.panel-topbar,.tasks-topbar.panel-topbar,.habits-topbar.panel-topbar,.topbar.panel-topbar,.schedule-header.panel-topbar { height: 58px; min-height: 58px; padding: 8px var(--panel-gutter); }
    .panel-topbar__icon { display: none; }
    .panel-topbar__identity h1 { font-size: var(--type-12); }
    .panel-topbar__identity > div > span { display: none; }
    .categories-header.panel-topbar,.settings-header.panel-topbar { margin-bottom: 16px; }
    .categories-header.panel-topbar .category-primary-button { width: 38px; height: 38px; flex: 0 0 38px; justify-content: center; padding: 0; font-size: 0; box-shadow: none; }
    .categories-header.panel-topbar .category-primary-button b { font-size: var(--type-19); }
    .panel-topbar .notification.icon-button { width: 38px; height: 38px; min-width: 38px; min-height: 38px; flex-basis: 38px; }
    .panel-topbar .notification.icon-button svg { width: 23px; height: 23px; }
    .panel-date-topbar .today-button { display: none; }
    .panel-date-topbar .date-nav-button { width: 32px; height: 38px; flex-basis: 32px; }
    .panel-date-topbar .date-nav-button svg { width: 15px; height: 15px; }
    .panel-date-topbar .current-date { min-width: 0; width: 0; flex: 1 1 0; height: 38px; padding-inline: 6px; }
    .panel-date-topbar .current-date strong { min-width: 0; overflow: hidden; text-align: center; text-overflow: ellipsis; white-space: nowrap; font-size: var(--type-9); }
    .panel-date-topbar .schedule-date-picker { position: fixed; inset-block-start: 65px; inset-inline-start: 50%; width: min(336px,calc(100vw - 20px)); max-height: calc(100dvh - 76px); transform: translateX(50%); }
    .schedule-header.panel-topbar { height: auto; min-height: 58px; grid-template-rows: 58px auto; padding-block: 0 8px; }
    .schedule-header .schedule-date-picker { inset-block-start: 65px; }
    .dashboard-main .board,.schedule-content,.habits-page,.projects-content,.task-stats,.tasks-toolbar,.tasks-list { padding-inline: var(--panel-gutter); }
    .mobile-bottom-nav__create > span { width: 49px; height: 49px; margin-top: -44px; }
    .mobile-bottom-nav__create > span svg { width: 23px; height: 23px; }
}
@media (max-width: 480px) {
    .panel-topbar,.projects-header.projects-topbar.panel-topbar,.tasks-topbar.panel-topbar,.habits-topbar.panel-topbar,.topbar.panel-topbar { height: 58px; min-height: 58px; }
    .panel-date-topbar .date-nav-button { width: 29px; flex-basis: 29px; }
    .panel-date-topbar .current-date strong { font-size: var(--type-8); }
}

/* Schedule may need a second line at tablet widths. Keep its controls visible. */
@media (min-width: 769px) and (max-width: 1200px) {
    .schedule-header.panel-topbar { height: auto; min-height: var(--panel-topbar-height); flex-wrap: wrap; }
}

/* The first mobile row follows the dashboard: menu | date | notifications. */
@media (max-width: 768px) {
    .schedule-header.panel-topbar {
        display: grid;
        grid-template-columns: 40px minmax(0,1fr) 38px;
        grid-template-rows: 58px auto;
        gap: 2px 7px;
        align-items: center;
        justify-content: stretch;
        height: auto;
        min-height: 58px;
        padding: 0 var(--panel-gutter) 8px;
    }
    .schedule-header.panel-topbar .schedule-header__right { grid-column: 1; grid-row: 1; min-width: 0; }
    .schedule-header.panel-topbar .schedule-toolbar { grid-column: 2; grid-row: 1; width: 100%; min-width: 0; flex: none; order: initial; margin: 0; padding: 0; }
    .schedule-header.panel-topbar .schedule-date-control,
    .schedule-header.panel-topbar .date-navigation { width: 100%; min-width: 0; }
    .schedule-header.panel-topbar .schedule-header__left { grid-column: 3; grid-row: 1; width: 38px; margin: 0; }
    .schedule-header.panel-topbar .schedule-view-tools { grid-column: 1 / -1; grid-row: 2; min-width: 0; width: 100%; }
    .schedule-header.panel-topbar .schedule-date-picker { inset-block-start: 65px; }

    .habits-topbar.panel-topbar { gap: 7px; }
    .habits-topbar.panel-topbar .date { width: 0; min-width: 0; flex: 1 1 0; gap: 7px; }
    .habits-topbar.panel-topbar .dashboard-title { display: none; }
    .habits-topbar.panel-topbar .mobile-sidebar-toggle { display: grid; width: 40px; height: 40px; flex: 0 0 40px; }
    .habits-topbar.panel-topbar .toolbar-right { width: 0; min-width: 0; flex: 1 1 0; }
    .habits-topbar.panel-topbar .schedule-date-control,
    .habits-topbar.panel-topbar .date-navigation { width: 100%; min-width: 0; }
    .habits-topbar.panel-topbar .schedule-date-control { flex: 1 1 0; }
    .habits-topbar.panel-topbar .current-date { width: 0; min-width: 0; flex: 1 1 0; }
    .habits-topbar.panel-topbar .current-date strong { width: 100%; text-align: center; }
    .habits-topbar.panel-topbar .current-date__icon { display: none; }
    .habits-topbar.panel-topbar .top-actions { width: 38px; height: 38px; min-width: 38px; flex: 0 0 38px; margin-inline-start: 0; }
}
