*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --sidebar-width: 280px;
    --mono: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;

    --bg: #ffffff;
    --sidebar-bg: #f6f8fa;
    --border: #e1e4e8;
    --text: #24292e;
    --muted: #586069;
    --link: #0366d6;
    --btn-bg: #fafbfc;
    --btn-border: #d1d5da;
    @media (prefers-color-scheme: dark) {
        --bg: #0d1117;
        --sidebar-bg: #161b22;
        --border:     #30363d;
        --text:       #e6edf3;
        --muted:      #8b949e;
        --link:       #58a6ff;
        --btn-bg:     #21262d;
        --btn-border: #30363d;
    }
}

html, body {
    background: var(--bg);
    height: 100%;
}

body {
  font-family: var(--sans);
  color: var(--text);
  overflow: hidden;
}

input[type="checkbox"][disabled] {
  appearance: none;
}
input[type="checkbox"][disabled]::before {
  color: var(--text);
  content: "☐";
}
input[type="checkbox"][disabled][checked]::before {
  content: "☑";
}

/* ── Layout ─────────────────────────────────────────────────────────────── */

#app {
  display: flex;
  height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────────────────────────────── */

#sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#sidebar-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 0;
}

#nav-toggle { display: none; }

#file-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px 0;
}

#file-list ul {
  list-style: none;
}

/* indent nested directories */
#file-list ul ul {
  padding-left: 14px;
}

.file-item a,
.dir-toggle {
  display: block;
  padding: 3px 16px;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
  text-decoration: none;
  user-select: none;
  border-radius: 4px;
  margin: 0 4px;
}

.file-item a:hover,
.dir-toggle:hover {
  background: #e8ebf0;
  color: var(--link);
}

.file-item a.active {
  background: #dce9f8;
  color: var(--link);
  font-weight: 500;
}

.dir-toggle {
  font-weight: 600;
  color: var(--muted);
}

.dir-toggle::before {
  display: inline-block;
  width: 1em;
  content: '▾';
  font-size: 10px;
  margin-right: 2px;
}

.dir-item.collapsed > .dir-toggle::before { content: '▸'; }
.dir-item.collapsed > ul { display: none; }

/* ── Content area ────────────────────────────────────────────────────────── */

main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* Toolbar */
#toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 16px;
  background: var(--sidebar-bg);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 8px;
}

#current-path {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#toolbar-buttons {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

button {
  padding: 4px 12px;
  font-size: 12px;
  font-family: var(--sans);
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  border-radius: 6px;
  cursor: pointer;
  color: var(--text);
  white-space: nowrap;
}

button:hover { background: #e8ebf0; }
button:active { background: #d9dde3; }

#content {
    line-height: 1.7;
    font-size: 15px;
    flex: 1;
    overflow: auto;
    padding: 28px 40px;

    :is(h1, h2, h3, h4, h5, h6) {
        margin-top: 1.4em;
        margin-bottom: 0.5em;
        line-height: 1.3;
    }


    h1:first-child,
    h2:first-child { margin-top: 0; }

    h1 { font-size: 1.8em; border-bottom: 1px solid var(--border); padding-bottom: 0.3em; }
    h2 { font-size: 1.4em; border-bottom: 1px solid var(--border); padding-bottom: 0.3em; }
    h3 { font-size: 1.15em; }

    p { margin-bottom: 1em; }

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

    pre {
        font-family: var(--mono);
        border: 1px solid var(--border);
        border-radius: 6px;
        margin-bottom: 1em;
        line-height: 1.5;
        font-size: 13px;
        padding: 0.5em;
    }

    [data-name="Preview"] {
        height: 100%;
    }
    [data-name="Preview"][data-ext="md"] {
        max-width: 40em;
    }

    embed {
        height: 100%;
        width: 100%;
    }

    img {
        max-width: 100%;
        max-height: 100%;
    }

    img { max-width: 100%; height: auto; }

    ul,
    ol {
        padding-left: 2em;
        margin-bottom: 1em;
    }

    li { margin-bottom: 0.25em; }

    blockquote {
        border-left: 4px solid var(--border);
        padding: 0 1em;
        color: var(--muted);
        margin: 0 0 1em;
    }

    table {
        border-collapse: collapse;
        margin-bottom: 1em;
        font-size: 14px;
    }

    th,
    td {
        border: 1px solid var(--border);
        padding: 6px 13px;
        text-align: left;
    }

    th { background: var(--sidebar-bg); font-weight: 600; }
    tr:nth-child(even) { background: var(--sidebar-bg); }

    hr {
        border: none;
        border-top: 1px solid var(--border);
        margin: 1.5em 0;
    }
}

/* ── Visibility ──────────────────────────────────────────────────────────── */

.hidden { display: none !important; }

#content > *:not(.active) { display: none; }


#raw-view {
  display: none;
  flex: 1;
  width: 100%;
  padding: 20px 24px;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.6;
  border: none;
  resize: none;
  outline: none;
  background: var(--bg);
  color: var(--text);
  tab-size: 4;
}

