:root {
    --theme-style: dark;
    --launcher-bg: #1a1a1a;
    --sidebar-bg: #1f1f1f;
    --main-bg: #242424;
    --modal-bg: #262626;
    --card-bg: #2d2d2d;
    --card-hover: #363636;
    
    --text-main: #d4d4d4;
    --text-muted: #8e8e8e;
    --text-bright: #ffffff;
    
    --border-main: #383838;
    --border-subtle: #2d2d2d;
    --border-highlight: #454545;
    
    --accent: #4a86e8;
    --accent-hover: #5b95f9;
    --link-color: #95c3d9;
    --link-hover: #b5e0f5;
    --danger: #e06c75;
    --danger-hover: #f07c85;
    
    --hover-bg: rgba(255, 255, 255, 0.07);
    --active-bg: rgba(255, 255, 255, 0.14);
    
    --folder-icon-color: #a0a0a0;
    
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-mono: "JetBrains Mono", Consolas, monospace;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body, html {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: var(--font-family);
    background-color: var(--launcher-bg);
    color: var(--text-main);
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}

.hidden {
    display: none !important;
}

.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.modal-window {
    background: var(--modal-bg);
    border: 1px solid var(--border-highlight);
    border-radius: 10px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
    width: 90%;
    max-width: 440px;
    overflow: hidden;
    animation: modalSlide 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.auth-card {
    max-width: 380px;
    padding: 24px;
}

.brand-badge {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-bright);
}

.brand-icon {
    color: var(--accent);
}

.auth-subtitle {
    margin-top: 10px;
    margin-bottom: 20px;
    color: var(--text-muted);
    font-size: 13px;
}

.input-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    margin-bottom: 6px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
}

.form-input, .form-textarea, select.form-input {
    width: 100%;
    padding: 10px 14px;
    background: #1a1a1a;
    border: 1px solid var(--border-main);
    border-radius: 6px;
    color: var(--text-bright);
    font-family: inherit;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s, background 0.2s;
}

select.form-input option {
    background: #1a1a1a;
    color: var(--text-bright);
}

.form-input:focus, .form-textarea:focus {
    border-color: var(--accent);
    background: #202020;
}

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

.error-text {
    color: var(--danger);
    font-size: 12px;
    margin-bottom: 12px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 18px;
    border-radius: 6px;
    border: none;
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-bright);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.18);
}

.btn-danger {
    background: rgba(224, 108, 117, 0.15);
    color: var(--danger);
}

.btn-danger:hover {
    background: rgba(224, 108, 117, 0.25);
}

.btn-block {
    width: 100%;
}

.btn-sm {
    padding: 5px 10px;
    font-size: 12px;
}

.app-layout {
    display: flex;
    width: 100vw;
    height: 100vh;
}

.launcher-ribbon {
    width: 58px;
    background: var(--launcher-bg);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    z-index: 10;
}

.launcher-top, .launcher-bottom {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ribbon-btn {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ribbon-btn:hover {
    background: var(--hover-bg);
    color: var(--text-bright);
}

.ribbon-btn.active {
    background: var(--active-bg);
    color: var(--accent);
}

.sidebar-pane {
    width: 280px;
    min-width: 180px;
    max-width: 600px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    user-select: none;
    position: relative;
}

.sidebar-resizer {
    width: 6px;
    height: 100vh;
    background: transparent;
    cursor: col-resize;
    z-index: 20;
    user-select: none;
    margin-left: -3px;
    margin-right: -3px;
    transition: background 0.15s ease;
}

.sidebar-resizer:hover, .sidebar-resizer.resizing {
    background: var(--accent);
}

.sidebar-header {
    padding: 14px;
    border-bottom: 1px solid var(--border-subtle);
}

.search-box {
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 10px;
    color: var(--text-muted);
    pointer-events: none;
}

.search-input {
    width: 100%;
    padding: 7px 12px 7px 32px;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border-main);
    border-radius: 6px;
    color: var(--text-main);
    font-size: 13px;
    outline: none;
}

.search-input:focus {
    border-color: var(--accent);
    color: var(--text-bright);
}

.sidebar-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-subtle);
}

