@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono&display=swap');

:root {
  --max-width: 800px;
  --space: 16px;
  --bg: #fafafa;
  --border: #ddd;
  --muted: #666;
  --accent: #0366d6;
  --radius: 6px;
  --inspector-width: 480px; /* adjustable */
}

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

body {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, monospace;
  line-height: 1.5;
  max-width: var(--max-width);
  margin: 40px auto;
  padding: 0 var(--space);
  color: #111;
  background: #fff;
}

.controls {
  margin-top: 16px;
}

.inline {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.buttons {
  margin-top: 12px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

textarea {
  width: 100%;
  height: 220px;
  margin-top: 12px;
  font-size: 14px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  resize: vertical;
}

/* Ensure buttons and inputs use the monospace font and render consistently */
button,
input,
select,
textarea {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, monospace;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* keep button appearance consistent across browsers */
button,
input[type="button"],
input[type="submit"] {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

button {
  padding: 6px 12px;
  cursor: pointer;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: var(--radius);
  transition: box-shadow .12s, transform .08s;
}
button:hover {
  box-shadow: 0 1px 6px rgba(0,0,0,0.08);
  transform: translateY(-1px);
}
button:focus {
  outline: 3px solid rgba(3,102,214,0.15);
  outline-offset: 2px;
}

button.primary {
  background: var(--accent);
  color: #fff;
  border-color: rgba(0,0,0,0.06);
  box-shadow: 0 8px 20px rgba(3,102,214,0.12);
}
button.primary:hover {
  box-shadow: 0 10px 24px rgba(3,102,214,0.16);
  transform: translateY(0);
}
button.primary:focus {
  outline: 3px solid rgba(3,102,214,0.18);
  outline-offset: 2px;
}

/* Preset toggle button styles (only for buttons with data-mode) */
.buttons button[data-mode] {
  /* preserve button feel */
}

.buttons button[data-mode][aria-pressed="true"] {
  background: var(--accent);
  color: #fff;
  border-color: rgba(0,0,0,0.06);
  box-shadow: 0 8px 20px rgba(3,102,214,0.18);
  transform: translateY(0); /* don't lift when active */
}
.buttons button[data-mode][aria-pressed="true"]:hover {
  box-shadow: 0 10px 24px rgba(3,102,214,0.22);
}

button.secondary {
  margin-left: auto;
}

.meta {
  margin-top: 8px;
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 13px;
}

#cap {
  width: 100px;
  max-width: 30%;
  min-width: 80px;
}

#status {
  opacity: 0.9;
  color: var(--muted);
}

.output {
  padding: 12px;
  border: 1px solid var(--border);
  white-space: pre-wrap;
  margin-top: 12px;
  background: var(--bg);
  font-family: 'JetBrains Mono', monospace;
  border-radius: var(--radius);
}

/* Debug UI - top-right toggle and right panel (overlay mode) */
.debug-toggle {
  position: fixed;
  top: 16px;
  right: 16px;
  padding: 6px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
  font-family: 'JetBrains Mono', monospace;
  z-index: 10001;
}
.debug-toggle[aria-pressed="true"] {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 8px 20px rgba(3,102,214,0.12);
}
.debug-panel {
  display: none;
  position: fixed;
  right: 0px;
  top: 64px;
  width: var(--inspector-width);
  max-height: calc(100vh - 160px);
  overflow: auto;
  border: 1px solid var(--border);
  background: #fbfdff;
  padding: 12px;
  border-radius: var(--radius);
  box-shadow: 0 6px 18px rgba(0,0,0,0.08);
  font-family: 'JetBrains Mono', monospace;
  z-index: 9999;
}
.debug-panel .debug-header {
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:8px;
  margin-bottom:8px;
}
.debug-panel .debug-body {
  display:flex;
  gap:12px;
  flex-direction:column;
}
.run-list {
  border-top: 1px solid rgba(0,0,0,0.04);
  padding-top: 8px;
  max-height: calc(100vh - 260px);
  overflow: auto;
}
.run-entry {
  padding: 8px;
  border-bottom: 1px solid rgba(0,0,0,0.04);
  cursor: pointer;
  font-size:13px;
}
.run-entry:hover { background: rgba(0,0,0,0.02); }
.run-snippet { color: var(--muted); font-size:12px; margin-top:4px; white-space:pre-wrap; }
.run-meta { font-size:12px; color:var(--muted); }
.run-empty { color: var(--muted); padding: 10px; font-size: 13px; text-align: center; }

/* Inspector tabs and content */
.run-inspector {
  margin-top: 12px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.inspector-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}

.inspector-tabs button {
  padding: 4px 10px;
  font-size: 12px;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  border-radius: var(--radius) var(--radius) 0 0;
  transition: background 0.15s, color 0.15s;
}

.inspector-tabs button:hover {
  background: rgba(3, 102, 214, 0.08);
  color: #111;
  transform: none;
  box-shadow: none;
}

.inspector-tabs button[aria-selected="true"] {
  background: var(--accent);
  color: #fff;
  font-weight: 500;
}

.inspector-tabs button:focus {
  outline: 2px solid rgba(3, 102, 214, 0.3);
  outline-offset: 1px;
}

.inspector-content {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, monospace;
  font-size: 13px;
  max-height: calc(100vh - 420px);
  overflow: auto;
}

.inspector-content h4 {
  margin: 12px 0 6px 0;
  font-size: 13px;
  color: #111;
}

.inspector-content h4:first-child {
  margin-top: 0;
}

.inspector-content pre {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, monospace;
  background: #f6f8fa;
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 4px;
  padding: 8px;
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-x: auto;
  margin: 0;
}

.inspector-content .tab-panel {
  display: none;
}

.inspector-content .tab-panel[aria-hidden="false"] {
  display: block;
}

/* On small screens, make the inspector a bottom sheet to avoid layout issues */
@media (max-width: 900px) {
  .debug-panel { width: 100%; right: 0; left: 0; top: auto; bottom: 0; max-height: 40vh; border-radius: 8px 8px 0 0; }
  .debug-toggle { right: 12px; }
  .inspector-content { max-height: calc(40vh - 200px); }
}
