:root {
  color-scheme: dark;
  --bg: #0f1115;
  --bg-raised: #15181e;
  --bg-panel: #181c23;
  --bg-panel-soft: #1d222a;
  --bg-hover: #252b34;
  --bg-active: #29333a;
  --border: #2a3039;
  --border-strong: #38404b;
  --text: #e7ebef;
  --text-muted: #9aa5b1;
  --text-dim: #697581;
  --accent: #6bd2c4;
  --accent-strong: #8ce8d9;
  --accent-ink: #102320;
  --warning: #e4b46b;
  --danger: #ef8e8e;
  --success: #71d49d;
  --topbar-height: 58px;
  --statusbar-height: 25px;
  --explorer-width: 272px;
  --activity-width: 0px;
}

* {
  box-sizing: border-box;
}

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

body {
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Inter, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 13px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
}

button:focus-visible,
input:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.hidden,
[hidden] {
  display: none !important;
}

.app-shell,
.editor-view,
.pair-view {
  min-height: 100%;
  height: 100%;
}

.pair-view {
  display: grid;
  place-items: center;
  overflow: auto;
  padding: 32px 20px;
  background: var(--bg);
}

.pair-frame {
  width: min(100%, 440px);
}

.pair-brand,
.topbar-brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--text);
  font-weight: 650;
  letter-spacing: 0.01em;
}

.pair-brand {
  margin: 0 0 22px 2px;
  font-size: 16px;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 1px solid #3b8179;
  border-radius: 6px;
  color: var(--accent-strong);
  background: #152a29;
}

.brand-mark svg {
  width: 16px;
  height: 16px;
  stroke-width: 1.8;
}

.brand-mark.compact {
  width: 25px;
  height: 25px;
  border-radius: 5px;
}

.pair-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 29px 30px 24px;
  background: var(--bg-raised);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.22);
}

.eyebrow,
.section-kicker,
.workspace-kicker {
  color: var(--text-dim);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 13px;
}

.eyebrow-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(107, 210, 196, 0.12);
}

.pair-card h1 {
  margin: 0;
  color: var(--text);
  font-size: 24px;
  font-weight: 630;
  letter-spacing: 0;
  line-height: 1.2;
}

.pair-copy {
  max-width: 36ch;
  margin: 11px 0 25px;
  color: var(--text-muted);
  font-size: 13px;
}

#pair-form label {
  display: block;
  margin-bottom: 8px;
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
}

.code-input-wrap {
  display: flex;
  align-items: center;
  min-height: 44px;
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  background: #111419;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.code-input-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(107, 210, 196, 0.12);
}

.code-input-wrap > svg {
  flex: 0 0 auto;
  width: 17px;
  height: 17px;
  margin-left: 13px;
  color: var(--text-dim);
}

.code-input-wrap input {
  min-width: 0;
  flex: 1;
  height: 42px;
  border: 0;
  outline: 0;
  padding: 0 10px;
  color: var(--text);
  background: transparent;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  letter-spacing: 0.04em;
}

.code-input-wrap input::placeholder {
  color: #66717d;
  letter-spacing: 0;
}

.primary-button,
.toolbar-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease, opacity 120ms ease;
}

.primary-button {
  width: 100%;
  min-height: 43px;
  margin-top: 16px;
  border: 1px solid var(--accent);
  border-radius: 5px;
  color: var(--accent-ink);
  background: var(--accent);
  font-weight: 650;
}

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

.primary-button:disabled,
.toolbar-button:disabled,
.icon-button:disabled {
  cursor: wait;
  opacity: 0.55;
}

.primary-button svg,
.toolbar-button svg {
  width: 16px;
  height: 16px;
}

.form-message {
  margin: 9px 0 0;
  color: var(--danger);
  font-size: 12px;
}

.pair-footnote {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 22px;
  color: var(--text-dim);
  font-size: 11px;
}

.pair-footnote svg {
  flex: 0 0 auto;
  width: 15px;
  height: 15px;
  color: var(--success);
}

.editor-view {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: var(--topbar-height);
  height: var(--topbar-height);
  border-bottom: 1px solid var(--border);
  padding: 0 13px;
  background: #13161b;
}

.topbar-left,
.topbar-actions,
.workspace-label,
.connection-pill,
.presence-label,
.status-left,
.status-right,
.explorer-heading,
.explorer-actions,
.editor-toolbar,
.editor-toolbar-actions,
.breadcrumbs,
.tab,
.tab-label,
.tab-close {
  display: flex;
  align-items: center;
}

