/* ============================================================================
   增强版网页邮箱 —— 参照 Microsoft 365 新版 Outlook（Fluent 2）
   ========================================================================== */

/* ---------- 功能区 ---------- */
.ribbon { flex: none; padding: 4px 8px 0; background: var(--canvas); }
.ribbon-tabs { display: flex; align-items: center; gap: 2px; height: 36px; padding: 0 4px; }
.ribbon-tab { position: relative; height: 32px; padding: 0 12px; border: 0; background: transparent; border-radius: var(--radius); font: inherit; font-size: 14px; color: var(--fg2); cursor: pointer; }
.ribbon-tab:hover { background: var(--colorSubtleBackgroundHover, rgba(0,0,0,.05)); color: var(--fg1); }
.ribbon-tab.on { color: var(--fg1); font-weight: 600; }
.ribbon-tab.on::after { content: ""; position: absolute; left: 50%; bottom: 2px; width: 20px; height: 3px; margin-left: -10px; border-radius: 2px; background: var(--brand); }
.ribbon-pin { width: 28px; height: 28px; display: grid; place-items: center; border: 0; background: transparent; border-radius: var(--radius); cursor: pointer; }
.ribbon-pin:hover { background: var(--colorSubtleBackgroundHover, rgba(0,0,0,.05)); }

.ribbon-panel {
    display: flex; align-items: stretch; gap: 0; margin: 2px 0 8px; padding: 4px 6px; min-height: 40px; overflow-x: auto;
    background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow2, 0 0 2px rgba(0,0,0,.12), 0 1px 2px rgba(0,0,0,.14));
}
.ribbon-empty { display: flex; align-items: center; padding: 0 12px; }

