/* Minimal stylesheet — system fonts only, single-column responsive layout. */

:root {
    --bg: #ffffff;
    --fg: #1f2328;
    --muted: #656d76;
    --border: #d0d7de;
    --link: #0969da;
    --accent: #0969da;
    --card: #f6f8fa;
    --code-bg: #f6f8fa;
    --ln: #8c959f;
    /* syntax tokens — GitHub Primer (light) */
    --tok-com:  #6e7781;
    --tok-str:  #0a3069;
    --tok-num:  #0550ae;
    --tok-kw:   #cf222e;
    --tok-var:  #953800;
    --tok-fn:   #8250df;
    --tok-tag:  #116329;
    --tok-attr: #0550ae;
    --tok-sel:  #8250df;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0d1117;
        --fg: #e6edf3;
        --muted: #8b949e;
        --border: #30363d;
        --link: #58a6ff;
        --accent: #58a6ff;
        --card: #161b22;
        --code-bg: #161b22;
        --ln: #6e7681;
        /* syntax tokens — GitHub Primer (dark) */
        --tok-com:  #8b949e;
        --tok-str:  #a5d6ff;
        --tok-num:  #79c0ff;
        --tok-kw:   #ff7b72;
        --tok-var:  #ffa657;
        --tok-fn:   #d2a8ff;
        --tok-tag:  #7ee787;
        --tok-attr: #79c0ff;
        --tok-sel:  #d2a8ff;
    }
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--fg);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.5;
    font-size: 16px;
}

.wrap {
    width: 100%;
    max-width: 960px;
    margin: 0 auto;
    padding: 0 16px;
}

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Header / footer */
.site-header {
    border-bottom: 1px solid var(--border);
    background: var(--card);
}
.site-header .wrap {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
}
.brand { font-weight: 700; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: var(--fg); }
.site-header nav a { color: var(--muted); }
main.wrap { padding-top: 24px; padding-bottom: 48px; min-height: 60vh; }
.site-footer { border-top: 1px solid var(--border); color: var(--muted); font-size: 14px; }
.site-footer .wrap { padding-top: 16px; padding-bottom: 16px; }

/* Typography */
h1 { font-size: 1.6rem; margin: 0 0 12px; }
h2 { font-size: 1.2rem; margin: 24px 0 12px; }
.muted { color: var(--muted); font-size: 0.9rem; }
.empty { color: var(--muted); font-style: italic; }

.crumbs { color: var(--muted); font-size: 0.9rem; margin-bottom: 8px; }
.file-meta { margin-bottom: 8px; }

/* Badges */
.badge {
    display: inline-block;
    font-size: 0.75rem;
    padding: 2px 8px;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--muted);
    vertical-align: middle;
    margin-left: 6px;
}

/* Repo list */
.repo-list { list-style: none; padding: 0; margin: 0; }
.repo-item { padding: 16px 0; border-bottom: 1px solid var(--border); }
.repo-name { font-size: 1.15rem; font-weight: 600; }
.repo-desc { margin: 6px 0; }

/* Tables */
.file-table { width: 100%; border-collapse: collapse; margin-top: 8px; }
.file-table th, .file-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.file-table th { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); }
.actions a, .actions form { margin-right: 10px; display: inline-block; }

/* Cards & forms */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 24px;
}
.form label { display: block; margin-bottom: 12px; font-size: 0.9rem; color: var(--muted); }
.form input[type=text], .form input[type=password], .form select, .form textarea {
    display: block;
    width: 100%;
    margin-top: 4px;
    padding: 8px 10px;
    font-size: 1rem;
    color: var(--fg);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-family: inherit;
}
.form textarea { resize: vertical; }

button, .btn-secondary {
    display: inline-block;
    padding: 8px 16px;
    font-size: 0.95rem;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--accent);
    color: #fff;
    cursor: pointer;
    font-family: inherit;
}
.btn-secondary { background: transparent; color: var(--fg); }
button:hover { opacity: 0.9; }
.row { display: flex; gap: 10px; align-items: center; }