.topbar-left {
  min-width: 0;
  gap: 13px;
}

.topbar-divider {
  width: 1px;
  height: 22px;
  background: var(--border);
}

.workspace-label {
  min-width: 0;
  flex-direction: column;
  align-items: flex-start;
  gap: 0;
  line-height: 1.25;
}

.workspace-label strong {
  max-width: 27ch;
  overflow: hidden;
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-actions {
  flex: 0 0 auto;
  gap: 8px;
}

.connection-pill {
  gap: 7px;
  min-height: 27px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0 10px;
  color: var(--text-muted);
  font-size: 11px;
}

.connection-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--warning);
}

.connection-pill[data-state="connected"] {
  border-color: rgba(113, 212, 157, 0.35);
  color: #a9e8c1;
}

.connection-pill[data-state="connected"] .connection-dot {
  background: var(--success);
  box-shadow: 0 0 0 3px rgba(113, 212, 157, 0.12);
}

.connection-pill[data-state="disconnected"],
.connection-pill[data-state="error"] {
  border-color: rgba(239, 142, 142, 0.32);
  color: #f2b1b1;
}

.connection-pill[data-state="disconnected"] .connection-dot,
.connection-pill[data-state="error"] .connection-dot {
  background: var(--danger);
}

.presence-label {
  color: var(--text-dim);
  font-size: 11px;
  white-space: nowrap;
}

.run-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 180px;
  color: var(--text-muted);
  font-size: 11px;
  white-space: nowrap;
}

.run-status-label {
  overflow: hidden;
  text-overflow: ellipsis;
}

.run-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-dim);
}

.run-status[data-state="running"] {
  color: var(--warning);
}

.run-status[data-state="running"] .run-status-dot {
  background: var(--warning);
  box-shadow: 0 0 0 3px rgba(228, 180, 107, 0.12);
  animation: pulse 1.2s ease-in-out infinite;
}

.run-status[data-state="success"] {
  color: var(--success);
}

.run-status[data-state="success"] .run-status-dot {
  background: var(--success);
}

.run-status[data-state="error"] {
  color: var(--danger);
}

.run-status[data-state="error"] .run-status-dot {
  background: var(--danger);
}

.toolbar-button {
  min-height: 31px;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  padding: 0 10px;
  color: var(--text);
  background: var(--bg-panel);
  font-size: 12px;
  font-weight: 600;
}

.toolbar-button:hover {
  border-color: #4b5962;
  background: var(--bg-hover);
}

#sync-button[data-dirty="true"] {
  border-color: rgba(107, 210, 196, 0.65);
  color: var(--accent-strong);
}

.icon-button {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 0;
  color: var(--text-muted);
  background: transparent;
}

.icon-button:hover {
  border-color: var(--border);
  color: var(--text);
  background: var(--bg-hover);
}

.icon-button svg {
  width: 16px;
  height: 16px;
}

.icon-button.subtle {
  color: var(--text-dim);
}

.workspace-layout {
  display: flex;
  flex: 1;
  min-height: 0;
}

.explorer-panel {
  display: flex;
  flex: 0 0 var(--explorer-width);
  flex-direction: column;
  min-width: 0;
  border-right: 1px solid var(--border);
  background: var(--bg-panel);
}

.explorer-heading {
  justify-content: space-between;
  min-height: 67px;
  padding: 14px 12px 10px 17px;
}

.explorer-heading h2 {
  margin: 2px 0 0;
  color: var(--text);
  font-size: 13px;
  font-weight: 650;
}

.explorer-actions {
  gap: 1px;
}

.drop-zone {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 37px;
  margin: 0 10px 11px;
  border: 1px dashed #3b4650;
  border-radius: 4px;
  padding: 0 10px;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 11px;
  transition: border-color 120ms ease, color 120ms ease, background-color 120ms ease;
}

.drop-zone:hover,
.drop-zone:focus-visible,
.drop-zone.is-dragover {
  border-color: var(--accent);
  color: var(--accent-strong);
  background: rgba(107, 210, 196, 0.06);
}

.drop-zone svg {
  width: 15px;
  height: 15px;
}

.tree-heading {
  display: flex;
  justify-content: space-between;
  padding: 0 17px 7px;
  color: var(--text-dim);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.11em;
}

.file-tree {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 0 7px 12px;
}

.file-tree::-webkit-scrollbar,
.tabs::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.file-tree::-webkit-scrollbar-thumb,
.tabs::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 8px;
  background: #3a434d;
  background-clip: padding-box;
}

