:root {
    --bg: #12131a;
    --surface: #1b1d28;
    --surface-hover: #22243333;
    --border: #2c2f3d;
    --text: #edeef3;
    --text-muted: #8b8fa3;
    --accent: #e8a33d;
    --accent-dim: #7a5824;
    --danger: #e0604f;
    --radius: 10px;
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-sans);
    -webkit-font-smoothing: antialiased;
}

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

button, input {
    font-family: inherit;
    font-size: inherit;
    color: inherit;
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Topbar */

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--bg);
    z-index: 10;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 16px;
    letter-spacing: 0.01em;
}

.brand-mark {
    color: var(--accent);
    letter-spacing: -2px;
    font-size: 14px;
}

/* Layout */

.wrap {
    max-width: 1080px;
    margin: 0 auto;
    padding: 24px 20px 64px;
}

.breadcrumb {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 20px;
}

.crumb { color: var(--text-muted); padding: 2px 4px; border-radius: 4px; }
.crumb:hover { color: var(--text); }
.crumb.is-current { color: var(--accent); }
.crumb-sep { opacity: 0.4; }

.flash {
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: 14px;
    margin-bottom: 18px;
    border: 1px solid transparent;
}
.flash-ok { background: rgba(232, 163, 61, 0.1); border-color: var(--accent-dim); color: var(--accent); }
.flash-err { background: rgba(224, 96, 79, 0.1); border-color: var(--danger); color: var(--danger); }

/* Toolbar */

.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 28px;
}

.inline-form {
    display: flex;
    gap: 8px;
    flex: 1 1 260px;
}

.inline-form input[type="text"] {
    flex: 1;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 12px;
    color: var(--text);
}

.inline-form input[type="text"]::placeholder { color: var(--text-muted); }

.file-picker {
    flex: 1;
    display: flex;
    align-items: center;
    background: var(--surface);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    padding: 10px 12px;
    color: var(--text-muted);
    cursor: pointer;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}
.file-picker input { display: none; }

/* Buttons */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    border-radius: var(--radius);
    padding: 10px 16px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.btn-primary { background: var(--accent); color: #1a1200; }
.btn-primary:hover { background: #f0ae4d; }

.btn-outline { background: transparent; border-color: var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }

.btn-ghost { background: transparent; color: var(--text-muted); padding: 8px 14px; }
.btn-ghost:hover { color: var(--text); }

.btn-danger { background: var(--danger); color: #2a0d08; }
.btn-danger:hover { background: #ea7b6c; }

.btn-block { width: 100%; margin-top: 6px; }

/* Grid & cards */

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 14px;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    position: relative;
    overflow: hidden;
    transition: border-color 0.15s ease;
}
.card:hover { border-color: #3a3d4f; }

.card-folder { border-left: 3px solid var(--accent); }

.card-open {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 18px 14px 44px;
    min-height: 96px;
}

.card-icon { font-size: 26px; line-height: 1; }

.card-name {
    font-size: 13.5px;
    font-family: var(--font-mono);
    word-break: break-word;
    line-height: 1.4;
}

.card-meta {
    font-size: 11.5px;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.card-actions {
    position: absolute;
    bottom: 8px;
    right: 8px;
    display: flex;
    gap: 4px;
}

.icon-btn {
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text-muted);
    border-radius: 6px;
    width: 26px;
    height: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 13px;
}
.icon-btn:hover { color: var(--text); border-color: var(--accent); }
.icon-btn-danger:hover { color: var(--danger); border-color: var(--danger); }

.empty-state {
    color: var(--text-muted);
    font-size: 14px;
    padding: 40px 0;
    text-align: center;
}

/* Modals */

.modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(6, 6, 10, 0.72);
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 100;
}
.modal-backdrop.is-open { display: flex; }

.modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    width: 100%;
    max-width: 720px;
    position: relative;
}
.modal-small { max-width: 380px; }

.modal h2 {
    margin: 0 0 14px;
    font-size: 16px;
    font-family: var(--font-mono);
}

.modal p { color: var(--text-muted); font-size: 14px; line-height: 1.5; }

.modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 22px;
    cursor: pointer;
    line-height: 1;
}
.modal-close:hover { color: var(--text); }

.modal video {
    width: 100%;
    max-height: 60vh;
    border-radius: 6px;
    background: #000;
    display: block;
}

.modal form input[type="text"] {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 12px;
    color: var(--text);
}

/* Login */

.login-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-card {
    width: 100%;
    max-width: 340px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px 28px;
    text-align: center;
}

.login-mark {
    color: var(--accent);
    font-size: 18px;
    letter-spacing: -2px;
    margin-bottom: 10px;
}

.login-card h1 { font-size: 19px; margin: 0 0 6px; }
.login-sub { color: var(--text-muted); font-size: 13.5px; margin: 0 0 22px; }

.login-card input[type="password"] {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 11px 12px;
    color: var(--text);
    margin-bottom: 12px;
    text-align: center;
}

.login-error {
    color: var(--danger);
    font-size: 13px;
    margin-bottom: 14px;
}

/* Responsive */

@media (max-width: 640px) {
    .topbar { padding: 14px 16px; }
    .wrap { padding: 18px 14px 48px; }
    .toolbar { flex-direction: column; }
    .inline-form { flex: 1 1 auto; }
    .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
    .card-open { padding: 14px 12px 40px; min-height: 78px; }
    .modal { padding: 18px; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; }
}
