* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --ink-blue: #1f3b2a;
    --ink-blue-light: #2d6a4f;
    --accent-red: #4f9f6a;
    --accent-red-dark: #3c7a52;
    --warm-paper: #f4f1e5;
    --warm-paper-deep: #e7dfcf;
    --craft-brown: #b08968;
    --craft-brown-dark: #8f6340;
    --text-muted: #4a5b47;
    --border-soft: #d4c9b8;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(160deg, var(--warm-paper-deep) 0%, var(--warm-paper) 55%, #f0f7f2 100%);
    min-height: 100vh;
    padding: 16px;
}

.global-header {
    background: linear-gradient(120deg, var(--ink-blue) 0%, rgba(31, 59, 42, 0.92) 100%);
    border-radius: 0;
    box-shadow: 0 18px 36px rgba(31, 59, 42, 0.22);
    padding: 8px 16px;
    display: flex;
    align-items: center;
    margin: -16px -16px 24px -16px;
}

.global-header__link {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    color: #ffffff;
    text-decoration: none;
    font-weight: 600;
    font-size: 18px;
    letter-spacing: 0.4px;
}

.global-header__logo {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.25);
}

.global-header__title {
    white-space: nowrap;
}

.container {
    background: rgba(255, 255, 255, 0.96);
    border-radius: 14px;
    box-shadow: 0 24px 48px rgba(31, 59, 42, 0.16);
    max-width: 1000px;
    width: 100%;
    overflow: hidden;
    border: 1px solid var(--border-soft);
    position: relative;
    margin: 0 auto;
}

.container::before {
    content: '';
    position: absolute;
    inset: 0;
    border-left: 6px solid var(--accent-red);
    border-bottom: 1px solid rgba(79, 159, 106, 0.12);
    pointer-events: none;
    border-radius: 12px;
}

.header {
    background: linear-gradient(120deg, rgba(237, 248, 240, 0.92) 0%, rgba(228, 240, 232, 0.95) 100%);
    color: var(--ink-blue);
    padding: 32px;
    text-align: center;
    border-bottom: 1px solid rgba(47, 90, 63, 0.1);
}

.header h1 {
    font-size: 28px;
    margin-bottom: 10px;
    letter-spacing: 2px;
    text-transform: uppercase;
}

.header p {
    font-size: 13px;
    color: var(--text-muted);
    letter-spacing: 0.4px;
}

.upload-area {
    padding: 40px;
    text-align: center;
}

.upload-box {
    border: 3px dashed var(--craft-brown);
    border-radius: 10px;
    padding: 60px 40px;
    transition: all 0.3s ease;
    cursor: pointer;
    background: linear-gradient(135deg, var(--warm-paper) 0%, #f8fbf6 50%, rgba(255, 255, 255, 0.93) 100%);
    box-shadow: inset 0 2px 12px rgba(79, 159, 106, 0.08);
}

.upload-box:hover {
    border-color: var(--accent-red);
    background: #f4faf3;
    box-shadow: inset 0 4px 18px rgba(79, 159, 106, 0.1);
}

.upload-box.dragover {
    border-color: var(--accent-red-dark);
    background: linear-gradient(135deg, #dff2e6 0%, var(--warm-paper) 100%);
    transform: scale(1.02);
    box-shadow: inset 0 4px 20px rgba(79, 159, 106, 0.18);
}

.upload-icon {
    font-size: 48px;
    margin-bottom: 20px;
}

.upload-text {
    font-size: 18px;
    color: var(--ink-blue);
    margin-bottom: 10px;
    font-weight: 600;
}

.upload-subtext {
    font-size: 13px;
    color: rgba(47, 90, 63, 0.75);
}

#fileInput {
    display: none;
}

.tree-container {
    padding: 30px 40px;
    display: none;
    max-height: 650px;
    overflow-y: auto;
    background: linear-gradient(180deg, rgba(236, 247, 239, 0.94) 0%, rgba(229, 240, 232, 0.92) 100%);
}

.tree-container.active {
    display: block;
}

.tree-container::-webkit-scrollbar {
    width: 10px;
}

.tree-container::-webkit-scrollbar-track {
    background: #e9f2eb;
}

.tree-container::-webkit-scrollbar-thumb {
    background: rgba(47, 90, 63, 0.4);
    border-radius: 5px;
}

.tree-container::-webkit-scrollbar-thumb:hover {
    background: rgba(47, 90, 63, 0.65);
}

.tree {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

.tree-root {
    margin-bottom: 10px;
    font-size: 16px;
    font-weight: 700;
    color: var(--ink-blue);
    padding: 12px 18px;
    background: rgba(255, 255, 255, 0.92);
    border-radius: 10px;
    box-shadow: 0 6px 16px rgba(31, 59, 42, 0.14);
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid rgba(79, 159, 106, 0.28);
}

.tree-item {
    display: flex;
    align-items: center;
    padding: 6px 10px;
    margin: 2px 0;
    border-radius: 6px;
    transition: all 0.2s ease;
    cursor: pointer;
    position: relative;
}

.tree-item:hover {
    background: rgba(79, 159, 106, 0.12);
    transform: translateX(3px);
}

.tree-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: transparent;
    border-radius: 3px;
    transition: background 0.2s ease;
}

.tree-item:hover::before {
    background: var(--accent-red);
}

.tree-item.tree-item-previewable .tree-file {
    cursor: zoom-in;
}

.tree-indent {
    display: inline-flex;
    align-items: center;
    color: rgba(92, 80, 70, 0.3);
    font-family: monospace;
    user-select: none;
}

.tree-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    margin-right: 5px;
    cursor: pointer;
    user-select: none;
    font-size: 12px;
    color: var(--accent-red);
    transition: transform 0.2s ease;
}

