/* 手表 / 极小屏适配（CD12 Max 等 W527 圆角方屏、糯米系统 WebView）
 * 由 app.js 根据 screen 尺寸 / UA / ?watch=1 / 菜单开关给 <html> 加 .watch。
 * 设计基准：CSS 视口 240×240 ~ 466×466，触控目标 ≥ 40px，单列，无 hover 依赖。
 */

.watch {
  --watch-pad: 8px;
}

/* 老 WebView（Chromium < 87）不支持 inset 简写，补一份四边 */
.watch .backdrop {
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
}

/* 顶栏：只保留 返回 / 标题 / 菜单 */
.watch .chat-header {
  height: 46px;
  padding: 0 4px;
  gap: 2px;
  border-bottom-width: 1px;
}
.watch .header-title {
  font-size: 15px;
  line-height: 1.15;
  max-width: 100%;
}
.watch .header-sub {
  margin-top: 1px;
  font-size: 10px;
  gap: 6px;
}
.watch .header-sub .dsh-status #dsh-text {
  max-width: 74px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.watch .mode-badge {
  font-size: 9.5px;
  padding: 0 5px;
  height: 15px;
  line-height: 15px;
}
.watch .icon-btn {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
}
.watch .icon-btn svg {
  width: 19px;
  height: 19px;
}
.watch .mock-chip {
  display: none;
}

/* 消息区 */
.watch .messages {
  padding: 8px 8px 2px;
}
.watch .message-list {
  gap: 8px;
}
.watch .msg-meta {
  font-size: 10px;
  margin-top: 3px;
}
.watch .bubble {
  padding: 8px 10px;
  font-size: 13px;
  line-height: 1.55;
  border-radius: 12px;
  max-width: 94%;
}
.watch .msg-user .bubble {
  border-bottom-right-radius: 5px;
}
.watch .msg-assistant .bubble {
  border-bottom-left-radius: 5px;
}
.watch .bubble pre,
.watch .bubble code {
  font-size: 11.5px;
}
.watch .bubble pre {
  padding: 6px 8px;
  max-height: 150px;
  overflow: auto;
}
.watch .bubble table {
  font-size: 11.5px;
}
.watch .bubble blockquote {
  padding-left: 8px;
}

/* 工具卡片：默认折叠，展开后内部滚动 */
.watch .tool-card {
  border-radius: 10px;
}
.watch .tool-head {
  padding: 7px 9px;
  gap: 6px;
  min-height: 38px;
}
.watch .tool-name {
  font-size: 12.5px;
}
.watch .tool-status {
  font-size: 10px;
  padding: 0 5px;
}
.watch .tool-body {
  padding: 0 9px 8px;
  font-size: 11.5px;
}
.watch .tool-body pre {
  max-height: 120px;
  overflow: auto;
  font-size: 11px;
}
.watch .tool-section-label {
  font-size: 10px;
}

/* 输入区：贴边、单行、按钮 ≥ 40px */
.watch .composer {
  padding: 5px 6px calc(5px + env(safe-area-inset-bottom));
  gap: 4px;
}
.watch .composer-row {
  gap: 4px;
  align-items: flex-end;
}
.watch .composer-input {
  font-size: 16px; /* 防 WebView 聚焦缩放 */
  line-height: 1.35;
  padding: 8px 10px;
  min-height: 38px;
  max-height: 84px;
  border-radius: 10px;
}
.watch .send-btn {
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  border-radius: 10px;
}
.watch .send-btn svg {
  width: 19px;
  height: 19px;
}
.watch .composer-row .icon-btn {
  width: 36px;
  height: 36px;
}
.watch .composer-foot {
  display: none; /* 手表上不提示快捷键，省一行高度 */
}

/* 运行条 / 思考条 */
.watch .typing-row,
.watch .run-bar {
  font-size: 11.5px;
  padding: 5px 8px;
  gap: 6px;
}
.watch .run-bar .btn-sm {
  height: 30px;
  padding: 0 10px;
  font-size: 11.5px;
}

/* 空状态 */
.watch .empty-state {
  padding: 10px 8px;
}
.watch .empty-state img {
  width: 40px;
  height: 40px;
  margin-bottom: 6px;
}
.watch .empty-state h2 {
  font-size: 15px;
  margin-bottom: 4px;
}
.watch .empty-state p {
  font-size: 11.5px;
  margin-bottom: 12px;
}
.watch .empty-state .empty-actions {
  flex-direction: column;
  width: 100%;
  gap: 8px;
}
.watch .empty-state .btn {
  width: 100%;
  height: 42px;
  font-size: 13.5px;
}

