/* 日历日/周/月：保留首页一级顶栏，并统一栏下间距
 * 生成器页 page.layout 进不了 body class，统一用 :has(.yj-cal-shell)
 * 日历页浅灰底（与月视图 --cal-bg-app 一致）；其它维度页不加载本文件，顶栏仍用暖纸色 */

/* 盖过 home-dimension-tabs 的纸色 html/body（同为 :has + !important，用双重 :has 提高优先级） */
html:has(.yj-cal-shell),
html:has(#home-dimension-tabs):has(.yj-cal-shell),
body:has(.yj-cal-shell),
body:has(#home-dimension-tabs):has(.yj-cal-shell) {
    --cal-bg-app: #F4F5F7;
    background-color: #F4F5F7 !important;
}

body:has(.yj-cal-shell) .material-layout,
body:has(.yj-cal-shell) .mdl-js-layout,
body:has(.yj-cal-shell) #main,
body:has(.yj-cal-shell) #main.material-layout__content,
body:has(.yj-cal-shell) .material-layout__content,
body:has(.yj-cal-shell) .material-index.mdl-grid,
body:has(.yj-cal-shell) .home-index-bleed {
    background: transparent !important;
    background-color: transparent !important;
}

/* 日历 tab：顶栏与页面同浅灰，离开日历后其它页仍走 home-dimension-tabs 暖色 */
body:has(.yj-cal-shell) .home-dim-tabs__bar {
    background: var(--cal-bg-app) !important;
    border-color: rgba(17, 24, 39, 0.08) !important;
    box-shadow: none !important;
    backdrop-filter: none;
}

/* 与首页/通史一致：清掉主题 165px 顶距 */
body:has(.yj-cal-shell) #main.material-layout__content,
body:has(.yj-cal-shell) .material-layout__content {
    padding-top: 0 !important;
}

body:has(.yj-cal-shell) .mdl-layout__drawer-button {
    display: none !important;
}

body:has(.yj-cal-shell) #home-dimension-tabs.home-dim-tabs.mdl-cell,
body:has(.yj-cal-shell) #home-dimension-tabs {
    background: transparent !important;
    width: 100%;
    max-width: none;
    margin: 0 !important;
    padding: 0 8px;
    box-sizing: border-box;
    flex: 0 0 auto;
}

/* 栏下间距三视图共用：仅靠 bar 的 margin-bottom */
body:has(.yj-cal-shell) .home-dim-tabs__bar {
    margin-bottom: 10px !important;
    top: calc(env(safe-area-inset-top, 0px) + var(--site-marquee-height, 0px));
}

body:has(.yj-cal-shell) .home-dim-tabs__bar a,
body:has(.yj-cal-shell) .home-dim-tabs__bar span {
    cursor: pointer;
    flex: 1 1 0 !important;
    text-align: center;
    padding: 11px 14px;
    border-radius: 999px;
    font-size: 16px;
    font-weight: 500;
    text-decoration: none;
    color: #7a6a57;
    background: transparent;
    border: 1px solid transparent;
    box-sizing: border-box;
}

body:has(.yj-cal-shell) .home-dim-tabs__bar .is-current {
    background: #fff !important;
    border-color: rgba(197, 156, 94, 0.45) !important;
    color: #5b4631 !important;
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(120, 90, 58, 0.18);
}

/* 日/周/月主体：栏下同一起点（不再叠加内边距） */
body:has(.yj-cal-shell) .yj-cal-body {
    width: 100%;
    max-width: none;
    box-sizing: border-box;
    margin: 0;
    padding: 0 8px 16px;
}

