/* zn 游乐场 — 极简黑白（日/夜两套配色走 CSS 变量） */

:root {
  --bg: #000;
  --fg: #d6d6d6;
  --muted: #5a5a5a;
  --line: #141414;
  --line-strong: #2e2e2e;
  --btn: #b0b0b0;
  --btn-strong: #fff;
  --accent: #7aa2f7;
  --placeholder: #2c2c2c;
}

[data-theme="light"] {
  --bg: #fff;
  --fg: #24292e;
  --muted: #999;
  --line: #e8e8e8;
  --line-strong: #c6c6c6;
  --btn: #555;
  --btn-strong: #000;
  --accent: #2f6feb;
  --placeholder: #bbb;
}

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

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--fg);
  font-family: ui-monospace, 'JetBrains Mono', 'SF Mono', SFMono-Regular, Menlo, Consolas, 'Liberation Mono', monospace;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---------- 顶栏 ---------- */
header {
  flex: 0 0 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  border-bottom: 1px solid var(--line-strong); /* 下边沿细直线 */
  background: var(--bg);
  user-select: none;
}

.brand { font-size: 14px; font-weight: 700; letter-spacing: .5px; color: var(--fg); }
.brand .dim { color: var(--muted); font-weight: 400; }

.actions { display: flex; align-items: center; gap: 12px; }

.status { font-size: 11px; color: var(--muted); margin-right: 6px; }

/* 运行按钮：黑白 */
.btn {
  background: transparent;
  color: var(--btn);
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  padding: 4px 14px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  transition: color .12s, border-color .12s;
}
.btn:hover { color: var(--btn-strong); border-color: var(--btn); }
.btn:disabled { opacity: .35; cursor: not-allowed; }

.btn-accent { color: var(--btn-strong); border-color: var(--line-strong); }
.btn-accent:hover { border-color: var(--btn-strong); }

/* 带下划线的文本按钮（朝/暮、文档、清空） */
.text-btn {
  background: none;
  border: none;
  padding: 0 2px;
  color: var(--btn);
  font: inherit;
  font-size: 12px;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  transition: color .12s;
}
.text-btn:hover { color: var(--btn-strong); }

/* ---------- 主体 ---------- */
main { flex: 1; display: flex; min-height: 0; }

#editor-wrap { flex: 3; min-width: 0; }
#editor { width: 100%; height: 100%; }

#term-wrap {
  flex: 2;
  min-width: 0;
  position: relative;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--line-strong); /* 电脑端与编辑器之间的线 */
  background: var(--bg);
}

#term { flex: 1; min-height: 0; padding: 8px 0 0 10px; }

/* 终端容器内边距：xterm 自身上内边距 8px */
#term .xterm { padding: 0; }

/* 清空按钮：终端右上角 */
.clear-btn {
  position: absolute;
  top: 6px;
  right: 12px;
  z-index: 5;
  font-size: 12px;
}

/* ---------- 输入行 ---------- */
#input-line {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 12px;
  border-top: 1px solid var(--line);
  background: var(--bg);
}

.prompt { color: var(--accent); font-size: 13px; user-select: none; }

#term-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--fg);
  font: inherit;
  font-size: 13px;
  caret-color: var(--accent);
}
#term-input::placeholder { color: var(--placeholder); }

/* ---------- 终端窄条 / 符号栏（仅移动端竖屏） ---------- */
#term-bar { display: none; }
#sym-bar { display: none; }

@media (max-width: 860px) and (orientation: portrait) {
  main { flex-direction: column; }

  #editor-wrap { flex: 1; min-height: 0; }

  /* 符号栏：终端收起时显示在窄条上方，可横向滑动 */
  #sym-bar {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    overflow-x: auto;
    border-top: 1px solid var(--line);
    background: var(--bg);
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  #sym-bar::-webkit-scrollbar { display: none; }
  body.term-open #sym-bar { display: none; }

  .sym-btn {
    flex: 0 0 auto;
    background: transparent;
    border: 1px solid var(--line-strong);
    border-radius: 4px;
    color: var(--fg);
    font: inherit;
    font-size: 12px;
    padding: 3px 8px;
    cursor: pointer;
  }

  /* 终端：收起时是底部窄条，展开占屏幕下方 60% */
  #term-wrap {
    flex: 0 0 auto;
    height: 36px;
    overflow: hidden;
    border-left: none;
    border-top: 1px solid var(--line-strong);
    transition: height .18s ease;
  }
  body.term-open #term-wrap { height: 60vh; }

  #term-bar {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: space-between;
    height: 36px;
    padding: 0 14px;
    font-size: 12px;
    color: var(--muted);
    cursor: pointer;
    user-select: none;
  }
  .term-bar-close {
    display: none;
    text-decoration: underline;
    color: var(--btn);
  }
  body.term-open .term-bar-close { display: inline; }

  #term { display: none; padding-top: 4px; }
  #input-line { display: none; }
  .clear-btn { display: none; top: 42px; }

  body.term-open #term { display: block; }
  body.term-open #input-line { display: flex; }
  body.term-open .clear-btn { display: inline; }
}
