/* ============ 复古 CRT 终端 ============ */
:root {
  --phos: #4dff88;         /* 荧光绿主色 */
  --phos-dim: #2ea35c;     /* 暗绿 */
  --phos-bright: #a8ffc4;  /* 高亮 */
  --bg: #061009;
  --amber: #ffd24d;        /* 主动消息琥珀色 */
  --red: #ff7b6b;          /* 状态/告警 */
  --scan: rgba(0, 0, 0, 0.22);
}

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

html, body {
  height: 100%;
  max-width: 100vw;
  overflow: hidden;
  overflow-x: hidden;
  background: #020604;
  font-family: "Cascadia Mono", "Consolas", "Courier New", "NSimSun", monospace;
  color: var(--phos);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

.crt {
  height: 100vh;
  height: 100dvh;
  max-width: 1080px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(ellipse at center, rgba(20, 80, 45, 0.16) 0%, rgba(0, 0, 0, 0.55) 100%),
    var(--bg);
  position: relative;
  padding: 10px 14px;
}

/* 扫描线 + 屏幕微弯 */
.crt::before {
  content: "";
  position: absolute; inset: 0;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0px, transparent 2px,
    var(--scan) 3px, var(--scan) 4px);
  pointer-events: none;
  z-index: 9;
}
.crt::after {
  content: "";
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at center, transparent 62%, rgba(0, 0, 0, 0.55) 100%);
  pointer-events: none;
  z-index: 10;
}

/* 微微闪烁 */
@keyframes flicker {
  0%, 100% { opacity: 1; }
  92% { opacity: 1; }
  93% { opacity: 0.86; }
  94% { opacity: 1; }
  97% { opacity: 0.93; }
}
.crt { animation: flicker 7s infinite; }

/* 方框光标 */
.cursor {
  display: inline-block;
  width: 0.62em; height: 1.05em;
  background: var(--phos);
  vertical-align: text-bottom;
  margin-left: 2px;
  animation: blink 1.05s steps(1) infinite;
  box-shadow: 0 0 8px var(--phos);
}
@keyframes blink { 50% { opacity: 0; } }

.glow { text-shadow: 0 0 6px rgba(77, 255, 136, 0.65); }

/* ============ 状态栏 ============ */
.statusbar {
  border: 1px solid var(--phos-dim);
  padding: 4px 10px;
  margin-bottom: 6px;
  background: rgba(10, 40, 24, 0.35);
  box-shadow: inset 0 0 18px rgba(46, 163, 92, 0.12);
}
.sb-row {
  display: flex;
  gap: 10px;
  align-items: baseline;
  flex-wrap: wrap;
  padding: 2px 0;
}
.status-cell { white-space: nowrap; max-width: 100%; min-width: 0; }
.status-cell.grow { flex: 1; min-width: 0; overflow: hidden; }
.sb-value {
  display: inline-block;
  max-width: 100%;
  vertical-align: bottom;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sb-label {
  color: var(--phos-dim);
  font-size: 12px;
  margin-right: 6px;
  letter-spacing: 2px;
}
.sb-value { font-size: 13px; color: var(--phos-bright); }
.sb-value.offline { color: var(--red); }

/* 可回复状态：绿=可即时聊，琥珀=留言排队，暗红=睡眠 */
.sb-value.avail { padding: 0 6px; border: 1px solid; }
.avail-free { color: var(--phos-bright); border-color: var(--phos-dim); }
.avail-queued { color: var(--amber); border-color: var(--amber); }
.avail-sleep { color: var(--red); border-color: var(--red); opacity: 0.85; }

/* ============ 映像条 ============ */
.profilebar {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--phos-dim);
  border-top: none;
  padding: 4px 10px;
  margin-bottom: 8px;
  font-size: 12px;
  background: rgba(10, 40, 24, 0.22);
  flex-wrap: wrap;
}
.pb-title { letter-spacing: 4px; color: var(--phos-dim); }
.pb-item { color: var(--phos-bright); min-width: 0; }
.pb-num { color: var(--phos); font-size: 14px; }
.pb-bar {
  width: 110px; min-width: 60px; flex: 0 1 110px; height: 8px;
  border: 1px solid var(--phos-dim);
  position: relative;
}
.pb-fill {
  height: 100%; width: 0%;
  background: var(--phos);
  box-shadow: 0 0 8px var(--phos);
  transition: width 0.6s ease;
}
.pb-sep { color: var(--phos-dim); }
.pb-imp { color: var(--phos-dim); flex: 1; min-width: 140px; }
.pb-pend { color: var(--amber); }

