* { box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  margin: 0;
  padding: 20px;
  background: #161923;
}

.container {
  margin: 0 auto;
}

.editor-container {
  display: flex;
  flex-direction: column;
  gap: 0;
  height: calc(100vh - 40px);
}

/* Draggable resize handle between editor and output */
.resize-handle {
  height: 6px;
  background: #161923;
  cursor: row-resize;
  flex-shrink: 0;
  position: relative;
  z-index: 10;
}

.resize-handle:hover,
.resize-handle.dragging {
  background: #6b9bd1;
}

.resize-handle::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 40px;
  height: 2px;
  background: #7f8599;
  border-radius: 1px;
}

.resize-handle:hover::after,
.resize-handle.dragging::after {
  background: #c8c9db;
}

.panel {
  background: #1e2230;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
  overflow: hidden;
  flex: 2;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.output-panel {
  flex: 1;
}

.panel-header {
  background: #252938;
  color: #c8c9db;
  padding: 10px 15px;
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#editor-container {
  flex: 1;
  min-height: 0;
  background: #161923;
}

#output {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 15px;
  font-family: 'Cascadia Code', 'Fira Code', Consolas, monospace;
  font-size: 13px;
  white-space: pre-wrap;
  background: #1a1d2a;
  color: #c8c9db;
}

label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 14px;
  color: #c8c9db;
}

select {
  padding: 8px 12px;
  border: 1px solid #3d4455;
  border-radius: 4px;
  font-size: 14px;
  background: #1e2230;
  color: #c8c9db;
}

.error { color: #f48771; }
.success { color: #89d185; }

/* Clickable source position links in error output */
.pos-link {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: #6b9bd1;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.pos-link:hover {
  color: #79c0ff;
}

/* ANSI color classes (match ANSI_COLORS in ui.js) — used in Monaco hover where inline
   styles are stripped by DOMPurify, so we need class-based fallbacks */
.ansi-c30 { color: #888888; }
.ansi-c31 { color: #f48771; }
.ansi-c32 { color: #89d185; }
.ansi-c33 { color: #e6b400; }
.ansi-c34 { color: #6b9bd1; }
.ansi-c35 { color: #c792ea; }
.ansi-c36 { color: #56b6c2; }
.ansi-c37 { color: #c8c9db; }
.ansi-bold { font-weight: bold; }

/* Status bar at bottom of editor panel */
.status-bar {
  padding: 6px 12px;
  font-size: 12px;
  background: #252938;
  color: #7f8599;
  border-top: 1px solid #3d4455;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 28px;
}

.status-bar::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #7f8599;
  flex-shrink: 0;
}


/* File tabs */
.file-tabs {
  display: flex;
  background: #1e2230;
  border-bottom: 1px solid #3d4455;
  overflow-x: auto;
}

.file-tab {
  padding: 8px 16px;
  background: #1e2230;
  color: #7f8599;
  border: none;
  cursor: pointer;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-right: 1px solid #3d4455;
  white-space: nowrap;
}

.file-tab:hover {
  background: #252938;
}

.file-tab.active {
  background: #161923;
  color: #c8c9db;
  border-bottom: 2px solid #6b5fc8;
  padding-bottom: 6px;
}

.file-tab .close-btn {
  opacity: 0.5;
  font-size: 14px;
}

.file-tab .close-btn:hover {
  opacity: 1;
}

.add-file-btn {
  padding: 8px 12px;
  background: transparent;
  color: #7f8599;
  border: none;
  cursor: pointer;
  font-size: 16px;
}

.add-file-btn:hover {
  color: #c8c9db;
  background: #252938;
}

/* Panel header buttons */
.panel-header-buttons {
  display: flex;
  gap: 8px;
}

#resetBtn {
  padding: 5px 10px;
  font-size: 12px;
  background: #3d4455;
  color: #c8c9db;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

#resetBtn:hover {
  background: #5a4a6a;
}

#shareBtn {
  padding: 5px 10px;
  font-size: 12px;
  background: #1e3a52;
  color: #6b9bd1;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

#shareBtn:hover {
  background: #2a4f6e;
  color: #a0c4e8;
}

/* Error highlighting */
.errorHighlight {
  background-color: rgba(255, 0, 0, 0.2);
  border-bottom: 2px wavy #f44;
}

.errorLine {
  background-color: rgba(255, 0, 0, 0.1);
}

.errorGlyph {
  background-color: #f44;
  border-radius: 50%;
  margin-left: 5px;
}

/* Warning highlighting */
.warningHighlight {
  background-color: rgba(230, 180, 0, 0.25);
  border-bottom: 2px wavy #e6b400;
}

.warningLine {
  background-color: rgba(230, 180, 0, 0.12);
}

.warningGlyph {
  background-color: #e6b400;
  border-radius: 50%;
  margin-left: 5px;
}

/* Solution file tab — same shape as regular tabs, distinct background */
.file-tab.solution { background: #1e1b2e; }
.file-tab.solution:hover { background: #262240; }
.file-tab.solution.active { background: #14121e; }

/* Persistent "Solution" button — sits on the right of the tab bar */
.solution-btn {
  margin-left: auto;
  padding: 4px 10px;
  background: #2a2540;
  color: #b0a0d0;
  border: 1px solid #3d3560;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  align-self: center;
  margin-right: 6px;
  white-space: nowrap;
}

.solution-btn:hover {
  background: #352d55;
  color: #d4c0f0;
}

/* Wide screen: side-by-side layout */
@media (min-width: 1200px) {
  .editor-container {
    flex-direction: row;
    gap: 8px;
  }

  .panel { flex: 1; }

  .resize-handle {
    display: none;
  }

  /* Override any inline heights set by resize drag */
  #editor-container, #output {
    height: auto !important;
  }
}