.tree-toggle.collapsed {
    transform: rotate(-90deg);
}

.tree-icon {
    margin-right: 8px;
    font-size: 16px;
    display: inline-flex;
    align-items: center;
}

.tree-folder {
    color: var(--ink-blue-light);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 5px;
}

.tree-folder .folder-icon {
    color: var(--craft-brown);
}

.tree-file {
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 5px;
}

.tree-children {
    margin-left: 20px;
    border-left: 2px solid rgba(79, 159, 106, 0.24);
    padding-left: 10px;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease;
}

.tree-children.collapsed {
    max-height: 0 !important;
    opacity: 0;
    margin: 0;
    padding: 0;
}

.file-extension {
    font-size: 11px;
    color: rgba(47, 90, 63, 0.65);
    margin-left: 5px;
    font-weight: 500;
}

.reset-btn {
    margin: 20px 40px 30px;
    padding: 12px 30px;
    background: linear-gradient(135deg, var(--ink-blue) 0%, var(--ink-blue-light) 100%);
    color: #ffffff;
    border: 2px solid rgba(31, 59, 42, 0.85);
    border-radius: 6px;
    font-size: 16px;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    display: none;
}

.reset-btn.active {
    display: inline-block;
}

.reset-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(31, 59, 42, 0.35);
}

.stats {
    margin: 0 40px 20px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.92);
    border-radius: 8px;
    display: none;
    font-size: 14px;
    color: var(--text-muted);
    box-shadow: 0 8px 20px rgba(31, 59, 42, 0.12);
    display: none;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    border: 1px solid rgba(79, 159, 106, 0.24);
}

.stats.active {
    display: grid;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 10px;
}

.filter-area {
    margin: 0 40px 20px;
    padding: 18px 20px;
    background: rgba(255, 255, 255, 0.94);
    border-radius: 8px;
    display: none;
    flex-direction: column;
    gap: 12px;
    box-shadow: 0 8px 20px rgba(31, 59, 42, 0.12);
    border: 1px solid rgba(79, 159, 106, 0.25);
}

.filter-area.active {
    display: flex;
}

.filter-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.filter-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--ink-blue-light);
}

.filter-clear-btn {
    background: none;
    border: none;
    color: var(--accent-red);
    font-size: 13px;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 6px;
    transition: background 0.2s ease, color 0.2s ease;
}

.filter-clear-btn:hover {
    background: rgba(79, 159, 106, 0.14);
    color: var(--accent-red-dark);
}

.filter-summary {
    font-size: 13px;
    color: rgba(92, 80, 70, 0.75);
}

.filter-options {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}


.preview-toggle {
    margin: 12px 40px 25px;
    display: none;
    align-items: center;
    gap: 14px;
    color: rgba(31, 59, 42, 0.85);
    font-size: 14px;
}

.preview-toggle.active {
    display: flex;
}

.preview-toggle label {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    font-weight: 600;
    color: var(--ink-blue-light);
    user-select: none;
}

.preview-toggle input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}

.preview-toggle-control {
    position: relative;
    flex-shrink: 0;
    width: 48px;
    height: 26px;
    border-radius: 999px;
    background: rgba(79, 159, 106, 0.25);
    transition: background 0.25s ease, box-shadow 0.25s ease;
    box-shadow: inset 0 0 0 1px rgba(79, 159, 106, 0.45);
}

