/* ErisPulse Dashboard – files
   资源管理器式文件管理：紧凑行列表 + 网格双视图、排序表头、
   选择操作条、行内 ⋮ 菜单（移动端 bottom-sheet） */

.fm2-card {
    padding: 0;
    overflow: hidden;
}

/* ── 面包屑（沿用 fm-crumb 系列类名） ── */
.fm2-crumbbar {
    flex: 1;
    min-width: 0;
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: none;
    display: flex;
    align-items: center;
}

.fm2-crumbbar::-webkit-scrollbar {
    display: none;
}

.fm-crumb {
    padding: 2px 6px;
    border-radius: 4px;
    cursor: pointer;
    font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
    font-size: 13px;
    color: var(--tx-s);
    transition: background-color 0.15s ease, color 0.15s ease;
}

.fm-crumb:hover {
    background: var(--accent-fill);
    color: #fff;
}

.fm-crumb.active {
    font-weight: 600;
    color: var(--tx-p);
}

.fm-crumb-count {
    font-size: 11px;
    color: var(--tx-t);
    margin-left: 6px;
}

.fm-crumb-sep {
    color: var(--tx-t);
    font-size: 12px;
}

.fm-icon {
    display: block;
}

/* ── 工具行：面包屑 + 搜索/视图/刷新 ── */
.fm2-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--bd);
    background: color-mix(in srgb, var(--bg-p) 40%, var(--bg-s));
}

.fm2-tools {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.fm2-search {
    width: 180px;
    padding: 6px 10px;
    border: 1px solid var(--bd);
    border-radius: 8px;
    background: var(--bg-t);
    color: var(--tx-p);
    font-size: 13px;
    outline: none;
}

.fm2-search:focus {
    border-color: var(--accent);
}

.fm2-toolbtn {
    width: 30px;
    height: 30px;
}

/* ── 操作行 ── */
.fm2-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--bd);
}

.fm2-actions-gap {
    flex: 1;
}

/* ── 选择操作条 ── */
.fm2-selbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 14px;
    border-bottom: 1px solid var(--bd);
    background: color-mix(in srgb, var(--accent) 7%, var(--bg-s));
}

.fm2-selcount {
    font-size: 13px;
    font-weight: 600;
    color: var(--accent);
}

.fm2-selgap {
    flex: 1;
}

/* ── 列表 ── */
.fm2-listwrap {
    min-height: 320px;
    max-height: calc(100vh - 340px);
    overflow-y: auto;
}

.fm2-headrow {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 130px 90px 34px;
    gap: 10px;
    align-items: center;
    padding: 7px 14px;
    border-bottom: 1px solid var(--bd);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--tx-t);
    position: sticky;
    top: 0;
    background: var(--bg-s);
    z-index: 1;
}

.fm2-col {
    cursor: pointer;
    user-select: none;
}

.fm2-col:hover {
    color: var(--tx-p);
}

.fm2-col-menu {
    cursor: default;
}

.fm2-row {
    display: grid;
    grid-template-columns: 22px minmax(0, 1fr) 130px 90px 34px;
    gap: 10px;
    align-items: center;
    padding: 8px 14px;
    border-bottom: 1px solid color-mix(in srgb, var(--bd) 45%, transparent);
    cursor: default;
    user-select: none;
    transition: background 0.12s ease;
}

.fm2-row:hover {
    background: color-mix(in srgb, var(--accent) 5%, transparent);
}

.fm2-row.selected {
    background: color-mix(in srgb, var(--accent) 10%, transparent);
}