.inline { display: inline; margin: 0; }
.link-btn {
    background: none;
    border: none;
    color: var(--link);
    padding: 0;
    cursor: pointer;
    font-size: inherit;
}
.link-btn.danger, .danger { color: #cf222e; }

.admin-bar { display: flex; align-items: center; justify-content: space-between; }

/* Notices */
.notice { background: #dafbe1; color: #116329; padding: 8px 12px; border-radius: 6px; }
.error  { background: #ffebe9; color: #cf222e; padding: 8px 12px; border-radius: 6px; }
@media (prefers-color-scheme: dark) {
    .notice { background: #12261e; color: #7ee787; }
    .error  { background: #2d1214; color: #ff7b72; }
}

/* Drag & drop */
.dropzone {
    border: 2px dashed var(--border);
    border-radius: 8px;
    padding: 24px;
    text-align: center;
    margin-bottom: 16px;
    transition: border-color 0.15s, background 0.15s;
}
.dropzone.over { border-color: var(--accent); background: rgba(9,105,218,0.06); }
.dropzone-buttons { justify-content: center; gap: 12px; flex-wrap: wrap; margin-top: 12px; }
.file-pick { cursor: pointer; }
.dir { margin-right: 2px; }
.file-names { list-style: none; padding: 0; margin: 12px 0 0; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.85rem; }

/* Code view */
.code-view {
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow-x: auto;
    background: var(--code-bg);
}
table.code {
    border-collapse: collapse;
    width: 100%;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
    font-size: 0.85rem;
}
table.code td { padding: 0; vertical-align: top; }
table.code td.ln {
    width: 1%;
    min-width: 42px;
    text-align: right;
    padding: 0 12px;
    color: var(--ln);
    user-select: none;
    white-space: nowrap;
    border-right: 1px solid var(--border);
}
table.code td.cl { padding-left: 14px; width: 100%; }
table.code pre {
    margin: 0;
    padding: 0;
    min-height: 1.35em;
    line-height: 1.35;
    white-space: pre;
    font-family: inherit;
    color: var(--fg);
}

/* Syntax tokens */
.tok-com  { color: var(--tok-com); font-style: italic; }
.tok-str  { color: var(--tok-str); }
.tok-num  { color: var(--tok-num); }
.tok-kw   { color: var(--tok-kw); }
.tok-var  { color: var(--tok-var); }
.tok-fn   { color: var(--tok-fn); }
.tok-tag  { color: var(--tok-tag); }
.tok-attr { color: var(--tok-attr); }
.tok-sel  { color: var(--tok-sel); }

/* File tree (shared by folder listing and file-view sidebar) */
.hidden { display: none !important; }
.tree-icon { margin-right: 4px; }
ul.tree { list-style: none; margin: 0; padding: 0; }
ul.tree ul.tree { margin-left: 18px; border-left: 1px solid var(--border); padding-left: 6px; }
.tree li { padding: 3px 0; font-size: 0.95rem; }
.tree-dir > details > summary {
    list-style: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 2px;
}
.tree-dir > details > summary::-webkit-details-marker { display: none; }
.tree-caret {
    display: inline-block;
    width: 14px;
    color: var(--muted);
    transition: transform 0.12s ease;
}
.tree-caret::before { content: "\25B8"; } /* ▸ */
.tree-dir > details[open] > summary .tree-caret { transform: rotate(90deg); }
.tree-file.active > a { font-weight: 600; color: var(--fg); }
.tree-up { padding: 3px 0 6px; margin-left: 16px; }
.tree-listing { margin-top: 8px; }

/* File view: sidebar + content two-column layout */
.file-layout { display: flex; gap: 16px; align-items: flex-start; }
.file-sidebar {
    flex: 0 0 240px;
    max-width: 240px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--card);
    padding: 10px;
    position: sticky;
    top: 12px;
    max-height: 80vh;
    overflow: auto;
}
.tree-search {
    width: 100%;
    margin-bottom: 8px;
    padding: 6px 8px;
    font-size: 0.85rem;
    color: var(--fg);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-family: inherit;
}
.file-main { flex: 1 1 auto; min-width: 0; }
.file-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; flex-wrap: wrap; }
.file-actions { display: flex; gap: 8px; }
.file-actions .btn-secondary { padding: 4px 12px; font-size: 0.85rem; }

/* Image viewer */
.image-view {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 24px;
    text-align: center;
    background-color: #fff;
    background-image:
        linear-gradient(45deg, #eee 25%, transparent 25%),
        linear-gradient(-45deg, #eee 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #eee 75%),
        linear-gradient(-45deg, transparent 75%, #eee 75%);
    background-size: 16px 16px;
    background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}
.image-view img { max-width: 100%; height: auto; }

/* README */
.readme {
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-top: 24px;
    overflow: hidden;
}
.readme-head {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    padding: 10px 16px;
    font-size: 0.9rem;
    font-weight: 600;
}
.readme-body { padding: 8px 24px 24px; }

/* Rendered markdown */
.markdown h1, .markdown h2, .markdown h3 { margin: 20px 0 12px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.markdown h1 { font-size: 1.5rem; }
.markdown h2 { font-size: 1.25rem; }
.markdown h3 { font-size: 1.05rem; border-bottom: none; }
.markdown p { margin: 12px 0; }
.markdown ul, .markdown ol { padding-left: 24px; }
.markdown blockquote { margin: 12px 0; padding: 0 14px; color: var(--muted); border-left: 3px solid var(--border); }
.markdown code {
    background: var(--code-bg);
    border-radius: 6px;
    padding: 2px 6px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.85em;
}
.markdown pre.md-code {
    background: var(--code-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px;
    overflow-x: auto;
}
.markdown pre.md-code code { background: none; padding: 0; font-size: 0.85rem; }
.markdown img { max-width: 100%; }
.markdown hr { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

@media (max-width: 600px) {
    body { font-size: 15px; }
    .site-header .wrap { height: 48px; }
    table.code { font-size: 0.75rem; }
    .file-layout { flex-direction: column; }
    .file-sidebar {
        flex-basis: auto;
        max-width: none;
        width: 100%;
        position: static;
        max-height: 40vh;
    }
    .readme-body { padding: 8px 14px 16px; }
}
