/* 服务器终端 · macOS Terminal 黑底白字主题 */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
  --bg: #000000;
  --bg-panel: #0d0d0d;
  --bar: #1e1e1e;
  --bar-line: #2c2c2c;
  --text: #e8e8e8;
  --text-bright: #ffffff;
  --text-dim: #7a7a7a;
  --text-faint: #4d4d4d;
  --green: #2fd45a;      /* 终端绿 */
  --cyan: #3bc1ff;       /* 终端青 */
  --yellow: #f5c542;
  --red: #ff5f56;
  --amber: #ffbd2e;
  --green-dot: #27c93f;
  --prompt: #8be9fd;
}

html, body { height: 100%; }
body {
  font-family: "SF Mono", "Menlo", "Monaco", "Consolas", "Liberation Mono", "Courier New", monospace;
  background: #000;
  color: var(--text);
  font-size: 13.5px;
  line-height: 1.6;
}

.hidden { display: none !important; }

/* 光标 */
.cursor { display: inline-block; width: 7px; height: 15px; background: var(--text-bright); vertical-align: -2px; }
.cursor.blink { animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* ---------- 整体布局 ---------- */
.app {
  width: 100%;
  height: 100dvh;
  margin: 0 auto;
  background: var(--bg);
  display: flex;
  flex-direction: column;
}

/* ---------- 访问口令（SSH 登录） ---------- */
.gate {
  position: fixed; inset: 0; z-index: 99;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.gate-card {
  width: 100%; max-width: 460px;
  background: var(--bg-panel);
  border: 1px solid var(--bar-line);
  border-radius: 8px;
  padding: 26px 24px 24px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, .6);
}
.gate-line { color: var(--text-dim); white-space: nowrap; overflow: hidden; }
.gate-prompt { color: var(--text-bright); margin-top: 12px; }
.gate-path { color: var(--cyan); }
.gate-hint { color: var(--text-dim); margin: 18px 0 8px; }
#gate-input {
  width: 100%; height: 40px;
  background: transparent;
  border: 1px solid var(--bar-line);
  border-radius: 6px;
  padding: 0 12px;
  font-size: 14px; font-family: inherit; color: var(--text-bright);
  outline: none;
}
#gate-input:focus { border-color: var(--green); }
#gate-btn {
  width: 100%; height: 38px; margin-top: 12px;
  border: 1px solid var(--green); border-radius: 6px;
  background: transparent; color: var(--green);
  font-size: 13.5px; font-family: inherit; cursor: pointer;
}
#gate-btn:hover { background: rgba(47, 212, 90, .1); }
#gate-btn:active { background: rgba(47, 212, 90, .18); }

/* ---------- 标题栏 ---------- */
.topbar {
  display: flex; align-items: center;
  height: 44px; padding: 0 16px;
  background: var(--bar);
  border-bottom: 1px solid var(--bar-line);
  flex-shrink: 0;
  position: relative;
  gap: 10px;
}

.topbar-title {
  flex: 1; min-width: 0;
  display: flex; align-items: baseline; gap: 8px;
  white-space: nowrap; overflow: hidden;
}
.tt-main { color: var(--text-bright); font-size: 13.5px; font-weight: 500; letter-spacing: .3px; }
.tt-sub { color: var(--text-faint); font-size: 12px; }

.topbar-right { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }

/* 下拉切换聊天对象 */
.target { position: relative; }
.target-btn {
  display: flex; align-items: center; gap: 6px;
  height: 26px; padding: 0 10px;
  background: transparent;
  border: 1px solid var(--bar-line); border-radius: 6px;
  color: var(--cyan); font-size: 12.5px; font-family: inherit;
  cursor: pointer;
}
.target-btn:hover { border-color: var(--text-dim); }
.target-label { max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.caret { color: var(--text-dim); font-size: 10px; }

.target-menu {
  position: absolute; top: 32px; right: 0; z-index: 50;
  min-width: 170px; max-width: 240px;
  background: var(--bg-panel);
  border: 1px solid var(--bar-line); border-radius: 8px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, .7);
  padding: 4px;
  max-height: 320px; overflow-y: auto;
}
.target-item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 12px;
  border-radius: 6px;
  color: var(--text); font-size: 12.5px; cursor: pointer;
  white-space: nowrap;
}
.target-item:hover { background: rgba(255, 255, 255, .06); }
.target-item.active { color: var(--green); }
.target-item .ti-label { overflow: hidden; text-overflow: ellipsis; }
.target-item .ti-badge {
  min-width: 16px; height: 16px; padding: 0 5px;
  background: var(--red); color: #fff; border-radius: 999px;
  font-size: 10px; line-height: 16px; text-align: center;
  display: none;
}
.target-item .ti-badge.show { display: inline-block; }
.target-empty { padding: 10px 12px; color: var(--text-faint); font-size: 12px; }