.tree-item {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 28px;
  border-radius: 3px;
  padding: 0 8px;
  color: var(--text-muted);
  cursor: pointer;
  text-align: left;
  user-select: none;
}

.tree-file-row {
  display: flex;
  align-items: center;
  min-height: 28px;
  border-radius: 3px;
}

.tree-file-row > .tree-item {
  flex: 1;
  min-width: 0;
}

.tree-run-button {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 25px;
  height: 25px;
  margin-right: 2px;
  border: 1px solid transparent;
  border-radius: 3px;
  color: var(--text-dim);
  background: transparent;
  cursor: pointer;
  opacity: 0;
  transition: opacity 120ms ease, color 120ms ease, background-color 120ms ease;
}

.tree-file-row:hover .tree-run-button,
.tree-file-row:focus-within .tree-run-button,
.tree-run-button:focus-visible {
  opacity: 1;
}

.tree-run-button:hover {
  border-color: var(--border);
  color: var(--accent-strong);
  background: var(--bg-hover);
}

.tree-run-button:disabled {
  cursor: wait;
  opacity: 0.45;
}

.tree-run-button svg {
  width: 14px;
  height: 14px;
}

.tree-item:hover {
  color: var(--text);
  background: var(--bg-hover);
}

.tree-item.is-active {
  color: var(--text);
  background: var(--bg-active);
}

.tree-item .tree-icon {
  flex: 0 0 auto;
  width: 15px;
  height: 15px;
  margin-right: 7px;
  color: var(--text-dim);
}

.tree-item.is-active .tree-icon {
  color: var(--accent);
}

.tree-item .tree-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tree-item .dirty-mark {
  flex: 0 0 auto;
  width: 5px;
  height: 5px;
  margin-left: auto;
  border-radius: 50%;
  background: var(--warning);
}

.tree-dir {
  min-height: 28px;
  color: var(--text-muted);
}

.tree-dir > .tree-item {
  color: var(--text-muted);
  font-weight: 600;
}

.tree-dir > .tree-item .tree-icon {
  width: 14px;
  height: 14px;
}

.tree-dir-children {
  margin-left: 13px;
  border-left: 1px solid rgba(83, 94, 105, 0.28);
  padding-left: 3px;
}

.tree-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 8px;
  padding: 26px 18px;
  color: var(--text-dim);
  font-size: 11px;
  text-align: center;
}

.tree-empty svg {
  width: 24px;
  height: 24px;
  color: #55616d;
}

.editor-main {
  display: flex;
  position: relative;
  flex: 1;
  min-width: 0;
  flex-direction: column;
  background: #101317;
}

.editor-toolbar {
  justify-content: space-between;
  min-height: 36px;
  border-bottom: 1px solid var(--border);
  padding: 0 9px 0 15px;
  background: #15181d;
}

.breadcrumbs {
  min-width: 0;
  gap: 4px;
  overflow: hidden;
  color: var(--text-dim);
  font-size: 11px;
  white-space: nowrap;
}

.breadcrumbs .crumb {
  overflow: hidden;
  text-overflow: ellipsis;
}

.breadcrumbs .crumb.current {
  color: var(--text-muted);
}

.breadcrumbs .crumb-separator {
  color: #4e5964;
}

.editor-toolbar-actions {
  flex: 0 0 auto;
  gap: 7px;
}

.dirty-indicator {
  color: var(--warning);
  font-size: 11px;
}

.tabs {
  display: flex;
  flex: 0 0 auto;
  min-height: 36px;
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
  background: #15181d;
}

.tab {
  flex: 0 0 auto;
  min-width: 130px;
  max-width: 220px;
  height: 36px;
  gap: 7px;
  border-right: 1px solid var(--border);
  border-top: 2px solid transparent;
  padding: 0 8px 0 13px;
  color: var(--text-dim);
  cursor: pointer;
  background: #15181d;
}

.tab:hover {
  color: var(--text-muted);
  background: var(--bg-hover);
}

.tab.is-active {
  border-top-color: var(--accent);
  color: var(--text);
  background: #101317;
}

.tab .tab-file-icon {
  flex: 0 0 auto;
  width: 14px;
  height: 14px;
  color: var(--text-dim);
}

.tab.is-active .tab-file-icon {
  color: var(--accent);
}

.tab-label {
  min-width: 0;
  flex: 1;
  gap: 5px;
  overflow: hidden;
}

.tab-label span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tab-dirty {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--warning);
}

.tab-close {
  flex: 0 0 auto;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 3px;
  color: var(--text-dim);
  background: transparent;
  cursor: pointer;
}