/* 登录页 */
.watch .login-view {
  padding: 8px;
}
.watch .login-card {
  padding: 16px 14px;
  border-radius: 16px;
}
.watch .login-logo {
  width: 46px;
  height: 46px;
  margin-bottom: 6px;
}
.watch .login-title {
  font-size: 19px;
}
.watch .login-sub,
.watch .login-hint {
  display: none;
}
.watch .login-card .input {
  height: 42px;
  font-size: 16px;
}
.watch .login-card .btn-block {
  height: 44px;
  margin-top: 10px;
  font-size: 14px;
}
.watch .login-error {
  font-size: 11.5px;
  margin-top: 4px;
}

/* 会话抽屉：整屏 */
.watch .drawer {
  width: 100%;
  max-width: 100%;
  padding: 0 6px calc(6px + env(safe-area-inset-bottom));
}
.watch .drawer-head {
  height: 42px;
  padding: 0 2px;
}
.watch .drawer-head h2 {
  font-size: 15px;
}
.watch .drawer .icon-btn {
  width: 36px;
  height: 36px;
}
.watch .conv-list {
  gap: 5px;
  padding: 2px 0 6px;
}
.watch .conv-item {
  padding: 8px 9px;
  border-radius: 10px;
}
.watch .conv-title {
  font-size: 13px;
}
.watch .conv-last {
  font-size: 11px;
  -webkit-line-clamp: 1;
  line-clamp: 1;
}
.watch .conv-meta {
  font-size: 9.5px;
}
.watch .drawer-foot .btn {
  height: 40px;
  font-size: 12.5px;
}

