/* Accent: violet #8945ee — matches the favicon (favicon -T -t OC -r 39 -f 8945ee)
 * so the chrome and the browser tab read as one design. Differs from the
 * BASIC sibling's #58a6ff (blue) so the two demos are visually separable. */
:root {
  --bg: #0e1116;
  --panel: #161b22;
  --panel-border: #30363d;
  --text: #d4d4d4;
  --text-dim: #8b949e;
  --accent: #8945ee;
  --accent-hover: #a16df5;
  --error: #f85149;
  --ok: #3fb950;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  min-height: 100vh;
}

.page {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px 16px 64px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.workspace {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: stretch;
  height: calc(100vh - 220px);
  min-height: 400px;
}

@media (max-width: 900px) {
  .workspace { grid-template-columns: 1fr; height: auto; }
  .panel-src textarea.src { min-height: 280px; }
  .panel-out pre.out { min-height: 280px; max-height: 480px; }
}

.panel-src, .panel-out {
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.panel-src textarea.src {
  flex: 1 1 0;
  min-height: 0;
  height: 100%;
  resize: none;
}

.panel-out pre.out {
  flex: 1 1 0;
  min-height: 0;
  max-height: none;
  height: 100%;
}

.chrome {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--panel-border);
}

.chrome h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  font-family: var(--mono);
  color: var(--text);
  letter-spacing: -0.02em;
}

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

.controls select,
button {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  padding: 6px 12px;
  font-family: var(--sans);
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.1s, background 0.1s;
}

.controls select:hover,
button:hover {
  border-color: var(--accent);
}

.controls button {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
  font-weight: 600;
  min-width: 64px;
}

.controls button:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.controls button.secondary {
  background: var(--panel);
  color: var(--text);
  border-color: var(--panel-border);
  font-weight: 500;
}

.controls button.secondary:hover {
  border-color: var(--accent);
  background: var(--panel);
  color: var(--accent);
}

select:disabled,
button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.demo-description {
  margin: 0;
  font-size: 12px;
  color: var(--text-dim);
  font-style: italic;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.panel label {
  font-size: 12px;
  color: var(--text-dim);
  text-transform: lowercase;
  letter-spacing: 0.04em;
}

textarea.src {
  width: 100%;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  padding: 10px 12px;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.5;
  resize: vertical;
  tab-size: 4;
}

textarea.src:focus {
  outline: none;
  border-color: var(--accent);
}

.status {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-dim);
  padding: 6px 0;
  border-top: 1px solid var(--panel-border);
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-error {
  color: var(--error);
}

.link-btn {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
  padding: 2px 8px;
  font-size: 11px;
  border-radius: 4px;
  min-width: 0;
  font-weight: 500;
}

.link-btn:hover {
  background: var(--accent);
  color: var(--bg);
}

.github-corner {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 100;
}
.github-corner svg {
  fill: var(--accent);
  color: var(--bg);
}
.github-corner:hover .octo-arm {
  animation: octocat-wave 560ms ease-in-out;
}
@keyframes octocat-wave {
  0%, 100% { transform: rotate(0); }
  20%, 60% { transform: rotate(-25deg); }
  40%, 80% { transform: rotate(10deg); }
}

pre.out {
  margin: 0;
  background: #0a0d12;
  color: var(--text);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  padding: 12px 14px;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.5;
  min-height: 120px;
  max-height: 480px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 20px;
  font-size: 0.75em;
  color: var(--text-dim);
  border-top: 1px solid var(--panel-border);
  flex-wrap: wrap;
  flex-shrink: 0;
}
footer a {
  color: var(--accent);
  text-decoration: none;
}
footer a:hover {
  text-decoration: underline;
}
.footer-sep { color: #444; }

.input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}
.input-row label {
  font-size: 0.85em;
  color: var(--text-dim);
}
.input-row input[type="text"] {
  flex: 1;
  font-family: inherit;
  font-size: 0.95em;
  padding: 4px 8px;
  background: #111;
  color: inherit;
  border: 1px solid var(--panel-border);
  border-radius: 3px;
}

.input-hint {
  margin: 4px 0 0 0;
  font-size: 0.75em;
  font-style: italic;
  color: var(--text-dim);
}
.input-hint code {
  font-family: var(--mono);
  font-style: normal;
  color: var(--accent);
}

/* ── Hardware panel (S2 + D2) ──
 * Floats bottom-right of the viewport. Top-right is taken by the
 * octocat corner; we don't compete for that space. */
.hw-panel {
  position: fixed;
  bottom: 16px;
  right: 16px;
  background: rgba(22, 27, 34, 0.92);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  padding: 10px 14px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-dim);
  z-index: 10;
  min-width: 130px;
  backdrop-filter: blur(4px);
}
.hw-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}
.hw-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}
.hw-row:last-child { margin-bottom: 0; }
.hw-label {
  color: var(--text-dim);
  min-width: 24px;
}
/* D2 LED: solid disc, glows when on */
.hw-led {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  display: inline-block;
}
.hw-led-on {
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}
.hw-led-off {
  background: #0a0d12;
  border: 1px solid var(--panel-border);
}
/* S2 switch: clickable pill */
.hw-switch {
  padding: 2px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
  user-select: none;
  letter-spacing: 0.04em;
}
.hw-switch-on {
  background: var(--accent);
  color: #ffffff;
}
.hw-switch-off {
  background: #0a0d12;
  color: var(--text-dim);
  border: 1px solid var(--panel-border);
}
.hw-switch:hover { opacity: 0.85; }

/* Help dialog (? button) */
.icon-btn {
  width: 32px;
  padding: 6px 0 !important;
  font-family: var(--mono);
  font-weight: 700;
  text-align: center;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 24px;
}

.modal {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  max-width: 820px;
  width: 100%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--panel-border);
  padding: 0 8px 0 0;
  background: #11161d;
}

.modal-tabs {
  display: flex;
  gap: 2px;
}

.modal-tab {
  background: transparent;
  color: var(--text-dim);
  border: none;
  padding: 12px 18px;
  font-family: var(--sans);
  font-size: 14px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
}

.modal-tab:hover { color: var(--text); }

.modal-tab.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

.modal-close {
  background: transparent;
  color: var(--text-dim);
  border: none;
  font-size: 24px;
  line-height: 1;
  padding: 4px 10px;
  cursor: pointer;
}

.modal-close:hover { color: var(--text); }

.modal-body {
  overflow-y: auto;
  padding: 18px 24px 24px;
  line-height: 1.5;
  font-size: 14px;
}

.modal-body h3 {
  margin: 18px 0 6px;
  font-size: 15px;
  color: var(--accent);
}

.modal-body h3:first-child { margin-top: 0; }

.modal-body p { margin: 8px 0; }

.modal-body ul {
  margin: 4px 0 10px;
  padding-left: 20px;
}

.modal-body li { margin: 4px 0; }

.modal-body code {
  font-family: var(--mono);
  font-size: 13px;
  background: #0a0d12;
  border: 1px solid var(--panel-border);
  padding: 1px 5px;
  border-radius: 3px;
}

.modal-body kbd {
  font-family: var(--mono);
  font-size: 12px;
  background: #0a0d12;
  border: 1px solid var(--panel-border);
  border-bottom-width: 2px;
  padding: 1px 5px;
  border-radius: 3px;
  color: var(--text);
}

