/* Styles for /files (moved out of the page so browsers can cache them) */
        :root { --color-danger: #ef4444; --color-gold: #b07d00; }

        @media (prefers-color-scheme: dark) {
            :root { --color-gold: #f5c542; }
        }

        * { margin: 0; padding: 0; box-sizing: border-box; }
        [hidden] { display: none !important; }

        body {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
            background-color: var(--color-light);
            color: var(--color-text);
            line-height: 1.6;
        }

        a { color: var(--color-link); }

        /* ── Header ── */
        header { background: var(--color-white); box-shadow: var(--shadow-sm); position: sticky; top: 0; z-index: 100; }
        nav { display: flex; justify-content: space-between; align-items: center; padding: 1rem 2rem; max-width: 1200px; margin: 0 auto; gap: 1rem; }
        .logo { display: flex; align-items: center; gap: 0.5rem; font-size: 1.5rem; font-weight: 700; color: var(--color-primary); text-decoration: none; flex-shrink: 0; }
        .nav-right { display: flex; gap: 0.75rem; align-items: center; }

        /* ── Buttons ── */
        .btn {
            display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
            height: 40px; padding: 0 1.1rem; border: none; border-radius: 8px; cursor: pointer;
            font: inherit; font-weight: 600; font-size: 0.95rem; text-decoration: none; white-space: nowrap;
            transition: background-color 0.2s ease, box-shadow 0.2s ease;
        }
        .btn:disabled { opacity: 0.6; cursor: not-allowed; }
        .btn-primary { background: var(--color-primary); color: #fff; }
        .btn-primary:hover:not(:disabled) { background: var(--color-accent); }
        .btn-secondary { background: var(--color-light); color: var(--color-text); box-shadow: inset 0 0 0 1px var(--color-border); }
        .btn-secondary:hover:not(:disabled) { background: var(--color-tint); }
        .btn-danger { background: #c81e1e; color: #fff; }
        .btn-ghost-danger { background: none; color: var(--color-danger); box-shadow: inset 0 0 0 1px rgba(239, 68, 68, 0.35); }
        .btn-ghost-danger:hover { background: rgba(239, 68, 68, 0.08); }
        .btn-sm { height: 32px; padding: 0 0.75rem; font-size: 0.85rem; }
        .save-btn.saved { color: var(--color-link); }
        .save-btn.saved .lbl { font-weight: 700; }
        .btn-locked { background: rgba(217, 154, 0, 0.12); color: var(--color-gold); }
        a.btn-locked:hover { background: rgba(217, 154, 0, 0.22); }

        /* ── Hero ── */
        .page-hero {
            background: linear-gradient(135deg, #134a38 0%, #1a654c 55%, #1f6a50 100%);
            color: #fff; padding: 3rem 2rem 4.5rem; text-align: center;
        }
        .page-hero h1 { font-size: 2.25rem; font-weight: 800; line-height: 1.3; margin-bottom: 0.5rem; }
        .page-hero p { font-size: 1.1rem; max-width: 640px; margin: 0 auto; }

        /* ── Layout ── */
        .container {
            max-width: 1200px; margin: -2.5rem auto 3rem; padding: 0 2rem; position: relative;
            display: grid; grid-template-columns: 270px minmax(0, 1fr); gap: 1.5rem; align-items: start;
        }
        .card { background: var(--color-white); border-radius: 12px; box-shadow: var(--shadow-sm); }

        /* ── Sidebar ── */
        .sidebar { display: flex; flex-direction: column; gap: 1rem; position: sticky; top: 90px; }
        .side-card { padding: 1.1rem; }
        .side-card h3, .side-card .side-title { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.6px; color: var(--color-gray); margin-bottom: 0.6rem; }

        .tree { list-style: none; }
        .tree ul { list-style: none; padding-left: 0.9rem; border-left: 1px solid var(--color-border); margin-left: 0.6rem; }
        .tree button {
            display: flex; align-items: center; gap: 0.45rem; width: 100%; text-align: left;
            background: none; border: none; font: inherit; font-size: 0.92rem; color: var(--color-text);
            padding: 0.35rem 0.5rem; border-radius: 6px; cursor: pointer;
        }
        .tree button:hover { background: var(--color-tint); }
        .tree button.active { background: var(--color-tint); color: var(--color-link); font-weight: 700; }
        .tree .lock { margin-left: auto; font-size: 0.75rem; display: inline-flex; }
        .tree button svg { flex-shrink: 0; }

        .tag-cloud { display: flex; flex-wrap: wrap; gap: 0.35rem; }

        .tag {
            display: inline-flex; align-items: center; gap: 0.3rem;
            padding: 0.12rem 0.55rem; border-radius: 999px;
            background: var(--color-tint); color: var(--color-link);
            font-size: 0.78rem; font-weight: 600; border: none; font-family: inherit; cursor: pointer;
        }
        .tag:hover, .tag.active { background: var(--color-primary); color: #fff; }
        .tag .count { opacity: 0.7; font-weight: 500; }

        .pro-card { background: #134a38; color: #fff; }
        .pro-card h3 { color: rgba(255,255,255,0.85); }
        .pro-card p { font-size: 0.9rem; }
        .pro-card a { color: #f2b134; font-weight: 700; }

        /* ── Admin bar ── */
        .admin-bar {
            display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap;
            padding: 0.75rem; margin-bottom: 1rem; box-shadow: var(--shadow-md);
            border: 1px solid color-mix(in srgb, #f5b301 45%, transparent);
        }
        .admin-bar .label { font-size: 0.8rem; font-weight: 800; color: var(--color-gold); text-transform: uppercase; letter-spacing: 0.06em; margin-right: 0.25rem; }
        .admin-bar .stats { margin-left: auto; font-size: 0.85rem; color: var(--color-gray); }

        /* ── Toolbar ── */
        /* Breadcrumb and search sit on the page, not in a box of their own */
        .card.toolbar { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; padding: 0.25rem 0 0; margin-bottom: 1.1rem; background: none; border: none; box-shadow: none; }
        .toolbar .search { background: var(--color-white); box-shadow: var(--shadow-sm); }
        .crumbs { display: flex; align-items: center; flex-wrap: wrap; gap: 0.25rem; font-size: 0.95rem; flex: 1 1 260px; min-width: 0; }
        .crumbs button { background: none; border: none; font: inherit; color: var(--color-link); cursor: pointer; padding: 0.15rem 0.3rem; border-radius: 4px; }
        .crumbs button:hover { background: var(--color-tint); }
        .crumbs .current { font-weight: 700; color: var(--color-heading); padding: 0.15rem 0.3rem; }
        .crumbs .sep { color: var(--color-gray); }

        .input, .select, .textarea {
            font: inherit; font-size: 0.95rem; color: var(--color-text); background: var(--color-white);
            border: 1px solid var(--color-border); border-radius: 8px; padding: 0 0.75rem; height: 40px; width: 100%;
        }
        .textarea { height: auto; padding: 0.6rem 0.75rem; resize: vertical; line-height: 1.5; }
        .input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(31, 106, 80, 0.15); }
        .toolbar .search { flex: 0 1 260px; }

        .filter-note { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; margin: -0.25rem 0 1rem; font-size: 0.9rem; color: var(--color-gray); }

        .folder-head { padding: 1.1rem 1.25rem; margin-bottom: 1rem; display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; flex-wrap: wrap; }
        .folder-head h2 { font-size: 1.3rem; color: var(--color-heading); display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
        .folder-head p { color: var(--color-gray); font-size: 0.95rem; margin-top: 0.2rem; }

        .section-title { font-size: 1.05rem; color: var(--color-heading); margin: 0.4rem 0 0.7rem 0.1rem; font-weight: 800; }

        /* ── Folders ── */
        .folder-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0.75rem; margin-bottom: 1.5rem; }
        .folder-card {
            position: relative; margin-top: 0.7rem; border-top-left-radius: 0;
            padding: 1rem; cursor: pointer; display: flex; flex-direction: column; gap: 0.25rem;
            transition: box-shadow 0.2s ease, transform 0.2s ease; text-align: left; border: none; font: inherit; color: inherit;
        }
        .folder-card:hover { box-shadow: var(--shadow-md); }
        .folder-card::before { content: ''; position: absolute; left: 0; top: -0.7rem; width: 42%; max-width: 9rem; height: 0.75rem; background: inherit; border-radius: 8px 10px 0 0; box-shadow: 0 -1px 0 var(--color-border), -1px 0 0 var(--color-border), 1px 0 0 var(--color-border); }
        .folder-card .top { display: flex; align-items: flex-start; gap: 0.5rem; }
        .folder-card .icon { line-height: 1; color: var(--color-link); display: inline-flex; }
        .folder-card .icon svg { width: 22px; height: 22px; }
        .folder-card .name { font-weight: 700; color: var(--color-heading); overflow-wrap: anywhere; }
        .folder-card .meta { font-size: 0.82rem; color: var(--color-gray); }
        .folder-card .admin-actions { display: flex; gap: 0.35rem; margin-top: 0.35rem; }

        /* ── Files ── */
        .file-list { display: flex; flex-direction: column; gap: 0.6rem; }
        .file {
            display: grid; grid-template-columns: 46px minmax(0, 1fr) auto; gap: 0.9rem; align-items: center;
            padding: 0.9rem 1rem;
        }
        .file.locked { opacity: 0.85; }
        .file-icon {
            width: 46px; height: 54px; border-radius: 8px; display: flex; align-items: flex-end; justify-content: center;
            padding-bottom: 0.4rem; font-size: 0.68rem; font-weight: 800; color: #fff; letter-spacing: 0.03em;
            background: #64748b; position: relative;
        }
        .file-icon::before { content: ''; position: absolute; top: 0; right: 0; border-style: solid; border-width: 0 12px 12px 0; border-color: transparent var(--color-white) rgba(255,255,255,0.4) transparent; }
        .ft-pdf { background: #dc2626; }
        .ft-doc { background: #2563eb; }
        .ft-ppt { background: #ea580c; }
        .ft-xls { background: #16a34a; }
        .ft-img { background: #9333ea; }
        .ft-zip { background: #78716c; }
        .ft-av { background: #db2777; }
        .file h3 { font-size: 1rem; color: var(--color-heading); line-height: 1.35; overflow-wrap: anywhere; display: flex; align-items: center; flex-wrap: wrap; gap: 0.4rem; }
        .file .desc { font-size: 0.88rem; color: var(--color-gray); margin-top: 0.15rem; overflow-wrap: anywhere; }
        .file .meta { font-size: 0.8rem; color: var(--color-gray); margin-top: 0.3rem; display: flex; flex-wrap: wrap; gap: 0.25rem 0.75rem; align-items: center; }
        .file .tags { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-top: 0.4rem; }
        .file-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; justify-content: flex-end; }

        .badge { display: inline-flex; align-items: center; gap: 0.2rem; font-size: 0.72rem; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; line-height: 1; padding: 0.22rem 0.42rem; border-radius: 4px; white-space: nowrap; }
        .badge-pro { color: #fff; background: var(--color-dark); }
        @media (prefers-color-scheme: dark) { .badge-pro { background: #1a654c; } }

        /* ── States ── */
        .empty { text-align: center; padding: 3rem 1.5rem; color: var(--color-gray); }
        .empty .icon { font-size: 2.5rem; margin-bottom: 0.5rem; }
        .empty h3 { color: var(--color-heading); margin-bottom: 0.25rem; }
        .skeleton { height: 80px; margin-bottom: 0.6rem; background: linear-gradient(90deg, var(--color-white) 0%, var(--color-tint) 50%, var(--color-white) 100%); background-size: 200% 100%; animation: shimmer 1.4s infinite; }
        @keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

        /* ── Modals ── */
        .modal { position: fixed; inset: 0; background: rgba(29, 27, 22, 0.55); display: flex; align-items: center; justify-content: center; padding: 1rem; z-index: 1000; }
        .modal-content { background: var(--color-white); border-radius: 14px; box-shadow: var(--shadow-lg); width: 100%; max-width: 560px; max-height: calc(100vh - 2rem); overflow-y: auto; padding: 1.5rem; }
        .modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
        .modal-header h2 { font-size: 1.25rem; color: var(--color-heading); }
        .modal-close { background: none; border: none; font-size: 1.6rem; line-height: 1; color: var(--color-gray); cursor: pointer; width: 36px; height: 36px; border-radius: 8px; }
        .modal-close:hover { background: var(--color-light); }
        .form-grid { display: flex; flex-direction: column; gap: 0.9rem; }
        .field label { display: block; font-weight: 600; font-size: 0.9rem; margin-bottom: 0.35rem; color: var(--color-heading); }
        .field .hint { font-size: 0.8rem; color: var(--color-gray); margin-top: 0.3rem; }
        .field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.9rem; }
        .modal-actions { display: flex; justify-content: flex-end; gap: 0.6rem; margin-top: 0.5rem; flex-wrap: wrap; }

        .dropzone {
            border: 2px dashed var(--color-border); border-radius: 12px; padding: 1.5rem; text-align: center;
            color: var(--color-gray); cursor: pointer; transition: border-color 0.2s ease, background-color 0.2s ease;
        }
        .dropzone:hover, .dropzone.over { border-color: var(--color-primary); background: var(--color-tint); }
        .dropzone strong { color: var(--color-link); }
        .dropzone input { display: none; }

        .upload-list { list-style: none; display: flex; flex-direction: column; gap: 0.5rem; }
        .upload-item { padding: 0.6rem 0.75rem; border-radius: 8px; background: var(--color-light); }
        .upload-item .row { display: flex; gap: 0.5rem; align-items: center; }
        .upload-item .input { height: 34px; font-size: 0.9rem; }
        .upload-item .size { font-size: 0.78rem; color: var(--color-gray); white-space: nowrap; }
        .upload-item .remove { background: none; border: none; font-size: 1.2rem; color: var(--color-gray); cursor: pointer; width: 28px; }
        .progress { height: 6px; border-radius: 999px; background: var(--color-border); overflow: hidden; margin-top: 0.4rem; }
        .progress span { display: block; height: 100%; width: 0; background: var(--color-primary); transition: width 0.2s ease; }
        .upload-item.done .progress span { background: var(--color-primary); }
        .upload-item.failed .progress span { background: var(--color-danger); width: 100% !important; }
        .upload-item .status { font-size: 0.78rem; margin-top: 0.25rem; color: var(--color-gray); }
        .upload-item.failed .status { color: var(--color-danger); }

        .tag-manager { list-style: none; display: flex; flex-direction: column; gap: 0.5rem; max-height: 50vh; overflow-y: auto; }
        .tag-manager li { display: flex; gap: 0.5rem; align-items: center; }
        .tag-manager .count { font-size: 0.8rem; color: var(--color-gray); white-space: nowrap; width: 4.5rem; }

        .gate { text-align: center; padding: 3rem 2rem; grid-column: 1 / -1; }
        .gate .icon { font-size: 3rem; }
        .gate h2 { color: var(--color-heading); margin: 0.5rem 0; }
        .gate p { color: var(--color-gray); margin-bottom: 1.25rem; }

        .toasts { position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 0.5rem; z-index: 2000; width: max-content; max-width: calc(100vw - 2rem); }
        .toast { background: var(--color-dark); color: #fff; padding: 0.75rem 1.1rem; border-radius: 10px; box-shadow: var(--shadow-lg); font-weight: 500; font-size: 0.92rem; }
        .toast.error { background: #b91c1c; }

        @media (max-width: 900px) {
            .container { grid-template-columns: minmax(0, 1fr); }
            .sidebar { position: static; order: 2; }
        }

        @media (max-width: 600px) {
            nav { padding: 0.75rem 1rem; }
            .logo { font-size: 1.25rem; }
            .logo svg { width: 32px; height: 32px; }
            .hide-sm { display: none; }
            .page-hero { padding: 2.25rem 1.25rem 3.75rem; }
            .page-hero h1 { font-size: 1.75rem; }
            .container { padding: 0 0.75rem; }
            .toolbar .search { flex: 1 1 100%; }
            .file { grid-template-columns: 40px minmax(0, 1fr); }
            .file-icon { width: 40px; height: 48px; }
            .file-actions { grid-column: 1 / -1; justify-content: flex-start; }
            .field-row { grid-template-columns: 1fr; }
            .admin-bar .stats { margin-left: 0; width: 100%; }
        }
    

        /* Pro files: how they're protected (shown to Pro members wherever Pro files are listed) */
        .pro-notice { display: flex; gap: 0.6rem; align-items: flex-start; padding: 0.8rem 1rem; border-left: 3px solid var(--color-gold); }
        .pro-notice svg { flex: none; margin-top: 0.15rem; color: var(--color-gold); }
        .pro-notice p { margin: 0; font-size: 0.9rem; line-height: 1.5; }
        /* Admin: trace a shared file */
        .trace-intro { margin: 0; color: var(--color-gray); font-size: 0.9rem; }
        #traceResult .muted { color: var(--color-gray); font-size: 0.85rem; }
        #traceResult .error-text { color: var(--color-danger); }
        .trace-table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
        .trace-table th, .trace-table td { text-align: left; padding: 0.45rem 0.5rem; border-bottom: 1px solid var(--color-border, rgba(0,0,0,.1)); vertical-align: top; }
        .trace-table code { font-size: 0.82rem; word-break: break-all; }
        .tag-cloud .tag-more { font-weight: 700; background: transparent; border-style: dashed; }
