/* Adream 移动 web / PWA。配色对齐手机 app：顶栏 #1C1E22、accent #7EE787、
   气泡同安卓 ChatScreen。单主题（浅色内容区 + 深色 chrome），圆角统一 12px。 */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --chrome: #1C1E22;
  --chrome-fg: #E6EDF3;
  --chrome-muted: #B1BAC4;
  --accent: #7EE787;
  --red: #FF7B72;
  --op-blue: #1976D2;
  --eng-red: #D32F2F;
  --stop-red: #E53935;
  --bg: #F5F5F5;
  --card: #FFFFFF;
  --text: #222222;
  --muted: #777777;
  --radius: 12px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
html, body { height: 100%; overscroll-behavior: none; }
body {
  font-family: -apple-system, "PingFang SC", "Noto Sans SC", sans-serif;
  background: var(--chrome);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}
.hidden { display: none !important; }
.view { height: 100dvh; display: flex; flex-direction: column; }

/* ── 登录 ── */
#view-login { align-items: center; justify-content: center; background: var(--chrome); }
.login-card { width: min(88vw, 340px); text-align: center; }
.login-logo { font-size: 44px; color: var(--accent); }
.login-card h1 { color: var(--chrome-fg); font-size: 30px; margin: 6px 0 2px; }
.login-sub { color: var(--chrome-muted); font-size: 13px; margin-bottom: 26px; }
.login-card input {
  width: 100%; height: 46px; margin-bottom: 12px; padding: 0 14px;
  border: 1px solid #3A3F46; border-radius: var(--radius);
  background: #22252B; color: var(--chrome-fg); font-size: 15px;
}
.login-card input::placeholder { color: #6B7280; }
.login-status { color: var(--red); font-size: 13px; margin-top: 10px; min-height: 18px; }

.btn-primary {
  width: 100%; height: 46px; border: none; border-radius: var(--radius);
  background: var(--accent); color: #10331A; font-size: 15px; font-weight: 600;
  cursor: pointer;
}
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.5; }
.btn-sm { width: auto; height: 36px; padding: 0 16px; font-size: 14px; }

/* ── 顶栏 ── */
#topbar {
  display: flex; align-items: center; gap: 6px;
  padding: calc(var(--safe-top) + 8px) 10px 8px;
  background: var(--chrome); flex-shrink: 0;
}
.dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.dot.red { background: var(--red); }
.dot.green { background: var(--accent); }
.dot.blue { background: var(--op-blue); }
.dot.dark-red { background: var(--eng-red); }
.tb-mono { font-family: ui-monospace, Menlo, monospace; font-size: 13px; color: var(--chrome-fg); }
.tb-path { color: var(--chrome-muted); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tb-spin { color: var(--accent); }
.tb-btn {
  border: none; background: none; color: var(--chrome-muted);
  font-size: 17px; padding: 4px 8px; border-radius: 8px; cursor: pointer;
}
.tb-btn:active { background: rgba(255,255,255,0.08); }
.tb-red { color: var(--red); }

/* ── 主区 ── */
#stage { flex: 1; position: relative; background: var(--bg); min-height: 0; }
#sandbox, #handoff-frame { width: 100%; height: 100%; border: none; display: block; background: #fff; }
#stage-card {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px; background: var(--bg);
}
#stage-text { font-size: 15px; font-weight: 500; }
#btn-restart { width: auto; padding: 0 22px; }
#handoff { position: absolute; inset: 0; display: flex; flex-direction: column; background: var(--bg); }
#handoff-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 12px; background: #FFF59D; font-size: 13px; font-weight: 500;
}