.sidebar-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.icon-btn:hover {
    background: var(--hover-bg);
    color: var(--text-bright);
}

.tree-view {
    flex: 1;
    overflow-y: auto;
    padding: 8px 4px;
}

.tree-view::-webkit-scrollbar {
    width: 6px;
}

.tree-view::-webkit-scrollbar-thumb {
    background: var(--border-main);
    border-radius: 3px;
}

.tree-item {
    display: flex;
    align-items: center;
    padding: 5px 8px;
    border-radius: 5px;
    cursor: pointer;
    margin-bottom: 1px;
    font-size: 13px;
    color: var(--text-main);
    transition: background 0.15s ease;
}

.tree-item:hover {
    background: var(--hover-bg);
    color: var(--text-bright);
}

.tree-item.active {
    background: var(--active-bg);
    color: var(--text-bright);
    font-weight: 500;
}

.tree-toggle {
    width: 16px;
    height: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-right: 4px;
    color: var(--text-muted);
    transition: transform 0.15s ease;
    cursor: pointer;
}

.tree-toggle:hover {
    color: var(--text-bright);
}

.tree-toggle.expanded {
    transform: rotate(90deg);
}

.tree-icon {
    margin-right: 8px;
    color: var(--folder-icon-color);
    display: inline-flex;
    align-items: center;
}

.note-icon {
    color: var(--link-color);
}

.tree-label {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tree-badge {
    font-size: 10px;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-muted);
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: 6px;
}

.tree-actions {
    display: none;
    gap: 2px;
}

.tree-item:hover .tree-actions {
    display: flex;
}

.tree-children {
    margin-left: 16px;
}

.content-pane {
    flex: 1;
    background: var(--main-bg);
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.content-header {
    height: 50px;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    background: rgba(0, 0, 0, 0.1);
}

.breadcrumbs {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-muted);
}

.crumb-separator {
    color: var(--border-main);
}

.crumb-link {
    cursor: pointer;
    transition: color 0.15s ease;
}

.crumb-link:hover {
    color: var(--link-color);
    text-decoration: underline;
}

.crumb-active {
    color: var(--text-bright);
    font-weight: 500;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.workspace-body {
    flex: 1;
    overflow-y: auto;
    padding: 30px 40px;
}

.workspace-body::-webkit-scrollbar {
    width: 8px;
}

.workspace-body::-webkit-scrollbar-thumb {
    background: var(--border-main);
    border-radius: 4px;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    text-align: center;
}

.empty-icon {
    margin-bottom: 16px;
    color: var(--border-main);
}

.empty-state h1 {
    font-size: 20px;
    color: var(--text-bright);
    margin-bottom: 8px;
}

.folder-workspace {
    max-width: 100%;
}

.folder-header-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 20px;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border-subtle);
}

.folder-header-title-box {
    display: flex;
    align-items: center;
    gap: 16px;
}

.folder-header-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 54px;
    height: 54px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-main);
    border-radius: 12px;
    color: var(--folder-icon-color);
}

.folder-main-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-bright);
}

.folder-main-subtitle {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 4px;
}

.folder-header-action-btns {
    display: flex;
    align-items: center;
    gap: 10px;
}

.folder-content-section {
    margin-bottom: 32px;
}

.section-heading {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-bright);
    margin-bottom: 14px;
}

.main-grid-layout {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
}