.fm2-icon {
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.fm2-icon .fm-icon {
    width: 19px;
    height: 19px;
}

.fm2-name {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13.5px;
    color: var(--tx-p);
    min-width: 0;
}

.fm2-nametext {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 可预览文件：名称尾部预览按钮（桌面 hover 浮现 / 触屏常显） */
.fm2-previewbtn {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    border: none;
    background: transparent;
    color: var(--tx-t);
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.15s ease, color 0.15s ease, background-color 0.15s ease;
}

.fm2-previewbtn svg {
    width: 14px;
    height: 14px;
}

.fm2-row:hover .fm2-previewbtn,
.fm2-previewbtn:focus-visible {
    opacity: 1;
}

.fm2-previewbtn:hover {
    color: var(--accent);
    background: var(--accent-soft);
}

.fm2-previewbtn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3.5px var(--accent-soft);
}

@media (hover: none) {
    .fm2-previewbtn {
        opacity: 1;
    }
}

.fm2-row.is-dir .fm2-name {
    font-weight: 600;
}

.fm2-date {
    font-size: 12px;
    color: var(--tx-s);
    font-variant-numeric: tabular-nums;
}

.fm2-size {
    font-size: 12px;
    color: var(--tx-s);
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.fm2-rowmenu {
    width: 26px;
    height: 26px;
    border: none;
    background: transparent;
    color: var(--tx-t);
    border-radius: 6px;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
}

.fm2-rowmenu:hover {
    background: var(--bg-t);
    color: var(--tx-p);
}

/* ── 网格视图 ── */
.fm2-list.fm2-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
    padding: 14px;
}

.fm2-tile {
    border: 1px solid var(--bd);
    border-radius: 10px;
    padding: 14px 10px 10px;
    text-align: center;
    cursor: default;
    user-select: none;
    transition: border-color 0.12s ease, background 0.12s ease;
}

.fm2-tile:hover {
    border-color: var(--bd-h);
    background: color-mix(in srgb, var(--accent) 4%, transparent);
}

.fm2-tile.selected {
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 10%, transparent);
}

.fm2-tile-icon .fm-icon {
    width: 30px;
    height: 30px;
}

.fm2-tile-name {
    margin-top: 8px;
    font-size: 12.5px;
    font-weight: 500;
    color: var(--tx-p);
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-height: 1.35;
    word-break: break-all;
}

.fm2-tile-meta {
    margin-top: 3px;
    font-size: 11px;
    color: var(--tx-t);
}

/* ── 右键菜单 / 移动端 bottom-sheet ── */
.fm-context-menu {
    position: fixed;
    z-index: 1200;
    min-width: 168px;
    background: var(--bg-t);
    border: 1px solid var(--bd);
    border-radius: 10px;
    padding: 5px;
    box-shadow: 0 10px 32px -8px rgba(0, 0, 0, 0.28);
}

.fm-ctx-item {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 8px 10px;
    border-radius: 7px;
    font-size: 13px;
    color: var(--tx-p);
    cursor: pointer;
}

.fm-ctx-item svg {
    width: 15px;
    height: 15px;
    color: var(--tx-s);
    flex-shrink: 0;
}

.fm-ctx-item:hover {
    background: color-mix(in srgb, var(--accent) 8%, transparent);
}

.fm-ctx-item.danger {
    color: var(--er-c);
}

.fm-ctx-item.danger svg {
    color: var(--er-c);
}

.fm-ctx-sep {
    height: 1px;
    margin: 4px 6px;
    background: var(--bd);
}

/* ── 编辑器模态窗 ── */
.fm-editor-modal .fm-editor-box {
    width: min(920px, 92vw);
    height: min(640px, 84vh);
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
}

.fm-editor-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--bd);
    flex-shrink: 0;
}

.fm-editor-icon {
    display: flex;
    align-items: center;
    color: var(--tx-s);
}

.fm-editor-icon svg {
    width: 20px;
    height: 20px;
}

.fm-editor-titles {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}