.tab-close:hover {
  color: var(--text);
  background: var(--bg-hover);
}

.tab-close svg {
  width: 14px;
  height: 14px;
}

.editor-container {
  position: relative;
  flex: 1;
  min-height: 0;
}

#monaco-editor {
  position: absolute;
  inset: 0;
}

.fallback-editor {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  resize: none;
  border: 0;
  outline: 0;
  padding: 14px 18px 20px;
  color: #dce3e8;
  background: #101317;
  font-family: "Cascadia Code", SFMono-Regular, Consolas, monospace;
  font-size: 13px;
  line-height: 21px;
  tab-size: 2;
  white-space: pre;
}

.editor-empty {
  display: grid;
  position: absolute;
  inset: 0;
  place-content: center;
  justify-items: center;
  align-content: center;
  gap: 8px;
  color: var(--text-dim);
  text-align: center;
}

.empty-glyph {
  display: grid;
  place-items: center;
  width: 50px;
  height: 50px;
  margin-bottom: 2px;
  border: 1px solid var(--border);
  border-radius: 7px;
  color: #687782;
  background: var(--bg-panel);
}

.empty-glyph svg {
  width: 24px;
  height: 24px;
}

.editor-empty h2 {
  margin: 0;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
}

.editor-empty p {
  margin: 0;
  color: var(--text-dim);
  font-size: 12px;
}

.editor-loading {
  display: flex;
  position: absolute;
  inset: 0;
  align-items: center;
  justify-content: center;
  gap: 9px;
  color: var(--text-muted);
  background: rgba(16, 19, 23, 0.9);
}

.loading-spinner {
  width: 15px;
  height: 15px;
  border: 2px solid #35414a;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes pulse {
  50% { opacity: 0.42; }
}

.statusbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: var(--statusbar-height);
  height: var(--statusbar-height);
  padding: 0 12px;
  color: #a5b2bc;
  background: #183b39;
  font-size: 10px;
}

.status-left,
.status-right {
  min-width: 0;
  gap: 12px;
}

.status-left span,
.status-right span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-separator {
  width: 1px;
  height: 12px;
  background: rgba(194, 231, 225, 0.28);
}

.toast-region {
  display: flex;
  position: fixed;
  z-index: 20;
  right: 16px;
  bottom: 38px;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  max-width: min(390px, calc(100vw - 32px));
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  padding: 10px 12px;
  color: var(--text);
  background: #20262d;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  font-size: 12px;
  pointer-events: auto;
}

.toast[data-kind="error"] {
  border-color: rgba(239, 142, 142, 0.44);
}

.toast[data-kind="success"] {
  border-color: rgba(113, 212, 157, 0.4);
}

.toast svg {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  color: var(--accent);
}

.toast[data-kind="error"] svg { color: var(--danger); }
.toast[data-kind="success"] svg { color: var(--success); }

.mobile-only {
  display: none;
}

@media (max-width: 860px) {
  :root { --explorer-width: 240px; }
  .presence-label { display: none; }
  .topbar-divider { display: none; }
}

@media (max-width: 680px) {
  .mobile-only { display: inline-flex; }
  .run-status { display: none; }
  .tree-run-button { opacity: 1; }
  .topbar { padding: 0 8px; }
  .topbar-left { gap: 8px; }
  .topbar-brand .brand-name { display: none; }
  .workspace-label strong { max-width: 18ch; }
  .topbar-actions { gap: 4px; }
  .connection-pill { padding: 0 7px; }
  .connection-pill span:last-child { display: none; }
  .toolbar-button { width: 31px; padding: 0; }
  .toolbar-button span { display: none; }

  .explorer-panel {
    position: absolute;
    z-index: 5;
    top: var(--topbar-height);
    bottom: var(--statusbar-height);
    left: 0;
    width: min(82vw, 300px);
    transform: translateX(-102%);
    box-shadow: 8px 0 24px rgba(0, 0, 0, 0.35);
    transition: transform 160ms ease;
  }

  .editor-view.explorer-open .explorer-panel { transform: translateX(0); }
  .editor-main { width: 100%; }
  .status-right { gap: 8px; }
  .status-right span:nth-child(1) { display: none; }
  .pair-card { padding: 25px 21px 21px; }
  .pair-view { padding: 20px 14px; }
}

@media (max-width: 420px) {
  .pair-card h1 { font-size: 21px; }
  .workspace-label { display: none; }
  .status-left { gap: 7px; }
  .status-left span:first-child { display: none; }
}