/* Error state */
.load-error {
  color: #cb2431;
  padding: 24px;
  font-size: 14px;
}

/* ── Sidebar overlay (mobile) ────────────────────────────────────────────── */

#sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 99;
}

#sidebar-overlay.visible { display: block; }

/* ── Mobile header ───────────────────────────────────────────────────────── */

#mobile-header {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--sidebar-bg);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

#mobile-repo-name {
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Narrow-screen layout ────────────────────────────────────────────────── */

@media (max-width: 700px) {
  #mobile-header { display: flex; }

  #sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 100;
    width: min(var(--sidebar-width), 85vw);
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }

  #sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 16px rgba(0, 0, 0, 0.2);
  }
}

/* ── Sidebar footer ──────────────────────────────────────────────────────── */

#sidebar-footer {
  flex-shrink: 0;
  padding: 8px 10px;
  border-top: 1px solid var(--border);
  font-size: 12px;
}

#sidebar-footer button {
  width: 100%;
  text-align: left;
  color: var(--muted);
}




/* Base16 Atelier Cave Light - Theme */
/* by Bram de Haan (http://atelierbram.github.io/syntax-highlighting/atelier-schemes/cave) */
/* Original Base16 color scheme by Chris Kempson (https://github.com/chriskempson/base16) */

/* Atelier-Cave Comment */
.hljs-comment,
.hljs-quote {
  color: #655f6d;
}

/* Atelier-Cave Red */
.hljs-variable,
.hljs-template-variable,
.hljs-attribute,
.hljs-tag,
.hljs-name,
.hljs-regexp,
.hljs-link,
.hljs-name,
.hljs-name,
.hljs-selector-id,
.hljs-selector-class {
  color: #be4678;
}

/* Atelier-Cave Orange */
.hljs-number,
.hljs-meta,
.hljs-built_in,
.hljs-builtin-name,
.hljs-literal,
.hljs-type,
.hljs-params {
  color: #aa573c;
}

/* Atelier-Cave Green */
.hljs-string,
.hljs-symbol,
.hljs-bullet {
  color: #2a9292;
}

/* Atelier-Cave Blue */
.hljs-title,
.hljs-section {
  color: #576ddb;
}

/* Atelier-Cave Purple */
.hljs-keyword,
.hljs-selector-tag {
  color: #955ae7;
}

.hljs-deletion,
.hljs-addition {
  color: #19171c;
  display: inline-block;
  width: 100%;
}

.hljs-deletion {
  background-color: #be4678;
}

.hljs-addition {
  background-color: #2a9292;
}

.hljs {
  display: block;
  overflow-x: auto;
  background: #efecf4;
  color: #585260;
  padding: 0.5em;
}

.hljs-emphasis {
  font-style: italic;
}

.hljs-strong {
  font-weight: bold;
}

@media (prefers-color-scheme: dark) {
    /* Base16 Atelier Cave Dark - Theme */
    /* by Bram de Haan (http://atelierbram.github.io/syntax-highlighting/atelier-schemes/cave) */
    /* Original Base16 color scheme by Chris Kempson (https://github.com/chriskempson/base16) */

    /* Atelier-Cave Comment */
    .hljs-comment,
    .hljs-quote {
        color: #7e7887;
    }

    /* Atelier-Cave Red */
    .hljs-variable,
    .hljs-template-variable,
    .hljs-attribute,
    .hljs-regexp,
    .hljs-link,
    .hljs-tag,
    .hljs-name,
    .hljs-selector-id,
    .hljs-selector-class {
        color: #be4678;
    }

    /* Atelier-Cave Orange */
    .hljs-number,
    .hljs-meta,
    .hljs-built_in,
    .hljs-builtin-name,
    .hljs-literal,
    .hljs-type,
    .hljs-params {
        color: #aa573c;
    }

    /* Atelier-Cave Green */
    .hljs-string,
    .hljs-symbol,
    .hljs-bullet {
        color: #2a9292;
    }

    /* Atelier-Cave Blue */
    .hljs-title,
    .hljs-section {
        color: #576ddb;
    }

    /* Atelier-Cave Purple */
    .hljs-keyword,
    .hljs-selector-tag {
        color: #955ae7;
    }

    .hljs-deletion,
    .hljs-addition {
        color: #19171c;
        display: inline-block;
        width: 100%;
    }

    .hljs-deletion {
        background-color: #be4678;
    }

    .hljs-addition {
        background-color: #2a9292;
    }

    .hljs {
        display: block;
        overflow-x: auto;
        background: #19171c;
        color: #8b8792;
        padding: 0.5em;
    }

    .hljs-emphasis {
        font-style: italic;
    }

    .hljs-strong {
        font-weight: bold;
    }
}

