:root {
  --bg: #fafafa;
  --fg: #1f2328;
  --muted: #6e7781;
  --border: #d0d7de;
  --accent: #0969da;
  --dir: #0969da;
  --selected-bg: #eaeef2;
  --code-bg: #f0f2f4;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1117;
    --fg: #e6edf3;
    --muted: #8b949e;
    --border: #30363d;
    --accent: #58a6ff;
    --dir: #58a6ff;
    --selected-bg: #161b22;
    --code-bg: #161b22;
  }
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 15px;
  line-height: 1.5;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.explorer {
  display: grid;
  grid-template-columns: minmax(260px, 340px) 1fr;
  min-height: 100vh;
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 16px;
  gap: 32px;
}

/* --- tree ------------------------------------------------------------- */

.tree {
  align-self: start;
  position: sticky;
  top: 32px;
}

.tree-root {
  font-weight: 700;
  margin-bottom: 4px;
}

.entries {
  list-style: none;
  margin: 0;
  padding: 0;
}

.entry {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  padding: 2px 6px 2px 0;
  border-radius: 4px;
}

.entry.selected {
  background: var(--selected-bg);
}

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

.hint {
  margin: 16px 0 0;
  font-size: 0.8em;
}

.branch {
  color: var(--muted);
  user-select: none;
  white-space: pre;
}

.entry-file .name {
  color: var(--fg);
}

.entry-dir .name {
  color: var(--dir);
  font-weight: 700;
}

.desc {
  color: var(--muted);
  flex-basis: 100%;
  padding-left: 4ch;
  font-size: 0.85em;
  overflow-wrap: anywhere;
}

/* --- content pane ----------------------------------------------------- */

.pane {
  border: 1px solid var(--border);
  border-radius: 6px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 64px);
}

.pane-header {
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.9em;
}

.content {
  padding: 16px 24px 24px;
  flex: 1;
}

/* App preview: the iframe fills the pane edge to edge. */
.content.frame {
  padding: 0;
  display: flex;
}

.content.frame iframe {
  flex: 1;
  width: 100%;
  border: 0;
  border-radius: 0 0 6px 6px;
  background: #fff;
}

.muted {
  color: var(--muted);
}

/* --- rendered markdown ------------------------------------------------ */

.markdown h1,
.markdown h2,
.markdown h3 {
  line-height: 1.25;
  margin: 1.2em 0 0.5em;
}

.markdown h1 {
  margin-top: 0.2em;
  padding-bottom: 0.3em;
  border-bottom: 1px solid var(--border);
}

.markdown p,
.markdown ul,
.markdown ol {
  margin: 0 0 1em;
}

.markdown ul {
  padding-left: 1.5em;
}

.markdown li {
  margin: 0.25em 0;
}

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

.markdown code {
  background: var(--code-bg);
  padding: 0.1em 0.3em;
  border-radius: 4px;
}

.markdown pre {
  background: var(--code-bg);
  padding: 12px;
  border-radius: 6px;
  overflow-x: auto;
}

.markdown pre code {
  background: none;
  padding: 0;
}

.content > pre {
  white-space: pre-wrap;
}

/* --- phone width ------------------------------------------------------ */

@media (max-width: 720px) {
  .explorer {
    grid-template-columns: 1fr;
    gap: 20px;
    padding: 20px 16px;
  }

  .tree {
    position: static;
  }

  .hint {
    display: none;
  }

  .pane {
    min-height: 0;
  }

  .content.frame iframe {
    height: 75vh;
  }

  .content {
    padding: 12px 16px 16px;
  }
}
