/* ==========================================================================
   MyFileDump theme — green terminal aesthetic, dark (default) + light mode.
   Switched via <html data-theme="dark|light"> (localStorage: mfd-theme).
   ========================================================================== */

/* Author display rules (.modal { display: grid }) would otherwise defeat the
   UA stylesheet's [hidden] handling — keep every [hidden] element truly gone. */
[hidden] {
    display: none !important;
}

:root,
[data-theme="dark"] {
    color-scheme: dark;

    --bg: #050805;
    --bg-raise: #0a120a;
    --bg-inset: #030603;
    --fg: #33ff66;
    --fg-bright: #00ff41;
    --fg-dim: #1f7a3d;
    --fg-muted: #4a8f5e;
    --border: #1d5c2e;
    --border-strong: #2c8747;

    --accent: #00ff41;
    --accent-soft: rgba(0, 255, 65, 0.12);

    --danger: #ff5555;
    --danger-soft: rgba(255, 85, 85, 0.12);

    --shadow: 0 0 0 1px rgba(0, 255, 65, 0.06), 0 8px 28px rgba(0, 0, 0, 0.55);
    --scanline: rgba(0, 255, 65, 0.025);

    --font: ui-monospace, "Cascadia Mono", "JetBrains Mono", Menlo, Consolas,
            "DejaVu Sans Mono", "Liberation Mono", monospace;
}

[data-theme="light"] {
    color-scheme: light;

    --bg: #eef3ec;
    --bg-raise: #f8fbf7;
    --bg-inset: #ffffff;
    --fg: #14571b;
    --fg-bright: #0b6623;
    --fg-dim: #7fa886;
    --fg-muted: #5c7d64;
    --border: #bcd4bd;
    --border-strong: #8fb995;

    --accent: #0b6623;
    --accent-soft: rgba(11, 102, 35, 0.08);

    --danger: #b3261e;
    --danger-soft: rgba(179, 38, 30, 0.08);

    --shadow: 0 0 0 1px rgba(20, 87, 27, 0.06), 0 6px 22px rgba(20, 87, 27, 0.10);
    --scanline: rgba(20, 87, 27, 0.02);
}

/* --- base ---------------------------------------------------------------- */
* { box-sizing: border-box; }

html { height: 100%; }

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    color: var(--fg);
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

/* faint CRT scanlines over everything, never intercepting clicks */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 999;
    background: repeating-linear-gradient(
        to bottom,
        transparent 0px, transparent 2px,
        var(--scanline) 3px
    );
}

::selection { background: var(--accent-soft); color: var(--fg-bright); }

a { color: var(--fg-bright); text-decoration: none; }
a:hover { text-decoration: underline; text-decoration-color: var(--fg-dim); }

h1, h2, h3 { color: var(--fg-bright); font-weight: 600; }
h1 { font-size: 20px; margin: 0 0 6px; }
h2 { font-size: 15px; margin: 0 0 10px; }
code {
    font-family: var(--font);
    background: var(--bg-inset);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 1px 5px;
    font-size: 0.92em;
}
pre code { border: 0; padding: 0; background: transparent; }

.hl { color: var(--fg-bright); }
.muted { color: var(--fg-muted); font-size: 0.92em; }
.hint { color: var(--fg-muted); font-size: 0.88em; margin: 6px 0 0; }

/* --- layout --------------------------------------------------------------- */
.wrap {
    width: min(1080px, calc(100% - 32px));
    margin: 22px auto 40px;
    flex: 1;
}

.page-head { margin-bottom: 18px; }
.page-head h1::after {
    content: "▊";
    color: var(--fg-bright);
    animation: blink 1.2s steps(2) infinite;
    margin-left: 4px;
}
@keyframes blink { 50% { opacity: 0; } }

.footer {
    border-top: 1px solid var(--border);
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    gap: 12px;
    font-size: 12px;
    color: var(--fg-muted);
}

