:root {
  --bg: #0f1117;
  --fg: #e5e9f0;
  --accent: #4f73ff;
  --muted: #7a8393;
  --edge: 28px;
  --overview-h: 84px;
}

* { box-sizing: border-box; }
html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, sans-serif;
  /* Prevent page-level scrollbars; the grid handles scrolling */
  overflow: hidden;
}

#toolbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 42px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px; /* default */
  background: rgba(15,17,23,0.8);
  -webkit-backdrop-filter: blur(6px);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  z-index: 10;
  /* Allow window drag when using hiddenInset title bar */
  -webkit-app-region: drag;
}

/* Spacer for macOS traffic lights area */
.traffic-spacer { flex: 0 0 0; width: 0; height: 100%; }
body.is-mac.traffic-visible .traffic-spacer { flex-basis: 65px; width: 65px; }

/* When traffic lights are visible on macOS, place brand on left and buttons on right */
body.is-mac.traffic-visible #toolbar { justify-content: space-between; }
body.is-mac.traffic-visible #toolbar .brand { order: 1; margin-left: 0; }
body.is-mac.traffic-visible #toolbar .toolbar-actions { order: 2; margin-left: auto; }

#toolbar button {
  height: 28px;
  padding: 0 10px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.12);
  background: #161a24;
  color: var(--fg);
  cursor: pointer;
  /* Interactive elements must be no-drag */
  -webkit-app-region: no-drag;
}
#toolbar button:hover { border-color: var(--accent); }
.hint { color: var(--muted); font-size: 12px; margin-left: 6px; -webkit-app-region: no-drag; }
.brand {
  margin-left: auto;
  font-weight: 700;
  font-size: 18px;
  color: var(--fg);
  opacity: 0.95;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  -webkit-app-region: no-drag;
}
.toolbar-actions { display: flex; align-items: center; gap: 8px; }

/* In windowed macOS, place brand left and buttons right */
body.is-mac.traffic-visible #toolbar .brand { order: 1; margin-left: 0; }
body.is-mac.traffic-visible #toolbar .toolbar-actions { order: 2; margin-left: auto; }

.brand-logo {
  height: 18px;
  width: auto;
  display: inline-block;
}

.grid {
  position: absolute;
  top: 42px; bottom: 0; left: 0; right: 0;
  overflow-x: auto;
  overflow-y: hidden;
  display: flex; /* columns horizontally */
  align-items: stretch;
  gap: 0;
  scroll-snap-type: none; /* disable column stickiness */
  will-change: scroll-position;
  /* Dark scrollbar theme */
  scrollbar-color: rgba(0,0,0,0.9) rgba(15,17,23,0.95);
  scrollbar-width: thin;
}

/* WebKit scrollbar styling for the main grid */
.grid::-webkit-scrollbar {
  height: 10px;
  background: rgba(15,17,23,0.95);
}
.grid::-webkit-scrollbar-track {
  background: rgba(15,17,23,0.95);
}
.grid::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,0.9);
  border-radius: 6px;
  border: 2px solid rgba(15,17,23,0.95);
}
.grid::-webkit-scrollbar-thumb:hover {
  background: rgba(0,0,0,1);
}

body.minimap-open .grid { bottom: var(--overview-h); }

/* Disable snapping near edges so + buttons can remain visible */
.grid.no-snap {
  scroll-snap-type: none;
}

.column {
  width: 50vw; /* keep edges off-screen by default */
  min-width: 50vw;
  flex: 0 0 auto;
  display: grid;
  grid-template-rows: 1fr 1fr; /* two rows */
  scroll-snap-align: start;
}

.pane {
  position: relative;
  border-right: 1px solid rgba(255,255,255,0.06);
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.pane.bottom { border-bottom: none; }
.column:last-child .pane { border-right: none; }

.pane .term {
  position: absolute;
  inset: 0;
}

/* xterm tweaks for dark bg; allow per-pane override via --term-bg */
.xterm .xterm-viewport { background-color: var(--term-bg, var(--bg)); }
.xterm .xterm-viewport { overflow-x: hidden; }

/* Edge add buttons as thin columns inside the grid */
.edge-cell {
  flex: 0 0 var(--edge);
  width: var(--edge);
  min-width: var(--edge);
  background: rgba(22,26,36,0.9);
  color: var(--fg);
  display: flex; /* always visible */
  align-items: center;
  justify-content: center;
  user-select: none;
}
.edge-cell.left { border-right: 1px solid rgba(255,255,255,0.06); }
.edge-cell.right { border-left: 1px solid rgba(255,255,255,0.06); }
.edge-btn-cell {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  border: none; background: transparent; color: var(--fg);
  font-size: 18px; cursor: pointer;
}
.edge-btn-cell:hover { background: rgba(30,36,48,0.95); }

/* Modal (Shortcuts) */
.hidden { display: none !important; }
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 30;
}
.modal {
  position: fixed;
  top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: min(560px, calc(100vw - 40px));
  max-height: 70vh;
  overflow: auto;
  background: #121622;
  color: var(--fg);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.4);
  z-index: 40;
}
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid rgba(255,255,255,0.08); }
.modal-body { padding: 12px 14px 16px; }
.modal-close { border: 1px solid rgba(255,255,255,0.12); background: #161a24; color: var(--fg); border-radius: 6px; height: 28px; padding: 0 10px; cursor: pointer; }
.shortcut-list { margin: 8px 0 0; padding-left: 18px; }
.shortcut-list li { margin: 8px 0; }
.key { display: inline-block; min-width: 16px; padding: 2px 6px; margin: 0 2px; border-radius: 6px; background: #0f1117; border: 1px solid rgba(255,255,255,0.12); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }
.modal-hint { margin-top: 8px; color: var(--muted); font-size: 12px; }

/* Horizontal minimap / overview */
.overview {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: var(--overview-h);
  background: rgba(10,12,18,0.92);
  -webkit-backdrop-filter: blur(6px);
  border-top: 1px solid rgba(255,255,255,0.06);
  z-index: 20;
  display: none;
  overflow: hidden; /* never show scrollbars inside minimap container */
}
.minimap-open .overview { display: block; }
.overview-resizer {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 8px;
  cursor: ns-resize;
  z-index: 2;
}
.overview-resizer::after {
  content: '';
  position: absolute;
  left: 50%; transform: translateX(-50%);
  top: 2px;
  width: 36px; height: 3px;
  border-radius: 2px;
  background: rgba(255,255,255,0.18);
}
.overview-track {
  position: absolute;
  inset: 0 8px 0 8px;
  overflow: hidden;
}
.overview-viewport {
  position: absolute;
  top: 6px; bottom: 6px;
  left: 0; width: 80px;
  border: 1px solid rgba(79,115,255,0.9);
  background: rgba(79,115,255,0.12);
  border-radius: 6px;
  pointer-events: none;
}
.overview-track:hover { cursor: grab; }

.ov-col, .ov-term {
  position: absolute;
  top: 4px; bottom: 4px;
  border: 1px solid rgba(255,255,255,0.08);
  background: transparent; /* pane backgrounds show actual terminal bg */
  border-radius: 6px;
  overflow: hidden;
}
.ov-col { display: grid; grid-template-rows: 1fr 1fr; }
.ov-pane {
  position: relative;
  overflow: hidden;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.ov-pane.bottom { border-bottom: none; }
.ov-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

/* Hide any scrollbars that might appear in the minimap container on WebKit */
.overview::-webkit-scrollbar,
.overview-track::-webkit-scrollbar {
  display: none;
}