.main-folder-card {
    background: var(--card-bg);
    border: 1px solid var(--border-main);
    border-radius: 10px;
    padding: 0 !important;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.main-folder-card-preview-thumb {
    width: 100% !important;
    aspect-ratio: 3 / 2 !important;
    height: auto !important;
    object-fit: cover !important;
    border: none !important;
    border-bottom: 1px solid var(--border-subtle) !important;
    background: var(--card-bg) !important;
    display: block !important;
}

.main-folder-card-body {
    padding: 16px !important;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    flex: 1;
    min-height: 90px;
}

.main-folder-card:hover {
    background: var(--card-hover);
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

.main-folder-card-top {
    display: flex;
    align-items: center;
    gap: 10px;
}

.main-folder-card-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-bright);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.main-folder-card-count {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 8px;
}

.main-note-card {
    background: var(--card-bg);
    border: 1px solid var(--border-main);
    border-radius: 10px !important;
    padding: 0 !important;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    overflow: hidden !important;
    position: relative !important;
}

.main-note-card:hover {
    background: var(--card-hover);
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.card-external-link-btn {
    position: absolute !important;
    top: 10px !important;
    right: 10px !important;
    z-index: 10 !important;
    width: 32px !important;
    height: 32px !important;
    border-radius: 50% !important;
    border: 1px solid var(--border-main) !important;
    background: rgba(30, 30, 30, 0.85) !important;
    backdrop-filter: blur(4px) !important;
    color: var(--text-bright) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    opacity: 0 !important;
    transition: all 0.2s ease !important;
}

.main-note-card:hover .card-external-link-btn {
    opacity: 1 !important;
}

.card-external-link-btn:hover {
    background: var(--accent) !important;
    border-color: var(--accent) !important;
    transform: scale(1.1) !important;
}

.main-note-card-preview-thumb {
    width: 100% !important;
    aspect-ratio: 3 / 2 !important;
    height: auto !important;
    object-fit: cover !important;
    border: none !important;
    border-bottom: 1px solid var(--border-subtle) !important;
    border-radius: 9px 9px 0 0 !important;
    background: var(--card-bg) !important;
    display: block !important;
}

.main-note-card-body {
    padding: 12px 14px !important;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 2;
    background: var(--card-bg);
}

.main-note-card-text-preview {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.4;
    max-height: 48px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.main-note-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
}

.main-note-card-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-bright);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.note-viewer {
    max-width: 100%;
}

.note-title {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-bright);
    margin-bottom: 12px;
    line-height: 1.3;
}

.note-meta {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 24px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    gap: 16px;
}

.note-content {
    font-size: 15px;
    line-height: 1.7;
    color: var(--text-main);
    word-break: break-word;
}

.tg-link-preview-card {
    background: #2a2a2a;
    border: 1px solid var(--border-main);
    border-left: 4px solid var(--accent);
    border-radius: 8px;
    overflow: hidden;
    margin: 16px 0;
    text-decoration: none !important;
    display: flex;
    flex-direction: column;
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.tg-link-preview-card:hover {
    border-color: var(--accent-hover);
    transform: translateY(-1px);
}

.tg-preview-banner {
    width: 100% !important;
    max-height: 520px !important;
    object-fit: contain !important;
    background: #141414 !important;
    cursor: zoom-in !important;
}

.tg-preview-content {
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.tg-preview-domain {
    font-size: 12px;
    font-weight: 600;
    color: var(--accent);
}

.tg-preview-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-bright);
    line-height: 1.3;
}

.tg-preview-desc {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.4;
    max-height: 60px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
}

.media-preview-container {
    margin: 16px 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.media-image-preview {
    max-width: 100%;
    max-height: 480px;
    border-radius: 8px;
    border: 1px solid var(--border-highlight);
    cursor: zoom-in;
    object-fit: contain;
    background: #000;
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.media-image-preview:hover {
    transform: scale(1.01);
    border-color: var(--accent);
}

.media-video-player {
    width: 100%;
    max-height: 480px;
    border-radius: 8px;
    border: 1px solid var(--border-highlight);
    background: #000;
    outline: none;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-subtle);
    background: rgba(0, 0, 0, 0.15);
}

.modal-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-bright);
    margin: 0;
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    padding: 14px 20px;
    background: rgba(0, 0, 0, 0.15);
    border-top: 1px solid var(--border-subtle);
}

.lightbox-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

#lightbox-img {
    max-width: 90vw;
    max-height: 88vh;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8);
    object-fit: contain;
}

.lightbox-close {
    position: absolute;
    top: -40px;
    right: 0;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    padding: 6px;
}

.lightbox-close:hover {
    background: rgba(255, 255, 255, 0.4);
}

@keyframes modalSlide {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.tree-item.drag-over, .main-folder-card.drag-over, .main-note-card.drag-over {
    background: rgba(74, 134, 232, 0.25) !important;
    border: 1.5px dashed var(--accent) !important;
}

.tree-item.dragging, .main-folder-card.dragging, .main-note-card.dragging {
    opacity: 0.5;
}