.fm-editor-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--tx-p);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.fm-editor-path {
    font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
    font-size: 11px;
    color: var(--tx-t);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.fm-editor-status {
    font-size: 12px;
    flex-shrink: 0;
}

.fm-editor-btns {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.fm-editor-container {
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.fm-editor-container .CodeMirror {
    height: 100%;
}

/* ── 移动端 ── */
@media (max-width: 768px) {
    .fm2-desktop-only {
        display: none !important;
    }

    .fm2-toolbar {
        flex-wrap: wrap;
    }

    .fm2-crumbbar {
        flex-basis: 100%;
        order: 2;
    }

    .fm2-tools {
        order: 1;
        flex: 1;
        justify-content: flex-end;
    }

    .fm2-search {
        flex: 1;
        width: auto;
        min-width: 0;
    }

    .fm2-actions .btn span {
        display: none;
    }

    .fm2-actions .btn svg {
        margin-right: 0 !important;
    }

    .fm2-actions .btn {
        padding: 6px 10px;
    }

    .fm2-listwrap {
        max-height: none;
    }

    .fm2-headrow {
        display: none;
    }

    .fm2-row {
        grid-template-columns: 24px minmax(0, 1fr) 30px;
        grid-template-rows: auto auto;
        row-gap: 2px;
        padding: 10px 12px;
    }

    .fm2-date,
    .fm2-size {
        display: none;
    }

    /* 修改时间落到名称下方第二行 */
    .fm2-row::after {
        content: attr(data-meta);
        grid-column: 2;
        grid-row: 2;
        font-size: 11px;
        color: var(--tx-t);
    }

    .fm2-rowmenu {
        display: flex;
        grid-column: 3;
        grid-row: 1 / span 2;
    }

    .fm2-list.fm2-grid {
        grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
        gap: 8px;
        padding: 10px;
    }

    /* 菜单变 bottom-sheet */
    .fm-context-menu.fm-ctx-sheet {
        left: 8px !important;
        right: 8px;
        bottom: 8px;
        top: auto !important;
        padding: 8px;
    }

    .fm-ctx-sheet .fm-ctx-item {
        padding: 12px 12px;
    }

    /* 编辑器全屏 */
    .fm-editor-modal .fm-editor-box {
        width: 100%;
        height: 100%;
        max-height: none;
        border-radius: 0;
    }
}

/* ── 编辑器 IDE 化：状态栏 + CodeMirror 打磨 ── */
.fm-editor-modal .fm-editor-box {
    width: min(1040px, 94vw);
    height: min(680px, 86vh);
}

.fm-editor-statusbar {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 5px 14px;
    border-top: 1px solid var(--bd);
    background: var(--bg-s);
    font-family: ui-monospace, "JetBrains Mono", "Cascadia Code", Consolas, monospace;
    font-size: 11px;
    color: var(--tx-s);
    flex-shrink: 0;
    user-select: none;
}

.fm2-status-item {
    white-space: nowrap;
}

.fm2-status-dim {
    opacity: 0.65;
}

.fm2-status-flex {
    flex: 1;
}

.fm-editor-status {
    font-weight: 600;
}

/* 亮色（default 主题）：gutter 分离 + 活动行高亮，向 IDE 观感靠拢 */
.fm-editor-box .cm-s-default .CodeMirror {
    font-family: ui-monospace, "JetBrains Mono", "Cascadia Code", Consolas, monospace;
    font-size: 13px;
    line-height: 1.55;
    color: var(--tx-p);
    background: var(--bg-t);
}

.fm-editor-box .cm-s-default .CodeMirror-gutters {
    background: var(--bg-s);
    border-right: 1px solid var(--bd);
}

.fm-editor-box .cm-s-default .CodeMirror-linenumber {
    color: var(--tx-t);
}

.fm-editor-box .cm-s-default .CodeMirror-activeline-background {
    background: color-mix(in srgb, var(--accent) 8%, transparent);
}

.fm-editor-box .cm-s-default .CodeMirror-activeline .CodeMirror-linenumber {
    color: var(--accent);
    font-weight: 600;
}

.fm-editor-box .cm-s-default .CodeMirror-cursor {
    border-left: 2px solid var(--accent);
}

.fm-editor-box .cm-s-default .CodeMirror-selected {
    background: color-mix(in srgb, var(--accent) 16%, transparent);
}

/* 暗色（dracula）：活动行补底色 */
.fm-editor-box .cm-s-dracula .CodeMirror-activeline-background {
    background: rgba(255, 255, 255, 0.06);
}

.fm-editor-box .CodeMirror {
    font-family: ui-monospace, "JetBrains Mono", "Cascadia Code", Consolas, monospace;
    font-size: 13px;
    line-height: 1.55;
}

/* 补全下拉与编辑器同风格 */
.fm-editor-box .CodeMirror-hints {
    z-index: 1300;
    font-family: ui-monospace, "JetBrains Mono", Consolas, monospace;
    font-size: 12.5px;
    border-radius: 8px;
    border: 1px solid var(--bd);
    box-shadow: 0 8px 24px -8px rgba(0, 0, 0, 0.25);
}

@media (max-width: 768px) {
    .fm2-status-dim {
        display: none;
    }
}

/* 状态栏保存按钮：紧凑，随状态栏高度 */
.fm-editor-savebtn {
    padding: 3px 14px;
    font-size: 12px;
    line-height: 1.4;
}

/* ════════════════ 在线预览模态（img/video/audio/PDF 原生标签） ════════════════ */
.fm-preview-modal .fm-preview-box {
    width: min(1080px, 94vw);
    height: min(720px, 88vh);
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
    border-radius: var(--radius-xl);
    border: 1px solid var(--bd);
    box-shadow: var(--shadow-hover);
    animation: modalIn 0.2s var(--ease-soft-spring) both;
}

/* ── 头部：类型图标 + 文件名/元信息 + 画廊导航/下载/关闭 ── */
.fm-preview-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--bd);
    flex-shrink: 0;
}

.fm-preview-icon {
    display: flex;
    align-items: center;
    color: var(--tx-s);
    flex-shrink: 0;
}

.fm-preview-icon svg {
    width: 20px;
    height: 20px;
}

.fm-preview-titles {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}

.fm-preview-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--tx-p);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.fm-preview-meta {
    font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
    font-size: 11px;
    color: var(--tx-t);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.fm-preview-hbtn {
    width: 30px;
    height: 30px;
    border-radius: 8px;
}

.fm-preview-hbtn svg {
    width: 15px;
    height: 15px;
}

/* ── 媒体区：次级底衬托，contain 自适应 ── */
.fm-preview-body {
    flex: 1;
    min-height: 0;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-s);
    overflow: hidden;
}