/* ============ 对话区 ============ */
.chat {
  flex: 1;
  overflow-y: auto;
  padding: 10px 12px;
  border: 1px solid var(--phos-dim);
  background: rgba(4, 18, 10, 0.5);
  line-height: 1.75;
  font-size: 15px;
  scrollbar-width: thin;
  scrollbar-color: var(--phos-dim) transparent;
}
.chat::-webkit-scrollbar { width: 6px; }
.chat::-webkit-scrollbar-thumb { background: var(--phos-dim); }

.line { margin-bottom: 14px; word-wrap: break-word; white-space: pre-wrap; }
.line .speaker { font-weight: bold; letter-spacing: 1px; }
.line.user .speaker { color: var(--phos-bright); }
.line.agent .speaker { color: var(--phos); }
.line .status {
  display: block;
  color: var(--phos-dim);
  font-size: 13px;
  font-style: italic;
  margin-top: 2px;
}
.line.proactive {
  border-left: 3px solid var(--amber);
  padding-left: 10px;
  color: var(--amber);
}
.line.proactive .tag {
  font-size: 11px;
  border: 1px solid var(--amber);
  padding: 0 6px;
  margin-right: 8px;
  letter-spacing: 2px;
}
.line.farewell { color: var(--phos-dim); }
.line.sys { color: var(--phos-dim); font-size: 13px; }
.line.intercepted { color: var(--red); opacity: 0.85; }
.line.pending-note { color: var(--phos-dim); font-size: 12px; font-style: italic; }
.line.event-note { color: var(--amber); font-size: 13px; opacity: 0.9; }

.typing .dots::after {
  content: "▌";
  animation: blink 0.9s steps(1) infinite;
}

/* ============ 输入区 ============ */
.inputbar {
  border: 1px solid var(--phos-dim);
  margin-top: 8px;
  background: rgba(8, 30, 18, 0.35);
}
.input-row { display: flex; align-items: flex-start; }
.prompt-label {
  padding: 10px 4px 10px 12px;
  color: var(--phos-bright);
  text-shadow: 0 0 6px rgba(77, 255, 136, 0.5);
}
textarea#input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  resize: none;
  color: var(--phos-bright);
  font-family: inherit;
  font-size: 16px;  /* 必须 ≥16px：任何模式下小于该值，手机聚焦输入框都会触发页面自动放大 */
  line-height: 1.6;
  padding: 10px 12px 6px 2px;
  max-height: 160px;
  caret-color: var(--phos);
  text-shadow: 0 0 6px rgba(77, 255, 136, 0.35);
}
.input-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 4px 12px 8px;
}
.btn-wake {
  background: transparent;
  color: var(--red);
  border: 1px solid var(--red);
  font-family: inherit;
  font-size: 12px;
  padding: 3px 12px;
  cursor: pointer;
  letter-spacing: 2px;
  transition: all 0.2s;
}
.btn-wake:hover {
  background: var(--red);
  color: #200;
  box-shadow: 0 0 12px rgba(255, 123, 107, 0.6);
}
.btn-wake:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-send {
  background: transparent;
  color: var(--phos-bright);
  border: 1px solid var(--phos-dim);
  font-family: inherit;
  font-size: 12px;
  padding: 3px 14px;
  cursor: pointer;
  letter-spacing: 2px;
  transition: all 0.2s;
  display: none;  /* 桌面用 Enter；触屏显示 */
}
.btn-send:hover {
  background: var(--phos-dim);
  color: #031007;
  box-shadow: 0 0 12px rgba(77, 255, 136, 0.5);
}
.hint { color: var(--phos-dim); font-size: 11px; letter-spacing: 1px; }

/* ============ 移动端适配（≤520px） ============ */
@media (max-width: 520px) {
  .crt { padding: 6px 6px; }
  .sb-row { gap: 4px 10px; }
  .sb-label { font-size: 10px; margin-right: 3px; letter-spacing: 1px; }
  .sb-value { font-size: 12px; }
  .sb-value.avail { padding: 0 4px; }
  .chat { font-size: 14px; line-height: 1.65; padding: 8px; }
  .profilebar { gap: 6px; font-size: 11px; }
  .pb-bar { flex-basis: 70px; }
  .pb-imp { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  .prompt-label { padding: 10px 2px 10px 8px; font-size: 13px; }
  /* 输入框必须 ≥16px：小于该值时 iOS/Android 聚焦会自动放大页面且不复原 */
  textarea#input { font-size: 16px; padding: 9px 8px 6px 2px; line-height: 1.5; }
  .btn-wake { font-size: 11px; padding: 3px 8px; letter-spacing: 1px; }
  .btn-send { display: inline-block; font-size: 12px; padding: 3px 12px; }
  .hint { display: none; }
  .input-actions { padding: 4px 8px 6px; }
}

/* 触屏设备（不依赖屏宽）：显示发送按钮 */
@media (pointer: coarse) {
  .btn-send { display: inline-block; }
}
