/* ============================================================
   Obsidian 式 Shell：扁平工作区、细边框、无厚卡片阴影。
   ============================================================ */

.shell-root.shell-root--surface {
    background: var(--obs-bg);
    box-shadow: none;
    overflow: hidden;
}

/* 路由切换 / 首帧恢复布局：遮罩盖住抖动，绘制稳定后由 ShellLayout 关闭 */
.shell-root--prefs-pending {
    visibility: hidden;
}

.shell-prefs-mask {
    position: absolute;
    inset: 0;
    z-index: 12000;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    background: var(--obs-bg, #fff);
    color: var(--obs-muted, #6b7280);
    pointer-events: all;
}

.shell-prefs-mask__inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.shell-prefs-mask__spinner {
    width: 1.5rem;
    height: 1.5rem;
    border: 2px solid color-mix(in oklab, var(--ox-accent, #4d8fe8) 22%, var(--ox-border, #e3e3e3));
    border-top-color: var(--ox-accent, #4d8fe8);
    border-radius: 50%;
    animation: shell-prefs-spin 0.7s linear infinite;
}

.shell-prefs-mask__text {
    margin: 0;
    font-size: var(--ox-fs-secondary, 0.75rem);
    font-weight: var(--ox-fw-regular, 400);
    line-height: 1.4;
}

@keyframes shell-prefs-spin {
    to {
        transform: rotate(360deg);
    }
}

.shell-viewport {
    /* 跟随 html data-ox-skin / data-ox-scheme-resolved（skins.css），勿写死浅色 */
    --obs-bg: var(--shell-content-bg, var(--ox-surface));
    --obs-sidebar: var(--shell-column-bg, var(--shell-muted-strip-bg));
    --obs-rail: var(--shell-rail-bg);
    --obs-border: var(--shell-rail-border, var(--ox-border));
    --obs-text: var(--ox-text-body);
    --obs-muted: var(--ox-text-secondary);
    --obs-hover: var(--ox-state-hover-bg);
    --obs-active: var(--ox-state-selected-chrome-bg, var(--ox-state-selected-bg));
    --obs-focus: var(--ox-accent);
    /* 左侧图标轨：点击面、glyph、默认/悬停/选中色 */
    --shell-rail-w: 3rem;
    --shell-rail-btn: var(--ox-btn-size);
    --shell-rail-face: 1.375rem;
    --shell-rail-glyph: 1.125rem;
    --shell-rail-gap: 0.25rem;
    --shell-rail-pad: 0.375rem;
    --shell-rail-icon: var(--ox-text-secondary);
    --shell-rail-icon-hover: var(--ox-text-primary);
    --shell-rail-icon-active: var(--ox-accent-foreground);
    position: relative;
    background: var(--obs-bg);
    color: var(--obs-text);
    overflow-x: hidden;
}

.shell-left-rail {
    width: var(--shell-rail-w) !important;
    min-width: var(--shell-rail-w) !important;
    max-width: var(--shell-rail-w) !important;
    background: var(--obs-rail) !important;
    border-right: 1px solid var(--obs-border) !important;
    padding: var(--shell-rail-pad) 0 !important;
    gap: var(--shell-rail-gap) !important;
    box-sizing: border-box;
}

.shell-left-middle,
.shell-left-rail-bottom {
    gap: var(--shell-rail-gap) !important;
    width: 100%;
}

/* 明暗快捷：悬停展开 Light / Dark / 跟随系统 */
.shell-scheme-menu {
    position: relative;
    z-index: 40;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--shell-rail-btn);
    height: var(--shell-rail-btn);
    flex-shrink: 0;
}

.shell-scheme-menu__flyout {
    position: absolute;
    left: calc(100% + 0.35rem);
    bottom: 0;
    display: none;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 7.5rem;
    padding: 0.35rem;
    border-radius: var(--ox-radius, 4px);
    border: 1px solid var(--ox-border, #e3e3e3);
    background: var(--ox-surface, #fff);
    box-shadow: var(--ox-shadow-overlay);
    color: var(--ox-text-body, #27272a);
}

.shell-scheme-menu__flyout::before {
    content: "";
    position: absolute;
    right: 100%;
    bottom: 0;
    width: 0.45rem;
    height: 100%;
}

.shell-scheme-menu:hover .shell-scheme-menu__flyout,
.shell-scheme-menu:focus-within .shell-scheme-menu__flyout {
    display: flex;
}

.shell-scheme-menu:hover .shell-scheme-menu__trigger,
.shell-scheme-menu:focus-within .shell-scheme-menu__trigger {
    background: var(--obs-hover);
    color: var(--shell-rail-icon-hover);
}

.shell-scheme-menu__item {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    width: 100%;
    margin: 0;
    padding: 0.4rem 0.5rem;
    border: none;
    border-radius: var(--ox-radius, 4px);
    background: transparent;
    color: var(--ox-text-body, #27272a);
    font-size: var(--ox-fs-secondary, 0.75rem);
    font-weight: var(--ox-fw-medium, 500);
    line-height: 1.2;
    text-align: left;
    cursor: pointer;
    white-space: nowrap;
}

.shell-scheme-menu__item .ph {
    font-size: 0.95rem;
    line-height: 1;
    color: var(--ox-text-secondary, #71717a);
}

.shell-scheme-menu__item:hover {
    background: var(--ox-state-hover-bg, #f4f4f5);
}

.shell-scheme-menu__item.is-active {
    background: color-mix(in oklab, var(--ox-accent, #3b82f6) 14%, var(--ox-surface, #fff));
    color: var(--ox-accent-foreground, #1d4ed8);
}

.shell-scheme-menu__item.is-active .ph {
    color: var(--ox-accent-foreground, #1d4ed8);
}

/* 主账号子账号：悬停从头像展开 */
.shell-left-rail {
    position: relative;
    z-index: 30;
}

.shell-account-menu {
    position: relative;
    z-index: 40;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--shell-rail-btn);
    height: var(--shell-rail-btn);
    flex-shrink: 0;
}

.shell-account-menu__flyout {
    position: absolute;
    left: calc(100% + 0.35rem);
    top: 0;
    display: none;
    flex-direction: column;
    gap: 0.15rem;
    width: 14rem;
    max-height: min(24rem, 70vh);
    overflow: auto;
    padding: 0.35rem;
    border-radius: var(--ox-radius, 4px);
    border: 1px solid var(--ox-border, #e3e3e3);
    background: var(--ox-surface, #fff);
    box-shadow: var(--ox-shadow-overlay);
    color: var(--ox-text-body, #27272a);
}

.shell-account-menu__flyout::before {
    content: "";
    position: absolute;
    right: 100%;
    top: 0;
    width: 0.45rem;
    height: 2.25rem;
}

.shell-account-menu:hover .shell-account-menu__flyout,
.shell-account-menu:focus-within .shell-account-menu__flyout {
    display: flex;
}

.shell-account-menu:hover .shell-account-menu__trigger,
.shell-account-menu:focus-within .shell-account-menu__trigger {
    background: var(--obs-hover);
    color: var(--shell-rail-icon-hover);
}

.shell-account-menu__label {
    padding: 0.25rem 0.45rem 0.1rem;
    font-size: var(--ox-fs-secondary, 0.75rem);
    color: var(--ox-text-secondary, #71717a);
}

.shell-account-menu__row {
    display: flex;
    align-items: stretch;
    gap: 0.15rem;
}

.shell-account-menu__item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.05rem;
    flex: 1;
    min-width: 0;
    margin: 0;
    padding: 0.35rem 0.45rem;
    border: none;
    border-radius: var(--ox-radius, 4px);
    background: transparent;
    color: var(--ox-text-body, #27272a);
    font-size: var(--ox-fs-secondary, 0.75rem);
    font-weight: var(--ox-fw-medium, 500);
    line-height: 1.2;
    text-align: left;
    cursor: pointer;
}

.shell-account-menu__item--flat {
    flex-direction: row;
    align-items: center;
    gap: 0.4rem;
}

.shell-account-menu__item .ph {
    font-size: 0.95rem;
    line-height: 1;
    color: var(--ox-text-secondary, #71717a);
}

.shell-account-menu__name {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.shell-account-menu__user {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: var(--ox-fw-regular, 400);
    color: var(--ox-text-secondary, #71717a);
}

.shell-account-menu__item:hover {
    background: var(--ox-state-hover-bg, #f4f4f5);
}

.shell-account-menu__item.is-active {
    background: color-mix(in oklab, var(--ox-accent, #3b82f6) 14%, var(--ox-surface, #fff));
    color: var(--ox-accent-foreground, #1d4ed8);
}

.shell-account-menu__remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    flex-shrink: 0;
    margin: 0;
    padding: 0;
    border: none;
    border-radius: var(--ox-radius, 4px);
    background: transparent;
    color: var(--ox-text-secondary, #71717a);
    cursor: pointer;
}

.shell-account-menu__remove:hover {
    background: var(--ox-state-hover-bg, #f4f4f5);
    color: var(--ox-text-body, #27272a);
}

.shell-account-menu__empty,
.shell-account-menu__error {
    margin: 0;
    padding: 0.2rem 0.45rem 0.35rem;
    font-size: var(--ox-fs-secondary, 0.75rem);
    color: var(--ox-text-secondary, #71717a);
}

.shell-account-menu__error {
    color: var(--ox-danger, #b91c1c);
}

.shell-account-menu__add {
    padding: 0.2rem 0.15rem 0.35rem;
}

.shell-account-menu__flyout .ox-user-combo {
    width: 100%;
}

/* Tooltip 包裹层也占满同一格子，避免 logo/钮视觉错位 */
.shell-left-rail .mud-tooltip-root {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: var(--shell-rail-btn);
    height: var(--shell-rail-btn);
    min-width: var(--shell-rail-btn);
    min-height: var(--shell-rail-btn);
    flex-shrink: 0;
    margin: 0;
    padding: 0;
    line-height: 0;
}

/* Logo / 头像 / 菜单钮：同一点击面（勿混用 manage-btn-icon / MudIconButton） */
.shell-left-rail .shell-brand,
.shell-left-rail .shell-user-avatar-btn,
.shell-left-rail .shell-icon,
.shell-left-rail .shell-scheme-menu__trigger,
.shell-left-rail .shell-account-menu__trigger {
    box-sizing: border-box;
    width: var(--shell-rail-btn) !important;
    height: var(--shell-rail-btn) !important;
    min-width: var(--shell-rail-btn) !important;
    min-height: var(--shell-rail-btn) !important;
    max-width: var(--shell-rail-btn) !important;
    max-height: var(--shell-rail-btn) !important;
    margin: 0 !important;
    padding: 0 !important;
    border-radius: var(--ox-radius, 4px);
    border: none;
    background: transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--shell-rail-icon);
    text-decoration: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background-color 0.12s ease, color 0.12s ease;
}

.shell-rail-slot {
    display: contents;
}

.shell-left-rail button.shell-icon {
    color: var(--shell-rail-icon);
}

.shell-left-rail .shell-icon:hover,
.shell-left-rail button.shell-icon:hover {
    background: var(--obs-hover);
    color: var(--shell-rail-icon-hover);
}

.shell-left-rail button.shell-icon.active,
.shell-left-rail button.shell-icon.active:hover {
    background: var(--obs-active);
    color: var(--shell-rail-icon-active);
}

.shell-brand {
    cursor: default;
}

.shell-brand-mark {
    width: var(--shell-rail-face) !important;
    height: auto !important;
    aspect-ratio: 139 / 150;
    max-height: var(--shell-rail-face) !important;
    object-fit: contain;
    display: block;
    background: transparent;
}

.shell-user-avatar-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.shell-left-rail .shell-user-avatar-btn:hover:not(:disabled) {
    background: var(--obs-hover);
    color: var(--shell-rail-icon-hover);
}

.shell-user-avatar-img {
    width: var(--shell-rail-face) !important;
    height: var(--shell-rail-face) !important;
    border-radius: 4px;
    object-fit: cover;
    display: block;
    background: var(--ox-state-hover-bg, #f4f4f5);
}

.shell-left-rail .shell-user-avatar-fallback {
    font-size: var(--shell-rail-glyph) !important;
    line-height: 1 !important;
    color: inherit !important;
}

.shell-mud-avatar.mud-avatar,
.shell-mud-avatar,
.shell-user-avatar {
    width: var(--shell-rail-face) !important;
    height: var(--shell-rail-face) !important;
    min-width: var(--shell-rail-face) !important;
    min-height: var(--shell-rail-face) !important;
    max-width: var(--shell-rail-face) !important;
    max-height: var(--shell-rail-face) !important;
    font-size: 0.65rem !important;
}

.shell-mud-avatar .mud-image,
.shell-mud-avatar img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover;
}

.shell-left-rail .shell-icon .ph,
.shell-left-rail .shell-scheme-menu__trigger .ph {
    font-size: var(--shell-rail-glyph) !important;
    line-height: 1 !important;
    width: 1em;
    height: 1em;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: inherit !important;
}

.shell-rail-loading.mud-progress-circular {
    width: var(--shell-rail-face) !important;
    height: var(--shell-rail-face) !important;
    margin: calc((var(--shell-rail-btn) - var(--shell-rail-face)) / 2) 0;
}

.shell-left-column,
.shell-left.shell-left-column {
    background: var(--obs-sidebar) !important;
    /* 右边线由 .shell-left-splitter 承担，避免双线形成空隙感 */
    border-right: none !important;
}

/* 子菜单列固定宽：由 --shell-left-w 驱动（拖拽 / 默认 264） */
.shell-left-sized {
    width: var(--shell-left-w, 264px);
    flex: 0 0 var(--shell-left-w, 264px);
    max-width: min(40vw, 420px);
    min-width: 0;
    box-sizing: border-box;
    overflow: hidden;
}

.shell-left-column--dim,
.shell-left-rail--dim {
    background: var(--obs-sidebar) !important;
}

.shell-subpanel {
    background: transparent;
    width: 100%;
    min-width: 0;
}

/* 左/右栏顶栏跟列面同色（勿用 --ox-header-bg：那是中间主面板顶栏） */
.shell-subpanel-detail-header.manage-detail-header,
.shell-left .manage-detail-header,
.shell-right-drawer .manage-detail-header {
    min-height: 2.25rem;
    height: 2.25rem;
    padding: 0 var(--ox-space, 0.5rem);
    border-bottom: 1px solid var(--obs-border);
    background: var(--obs-sidebar) !important;
    box-shadow: none;
    border-radius: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.25rem;
}

.shell-subpanel-detail-header .manage-detail-title,
.shell-left .manage-detail-title {
    font-size: var(--ox-fs-title, 0.875rem);
    font-weight: var(--ox-fw-semibold, 600);
    letter-spacing: normal;
    text-transform: none;
    color: var(--ox-text-primary, var(--obs-text, #18181b));
    line-height: 1.25;
}

.shell-subnav-list {
    padding: 0.25rem var(--ox-space, 0.5rem) var(--ox-space, 0.5rem);
}

.shell-main-area,
.shell-middle.shell-main-pane,
.shell-middle--content-dim {
    background: var(--obs-bg) !important;
}

.shell-middle.shell-main-pane {
    box-sizing: border-box;
    /* 四边贴齐：勿留 padding，否则面板右/底边框外会露一条底色空隙 */
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0;
    overflow-x: hidden;
    overflow-y: auto;
    min-width: 0;
}

.shell-middle.shell-main-pane > * {
    margin: 0;
    min-height: 0;
    min-width: 0;
    max-width: 100%;
}

.shell-middle.shell-main-pane > .manage-middle {
    flex: 1 1 auto;
    height: auto;
    min-height: 0;
    min-width: 0;
    max-width: 100%;
    width: auto;
    align-self: stretch;
    margin: 0;
}

.shell-main-area {
    min-width: 0;
    overflow: hidden;
}

/* 工作区面板：细边、无阴影（替代厚 MudPaper） */
.ox-workspace,
.ox-workspace.mud-paper {
    background: var(--obs-bg);
    border: 1px solid var(--obs-border);
    border-radius: 4px;
    box-shadow: none !important;
}

.ox-workspace.mud-paper {
    padding: var(--ox-space, 0.5rem) !important;
}

.ox-workspace-title {
    font-size: var(--ox-fs-title, 0.875rem);
    font-weight: var(--ox-fw-semibold, 600);
    color: var(--ox-text-primary, var(--obs-text));
    margin: 0;
}

.ox-workspace-lead {
    font-size: var(--ox-fs-secondary, 0.75rem);
    font-weight: var(--ox-fw-regular, 400);
    color: var(--ox-text-secondary, var(--obs-muted));
    margin: 0;
}

/* 管理面板去卡片感 */
.manage-panel {
    box-shadow: none !important;
    border-radius: 4px;
    border-color: var(--obs-border);
}

.manage-panel-header {
    background: transparent;
    border-bottom: 1px solid var(--obs-border);
    min-height: var(--ox-panel-header-h, 2.25rem);
    height: var(--ox-panel-header-h, 2.25rem);
    box-shadow: none;
}

/* 右侧抽屉：像 Obsidian 侧栏，非 Material 浮层 */
.shell-right-drawer.mud-drawer {
    height: 100%;
    border-left: 1px solid var(--obs-border);
    box-shadow: none !important;
}

.shell-right-drawer .mud-drawer-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 0;
    background: var(--obs-sidebar);
}

.shell-right-drawer-pane {
    height: 100%;
    min-height: 0;
    background: var(--obs-sidebar);
}

.shell-right-drawer .shell-right-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    /* 底无 padding：与全局一致，避免 sticky 底栏负 margin 裁切 */
    padding: 0 var(--ox-space, 0.5rem);
    display: flex;
    flex-direction: column;
    gap: 0;
}

.shell-right-drawer .shell-right-scroll > * {
    margin-top: 0 !important;
    margin-bottom: 0 !important;
}

/* 右栏顶栏：拉满/背景/高度走 ox-ui-system .manage-detail-header，勿再 transparent 或自造高度 */

.shell-right-drawer .manage-detail-header + .ox-form-stack,
.shell-right-drawer .manage-detail-header + .tasks-manage-right-body,
.shell-right-drawer .manage-detail-header + .ox-form-field-legend {
    margin-top: 0.75rem !important;
}

.shell-right-drawer .ox-form-stack,
.shell-right-drawer .tasks-manage-right-body {
    flex: 1 1 auto;
    min-height: 0;
}

/* 右栏底栏：样式统一走 ox-ui-system .ox-form-actions.shell-right-sticky-actions，勿在此覆盖 padding/背景 */

/* 勿用 background 简写：会清空 select 的 background-image（下拉箭头） */
.shell-right-drawer .ox-form-control:not(:disabled):not([readonly]),
.shell-right-drawer select.ox-form-control:not(:disabled),
.shell-right-drawer textarea.ox-form-control:not(:disabled):not([readonly]) {
    background-color: var(--ox-surface);
}

.shell-right-drawer .ox-form-field-legend__text {
    background: var(--obs-sidebar);
}

.mud-overlay {
    backdrop-filter: none;
    background-color: rgba(15, 15, 15, 0.22) !important;
}

/* 堆叠：无重合边距 */
.ox-space-stack {
    display: flex;
    flex-direction: column;
    gap: var(--ox-space, 0.5rem);
}

.ox-space-stack > * {
    margin-top: 0 !important;
    margin-bottom: 0 !important;
}

/* Mud 表格贴近 Obsidian：紧凑、细线 */
.mud-table {
    background: transparent;
}

.mud-table .mud-table-cell {
    border-color: var(--obs-border);
}

.mud-button-root {
    text-transform: none;
    letter-spacing: normal;
}

.shell-left-splitter {
    /* 通顶实线由全局 .shell-left-splitter background 承担；勿再 border / 渐变顶段留白 */
    border-right: none !important;
    margin: 0;
    padding: 0;
}
