/* ==========================================================================
   SYSTEM 插件 · 终端极客风格
   独立于 neo-brutalism.css，不复用任何新粗野主义视觉变量。
   区域顺序（纵向）：① 命令历史 → ② 命令输入区 → ③ 环境变量(可折叠) → ④ 标准输出/报错
   ========================================================================== */

.term-shell {
  --term-bg: #0b0f14;
  --term-panel: #111820;
  --term-panel-2: #0e151c;
  --term-border: #22303b;
  --term-border-soft: #1a2630;
  --term-fg: #c9d5df;
  --term-muted: #6b7c8a;
  --term-cyan: #56d4dd;
  --term-green: #7ee787;
  --term-red: #ff7b72;
  --term-purple: #d2a8ff;
  --term-yellow: #e3b341;
  --term-blue: #79c0ff;
  --term-font: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  background: var(--term-bg);
  border: 1px solid var(--term-border);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 16px 48px rgba(0, 0, 0, .35);
  color: var(--term-fg);
  font-family: var(--term-font);
  font-size: 13px;
}

/* 顶部标题栏：左侧品牌标识 */
.term-titlebar {
  display: flex; align-items: center; gap: .75rem;
  height: 38px; padding: 0 1rem;
  background: linear-gradient(180deg, #18222c, #121a22);
  border-bottom: 1px solid var(--term-border);
}
.term-brand {
  flex: 0 0 auto; font-weight: 800; font-size: 14px; letter-spacing: .02em;
  color: var(--term-cyan);
}
.term-title {
  flex: 1; text-align: center; color: var(--term-muted);
  font-size: 11px; letter-spacing: .12em; text-transform: uppercase;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.term-title strong { color: var(--term-cyan); font-weight: 700; }
.term-title-right { flex: 0 0 auto; color: var(--term-muted); font-size: 11px; }

/* 通用面板头 */
.term-pane { min-width: 0; border-bottom: 1px solid var(--term-border); }
.term-pane-head {
  display: flex; align-items: center; justify-content: space-between;
  height: 30px; padding: 0 .9rem;
  background: var(--term-panel-2);
  border-bottom: 1px solid var(--term-border-soft);
}
.term-pane-title { color: var(--term-muted); font-size: 10px; letter-spacing: .16em; font-weight: 700; }
.term-pane-meta { color: var(--term-muted); font-size: 10px; }

/* ① 命令历史：整块可选中复制，行号可点击 */
.term-history {
  height: 220px; overflow-y: auto; padding: .65rem .5rem;
  background: var(--term-panel);
  user-select: text; -webkit-user-select: text;
}
.term-code { display: flex; flex-direction: column; }
.term-code-line {
  display: flex; align-items: flex-start; gap: .55rem;
  padding: .12rem .35rem; border-radius: 3px;
  white-space: pre; min-height: 1.5rem;
}
.term-code-line:hover { background: rgba(86, 212, 221, .06); }
.term-code-line.is-selected { background: rgba(86, 212, 221, .12); }
.term-lineno {
  flex: 0 0 2.1rem; text-align: right; cursor: pointer;
  background: none; border: 0; padding: 0; color: #445565;
  font-family: inherit; font-size: 11px; line-height: 1.5;
}
.term-lineno:hover, .term-code-line.is-selected .term-lineno { color: var(--term-cyan); }
.term-code-text { color: var(--term-fg); font-family: inherit; font-size: 12px; line-height: 1.5; }
.term-slash { color: var(--term-purple); font-weight: 700; }

/* ② 命令输入区：仿终端提示符 + 5 倍行高编辑区 + 辅助输入栏 */
.term-inputzone {
  background: #0a1016;
  border-bottom: 1px solid var(--term-border);
  padding: .55rem .9rem .65rem;
}
.term-input-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: .75rem; margin-bottom: .35rem;
}
.term-ps1 { color: var(--term-green); font-size: 12px; white-space: nowrap; }
.term-ps1-user { color: var(--term-cyan); }
.term-ps1-cd { color: var(--term-yellow); }
.term-ps1-slash { color: var(--term-purple); font-weight: 700; margin-left: .15rem; }
.term-input-hint { color: #445565; font-size: 10px; }
/* 编辑区：neo-brutalism.css 对 textarea 用了 !important 强制白底黑字，
   这里用更高优先级 + !important 覆盖，保证与终端同色、同字体。 */
.term-shell textarea.term-input {
  display: block; width: 100%; box-sizing: border-box;
  background: #070c11 !important;
  color: var(--term-fg) !important;
  border: 1px solid var(--term-border) !important;
  border-radius: 4px !important;
  box-shadow: none !important;
  font-family: var(--term-font) !important;
  font-size: 13px !important;
  font-weight: 400 !important;
  line-height: 1.7 !important;
  outline: none !important;
  resize: vertical;
  /* 5 倍行高：行高 * 5 + 上下 padding */
  min-height: calc(1.7em * 5 + .9rem);
  padding: .45rem .6rem;
  caret-color: var(--term-green);
}
.term-shell textarea.term-input:focus {
  border-color: #2a4a58 !important;
  box-shadow: 0 0 0 2px rgba(86, 212, 221, .1) !important;
  outline: none !important;
}
.term-shell textarea.term-input::placeholder { color: #445565 !important; font-weight: 400 !important; }

/* 辅助输入栏：所有按键（含「运行」）统一同款样式 */
.term-aux {
  display: flex; align-items: center; flex-wrap: wrap; gap: .35rem;
  margin-top: .55rem; padding-top: .55rem;
  border-top: 1px dashed var(--term-border-soft);
}
.term-aux-label { color: var(--term-muted); font-size: 10px; letter-spacing: .08em; margin-right: .15rem; }
.term-aux button {
  background: #101922; color: #9fb0bd;
  border: 1px solid #26343f; border-radius: 4px;
  padding: .22rem .5rem; font-family: inherit; font-size: 11px;
  cursor: pointer; line-height: 1.4;
}
.term-aux button:hover { background: #17252f; color: var(--term-cyan); border-color: #2a4a58; }
.term-aux button:active { transform: translateY(1px); }
.term-aux button:disabled { opacity: .5; cursor: wait; }

/* ③ 环境变量（可折叠） */
.term-fold-head {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; height: 30px; padding: 0 .9rem;
  background: var(--term-panel-2);
  border: 0; border-bottom: 1px solid var(--term-border-soft);
  cursor: pointer; text-align: left;
}
.term-fold-head:hover { background: #131d26; }
.term-fold-toggle { display: flex; align-items: center; gap: .5rem; color: var(--term-muted); font-size: 10px; }
.term-fold-toggle span:last-child { color: var(--term-cyan); font-size: 14px; font-weight: 700; }
.term-env {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: .35rem .9rem; padding: .75rem 1rem; background: var(--term-panel);
}
.term-env-row { display: flex; gap: .3rem; min-width: 0; font-size: 12px; }
.term-env-key { color: var(--term-purple); font-weight: 700; }
.term-env-eq { color: var(--term-muted); }
.term-env-val { color: var(--term-yellow); word-break: break-all; }

/* ④ 标准输出 / 报错（最下方）
   旧版固定 height:300px + padding:.85rem + line-height:1.6，短输出时上下出现大片空白；
   改为随内容自适应，仅保留上限用于滚动，并收紧行距与块间距。 */
.term-output {
  min-height: 56px; max-height: 300px; height: auto; overflow-y: auto;
  padding: .4rem .9rem;
  background: var(--term-panel);
  line-height: 1.45; white-space: normal; word-break: break-word;
}
/* pre-wrap 只作用于真正的文本行：若加在容器上，HTML 模板缩进的换行会被当成空行渲染，
   表现为正文上下出现大片无内容区域。 */
.term-line, .term-cmdline { white-space: pre-wrap; }
.term-block { margin-bottom: .35rem; }
.term-block:last-child { margin-bottom: 0; }
.term-cmdline { color: var(--term-blue); margin-bottom: 0; }
.term-prompt-symbol { color: var(--term-purple); font-weight: 700; }
.term-line.term-out { color: var(--term-green); }
.term-line.term-err { color: var(--term-red); }
.term-muted { color: var(--term-muted); font-style: italic; }

/* 滚动条 */
.term-history::-webkit-scrollbar, .term-output::-webkit-scrollbar { width: 8px; }
.term-history::-webkit-scrollbar-thumb, .term-output::-webkit-scrollbar-thumb { background: #263442; border-radius: 4px; }
.term-history::-webkit-scrollbar-track, .term-output::-webkit-scrollbar-track { background: transparent; }

@media (max-width: 600px) {
  .term-shell { font-size: 12px; }
  .term-title-right { display: none; }
  .term-history { height: 180px; }
  .term-output { max-height: 240px; }
  .term-ps1 { font-size: 11px; }
  .term-input-hint { display: none; }
  .term-env { grid-template-columns: 1fr; }
  .term-aux button { padding: .28rem .55rem; }
}