body:has(.yj-cal-shell) .material-index.home-index-bleed.yj-cal-shell {
    display: flex !important;
    flex-direction: column !important;
    float: none !important;
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* —— 月视图：一屏吃满，但顶栏保留 —— */
html:has(.yj-cal-shell[data-yj-mode="month"]),
body:has(.yj-cal-shell[data-yj-mode="month"]) {
    height: 100%;
    overflow: hidden !important;
}

body:has(.yj-cal-shell[data-yj-mode="month"]) .mdl-mini-footer,
body:has(.yj-cal-shell[data-yj-mode="month"]) .hx-app-download-root,
body:has(.yj-cal-shell[data-yj-mode="month"]) .hx-app-download-fab {
    display: none !important;
}

body:has(.yj-cal-shell[data-yj-mode="month"]) .material-layout {
    height: 100dvh !important;
    max-height: 100dvh !important;
    overflow: hidden !important;
}

body:has(.yj-cal-shell[data-yj-mode="month"]) .material-layout__content {
    display: flex !important;
    flex-direction: column !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    padding: 0 !important;
    margin: 0 !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
}

body:has(.yj-cal-shell[data-yj-mode="month"]) .yj-cal-shell {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    height: 100% !important;
}

body:has(.yj-cal-shell[data-yj-mode="month"]) .yj-cal-body {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding-bottom: 6px;
}

body:has(.yj-cal-shell[data-yj-mode="month"]) .yj-calendar {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    height: auto !important;
    max-height: none !important;
    width: min(100%, 920px) !important;
    margin-left: auto !important;
    margin-right: auto !important;
}

/* —— 日周月浮窗（与月视图右上角同尺寸） —— */
.yj-cal-float-wrap {
    position: sticky;
    top: calc(env(safe-area-inset-top, 0px) + var(--site-marquee-height, 0px) + var(--home-dim-primary-bar-h, 52px) + 6px);
    z-index: 46;
    display: flex;
    justify-content: flex-end;
    width: min(100%, 920px);
    max-width: 920px;
    margin: 0 auto 8px;
    padding: 0 10px;
    box-sizing: border-box;
    pointer-events: none;
}

.yj-cal-float-views {
    pointer-events: auto;
    position: relative;
    display: inline-flex;
    align-items: stretch;
    gap: 0;
    margin: 0;
    padding: 2px;
    background: #FFFFFF;
    border: 1px solid #E5E7EB;
    border-radius: 999px;
    box-shadow: 0 6px 20px rgba(17, 24, 39, 0.10);
}

.yj-cal-views-pill {
    position: absolute;
    top: 2px;
    bottom: 2px;
    left: 0;
    width: 36px;
    border-radius: 999px;
    background: #F3D5B5;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.55) inset;
    transform: translateX(2px);
    transition:
        transform 0.38s cubic-bezier(0.34, 1.35, 0.64, 1),
        width 0.38s cubic-bezier(0.34, 1.35, 0.64, 1);
    z-index: 0;
    pointer-events: none;
}

.yj-cal-float-views a {
    position: relative;
    z-index: 1;
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 800;
    line-height: 1.2;
    text-decoration: none;
    color: #6B7280;
    background: transparent;
    border: 0;
    cursor: pointer;
    transition: color 0.2s ease;
}

.yj-cal-float-views a.is-on {
    color: #111827;
}

/* —— ViewPager：日 | 周 | 月 —— */
.yj-cal-pager {
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    overflow: hidden;
    touch-action: pan-y;
}

.yj-cal-pager-track {
    display: flex;
    width: 300%;
    min-height: 100%;
    will-change: transform;
    transition: transform 0.36s cubic-bezier(0.22, 1, 0.36, 1);
}

.yj-cal-pager-track.is-dragging {
    transition: none;
}

.yj-cal-pager-pane {
    width: calc(100% / 3);
    flex: 0 0 calc(100% / 3);
    min-width: 0;
    min-height: 40vh;
    box-sizing: border-box;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
}

.yj-cal-pager-pane .yj-cal-body {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 0 8px 16px;
    box-sizing: border-box;
}

.yj-cal-pane-loading {
    margin: 48px auto;
    text-align: center;
    font-size: 13px;
    font-weight: 700;
    color: #6B7280;
}

/* 月视图一屏：pager 吃满剩余高度；track 仍横向三页，勿改成 column */
body:has(.yj-cal-shell[data-yj-mode="month"]) .yj-cal-pager {
    flex: 1 1 auto;
    min-height: 0;
    display: block;
}

body:has(.yj-cal-shell[data-yj-mode="month"]) .yj-cal-pager-track {
    height: 100%;
    min-height: 100%;
    align-items: stretch;
}

body:has(.yj-cal-shell[data-yj-mode="month"]) .yj-cal-pager-pane.is-current,
body:has(.yj-cal-shell[data-yj-mode="month"]) .yj-cal-pager-pane.is-current .yj-cal-body {
    min-height: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

body:has(.yj-cal-shell[data-yj-mode="month"]) .yj-cal-float-wrap {
    flex: 0 0 auto;
}