/* --- top bar ---------------------------------------------------------------- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 10px 16px;
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: blur(6px);
    border-bottom: 1px solid var(--border);
}

.brand {
    display: inline-flex;
    align-items: baseline;
    gap: 8px;
    font-weight: 700;
    color: var(--fg-bright);
    white-space: nowrap;
}
.brand:hover { text-decoration: none; }
.brand-glyph { color: var(--fg); }
.brand-name { letter-spacing: 0.5px; }

.nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav a {
    color: var(--fg);
    padding: 4px 10px;
    border: 1px solid transparent;
    border-radius: 4px;
}
.nav a:hover { border-color: var(--border-strong); text-decoration: none; background: var(--accent-soft); }

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.whoami { color: var(--fg-muted); white-space: nowrap; font-size: 12px; }
.admin-flag {
    display: inline-block;
    margin-left: 6px;
    padding: 0 6px;
    border: 1px solid var(--border-strong);
    border-radius: 3px;
    color: var(--fg-bright);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    background: var(--accent-soft);
}
.you-flag { color: var(--fg-muted); font-size: 11px; }

/* --- buttons ------------------------------------------------------------------ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-family: var(--font);
    font-size: 13px;
    color: var(--fg);
    background: var(--bg-raise);
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    padding: 6px 12px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    white-space: nowrap;
}
.btn:hover {
    background: var(--accent-soft);
    border-color: var(--fg-bright);
    color: var(--fg-bright);
    text-decoration: none;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { color: #03130a; background: var(--fg-bright); border-color: var(--fg-bright); font-weight: 700; }
.btn-primary:hover { color: #03130a; background: var(--fg-bright); filter: brightness(1.15); }
[data-theme="light"] .btn-primary { color: #f2f7f0; }
[data-theme="light"] .btn-primary:hover { color: #f2f7f0; }
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-danger { color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); color: var(--danger); }
.btn-sm { padding: 2px 8px; font-size: 12px; }
.btn-block { width: 100%; }

.inline-form { display: inline-flex; gap: 6px; margin: 0; }

/* --- forms ---------------------------------------------------------------------- */
label {
    font-size: 12px;
    color: var(--fg-muted);
    display: block;
    margin-bottom: 4px;
    letter-spacing: 0.4px;
}

input[type="text"], input[type="password"], input[type="search"],
input[type="number"], select, textarea {
    width: 100%;
    font-family: var(--font);
    font-size: 13px;
    color: var(--fg-bright);
    background: var(--bg-inset);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 8px 10px;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
    border-color: var(--fg-bright);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
input::placeholder { color: var(--fg-dim); }

.stack { display: flex; flex-direction: column; gap: 10px; }
.stack .btn { margin-top: 4px; }
.form-row { display: flex; gap: 10px; }
.form-col { flex: 1; min-width: 0; }
.checkline { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--fg); cursor: pointer; }
.checkline input { width: auto; }

/* --- flash messages ---------------------------------------------------------------- */
.flash {
    position: fixed;
    top: 58px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 200;
    display: flex;
    align-items: center;
    gap: 14px;
    max-width: min(680px, calc(100% - 32px));
    padding: 10px 14px;
    border-radius: 4px;
    font-size: 13px;
    box-shadow: var(--shadow);
    animation: slide-in 0.18s ease-out;
}
@keyframes slide-in { from { opacity: 0; transform: translate(-50%, -8px); } }
.flash-success { background: var(--bg-raise); border: 1px solid var(--fg-bright); color: var(--fg-bright); }
.flash-error { background: var(--bg-raise); border: 1px solid var(--danger); color: var(--danger); }
.flash.fade { opacity: 0; transition: opacity 0.8s; }
.flash-close {
    background: none;
    border: 0;
    color: inherit;
    font-size: 15px;
    cursor: pointer;
    padding: 0 2px;
    font-family: var(--font);
}

/* --- cards / generic surfaces -------------------------------------------------------- */
.card {
    background: var(--bg-raise);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 18px;
    box-shadow: var(--shadow);
}
.card-title { border-bottom: 1px dashed var(--border); padding-bottom: 8px; margin-bottom: 14px; }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.kv dt { color: var(--fg-muted); font-size: 12px; }
.kv dd { margin: 0; color: var(--fg); word-break: break-word; }

.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { text-align: center; padding: 14px 10px; }
.stat-num { font-size: 22px; color: var(--fg-bright); font-weight: 700; }
.stat-label { color: var(--fg-muted); font-size: 11px; text-transform: uppercase; letter-spacing: 1px; }

/* --- toolbar / search / tag cloud ---------------------------------------------------- */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}
.search-form { display: flex; gap: 8px; align-items: center; }
.search-form input[type="search"] { width: 240px; }

.tag-cloud { display: flex; flex-wrap: wrap; gap: 6px; }
.tagchip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    color: var(--fg);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 1px 9px;
    background: var(--bg-inset);
}
.tagchip span { color: var(--fg-muted); font-size: 10px; }
.tagchip:hover { border-color: var(--fg-bright); color: var(--fg-bright); text-decoration: none; }
.tagchip.active {
    border-color: var(--fg-bright);
    color: var(--fg-bright);
    background: var(--accent-soft);
}