/* 连接状态 */
.conn { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-dim); white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #555; display: inline-block; }
.dot.on { background: var(--green); box-shadow: 0 0 6px rgba(47, 212, 90, .6); }
.dot.off { background: #555; }

/* 伪装切换按钮（近乎隐形：按住显示真实对话，松开恢复伪装） */
.reveal-btn {
  width: 20px; height: 20px; padding: 0 3px;
  background: transparent; border: none; border-radius: 4px;
  color: rgba(255, 255, 255, .05); font-size: 13px; line-height: 20px;
  font-family: inherit; cursor: default; user-select: none;
  -webkit-user-select: none; touch-action: none; flex-shrink: 0;
}
.reveal-btn:hover { color: rgba(255, 255, 255, .2); }
.reveal-btn:active { color: rgba(255, 255, 255, .38); }

/* ---------- 聊天区（终端） ---------- */
.chat {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px 10px;
  overscroll-behavior: contain;
  background: var(--bg);
  scrollbar-color: #333 #000;
}
.chat::-webkit-scrollbar { width: 9px; }
.chat::-webkit-scrollbar-thumb { background: #2e2e2e; border-radius: 4px; }
.chat::-webkit-scrollbar-track { background: transparent; }

.chat-empty {
  height: 100%; display: flex; flex-direction: column;
  align-items: flex-start; justify-content: center;
  padding: 0 8px;
}
.empty-text { color: var(--text-bright); font-size: 14px; }
.empty-sub { color: var(--text-faint); font-size: 12px; margin-top: 8px; }

/* 伪装模式的命令输出行（暗色，模拟终端回显） */
.fake-out { color: var(--text-dim); font-size: 12.5px; }

/* 单条终端行 */
.t-line {
  display: flex; flex-wrap: wrap; align-items: baseline;
  gap: 2px; margin: 2px 0;
  white-space: pre-wrap; word-break: break-word;
  font-size: 13.5px; line-height: 1.65;
}
.t-time { color: var(--text-faint); flex-shrink: 0; }
.t-user { color: var(--cyan); flex-shrink: 0; }
.t-user.me { color: var(--green); }
.t-sep { color: var(--text-dim); flex-shrink: 0; }
.t-text { color: var(--text-bright); }

/* 媒体：图片 / 视频（终端内嵌，左对齐） */
.t-media { margin: 4px 0 6px 18px; }
.msg-img {
  display: block;
  max-width: 220px; max-height: 280px;
  border: 1px solid #333; border-radius: 4px;
  cursor: zoom-in; object-fit: cover; background: #000;
}
/* 图片占位符 <pic>（终端风格，点击预览） */
.pic-tag {
  display: inline-block;
  flex-shrink: 0;
  padding: 1px 7px;
  border: 1px dashed var(--text-dim);
  border-radius: 3px;
  color: var(--cyan);
  background: rgba(59, 193, 255, .07);
  font-size: 12px;
  line-height: 1.4;
  cursor: zoom-in;
  user-select: none;
}
.pic-tag:hover { border-color: var(--cyan); color: var(--text-bright); background: rgba(59, 193, 255, .14); }
/* 显示真实内容时的实图（行内缩略图，点击放大） */
.msg-img.real-img {
  display: inline-block;
  max-width: 200px; max-height: 220px;
  margin: 2px 0;
  object-fit: contain;
}
.msg-video {
  display: block;
  max-width: 240px; max-height: 320px;
  border: 1px solid #333; border-radius: 4px; background: #000;
}
.msg-media-fail { color: var(--red); font-size: 12px; }

/* 语音条 */
.voice {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px;
  border: 1px solid var(--green); border-radius: 6px;
  color: var(--green); cursor: pointer;
  user-select: none; min-width: 86px; font-size: 12.5px;
}
.voice .v-icon { font-size: 13px; line-height: 1; }
.voice.playing .v-icon { animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.voice .v-wave { display: flex; align-items: center; gap: 2.5px; height: 13px; }
.voice .v-wave i {
  display: block; width: 2.5px; border-radius: 2px; background: var(--green);
  animation: vw 1s infinite ease-in-out;
}
.voice .v-wave i:nth-child(1){height:6px} .voice .v-wave i:nth-child(2){height:10px;animation-delay:.15s}
.voice .v-wave i:nth-child(3){height:13px;animation-delay:.3s} .voice .v-wave i:nth-child(4){height:9px;animation-delay:.45s}
.voice .v-wave i:nth-child(5){height:11px;animation-delay:.6s} .voice .v-wave i:nth-child(6){height:7px;animation-delay:.75s}
.voice.paused .v-wave i { animation-play-state: paused; }
@keyframes vw { 0%,100%{transform:scaleY(.55)} 50%{transform:scaleY(1)} }

.asr-text {
  margin: 4px 0 2px 18px;
  padding: 6px 10px;
  border-left: 2px solid var(--green);
  background: #0a0f0a;
  font-size: 12px; color: var(--text-dim);
  line-height: 1.5; max-width: 100%;
}
.asr-label { color: var(--text-faint); font-size: 11px; margin-right: 5px; }

/* 发送状态 */
.t-status { color: var(--text-faint); font-size: 11px; }
.t-status.failed { color: var(--red); }

/* ---------- 图片放大 ---------- */
.lightbox {
  position: fixed; inset: 0; z-index: 98;
  background: rgba(0, 0, 0, .92);
  display: flex; align-items: center; justify-content: center;
  cursor: zoom-out; padding: 24px;
}
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 4px; object-fit: contain; }

/* ---------- 附件预览条（跟随输入行，流内） ---------- */
.attach-bar {
  margin: 4px 0 0;
  padding: 6px 0 0;
  border-top: 1px dashed var(--text-faint);
}
.attach-list { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 8px; }
.attach-item {
  position: relative; flex-shrink: 0;
  width: 60px; height: 60px;
  border-radius: 6px; overflow: hidden;
  border: 1px solid var(--bar-line); background: #111;
  display: flex; align-items: center; justify-content: center;
}
.attach-item img, .attach-item video { width: 100%; height: 100%; object-fit: cover; }
.attach-item .file-tag { font-size: 10px; color: var(--text-dim); text-align: center; padding: 4px; word-break: break-all; }
.attach-del {
  position: absolute; top: 2px; right: 2px;
  width: 18px; height: 18px; border-radius: 50%;
  background: rgba(0, 0, 0, .7); color: #fff;
  border: none; font-size: 11px; line-height: 18px;
  cursor: pointer; padding: 0; text-align: center;
}

/* ---------- 命令行输入行（聊天流末尾，像继续敲命令） ---------- */
.input-row {
  display: flex; align-items: flex-end; flex-wrap: wrap;
  gap: 6px;
  padding: 6px 0 10px;
  margin-top: 4px;
  font-size: 13.5px; line-height: 1.65;
}
.input-row .t-user, .input-row .t-sep { line-height: 1.65; }
#input {
  flex: 1; min-width: 120px;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-bright);
  font-family: inherit; font-size: 13.5px; line-height: 1.65;
  resize: none; max-height: 96px;
  padding: 0;
}
#input::placeholder { color: var(--text-faint); }
.attach-btn {
  width: 28px; height: 28px; flex-shrink: 0;
  border: 1px solid var(--bar-line); border-radius: 6px;
  background: transparent; font-size: 13px; cursor: pointer;
  filter: grayscale(1); opacity: .45;
  align-self: center;
}
.attach-btn:hover { border-color: var(--text-dim); opacity: .9; }
.send-btn {
  height: 28px; padding: 0 10px; flex-shrink: 0;
  border: 1px solid var(--green); border-radius: 6px;
  background: transparent; color: var(--green);
  font-size: 12.5px; font-family: inherit; cursor: pointer;
  align-self: center;
}
.send-btn:disabled { opacity: .3; cursor: default; }
.send-btn:not(:disabled):hover { background: rgba(47, 212, 90, .1); }
.send-btn:not(:disabled):active { background: rgba(47, 212, 90, .18); }