/* 底部弹层（审批/提问/新建会话/菜单） */
.watch .sheet {
  max-height: 92vh;
  border-radius: 14px 14px 0 0;
  padding: 0 8px calc(8px + env(safe-area-inset-bottom));
}
.watch .sheet-grab {
  margin: 5px auto 0;
}
.watch .sheet-head {
  height: 36px;
  padding: 4px 8px;
}
.watch .sheet-head h3 {
  font-size: 14px;
}
.watch .sheet {
  max-height: 94vh;
}
.watch .sheet-body {
  max-height: calc(92vh - 52px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 4px;
}
.watch .sheet-item {
  padding: 7px 8px;
  gap: 8px;
  border-radius: 10px;
}
.watch .sheet-item-title {
  font-size: 13px;
}
.watch .sheet-item-desc {
  font-size: 10.5px;
  -webkit-line-clamp: 1;
  line-clamp: 1;
}
.watch .sheet-note {
  font-size: 11px;
  margin: 2px 0 8px;
}
.watch .mode-option {
  padding: 8px;
  gap: 8px;
}
.watch .mode-option-name {
  font-size: 13.5px;
}
.watch .mode-option-hint {
  font-size: 10.5px;
  -webkit-line-clamp: 2;
  line-clamp: 2;
}
.watch .mode-option-model {
  display: none;
}
.watch .sheet-actions {
  flex-direction: column; /* 小屏上允许/拒绝竖排，手指不会点错 */
  gap: 8px;
}
.watch .sheet-actions .btn {
  height: 44px;
  font-size: 14px;
}
.watch .sheet-error {
  font-size: 11.5px;
}
.watch .approval-tool {
  font-size: 11px;
  padding: 5px 7px;
}
.watch .approval-reason {
  font-size: 11px;
  line-height: 1.5;
  max-height: 68px;
  overflow-y: auto;
  padding: 6px 8px;
}

/* 审批/提问的按钮固定在弹层底部：小屏上不用先滚到底才能点 */
.watch .sheet-body .sheet-actions {
  position: sticky;
  bottom: 0;
  z-index: 2;
  margin: 6px -8px 0;
  padding: 8px 8px calc(2px + env(safe-area-inset-bottom));
  background: #101822;
  border-top: 1px solid var(--border-soft);
  box-shadow: 0 -10px 20px -12px rgba(0, 0, 0, 0.9);
}

/* 截图查看器 / 通用弹层 */
.watch .toast {
  font-size: 12px;
  max-width: 92%;
}

/* 极窄（≤ 260px）再收一档 */
@media (max-width: 260px) {
  .watch .chat-header {
    height: 42px;
  }
  .watch .header-sub {
    display: none; /* 只留标题 + 状态点靠边框 */
  }
  .watch .bubble {
    font-size: 12.5px;
    padding: 7px 9px;
  }
  .watch .composer-input {
    font-size: 15px;
  }
  .watch .sheet-item-desc {
    display: none;
  }
}

/* 矮屏（横置或方屏）压缩纵向 */
@media (max-height: 300px) {
  .watch .chat-header {
    height: 40px;
  }
  .watch .header-sub {
    display: none;
  }
  .watch .empty-state img {
    display: none;
  }
  .watch .composer-input {
    max-height: 60px;
  }
}

/* 大一点的方屏手表（CSS 视口 380–520，例如 466×466 @DPR1）：字号和触控区要跟着放大，
 * 否则 13px 的字在 1.7 英寸屏上物理尺寸过小。 */
@media (min-width: 380px) {
  .watch .chat-header {
    height: 56px;
    padding: 0 6px;
  }
  .watch .header-title {
    font-size: 18px;
  }
  .watch .header-sub {
    display: flex;
    font-size: 11.5px;
  }
  .watch .mode-badge {
    font-size: 10.5px;
    height: 18px;
    line-height: 18px;
    padding: 0 7px;
  }
  .watch .icon-btn {
    width: 46px;
    height: 46px;
  }
  .watch .icon-btn svg {
    width: 23px;
    height: 23px;
  }
  .watch .bubble {
    font-size: 16px;
    padding: 10px 13px;
    border-radius: 15px;
    max-width: 92%;
  }
  .watch .bubble pre,
  .watch .bubble code {
    font-size: 14px;
  }
  .watch .bubble table {
    font-size: 14px;
  }
  .watch .msg-meta {
    font-size: 11.5px;
  }
  .watch .messages {
    padding: 10px 10px 4px;
  }
  .watch .tool-head {
    min-height: 46px;
    padding: 9px 11px;
  }
  .watch .tool-name {
    font-size: 15px;
  }
  .watch .tool-body {
    font-size: 13.5px;
  }
  .watch .tool-body pre {
    font-size: 13px;
    max-height: 190px;
  }
  .watch .composer {
    padding: 7px 8px calc(7px + env(safe-area-inset-bottom));
  }
  .watch .composer-input {
    font-size: 18px;
    min-height: 48px;
    padding: 11px 13px;
    max-height: 120px;
    border-radius: 13px;
  }
  .watch .send-btn {
    width: 50px;
    height: 50px;
    border-radius: 13px;
  }
  .watch .send-btn svg {
    width: 24px;
    height: 24px;
  }
  .watch .composer-row .icon-btn {
    width: 44px;
    height: 44px;
  }
  .watch .login-card {
    padding: 24px 22px;
    max-width: 92vw;
  }
  .watch .login-logo {
    width: 62px;
    height: 62px;
  }
  .watch .login-title {
    font-size: 25px;
  }
  .watch .login-card .input {
    height: 52px;
    font-size: 19px;
  }
  .watch .login-card .btn-block {
    height: 54px;
    margin-top: 14px;
    font-size: 17px;
  }
  .watch .empty-state h2 {
    font-size: 19px;
  }
  .watch .empty-state p {
    font-size: 14px;
  }
  .watch .empty-state .btn {
    height: 50px;
    font-size: 16px;
  }
  .watch .sheet {
    max-width: 100%;
    max-height: 94vh;
  }
  .watch .sheet-head {
    height: 44px;
  }
  .watch .sheet-head h3 {
    font-size: 17px;
  }
  .watch .sheet-item {
    padding: 10px 11px;
  }
  .watch .sheet-item-title {
    font-size: 16px;
  }
  .watch .sheet-item-desc {
    font-size: 12.5px;
  }
  .watch .sheet-actions .btn {
    height: 52px;
    font-size: 16.5px;
  }
  .watch .approval-tool {
    font-size: 13px;
  }
  .watch .approval-reason {
    font-size: 13.5px;
    max-height: 120px;
  }
  .watch .conv-title {
    font-size: 15px;
  }
  .watch .conv-last {
    font-size: 12.5px;
  }
  .watch .drawer-head h2 {
    font-size: 18px;
  }
}

/* 没有 JS 时的兜底：直接按宽度命中最小一套 */
@media (max-width: 300px) and (max-height: 400px) {
  .chat-header { height: 44px; }
  .bubble { font-size: 12.5px; }
  .composer-foot { display: none; }
  .sheet-actions { flex-direction: column; }
}
