/* GitHub-like chrome (Primer colours), light and dark. The document itself lives in the sandboxed frame. */
:root {
  color-scheme: light dark;
  --bg: #ffffff; --bg-subtle: #f6f8fa; --fg: #1f2328; --muted: #59636e; --border: #d1d9e0;
  --link: #0969da; --accent-bg: #ddf4ff; --folder: #54aeff; --btn-bg: #f6f8fa; --btn-hover: #eef1f4;
  --primary: #1f883d; --primary-hover: #1a7f37; --george: #0071e3;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1117; --bg-subtle: #010409; --fg: #e6edf3; --muted: #8b949e; --border: #30363d;
    --link: #4493f8; --accent-bg: #121d2f; --folder: #54aeff; --btn-bg: #21262d; --btn-hover: #30363d;
    --primary: #238636; --primary-hover: #2ea043;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  display: flex; flex-direction: column; background: var(--bg); color: var(--fg);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
.octicon { width: 16px; height: 16px; fill: currentColor; vertical-align: text-bottom; flex: none; }
.octicon-lg { width: 48px; height: 48px; }

/* Header */
.bar { display: flex; gap: 8px; align-items: center; padding: 8px 16px; background: var(--bg-subtle); border-bottom: 1px solid var(--border); }
.brand { display: inline-flex; align-items: center; gap: 6px; font-size: 16px; font-weight: 600; color: var(--fg); }
.brand:hover { text-decoration: none; }
.george { width: 28px; height: 28px; color: var(--george); fill: currentColor; flex: none; }
.george-lg { width: 48px; height: 48px; }
.lockup { display: flex; align-items: center; gap: 20px; }
.where { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 14px; }
.where a { color: var(--link); }
.where strong { color: var(--fg); font-weight: 600; }
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; font: inherit; font-weight: 500; line-height: 20px;
  color: var(--fg); background: var(--btn-bg); border: 1px solid var(--border); border-radius: 6px; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--btn-hover); text-decoration: none; }
.btn-primary { color: #fff; background: var(--primary); border-color: rgba(31, 35, 40, .15); }
.btn-primary:hover { background: var(--primary-hover); }
.iconbtn { display: inline-flex; padding: 6px; color: var(--muted); background: none; border: 1px solid transparent; border-radius: 6px; cursor: pointer; }
.iconbtn:hover { color: var(--fg); background: var(--btn-hover); border-color: var(--border); }

/* "Open link" panel under the header, shown on demand */
.url-panel { padding: 12px 16px; background: var(--bg-subtle); border-bottom: 1px solid var(--border); }
.url-form { display: grid; grid-template-columns: 1fr auto; gap: 8px; max-width: 760px; }
.url-form label { grid-column: 1 / -1; font-weight: 600; }
.url-form input { font: inherit; padding: 5px 12px; line-height: 20px; color: var(--fg); background: var(--bg); border: 1px solid var(--border); border-radius: 6px; }
.url-form input:focus { outline: 2px solid var(--link); outline-offset: -1px; }

.status { margin: 0; padding: 8px 16px; color: var(--muted); border-bottom: 1px solid var(--border); }

/* Centred login box */
.center { flex: 1; display: flex; align-items: flex-start; justify-content: center; padding: 64px 16px; }
.login-box { width: 340px; display: grid; gap: 12px; justify-items: center; text-align: center; padding: 24px 16px; background: var(--bg-subtle); border: 1px solid var(--border); border-radius: 6px; }
.login-box h1 { margin: 0; font-size: 24px; font-weight: 300; }
.login-box .btn { width: 100%; justify-content: center; }
.hint { margin: 0; color: var(--muted); font-size: 13px; }

/* Home: repositories like the GitHub repository list */
.home { flex: 1; overflow: auto; }
.home-inner { max-width: 960px; margin: 0 auto; padding: 24px 16px; }
.home h2 { display: flex; align-items: center; gap: 8px; margin: 24px 0 0; padding-bottom: 8px; font-size: 20px; font-weight: 600; border-bottom: 1px solid var(--border); }
.home h2:first-child { margin-top: 0; }
.repos { list-style: none; margin: 0; padding: 0; }
.repos li { display: grid; grid-template-columns: 1fr auto; gap: 4px 16px; padding: 16px 0; border-bottom: 1px solid var(--border); }
.repos .name { grid-column: 1; display: inline-flex; align-items: center; gap: 8px; font-size: 16px; font-weight: 600; }
.repos .badge { padding: 0 7px; font-size: 12px; font-weight: 500; line-height: 18px; color: var(--muted); border: 1px solid var(--border); border-radius: 2em; }
.repos .desc { grid-column: 1; color: var(--muted); }
.repos time { grid-column: 2; grid-row: 1 / span 2; align-self: center; color: var(--muted); font-size: 12px; white-space: nowrap; }

/* Workspace: collapsible tree on the left, document on the right */
.workspace { flex: 1; display: flex; min-height: 0; }
.sidebar { width: 300px; flex: none; overflow: auto; padding: 8px; background: var(--bg-subtle); border-right: 1px solid var(--border); }
.content { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.placeholder { margin: 0; padding: 48px 24px; color: var(--muted); text-align: center; }
.frame-host { flex: 1; min-height: 0; }
.frame-host iframe { display: block; width: 100%; height: 100%; border: 0; background: #fff; }

.tree ul { list-style: none; margin: 0; padding: 0; }
.tree ul ul { padding-left: 16px; }
.tree summary, .tree .file { display: flex; align-items: center; gap: 6px; height: 28px; padding: 0 8px; border-radius: 6px; color: var(--fg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tree summary { cursor: pointer; list-style: none; }
.tree summary::-webkit-details-marker { display: none; }
.tree summary .chevron { color: var(--muted); transition: transform .1s; }
.tree details[open] > summary .chevron { transform: rotate(90deg); }
.tree summary .octicon-folder { color: var(--folder); }
.tree .file { padding-left: 30px; }
.tree .file .octicon { color: var(--muted); }
.tree .file span { overflow: hidden; text-overflow: ellipsis; }
.tree summary:hover, .tree .file:hover { background: var(--btn-hover); text-decoration: none; }
.tree .file.active { background: var(--accent-bg); font-weight: 600; }
.tree .note { padding: 8px; color: var(--muted); }