/* --- file table ------------------------------------------------------------------------ */
.file-table, .user-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-raise);
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
    font-size: 13px;
}
.file-table th, .user-table th {
    text-align: left;
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--fg-muted);
    background: var(--bg-inset);
    border-bottom: 1px solid var(--border);
    padding: 8px 12px;
}
.file-table td, .user-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.file-table tbody tr:last-child td, .user-table tbody tr:last-child td { border-bottom: 0; }
.file-table tbody tr:hover td { background: var(--accent-soft); }

.col-size, .col-date { color: var(--fg-muted); white-space: nowrap; }
.col-actions { text-align: right; white-space: nowrap; }
.f-icon { color: var(--fg-bright); margin-right: 8px; }
.fname { word-break: break-all; }
.empty-row td { text-align: center; padding: 26px 12px; }

.u-name a { font-weight: 600; }
.u-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }

/* --- upload zone ------------------------------------------------------------------------- */
.upload { margin-bottom: 18px; }
.upload-inner {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px;
    border: 1px dashed var(--border-strong);
    border-radius: 6px;
    transition: background 0.15s, border-color 0.15s;
}
.upload.drag .upload-inner {
    background: var(--accent-soft);
    border-color: var(--fg-bright);
}
.upload-glyph { font-size: 26px; color: var(--fg-bright); }
.upload-tags { margin-top: 12px; }
.upload-tags input { margin-top: 4px; }

