:root {
  color-scheme: dark light;
  --bg: #0f1419;
  --fg: #e6edf3;
  --muted: #8b949e;
  --border: #30363d;
  --accent: #58a6ff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.55;
}

.top {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: #161b22;
}

.top-spacer {
  flex: 1;
  min-width: 0;
}

.slug-label {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.5rem;
  font-size: 0.9rem;
  min-width: 0;
}

.slug-label:empty {
  display: none;
}

.slug-label .gh-crumb-sep {
  color: var(--muted);
  user-select: none;
}

.slug-label .gh-crumb a {
  color: var(--accent);
  text-decoration: none;
}

.slug-label .gh-crumb a:hover {
  text-decoration: underline;
}

.slug-label .gh-crumb-current {
  color: var(--fg);
}

#gh-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
  font-size: 0.85rem;
}

#gh-actions[hidden] {
  display: none !important;
}

#gh-actions a {
  color: var(--accent);
  text-decoration: none;
  white-space: nowrap;
}

#gh-actions a:hover {
  text-decoration: underline;
}

#gh-actions a[aria-disabled="true"] {
  color: var(--muted);
  pointer-events: none;
  text-decoration: none;
}

.gh-browser {
  margin: 0 0 1.5rem;
}

.gh-browser h1 {
  font-size: 1.35rem;
  margin: 0 0 1rem;
  font-weight: 600;
}

.gh-entries {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: #161b22;
}

.gh-entries li + li {
  border-top: 1px solid var(--border);
}

.gh-entries a {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 0.85rem;
  color: var(--fg);
  text-decoration: none;
}

.gh-entries a:hover {
  background: #1c2128;
  color: var(--accent);
}

.gh-entry-icon {
  flex-shrink: 0;
  width: 1.25rem;
  height: 1.25rem;
  color: var(--muted);
}

.gh-entries a:hover .gh-entry-icon {
  color: var(--accent);
}

.gh-readme {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.gh-readme h2 {
  font-size: 1rem;
  color: var(--muted);
  margin: 0 0 1rem;
  font-weight: 500;
}

.gh-file-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem;
  background: #161b22;
}

.gh-file-card p {
  margin: 0.5rem 0;
}

.gh-file-preview {
  margin-top: 1rem;
  text-align: center;
}

.gh-file-preview img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.top a {
  color: var(--accent);
  text-decoration: none;
}

.top a:hover {
  text-decoration: underline;
}


#main {
  max-width: 52rem;
  margin: 0 auto;
  padding: 1.25rem 1rem 3rem;
}

#main h1,
#main h2,
#main h3 {
  margin-top: 1.5rem;
}

#main code {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 0.88em;
  padding: 0.12em 0.38em;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #e6edf3;
  word-break: break-word;
}

#main pre code {
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  font-size: inherit;
  color: inherit;
  word-break: normal;
}

#main pre:not(.out-log) {
  background: #161b22;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.75rem 1rem;
  overflow: auto;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 15px;
  line-height: 1.5;
}

#main table {
  width: 100%;
  margin: 1.25rem 0;
  border-collapse: separate;
  border-spacing: 0;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 8px;
  overflow: hidden;
  background: #161b22;
  font-size: 0.95rem;
  line-height: 1.45;
}

#main thead th {
  background: #1c2128;
  font-weight: 600;
  color: var(--fg);
}

#main th,
#main td {
  padding: 0.55rem 0.85rem;
  text-align: left;
  vertical-align: top;
  border-right: 1px solid rgba(255, 255, 255, 0.18);
  border-bottom: 1px solid rgba(255, 255, 255, 0.18);
}

#main th:last-child,
#main td:last-child {
  border-right: none;
}

#main tbody tr:last-child td {
  border-bottom: none;
}

#main tbody tr:nth-child(even) td {
  background: rgba(255, 255, 255, 0.03);
}

#main tbody tr:hover td {
  background: rgba(88, 166, 255, 0.06);
}

.code-playground {
  margin: 1rem 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: #161b22;
}

.code-playground .playground-editor-wrap {
  position: relative;
}

.code-playground .ace-mount {
  min-height: 4.5rem;
  width: 100%;
}

/* Scrollbar flush to the playground edge; inset text only so Run/Stop don't cover lines. */
.code-playground .ace-mount .ace_scroller {
  right: 0 !important;
}

.code-playground .ace-mount .ace_scrollbar-v {
  right: 0 !important;
  width: 12px;
}

.code-playground .ace-mount .ace_scrollbar-h {
  left: 0 !important;
  right: 12px !important;
  height: 12px;
}

.code-playground .pg-overlay {
  position: absolute;
  top: 8px;
  left: 0;
  right: 0;
  height: 40px;
  z-index: 12;
  pointer-events: none;
}

.code-playground .pg-overlay .pg-icon-btn {
  position: absolute;
  top: 0;
  pointer-events: auto;
}

/* Play unchanged; stop nudged left (was flush right beside play) */
.code-playground .pg-run {
  right: 64px;
}

.code-playground .pg-stop {
  right: 22px;
}

.code-playground .pg-run.pg-icon-btn {
  color: var(--fg);
  opacity: 0.92;
}

.code-playground .pg-icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  min-height: 40px;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  box-shadow: none;
}

.code-playground .pg-icon-btn:hover:not(:disabled) {
  background: transparent;
  border: none;
  color: var(--fg);
}

.code-playground .pg-icon-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.code-playground .pg-icon-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.code-playground .pg-icon-btn svg {
  display: block;
  pointer-events: none;
}

.code-playground .pg-stop:not(:disabled) {
  color: #f85149;
}

.code-playground .term-panel {
  display: none;
  flex-direction: column;
  background: #010409;
  border-top: 1px solid var(--border);
}

.code-playground .term-panel.is-visible {
  display: flex;
}

.code-playground .term-panel-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.35rem 0.5rem;
  min-height: 36px;
  background: #0d1117;
  border-bottom: 1px solid var(--border);
}

.code-playground .term-panel-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: auto;
}

.code-playground .term-panel-title {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--muted);
  padding-left: 0.25rem;
}

.code-playground .term-panel-subtitle {
  margin-left: 0.5rem;
  font-size: 0.75rem;
  font-weight: 400;
  text-transform: none;
  letter-spacing: normal;
  color: var(--muted);
}

.code-playground .pg-compile-log {
  display: block;
  margin: 0;
  border-bottom: 1px solid var(--border);
  padding: 0.65rem 0.85rem;
  background: #0d1117;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.45;
  max-height: 16rem;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  color: #e6edf3;
}

.code-playground .pg-compile-log[hidden] {
  display: none !important;
}

.code-playground .pg-compile-log.is-error {
  color: #ff7b72;
}

.code-playground .pg-compile-log.is-status {
  color: var(--muted);
}

.code-playground .term-panel.is-minimized .term-mount-wrap,
.code-playground .term-panel.is-minimized .pg-compile-log {
  display: none;
}

.code-playground .term-panel.is-minimized .term-panel-bar {
  border-bottom: none;
}

.code-playground .term-mount-wrap {
  min-height: 160px;
}

.code-playground .term-mount {
  height: 160px;
  cursor: text;
  outline: none;
}

/* Indent program output from the left edge */
.code-playground .term-mount > .xterm {
  padding-left: 14px;
  box-sizing: border-box;
}

.code-playground .term-mount:focus {
  box-shadow: inset 0 0 0 1px var(--accent);
}

.err {
  color: #f85149;
}
