* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0f0f13;
  --surface:   #16161e;
  --surface2:  #1e1e2a;
  --surface3:  #252535;
  --border:    #2a2a3a;
  --accent:    #7c6af7;
  --accent2:   #56cfb2;
  --red:       #ff5f57;
  --yellow:    #febc2e;
  --green:     #28c840;
  --text:      #c9d1d9;
  --text-dim:  #6e7681;
  --html-col:  #e34c26;
  --css-col:   #264de4;
  --js-col:    #f7df1e;
}

body {
  font-family: 'Inter', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ── SVG icons ── */
svg { width: 14px; height: 14px; flex-shrink: 0; }

/* ── Title Bar ── */
.titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
  height: 38px;
  flex-shrink: 0;
  user-select: none;
}

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

.logo-svg { width: 20px; height: 20px; }

.logo-text { font-size: 13px; color: var(--text-dim); letter-spacing: 0.5px; }
.logo-text strong { color: var(--text); }

.titlebar-center {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--text-dim);
}

#lang-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 20px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  letter-spacing: 0.5px;
}

/* ── Workspace (sidebar + main) ── */
.workspace {
  display: flex;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

/* ── Sidebar ── */
.sidebar {
  width: 170px;
  min-width: 120px;
  max-width: 280px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex-shrink: 0;
  overflow-y: auto;
}

.sidebar-section { margin-bottom: 14px; }

.section-label {
  font-size: 9px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: 5px;
  padding-left: 4px;
}

.sidebar button {
  width: 100%;
  padding: 7px 9px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 12px;
  font-family: 'Inter', sans-serif;
  text-align: left;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 7px;
  transition: all 0.15s;
  margin-bottom: 2px;
}

.sidebar button svg { stroke: currentColor; }

.sidebar button:hover { background: var(--surface3); color: var(--text); border-color: var(--border); }

.sidebar button.active {
  background: linear-gradient(135deg, rgba(124,106,247,0.2), rgba(86,207,178,0.1));
  border-color: var(--accent);
  color: #fff;
}

.run-btn { background: linear-gradient(135deg, #1a7a3a, #0f5c2a) !important; border-color: #1a7a3a !important; color: #fff !important; }
.run-btn:hover { filter: brightness(1.2); }
.run-btn svg { fill: #fff; stroke: none; width: 12px; height: 12px; }

.export-btn svg { width: 13px; height: 13px; }
.export-all-btn {
  background: linear-gradient(135deg, rgba(124,106,247,0.15), rgba(86,207,178,0.08)) !important;
  border-color: var(--accent) !important;
  color: var(--accent) !important;
  margin-top: 4px;
}
.export-all-btn:hover { filter: brightness(1.2); }

/* Toggle */
.auto-label {
  font-size: 12px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 4px;
}

.toggle-wrap { position: relative; width: 32px; height: 17px; flex-shrink: 0; }
.toggle-wrap input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--surface3);
  border-radius: 17px;
  border: 1px solid var(--border);
  transition: 0.2s;
  cursor: pointer;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 11px; height: 11px;
  left: 2px; top: 2px;
  background: var(--text-dim);
  border-radius: 50%;
  transition: 0.2s;
}

.toggle-wrap input:checked + .toggle-slider { background: linear-gradient(135deg, var(--accent), var(--accent2)); border-color: var(--accent); }
.toggle-wrap input:checked + .toggle-slider::before { transform: translateX(15px); background: #fff; }

.sidebar-footer { margin-top: auto; padding-top: 8px; border-top: 1px solid var(--border); }
.version { font-size: 10px; color: var(--text-dim); padding-left: 4px; }

/* ── Resize Handles ── */
.resize-handle {
  background: var(--border);
  flex-shrink: 0;
  transition: background 0.15s;
  position: relative;
  z-index: 10;
}

.resize-handle:hover,
.resize-handle.dragging { background: var(--accent); }

/* Wider invisible hit area via pseudo-element */
.resize-h {
  width: 4px;
  cursor: col-resize;
}
.resize-h::after {
  content: '';
  position: absolute;
  top: 0; bottom: 0;
  left: -4px; right: -4px;
  cursor: col-resize;
  z-index: 20;
}

.resize-v {
  height: 4px;
  cursor: row-resize;
  width: 100%;
}
.resize-v::after {
  content: '';
  position: absolute;
  left: 0; right: 0;
  top: -4px; bottom: -4px;
  cursor: row-resize;
  z-index: 20;
}

/* Drag overlay — blocks iframe from eating mouse events */
#drag-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
}
#drag-overlay.col-active { cursor: col-resize; display: block; }
#drag-overlay.row-active { cursor: row-resize; display: block; }

/* ── Main Area ── */
.main-area {
  display: flex;
  flex: 1;
  overflow: hidden;
  min-width: 0;
}

/* ── Editor Area ── */
.editor-area {
  display: flex;
  flex-direction: column;
  width: 50%;
  min-width: 150px;
  overflow: hidden;
}

.tabs {
  display: flex;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 4px;
  gap: 1px;
  flex-shrink: 0;
}

.tab {
  padding: 7px 13px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 12px;
  font-family: 'Inter', sans-serif;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: color 0.15s;
  white-space: nowrap;
}

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

.tab-icon {
  font-size: 9px;
  font-weight: 700;
  width: 15px; height: 15px;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.html-icon { background: var(--html-col); color: #fff; }
.css-icon  { background: var(--css-col);  color: #fff; }
.js-icon   { background: var(--js-col);   color: #000; }

.tabs.hidden { display: none; }

#editor { flex: 1; overflow: hidden; }

/* ── Preview Area ── */
.preview-area {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 100px;
  overflow: hidden;
}

/* ── Shared Panel Header ── */
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 5px 10px;
  flex-shrink: 0;
  height: 32px;
}

.panel-header-left {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.panel-header-left svg { width: 13px; height: 13px; }

.icon-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  cursor: pointer;
  border-radius: 4px;
  padding: 3px 6px;
  display: flex;
  align-items: center;
  transition: all 0.15s;
}

.icon-btn:hover { background: var(--surface3); color: var(--text); }
.icon-btn svg { width: 12px; height: 12px; }

#preview { flex: 1; border: none; background: #fff; }

/* ── Terminal ── */
.terminal-wrap {
  background: #0a0a0f;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  height: 180px;
  min-height: 60px;
  max-height: 60vh;
}

.terminal-dots { display: flex; gap: 5px; align-items: center; }

.dot { width: 10px; height: 10px; border-radius: 50%; }
.dot.red    { background: var(--red); }
.dot.yellow { background: var(--yellow); }
.dot.green  { background: var(--green); }

#terminal {
  flex: 1;
  color: #a8ff78;
  padding: 8px 14px;
  overflow-y: auto;
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  font-size: 12.5px;
  white-space: pre-wrap;
  line-height: 1.6;
}

#terminal::-webkit-scrollbar { width: 4px; }
#terminal::-webkit-scrollbar-track { background: transparent; }
#terminal::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.prompt { color: var(--accent2); }
.error   { color: var(--red); }
.info    { color: #79c0ff; }

/* ── Footer ── */
.footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  padding: 3px 14px;
  font-size: 11px;
  color: #fff;
  flex-shrink: 0;
  letter-spacing: 0.3px;
}

.footer-left { display: flex; align-items: center; gap: 6px; }
.footer-left svg { width: 13px; height: 13px; stroke: rgba(255,255,255,0.8); }
.footer strong { font-weight: 600; }
.footer-right { opacity: 0.8; }