/* ── 对话抽屉 ── */
#drawer {
  background: #FAFAFA; border-top: 1px solid #E5E5E5; flex-shrink: 0;
  display: flex; flex-direction: column;
  transition: height 0.22s ease-out;
  padding-bottom: var(--safe-bottom);
}
#drawer.peek { height: calc(52px + var(--safe-bottom)); }
#drawer.open { height: calc(62dvh + var(--safe-bottom)); }
#drawer-handle { flex-shrink: 0; cursor: pointer; }
.handle-bar { width: 36px; height: 4px; border-radius: 2px; background: #CCC; margin: 6px auto 4px; }
.handle-row {
  display: flex; justify-content: space-between; padding: 0 16px 6px;
  font-size: 12px; color: #666;
}
.handle-hint { color: #999; }
#chat-body { flex: 1; display: none; flex-direction: column; min-height: 0; }
#drawer.open #chat-body { display: flex; }
#msgs { flex: 1; overflow-y: auto; padding: 6px 10px; -webkit-overflow-scrolling: touch; }

.msg { max-width: 86%; margin: 4px 0; padding: 8px 12px; border-radius: var(--radius);
  font-size: 14px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.msg.user     { background: #DCEFFF; margin-left: auto; }
.msg.agent    { background: #EEEEEE; }
.msg.operator { background: #EDE7F6; }
.msg.system   { background: #FFF5C2; font-size: 12px; }
.msg.tool     { background: #E8F5E9; font-size: 12px; }
.msg.live     { background: #E3F2FD; font-size: 12px; color: #263238; }
.msg.live::before { content: "⏳ "; }

#input-row { display: flex; gap: 6px; align-items: center; padding: 6px 8px 4px; background: #fff; }
#in-text {
  flex: 1; height: 40px; padding: 0 12px; font-size: 15px;
  border: 1px solid #DDD; border-radius: var(--radius); background: #fff; color: var(--text);
}
.btn-stop {
  width: 40px; height: 40px; border: none; border-radius: 50%;
  background: var(--stop-red); color: #fff; font-size: 14px; cursor: pointer; flex-shrink: 0;
}
#btn-ptt {
  margin: 4px 8px 8px; height: 44px; border: 1.5px solid var(--op-blue);
  border-radius: var(--radius); background: #fff; color: var(--op-blue);
  font-size: 15px; font-weight: 600; cursor: pointer;
  -webkit-user-select: none; user-select: none; touch-action: none;
}
#btn-ptt.recording { background: var(--op-blue); color: #fff; }
#btn-ptt.cancel { background: #B71C1C; border-color: #B71C1C; color: #fff; }

/* ── 弹窗 / snack / 安装引导 ── */
.mask { position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 30;
  display: flex; align-items: center; justify-content: center; }
.dialog { width: min(88vw, 360px); background: #fff; border-radius: 16px; padding: 18px; }
.dialog h3 { font-size: 16px; margin-bottom: 8px; }
.dialog-sub { font-size: 12px; color: var(--muted); margin-bottom: 12px; line-height: 1.6; }
.dialog textarea {
  width: 100%; padding: 10px; font-size: 14px; font-family: inherit;
  border: 1px solid #DDD; border-radius: var(--radius); resize: vertical;
}
.dialog-actions { display: flex; gap: 8px; margin-top: 14px; }
.dialog-actions button { flex: 1; height: 40px; border-radius: var(--radius);
  border: 1px solid #DDD; background: #fff; font-size: 14px; cursor: pointer; }
.dialog-actions .btn-primary { border: none; }

#snack {
  position: fixed; left: 12px; right: 12px; bottom: calc(70px + var(--safe-bottom));
  background: #323232; color: #fff; padding: 10px 16px; border-radius: var(--radius);
  font-size: 13px; z-index: 40;
}
#ios-hint {
  position: fixed; left: 10px; right: 10px; bottom: calc(10px + var(--safe-bottom));
  background: var(--chrome); color: var(--chrome-fg); border: 1px solid #3A3F46;
  padding: 12px 14px; border-radius: 14px; font-size: 13px; line-height: 1.7; z-index: 50;
}
#ios-hint b { color: var(--accent); }
.share-glyph { font-size: 15px; }
#ios-hint button {
  float: right; margin-top: 4px; border: none; background: none;
  color: var(--chrome-muted); font-size: 13px; cursor: pointer;
}