.ribbon-group { display: flex; flex-direction: column; flex: none; position: relative; }
.ribbon-group + .ribbon-group::before { content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 1px; background: var(--colorNeutralStroke2, #e0e0e0); }
.ribbon-group-body { display: flex; align-items: center; gap: 2px; padding: 0 6px; flex: 1; }
.ribbon-group-label { display: none; }
.rb-col { display: flex; align-items: center; gap: 2px; }
.rb-info { flex-direction: column; align-items: flex-start; gap: 2px; padding: 0 8px; font-size: 12px; }

/* 按钮（简化功能区：图标 + 文字，单行） */
.rb-btn {
    display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 8px; border: 1px solid transparent; border-radius: var(--radius);
    background: transparent; color: var(--fg1); font: inherit; font-size: 14px; white-space: nowrap; cursor: pointer;
}
.rb-btn:hover:not(:disabled) { background: var(--colorSubtleBackgroundHover, #f5f5f5); }
.rb-btn:active:not(:disabled) { background: var(--colorSubtleBackgroundPressed, #e0e0e0); }
.rb-btn:disabled { color: var(--fg4); cursor: default; }
.rb-btn.checked { background: var(--colorSubtleBackgroundSelected, #ebebeb); }
.rb-btn .rb-caret { margin-left: -2px; }
.rb-btn svg { flex: none; }
/* 简化布局下大按钮的 24px 图标缩成 20px */
.ribbon.simplified .rb-btn.large svg { width: 20px; height: 20px; }

/* ---------- 经典功能区：大图标 + 组名（多行） ---------- */
.ribbon.classic .ribbon-panel { min-height: 96px; padding: 6px 4px 2px; }
.ribbon.classic .ribbon-group-body { align-items: stretch; padding: 0 6px; }
.ribbon.classic .ribbon-group-label { display: block; text-align: center; font-size: 12px; color: var(--fg3); padding: 2px 6px 0; white-space: nowrap; }
.ribbon.classic .rb-col { flex-direction: column; align-items: stretch; justify-content: flex-start; gap: 0; }
.ribbon.classic .rb-col .rb-btn { height: 24px; font-size: 13px; }
.ribbon.classic .rb-btn.large { flex-direction: column; justify-content: flex-start; gap: 4px; height: 70px; min-width: 56px; padding: 6px 6px 4px; font-size: 13px; white-space: normal; text-align: center; }
.ribbon.classic .rb-btn.large .rb-label { line-height: 16px; max-width: 72px; }
.ribbon.classic .rb-btn.large .rb-caret { margin: -4px 0 0; }
.ribbon.classic .ribbon-group + .ribbon-group::before { top: 4px; bottom: 4px; }

.ribbon.collapsed .ribbon-panel { position: absolute; z-index: 30; left: 8px; right: 8px; box-shadow: var(--shadow-flyout); }
.ribbon.collapsed { position: relative; }

/* ---------- 增强版整体：面板为圆角卡片，浮在灰色画布上（新版 Outlook） ---------- */
.mail-app.enhanced .mail-main { background: var(--canvas); }
.mail-app.enhanced .mail-panes { gap: 8px; padding: 0 8px 8px; background: var(--canvas); }
.mail-app.enhanced .list-pane, .mail-app.enhanced .reading-pane { background: var(--surface); border-radius: var(--radius-lg); border: 0; box-shadow: var(--shadow2, 0 0 2px rgba(0,0,0,.12), 0 1px 2px rgba(0,0,0,.14)); overflow: hidden; }

/* 阅读窗格在底部 */
.mail-panes.pane-bottom { flex-direction: column; }
.mail-panes.pane-bottom .list-pane { width: auto; max-width: none; flex: 0 0 42%; min-height: 160px; }
.mail-panes.pane-bottom .reading-pane { flex: 1; min-height: 0; }
/* 关闭阅读窗格：列表占满；打开邮件后阅读区占满，带“返回”按钮 */
.mail-panes.pane-off .list-pane { width: auto; max-width: none; flex: 1; }
.mail-panes.pane-off .reading-pane { display: none; }
.mail-panes.pane-off.reading .list-pane { display: none; }
.mail-panes.pane-off.reading .reading-pane { display: flex; flex: 1; }
.reading-back { display: inline-flex; align-items: center; gap: 6px; margin: 8px 12px 0; padding: 4px 8px; border: 0; background: transparent; color: var(--brand-fg); font: inherit; cursor: pointer; border-radius: var(--radius); align-self: flex-start; }
.reading-back:hover { background: var(--hover); }
/* 表格视图需要更宽的列表 */
.mail-panes.pane-right .table-pane { width: 46%; max-width: 760px; min-width: 520px; }

/* 卡片列表的紧凑行距 */
.mail-panes.dense .msg { padding-top: 6px; padding-bottom: 6px; }
.mail-panes.dense .msg-preview { display: none; }
.msg-subject-row { display: flex; align-items: center; gap: 6px; min-width: 0; }
.msg-subject-row .msg-subject { flex: 1; min-width: 0; }

/* ---------- 多列表格列表 ---------- */
.mt { width: 100%; border-collapse: separate; border-spacing: 0; table-layout: fixed; font-size: 13px; }
.mt thead th {
    position: sticky; top: 0; z-index: 1; height: 32px; padding: 0 8px; text-align: left; font-weight: 400; color: var(--fg2);
    background: var(--surface); border-bottom: 1px solid var(--colorNeutralStroke2, #e0e0e0); white-space: nowrap; user-select: none;
}
.mt th.sortable { cursor: pointer; }
.mt th.sortable:hover { background: var(--hover); }
.mt th.sorted { color: var(--fg1); font-weight: 600; }
.mt th > span { vertical-align: middle; margin-right: 4px; }
.mt td { padding: 0 8px; height: 52px; border-bottom: 1px solid var(--colorNeutralStroke3, #f0f0f0); color: var(--fg2); vertical-align: middle; overflow: hidden; }
.table-pane.compact .mt td { height: 32px; }
.mt .mt-check { width: 36px; padding: 0 0 0 12px; }
.mt .mt-icons { width: 28px; padding: 0 2px; text-align: center; }
.mt .mt-from { width: 24%; }
.mt .mt-from .ellipsis { display: block; }
.mt .mt-date { width: 104px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.mt .mt-size { width: 72px; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--fg3); }
.mt .mt-flag { width: 36px; padding: 0 6px; text-align: center; }
.mt-subject-line { display: flex; align-items: center; gap: 6px; min-width: 0; color: var(--fg1); }
.mt-subject-line .ellipsis { flex: 0 1 auto; min-width: 0; }
.mt-preview { color: var(--fg3); font-size: 12px; margin-top: 2px; }
.mt-row { cursor: pointer; }
.mt-row:hover td { background: var(--hover); }
.mt-row.unread td { color: var(--fg1); }
.mt-row.unread .mt-from, .mt-row.unread .mt-subject-line { font-weight: 600; }
.mt-row.unread td:first-child { box-shadow: inset 3px 0 0 var(--brand); }
.mt-row.selected td, .mt-row.open td { background: var(--colorBrandBackground2, #ebf3fc); }
.mt-flag-btn { width: 24px; height: 24px; display: grid; place-items: center; border: 0; background: transparent; border-radius: var(--radius); cursor: pointer; opacity: 0; }
.mt-row:hover .mt-flag-btn, .mt-flag-btn.on { opacity: 1; }
.mt-flag-btn:hover { background: var(--colorSubtleBackgroundHover, #f0f0f0); }
.mt-skeleton td { height: 40px; }

/* 简化功能区放不下时逐级只显示图标（悬停仍有文字提示），与新版 Outlook 一致 */
.ribbon-panel { container-type: inline-size; }
@container (max-width: 1420px) {
    .ribbon.simplified .rb-col .rb-label { display: none; }
    .ribbon.simplified .rb-col .rb-btn { padding: 0 6px; }
}
@container (max-width: 1060px) {
    .ribbon.simplified .rb-btn:not(.rb-keep) .rb-label { display: none; }
}

/* ---------- 搜索文件夹与高级搜索 ---------- */
.search-folder { padding-left: 8px; }
.search-folder-del { margin-left: auto; width: 24px; height: 24px; display: grid; place-items: center; border: 0; background: transparent; border-radius: var(--radius); cursor: pointer; opacity: 0; }
.search-folder:hover .search-folder-del { opacity: 1; }
.search-folder-del:hover { background: var(--colorSubtleBackgroundHover, #ebebeb); }
.adv-form { display: flex; flex-direction: column; gap: 14px; }
.adv-row { display: grid; grid-template-columns: 76px 1fr; align-items: center; gap: 12px; }
.adv-row > label { color: var(--fg2); font-size: 13px; }
.adv-row .fl-input, .adv-row .fl-select { width: 100%; }
.adv-range { display: flex; align-items: center; gap: 8px; }
.adv-range .fl-input { flex: 1; min-width: 0; }
.adv-checks { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.adv-checks label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.adv-save { margin-top: 6px; padding: 12px; border-radius: var(--radius-lg); background: var(--surface-alt); display: flex; flex-direction: column; gap: 8px; }
.adv-save > label { font-weight: 600; font-size: 13px; }
.adv-save-row { display: flex; gap: 8px; }
.adv-save-row .fl-input { flex: 1; }

/* 阅读区邮件头：新版 Outlook 式“答复 | 全部答复 | 转发”按钮组，时间在下方 */
.ol-meta { flex-direction: column; align-items: flex-end; gap: 6px; }
.ol-actions { display: flex; align-items: center; gap: 6px; }
.ol-group { display: inline-flex; border: 1px solid var(--stroke, #d1d1d1); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.ol-group button, .ol-more { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border: 0; background: transparent; font: inherit; font-size: 14px; color: var(--fg1, #242424); cursor: pointer; white-space: nowrap; }
.ol-group button + button { border-left: 1px solid var(--stroke, #d1d1d1); }
.ol-group button:hover, .ol-more:hover { background: var(--hover); }
.ol-more { width: 34px; padding: 0; justify-content: center; border: 1px solid var(--stroke, #d1d1d1); border-radius: var(--radius); }
