* {
    box-sizing: border-box;
}

html, body {
    height: 100%;
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", sans-serif;
    background: #1d1f27;
    color: #f1f3f5;
}

a {
    color: inherit;
    text-decoration: none;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.fm-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(17, 18, 26, 0.9);
    backdrop-filter: blur(8px);
    position: sticky;
    top: 0;
    z-index: 20;
}

.fm-header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.fm-header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.fm-breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
}

.fm-breadcrumb span {
    padding: 4px 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
}

.fm-breadcrumb span:hover {
    background: rgba(255, 255, 255, 0.08);
}

.fm-btn {
    border: none;
    border-radius: 6px;
    padding: 6px 14px;
    font-size: 14px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.08);
    color: inherit;
    transition: background 0.2s, transform 0.2s;
}

.fm-btn:hover {
    background: rgba(255, 255, 255, 0.16);
}

.fm-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.fm-btn.primary {
    background: #3d8bfd;
    color: #fff;
}

.fm-btn.primary:hover {
    background: #377df5;
}

.fm-btn.danger {
    background: #f06595;
    color: #fff;
}

.fm-btn.danger:hover {
    background: #e64980;
}

.fm-main {
    flex: 1;
    display: grid;
    grid-template-columns: 260px 1fr;
    overflow: hidden;
}

.fm-sidebar {
    border-right: 1px solid rgba(255, 255, 255, 0.06);
    padding: 16px 12px;
    overflow-y: auto;
    background: rgba(17, 18, 26, 0.92);
}

.fm-sidebar-title {
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 12px;
}

.fm-tree {
    list-style: none;
    padding-left: 0;
    margin: 0;
    font-size: 14px;
}

.fm-tree li {
    margin: 4px 0;
}

.fm-tree-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
}

.fm-tree-item:hover,
.fm-tree-item.active {
    background: rgba(255, 255, 255, 0.1);
}

.fm-tree-toggle {
    width: 16px;
    text-align: center;
    cursor: pointer;
    color: rgba(255, 255, 255, 0.6);
}

.fm-tree-children {
    list-style: none;
    padding-left: 16px;
    margin: 6px 0 0;
    border-left: 1px dashed rgba(255, 255, 255, 0.1);
}

.fm-content {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.fm-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(17, 18, 26, 0.8);
    backdrop-filter: blur(8px);
    position: sticky;
    top: 0;
    z-index: 10;
}

.fm-toolbar-right {
    display: flex;
    gap: 10px;
}

.fm-selection-info {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.65);
}

.fm-grid {
    flex: 1;
    padding: 18px;
    position: relative;
    overflow: auto;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 14px;
}

.fm-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid transparent;
    border-radius: 12px;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    justify-content: space-between;
    cursor: pointer;
    transition: border 0.2s, background 0.2s, transform 0.2s;
    user-select: none;
    aspect-ratio: 1;
}

.fm-card:hover {
    border-color: rgba(255, 255, 255, 0.16);
}

.fm-card.selected {
    border-color: #3d8bfd;
    background: rgba(61, 139, 253, 0.2);
}

.fm-card-icon {
    font-size: 32px;
}

.fm-card-name {
    font-size: 14px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.fm-card-meta {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
    line-height: 1.5;
}

.fm-status-bar {
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    padding: 8px 16px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.55);
    background: rgba(17, 18, 26, 0.8);
}

.fm-context-menu {
    position: fixed;
    z-index: 1000;
    background: rgba(17, 18, 26, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    padding: 6px 0;
    width: 180px;
    display: none;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

.fm-context-menu button {
    width: 100%;
    border: none;
    background: transparent;
    color: inherit;
    padding: 8px 16px;
    text-align: left;
    font-size: 14px;
    cursor: pointer;
}

.fm-context-menu button:hover {
    background: rgba(255, 255, 255, 0.1);
}

.fm-dialog-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1100;
}

.fm-dialog-backdrop[hidden] {
    display: none !important;
}

.fm-dialog {
    background: #1f212b;
    border-radius: 12px;
    padding: 24px;
    width: 360px;
    max-width: 92vw;
}

.fm-dialog h3 {
    margin: 0 0 16px;
}

.fm-dialog input,
.fm-dialog textarea {
    width: 100%;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.05);
    color: inherit;
    font-size: 14px;
}

.fm-dialog textarea {
    min-height: 120px;
    resize: vertical;
}

.fm-dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 20px;
}

.fm-selection-rect {
    position: absolute;
    border: 1px solid rgba(61, 139, 253, 0.8);
    background: rgba(61, 139, 253, 0.25);
    pointer-events: none;
    z-index: 50;
}

.fm-drop-overlay {
    position: absolute;
    inset: 0;
    border: 2px dashed rgba(61, 139, 253, 0.8);
    background: rgba(61, 139, 253, 0.12);
    display: none;
    justify-content: center;
    align-items: center;
    font-size: 16px;
    font-weight: 600;
    color: rgba(61, 139, 253, 0.9);
}

.fm-grid.drop-target .fm-drop-overlay {
    display: flex;
}