.fm-preview-media {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
}

.fm-preview-body iframe.fm-preview-media {
    width: 100%;
    height: 100%;
    flex: 1;
    border: 0;
    background: var(--bg-t);
}

/* 音频：大图标 + 原生控件 */
.fm-preview-audiowrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
    padding: 24px;
    width: 100%;
}

.fm-preview-audioicon {
    width: 64px;
    height: 64px;
    color: var(--tx-t);
}

.fm-preview-audiowrap audio {
    width: min(420px, 86%);
}

/* 加载骨架：呼吸态（设计语言·加载态规范） */
.fm-preview-loading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-s);
    z-index: 1;
    pointer-events: none;
}

.fm-preview-skel {
    width: 46%;
    height: 46%;
    min-width: 180px;
    min-height: 120px;
    border-radius: 14px;
    background: var(--bd);
    animation: fmPreviewBreath 1.2s ease-in-out infinite;
}

@keyframes fmPreviewBreath {
    0%,
    100% {
        opacity: 0.35;
    }

    50% {
        opacity: 0.7;
    }
}

@media (prefers-reduced-motion: reduce) {
    .fm-preview-skel {
        animation: none;
    }

    .fm-preview-modal .fm-preview-box {
        animation: none;
    }
}

/* ── 底部信息条 ── */
.fm-preview-footer {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 14px;
    border-top: 1px solid var(--bd);
    background: var(--bg-s);
    font-size: 12px;
    color: var(--tx-s);
    flex-shrink: 0;
    min-height: 31px;
}

.fm-preview-info {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.fm-preview-hint {
    color: var(--tx-t);
    flex-shrink: 0;
    font-size: 11.5px;
}

/* ── 移动端：全屏预览 ── */
@media (max-width: 768px) {
    .fm-preview-modal .fm-preview-box {
        width: 100%;
        height: 100%;
        max-height: none;
        border-radius: 0;
        border: none;
    }
}

/* ══════════ 移动端（≤768）：文件管理触控目标 ≥40px ══════════ */
@media (max-width: 768px) {
    .fm2-search {
        min-height: 40px;
        font-size: 16px; /* 防 iOS 聚焦自动放大 */
        flex: 1 1 120px;
        width: auto;
    }

    .fm2-toolbtn {
        width: 40px;
        height: 40px;
    }

    .fm2-rowmenu {
        width: 40px;
        height: 40px;
    }

    .fm2-previewbtn {
        width: 40px;
        height: 40px;
    }
}