.preview-toggle-control::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #ffffff;
    box-shadow: 0 4px 10px rgba(31, 59, 42, 0.25);
    transition: transform 0.25s ease, background 0.25s ease;
}

.preview-toggle label:hover .preview-toggle-control {
    box-shadow: inset 0 0 0 1px rgba(79, 159, 106, 0.6);
}

.preview-toggle input[type="checkbox"]:checked + .preview-toggle-control {
    background: var(--accent-red);
    box-shadow: inset 0 0 0 1px rgba(31, 59, 42, 0.2);
}

.preview-toggle input[type="checkbox"]:checked + .preview-toggle-control::after {
    transform: translateX(22px);
    background: #edf9f1;
}

.preview-toggle label span:last-child {
    color: rgba(31, 59, 42, 0.92);
    letter-spacing: 0.2px;
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 999px;
    background: rgba(231, 244, 236, 0.9);
    border: 1px solid rgba(79, 159, 106, 0.45);
    font-size: 13px;
    color: var(--ink-blue-light);
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.filter-chip:hover {
    background: rgba(79, 159, 106, 0.16);
    border-color: var(--accent-red);
}

.filter-chip input {
    margin: 0;
}

.filter-empty {
    margin: 15px 0 0 18px;
    color: rgba(92, 80, 70, 0.55);
    font-size: 13px;
}

.stat-icon {
    font-size: 24px;
}

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-label {
    font-size: 12px;
    color: rgba(92, 80, 70, 0.6);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--accent-red);
}

.loading {
    text-align: center;
    padding: 40px;
    display: none;
    color: var(--accent-red);
    letter-spacing: 0.4px;
}

.loading.active {
    display: block;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--accent-red);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.expand-all-btn {
    margin: 0 40px 15px;
    padding: 8px 20px;
    background: rgba(255, 255, 255, 0.95);
    color: var(--ink-blue);
    border: 2px solid rgba(31, 59, 42, 0.25);
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: none;
}

.expand-all-btn.active {
    display: inline-block;
}

.expand-all-btn:hover {
    background: var(--ink-blue);
    color: #ffffff;
    border-color: rgba(31, 59, 42, 0.65);
}

.copy-actions {
    margin: 0 40px 25px;
    display: none;
    gap: 12px;
}

.copy-actions.active {
    display: flex;
    flex-wrap: wrap;
}

.copy-visible-btn {
    padding: 8px 20px;
    background: rgba(255, 255, 255, 0.95);
    color: var(--ink-blue-light);
    border: 2px solid rgba(79, 159, 106, 0.45);
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.copy-visible-btn:hover {
    background: rgba(79, 159, 106, 0.12);
    color: var(--accent-red-dark);
    border-color: var(--accent-red);
}

.image-preview {
    position: fixed;
    display: none;
    pointer-events: none;
    z-index: 1000;
    transform: translate3d(0, 0, 0);
}

.image-preview.active {
    display: block;
}

.image-preview-dialog {
    background: rgba(31, 59, 42, 0.96);
    color: #f4f8f5;
    border-radius: 10px;
    box-shadow: 0 12px 32px rgba(31, 59, 42, 0.4);
    max-width: 560px;
    min-width: 360px;
    max-height: 72vh;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px 16px 16px;
    pointer-events: none;
}

.image-preview-close {
    display: none;
}

.image-preview-meta {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.image-preview-name {
    font-size: 13px;
    font-weight: 600;
    word-break: break-all;
}

.image-preview-size {
    font-size: 11px;
    opacity: 0.75;
}

.image-preview-body {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: stretch;
    gap: 12px;
    max-height: 48vh;
    overflow: hidden;
}

.image-preview-body img {
    max-width: 100%;
    max-height: 48vh;
    border-radius: 6px;
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.35);
    align-self: center;
}

.preview-text {
    display: none;
    max-width: 100%;
    max-height: 48vh;
    overflow: auto;
    padding: 12px 14px;
    border-radius: 6px;
    background: rgba(27, 55, 39, 0.4);
    font-family: 'Fira Code', 'Source Code Pro', 'Consolas', monospace;
    font-size: 12px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
    color: #e9f7ed;
}

.preview-pdf {
    display: none;
    width: 100%;
    height: 60vh;
    border: none;
    border-radius: 6px;
    background: rgba(27, 55, 39, 0.6);
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.35);
}
