/* ─────────────────────────────────────────────
   APCSP IDE — style.css (simplified)
   ───────────────────────────────────────────── */

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

:root {
  /* chrome */
  --titlebar-h:   44px;
  --tabbar-h:     36px;

  /* palette */
  --bg-base:      #1e1e1e;
  --bg-editor:    #1e1e1e;
  --bg-titlebar:  #323233;
  --bg-tab:       #2d2d2d;
  --bg-tab-active:#1e1e1e;
  --bg-console:   #1e1e1e;
  --bg-input:     #3c3c3c;
  --bg-hover:     #2a2d2e;
  --bg-selection: #264f78;

  /* borders */
  --border:       #444;
  --border-light: #3c3c3c;

  /* text */
  --text:         #d4d4d4;
  --text-dim:     #888;

  /* accents */
  --accent:       #007acc;
  --accent-run:   #388a34;
  --accent-run-h: #3ea83a;
  --error:        #f44747;
  --success:      #4ec9b0;
  --output:       #d4d4d4;

  --font-code: 'JetBrains Mono', 'Consolas', monospace;
  --font-ui:   'Inter', 'Segoe UI', sans-serif;
  --code-size: 13.5px;
  --ui-size:   12px;
}

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg-base);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: var(--ui-size);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── Titlebar ── */
.titlebar {
  height: var(--titlebar-h);
  background: var(--bg-titlebar);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  border-bottom: 1px solid #111;
  flex-shrink: 0;
  user-select: none;
}
.titlebar-left  { display: flex; align-items: center; }
.titlebar-right { display: flex; align-items: center; gap: 6px; }
.titlebar-center {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  color: var(--text-dim);
  pointer-events: none;
}

.app-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  font-family: var(--font-ui);
  letter-spacing: 0.03em;
}

.tb-btn {
  font-family: var(--font-ui);
  font-size: 11px;
  padding: 4px 11px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.12s;
}
.tb-btn:hover { background: var(--bg-hover); color: var(--text); }

.run-btn {
  background: var(--accent-run) !important;
  border-color: transparent !important;
  color: #fff !important;
  font-weight: 500;
}
.run-btn:hover { background: var(--accent-run-h) !important; }
.run-btn.running { background: #8b0000 !important; }

/* ── Layout ── */
.workspace {
  display: flex;
  height: calc(100vh - var(--titlebar-h));
  overflow: hidden;
}

/* ── Main column ── */
.main-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* ── Tab bar ── */
.tab-bar {
  height: var(--tabbar-h);
  background: var(--bg-tab);
  display: flex;
  align-items: flex-end;
  border-bottom: 1px solid #111;
  overflow-x: auto;
  flex-shrink: 0;
  scrollbar-width: none;
}
.tab-bar::-webkit-scrollbar { display: none; }

.tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  height: 33px;
  background: var(--bg-tab);
  border-right: 1px solid #111;
  border-top: 2px solid transparent;
  font-size: 12px;
  color: var(--text-dim);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all 0.1s;
}
.tab:hover { color: var(--text); }
.tab.active {
  background: var(--bg-tab-active);
  color: var(--text);
  border-top-color: var(--accent);
}
.tab .tab-dot {
  font-size: 8px;
  color: var(--text-dim);
  display: none;
}
.tab.dirty .tab-dot { display: inline; }
.tab .tab-close {
  opacity: 0;
  font-size: 12px;
  line-height: 1;
  padding: 1px 2px;
  border-radius: 2px;
  color: var(--text-dim);
}
.tab:hover .tab-close,
.tab.active .tab-close { opacity: 1; }
.tab .tab-close:hover { background: rgba(255,255,255,0.12); color: var(--text); }

/* ── Code pane ── */
.code-pane {
  flex: 1;
  display: flex;
  overflow: hidden;
  min-height: 0;
}

#editor {
  flex: 1;
  padding: 10px 16px;
  font-family: var(--font-code);
  font-size: var(--code-size);
  line-height: 1.6;
  color: var(--text);
  caret-color: #aeafad;
  background: var(--bg-editor);
  border: none;
  outline: none;
  resize: none;
  tab-size: 3;
  white-space: pre;
  overflow-wrap: normal;
  overflow: auto;
}
#editor::selection { background: var(--bg-selection); }