.upload-progress { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.up-row {
    display: grid;
    grid-template-columns: minmax(120px, 1fr) minmax(80px, 240px) max-content;
    align-items: center;
    gap: 10px;
    font-size: 12px;
}
.up-name { word-break: break-all; }
.up-bar {
    height: 8px;
    background: var(--bg-inset);
    border: 1px solid var(--border);
    border-radius: 999px;
    overflow: hidden;
}
.up-fill {
    display: block;
    height: 100%;
    width: 0;
    background: repeating-linear-gradient(
        90deg,
        var(--fg-bright) 0 8px,
        var(--fg-dim) 8px 10px
    );
    transition: width 0.15s;
}
.up-status { color: var(--fg-muted); min-width: 70px; text-align: right; }
.up-done .up-status { color: var(--fg-bright); }
.up-error .up-status, .up-error .up-name { color: var(--danger); }

.linklike { display: inline; color: var(--fg-bright); text-decoration: underline; cursor: pointer; }
.upload input[type="file"] { display: none; }

.upload-expiry { margin-top: 12px; }
.upload-expiry select, .modal-box select { max-width: 280px; }

.temp-chip {
    display: inline-block;
    margin-left: 10px;
    padding: 0 8px;
    font-size: 10px;
    letter-spacing: 0.4px;
    color: var(--fg-muted);
    border: 1px dashed var(--border-strong);
    border-radius: 999px;
    white-space: nowrap;
    vertical-align: middle;
}

/* --- login audit ---------------------------------------------------------------------------- */
.audit-card { margin-top: 16px; }
.audit-outcome {
    display: inline-block;
    padding: 1px 8px;
    font-size: 10px;
    letter-spacing: 0.4px;
    border-radius: 3px;
    border: 1px solid var(--border);
}
.audit-outcome.ok { color: var(--fg-bright); border-color: var(--border-strong); }
.audit-outcome.no  { color: var(--danger); border-color: var(--danger); }
.audit-agent { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --- modals ------------------------------------------------------------------------------ */
.modal {
    position: fixed;
    inset: 0;
    z-index: 300;
    display: grid;
    place-items: center;
    background: rgba(1, 4, 2, 0.72);
    backdrop-filter: blur(3px);
}
[data-theme="light"] .modal { background: rgba(20, 40, 24, 0.35); }
.modal-box {
    width: min(720px, calc(100% - 32px));
    max-height: min(640px, calc(100vh - 48px));
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.modal-box-narrow { width: min(460px, calc(100% - 32px)); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.modal-title { margin: 0; font-size: 15px; word-break: break-all; }
.modal-filter { margin-bottom: 2px; }
.modal-actions { display: flex; justify-content: flex-end; }

/* --- archive tree --------------------------------------------------------------------------- */
.archive-tree {
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-inset);
    padding: 8px 10px;
    min-height: 120px;
    font-size: 12px;
}
.archive-tree details { margin-left: 0; }
.archive-tree details details { margin-left: 16px; }
.arc-dir { cursor: pointer; color: var(--fg-bright); padding: 2px 0; user-select: none; }
.arc-dir:hover { text-decoration: underline; }
.arc-dir::marker { color: var(--fg-dim); }
.arc-dir-body { margin-left: 14px; }
.arc-file {
    display: grid;
    grid-template-columns: 1fr max-content max-content;
    gap: 12px;
    padding: 1px 0;
}
.arc-name { word-break: break-all; }
.arc-size, .arc-date { color: var(--fg-muted); white-space: nowrap; }
.arc-empty { padding: 20px 0; text-align: center; }
.arc-error { color: var(--danger); }

/* --- markdown viewer -------------------------------------------------------------------------- */
.md-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 16px;
}
.md-head-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.md-filename { margin: 0; word-break: break-all; }
.md-head-right { display: flex; gap: 8px; }
.md-raw {
    background: var(--bg-inset);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 16px;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-word;
    color: var(--fg);
    font-size: 13px;
    margin: 0;
}

.markdown {
    background: var(--bg-raise);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 26px 30px;
    font-size: 14px;
    line-height: 1.7;
    overflow-wrap: break-word;
}
.markdown > :first-child { margin-top: 0; }
.markdown > :last-child { margin-bottom: 0; }
.markdown h1, .markdown h2, .markdown h3,
.markdown h4, .markdown h5, .markdown h6 {
    border-bottom: 1px dashed var(--border);
    padding-bottom: 4px;
    margin: 22px 0 10px;
}
.markdown h1 { font-size: 19px; }
.markdown h2 { font-size: 17px; }
.markdown h3 { font-size: 15px; }
.markdown p { margin: 10px 0; }
.markdown ul, .markdown ol { margin: 10px 0; padding-left: 26px; }
.markdown li { margin: 3px 0; }
.markdown blockquote {
    margin: 12px 0;
    padding: 8px 16px;
    border-left: 3px solid var(--fg-bright);
    background: var(--bg-inset);
    color: var(--fg);
}
.markdown pre {
    background: var(--bg-inset);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 12px 14px;
    overflow: auto;
    margin: 12px 0;
    font-size: 13px;
}
.markdown img { max-width: 100%; border: 1px solid var(--border); border-radius: 4px; }
.markdown table { border-collapse: collapse; margin: 12px 0; font-size: 13px; width: 100%; }
.markdown th, .markdown td { border: 1px solid var(--border); padding: 6px 10px; }
.markdown th { background: var(--bg-inset); color: var(--fg-bright); }
.markdown hr { border: 0; border-top: 1px dashed var(--border-strong); margin: 18px 0; }
.markdown del { color: var(--fg-muted); }

/* --- profile ------------------------------------------------------------------------------------ */
.profile-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.profile-card { text-align: center; }
.avatar {
    width: 72px;
    height: 72px;
    margin: 6px auto 12px;
    display: grid;
    place-items: center;
    border: 1px solid var(--border-strong);
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--fg-bright);
    font-size: 24px;
    font-weight: 700;
}
.profile-name { margin: 0; }
.profile-card .kv { text-align: left; margin-top: 16px; }
.profile-links { margin-top: 16px; }

/* --- admin ---------------------------------------------------------------------------------------- */
.admin-grid {
    display: grid;
    grid-template-columns: minmax(320px, 5fr) minmax(360px, 7fr);
    gap: 16px;
    align-items: start;
}
.admin-grid .card-title:not(:first-child) { margin-top: 22px; }

/* --- auth ------------------------------------------------------------------------------------------ */
.auth-card { max-width: 400px; margin: 8vh auto 0; text-align: center; }
.auth-glyph { font-size: 30px; color: var(--fg-bright); margin-bottom: 6px; }
.auth-title { margin-bottom: 4px; }
.auth-card form { text-align: left; margin-top: 18px; }
.auth-foot { margin-top: 16px; font-size: 11px; }

/* --- error page -------------------------------------------------------------------------------------- */
.error-card { max-width: 460px; margin: 10vh auto 0; text-align: center; }
.error-code {
    font-size: 52px;
    color: var(--fg-dim);
    font-weight: 700;
    letter-spacing: 4px;
    text-shadow: 0 0 18px var(--accent-soft);
}
.error-title { margin: 6px 0; }
.error-message { color: var(--fg-muted); }
.error-actions { display: flex; gap: 10px; justify-content: center; margin-top: 16px; }

/* --- responsive ---------------------------------------------------------------------------------------- */
@media (max-width: 860px) {
    .profile-grid, .admin-grid { grid-template-columns: 1fr; }
    .topbar { flex-wrap: wrap; }
    .topbar-right { margin-left: 0; width: 100%; justify-content: flex-end; }
}
@media (max-width: 640px) {
    .search-form input[type="search"] { width: 150px; }
    .file-table th.col-tags, .file-table td.col-tags { display: none; }
    .form-row { flex-direction: column; }
    .up-row { grid-template-columns: 1fr max-content; }
    .up-bar { display: none; }
}





