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

:root {
  --bg: #212121;
  --bg-panel: #2b2b2b;
  --bg-editor: #263238; /* material theme base */
  --bg-soft: #333;
  --border: #3a3a3a;
  --text: #eceff1;
  --muted: #9e9e9e;
  --accent: #4caf50;
  --accent-hover: #66bb6a;
  --red: #e57373;
  --edit-bg: #263238;
}

html,
body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
}

body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ---------- 顶栏 ---------- */
.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 8px;
  user-select: none;
}

.logo {
  font-size: 20px;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: 0.5px;
}

.brand-sub {
  font-size: 12px;
  color: var(--muted);
}

.lang-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}

.lang-label {
  font-size: 13px;
  color: var(--muted);
}

#langSelect {
  background: var(--bg-soft);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 5px 8px;
  font-size: 13px;
  max-width: 180px;
  outline: none;
  cursor: pointer;
}

#langSelect:focus {
  border-color: var(--accent);
}

.btn {
  background: var(--bg-soft);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
  white-space: nowrap;
}

.btn:hover {
  background: #444;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-run {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
  padding: 6px 18px;
}

.btn-run:hover {
  background: var(--accent-hover);
}

.btn-file {
  position: relative;
  overflow: hidden;
}

.btn-file input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.spacer {
  flex: 1;
}

/* ---------- 工作区 ---------- */
.workspace {
  flex: 1;
  display: flex;
  min-height: 0;
}

.pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}

.pane-editor {
  flex: 1 1 55%;
  border-right: 1px solid var(--border);
}

.pane-console {
  flex: 1 1 45%;
  background: var(--bg-panel);
}

.pane-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.pane-title {
  font-size: 13px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cursor-pos {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.stdin-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}

.stdin-toggle input {
  accent-color: var(--accent);
  cursor: pointer;
}

/* 编辑器容器 */
.CodeMirror {
  flex: 1;
  height: auto;
  min-height: 0;
  font-size: 14px;
  line-height: 1.5;
}

/* ---------- 控制台 ---------- */
.console-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.output {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 12px 14px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 13.5px;
  white-space: pre-wrap;
  word-break: break-word;
  color: #d8e0e3;
  background: transparent;
  line-height: 1.55;
}

.output .stderr {
  color: var(--red);
}

.output:empty::before {
  content: "运行后将在此处显示输出与错误……";
  color: #5a5a5a;
}

.output.loading {
  color: #ffb74d;
}

.stdin-box {
  flex-shrink: 0;
  border-top: 1px dashed var(--border);
  padding: 8px 12px;
}

.stdin-label {
  font-size: 12px;
  color: var(--accent-hover);
  margin-bottom: 6px;
}

.stdin-box.hidden {
  display: none;
}

#stdin {
  width: 100%;
  height: 76px;
  resize: vertical;
  background: var(--bg-soft);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px 10px;
  font-family: "SFMono-Regular", Consolas, Menlo, monospace;
  font-size: 13px;
  outline: none;
}

#stdin:focus {
  border-color: var(--accent);
}

.status {
  flex-shrink: 0;
  padding: 5px 14px;
  font-size: 12px;
  color: var(--muted);
  border-top: 1px solid var(--border);
  min-height: 24px;
}

.status.error {
  color: var(--red);
}

.status.success {
  color: var(--accent-hover);
}

@media (max-width: 720px) {
  .workspace {
    flex-direction: column;
  }
  .pane-editor {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .brand-sub,
  .cursor-pos {
    display: none;
  }
}