:root {
  --bg: #0b0d10;
  --bg-elevated: #14181e;
  --border: #2a313b;
  --text: #e8eaed;
  --muted: #8b949e;
  --accent: #6ee7ff;
  --hover: #1c222b;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
}

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

html,
body {
  margin: 0;
  height: 100%;
}

body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  background:
    radial-gradient(1200px 500px at 50% -10%, rgba(110, 231, 255, 0.06), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

.topbar {
  flex-shrink: 0;
  z-index: 10;
  padding: 0.75rem 1.25rem;
  background: rgba(11, 13, 16, 0.92);
  border-bottom: 1px solid var(--border);
}

.nav {
  display: flex;
  align-items: center;
}

.dropdown {
  position: relative;
}

.dropdown-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-elevated);
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
}

.dropdown-toggle:hover,
.dropdown.is-open .dropdown-toggle {
  border-color: #3a4452;
  background: var(--hover);
}

.dropdown-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.chevron {
  width: 0.45rem;
  height: 0.45rem;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg) translateY(-1px);
  transition: transform 0.15s ease;
}

.dropdown.is-open .chevron {
  transform: rotate(225deg) translateY(-1px);
}

.dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 0.4rem);
  left: 0;
  min-width: 12.5rem;
  margin: 0;
  padding: 0.35rem;
  list-style: none;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
}

.dropdown.is-open .dropdown-menu {
  display: block;
}

.dropdown-menu a {
  display: block;
  padding: 0.6rem 0.75rem;
  border-radius: 7px;
  color: var(--text);
  text-decoration: none;
  font-size: 0.92rem;
}

.dropdown-menu a:hover,
.dropdown-menu a:focus-visible {
  background: var(--hover);
  outline: none;
}

.dropdown-menu a.is-active {
  color: var(--accent);
}

.stage {
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 2rem 1rem;
  overflow: auto;
}

.stage.has-pinout {
  display: flex;
  padding: 0;
  overflow: hidden;
}

.coming-soon {
  margin: 0;
  color: var(--muted);
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  font-weight: 500;
  letter-spacing: 0.04em;
}

.pinout-screen {
  display: flex;
  flex-direction: row;
  flex: 1;
  width: 100%;
  height: 100%;
  min-height: 0;
}

.workspace {
  display: flex;
  flex-direction: row;
  flex: 1;
  width: 100%;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.pane {
  min-height: 0;
}

.pane-pins {
  display: flex;
  flex: 0 0 auto;
  align-self: stretch;
  overflow: auto;
  padding: 0.7rem 0.75rem;
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
}

.pinout {
  display: flex;
  flex-direction: column;
  justify-content: space-evenly;
  gap: 0.15rem;
  width: max-content;
  min-height: 100%;
}

.pin-row {
  display: grid;
  grid-template-columns: auto 1.6rem 0.9rem 0.9rem 1.6rem auto;
  align-items: center;
  column-gap: 0.35rem;
}

.pane-editor {
  display: flex;
  flex: 1 1 0%;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  align-self: stretch;
  background: #0e1217;
}

.code-editor {
  display: flex;
  flex: 1;
  min-height: 0;
  background: #0e1217;
}

.code-gutter {
  flex: 0 0 auto;
  margin: 0;
  padding: 0.9rem 0.65rem 0.9rem 0.8rem;
  border-right: 1px solid var(--border);
  background: #0b0e12;
  color: #5b6573;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 14px;
  line-height: 1.5;
  text-align: right;
  white-space: pre;
  overflow: hidden;
  user-select: none;
}

.code-input {
  flex: 1;
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 0.9rem 1rem;
  border: 0;
  resize: none;
  background: #0e1217;
  color: var(--text);
  caret-color: var(--accent);
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 14px;
  line-height: 1.5;
  tab-size: 2;
  white-space: pre;
  overflow: auto;
}

.code-input:focus {
  outline: none;
}

.code-input::placeholder {
  color: #5b6573;
}

.gpio-btn {
  min-width: 5.6rem;
  padding: 0.28rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #10141a;
  color: var(--accent);
  font: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
  cursor: pointer;
}

.gpio-btn.is-alt {
  color: #fbbf24;
  border-color: #5a4a20;
}

.gpio-btn.is-fixed {
  color: var(--muted);
  cursor: default;
}

.gpio-btn:hover {
  background: var(--hover);
  border-color: #3a4452;
}

.gpio-btn.is-open {
  border-color: var(--accent);
}

.pin-menu {
  position: fixed;
  z-index: 40;
  min-width: 11.5rem;
  padding: 0.3rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-elevated);
  box-shadow: var(--shadow);
}

.pin-menu-head {
  padding: 0.4rem 0.65rem 0.35rem;
  color: var(--muted);
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.pin-menu-list {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.pin-menu-item {
  display: block;
  width: 100%;
  padding: 0.45rem 0.65rem;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.85rem;
  text-align: left;
  cursor: pointer;
}

.pin-menu-item:hover,
.pin-menu-item:focus-visible {
  background: var(--hover);
  outline: none;
}

.pin-menu-item.is-active {
  color: var(--accent);
}

.gpio-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.gpio-btn.left {
  justify-self: end;
}

.gpio-btn.right {
  justify-self: start;
}

.pin-num {
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}

.pin-hole {
  width: 0.72rem;
  height: 0.72rem;
  justify-self: center;
  border: 2px solid #5c6673;
  border-radius: 50%;
  background: #07090c;
}