/* ── Console ── */
.console-panel {
  height: 200px;
  min-height: 80px;
  display: flex;
  flex-direction: column;
  background: var(--bg-console);
  border-top: 1px solid #111;
  flex-shrink: 0;
}
.console-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  height: 30px;
  background: #252526;
  border-bottom: 1px solid #111;
  flex-shrink: 0;
}
.console-tabs { display: flex; }
.con-tab {
  font-size: 11px;
  padding: 0 12px;
  line-height: 30px;
  color: var(--text-dim);
  cursor: pointer;
  letter-spacing: 0.08em;
  font-weight: 500;
}
.con-tab.active { color: var(--text); border-bottom: 2px solid var(--accent); }
.console-header-right button {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 11px;
  cursor: pointer;
  padding: 2px 8px;
  border-radius: 2px;
  font-family: var(--font-ui);
}
.console-header-right button:hover { background: var(--bg-hover); color: var(--text); }

.console-output {
  flex: 1;
  overflow-y: auto;
  padding: 8px 14px;
  font-family: var(--font-code);
  font-size: 12.5px;
  line-height: 1.65;
}
.console-output::-webkit-scrollbar { width: 6px; }
.console-output::-webkit-scrollbar-track { background: var(--bg-console); }
.console-output::-webkit-scrollbar-thumb { background: #424242; border-radius: 3px; }

.con-welcome {
  color: var(--text-dim);
  display: block;
}
.con-welcome kbd {
  background: #3c3c3c;
  border: 1px solid #555;
  border-radius: 3px;
  padding: 0 4px;
  font-family: var(--font-code);
  font-size: 11px;
}

.con-line {
  display: block;
  white-space: pre-wrap;
  word-break: break-all;
  animation: fadein 0.08s ease;
}
@keyframes fadein { from { opacity:0; } to { opacity:1; } }
.con-line.output  { color: var(--output); }
.con-line.error   { color: var(--error); }
.con-line.error::before   { content: '✖ '; }
.con-line.info    { color: var(--text-dim); }
.con-line.stdin   { color: #cca700; }
.con-line.stdin::before { content: '▸ '; }
.con-line.success { color: var(--success); }

.console-stdin {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-top: 1px solid var(--border-light);
  background: #1a1a1a;
  flex-shrink: 0;
}
.console-stdin.hidden { display: none; }
.stdin-label { font-family: var(--font-code); font-size: 12px; color: #cca700; flex-shrink: 0; }
#stdin-input {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--font-code);
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 2px;
  outline: none;
}
#stdin-input:focus { border-color: #cca700; }
#stdin-send {
  background: #3c3c3c;
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 2px;
  cursor: pointer;
}
#stdin-send:hover { background: #4c4c4c; }

/* ── Modal ── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.overlay.hidden { display: none; }
.modal {
  background: #252526;
  border: 1px solid var(--border);
  border-radius: 6px;
  width: 620px;
  max-width: 95vw;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.7);
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
}
#modal-close {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 16px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}
#modal-close:hover { color: var(--text); }
.modal-body {
  overflow-y: auto;
  padding: 16px;
}
.modal-body::-webkit-scrollbar { width: 6px; }
.modal-body::-webkit-scrollbar-thumb { background: #424242; border-radius: 3px; }

.ref-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
.ref-table th {
  text-align: left;
  padding: 6px 12px;
  background: #1e1e1e;
  color: var(--text-dim);
  font-weight: 600;
  letter-spacing: 0.06em;
  font-size: 11px;
  border-bottom: 1px solid var(--border);
}
.ref-table td {
  padding: 6px 12px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text);
  vertical-align: middle;
}
.ref-table tr:hover td { background: var(--bg-hover); }
.ref-table code {
  font-family: var(--font-code);
  font-size: 12px;
  background: #1e1e1e;
  padding: 1px 5px;
  border-radius: 3px;
  color: #569cd6;
}

/* ── Responsive ── */
@media (max-width: 480px) {
  .titlebar-center { display: none; }
}

