/* xZ Studio 工作台：颜色、字号照「xZ Studio 界面草图」。手机优先，宽度 ≥ 900px 换成左侧导航 */
:root {
  --bg: #F4F5F7; --surface: #FFFFFF; --text: #14161B; --muted: #5A6170; --muted2: #3F4552;
  --border: #E3E6EB; --line: #EEF0F3; --chip: #D5D9E0; --input: #B8BEC9;
  --blue: #2952E3; --blue-dark: #1E40AF; --blue-soft: #E8EEFD; --blue-line: #C9D4F7;
  --orange: #9A3412; --orange-soft: #FFF1E6; --orange-line: #F3C9A8;
  --green: #166534; --green-soft: #E7F6EC; --red: #B42318; --red-soft: #FDECEC; --gray-soft: #EEF0F3;
  --tabs-h: 60px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  -webkit-text-size-adjust: 100%;
}
[hidden] { display: none !important; }
a { color: var(--blue); }
a:hover { color: var(--blue-dark); }
h1, h2, p { margin: 0; }
h1 { font-size: 20px; line-height: 1.3; }
h2 { font-size: 16px; line-height: 1.35; }
button, input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.strong { font-weight: 600; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.err { color: var(--red); font-size: 13px; font-weight: 600; min-height: 1.5em; }

/* 按钮、输入框、标签 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 18px; border-radius: 10px; border: 1px solid var(--chip);
  background: var(--surface); font-weight: 700; text-decoration: none; color: var(--text); cursor: pointer;
}
.btn:hover { border-color: var(--input); color: var(--text); }
.btn.primary { border-color: var(--blue); background: var(--blue); color: #FFFFFF; }
.btn.primary:hover { background: var(--blue-dark); border-color: var(--blue-dark); color: #FFFFFF; }
.btn.danger { border-color: var(--red); background: var(--red); color: #FFFFFF; }
.btn:disabled { opacity: .55; cursor: default; }
.chip-btn {
  display: inline-flex; align-items: center; gap: 4px; min-height: 44px; padding: 0 14px;
  border-radius: 22px; border: 1px solid var(--blue-line); background: var(--surface);
  color: var(--blue-dark); font-size: 13px; font-weight: 600; text-decoration: none; cursor: pointer;
}
.chip-btn[aria-pressed="true"] { background: var(--blue-soft); border-color: var(--blue); }
.link-btn { min-height: 44px; padding: 0 8px; border: 0; background: none; color: var(--muted); font-size: 13px; cursor: pointer; }
.link-btn:hover { color: var(--text); }
.input {
  width: 100%; min-height: 44px; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--input); background: var(--surface); line-height: 1.6;
}
.input:focus { outline: 2px solid var(--blue); outline-offset: -1px; border-color: var(--blue); }
.input::placeholder { color: var(--muted); }
textarea.input { resize: none; }
.pill {
  display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 6px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.blue { background: var(--blue-soft); color: var(--blue-dark); }
.orange { background: var(--orange-soft); color: var(--orange); }
.green { background: var(--green-soft); color: var(--green); }
.red { background: var(--red-soft); color: var(--red); }
.gray { background: var(--gray-soft); color: var(--muted2); }
.badge {
  min-width: 20px; padding: 0 6px; border-radius: 10px; background: var(--orange-soft); color: var(--orange);
  font-size: 12px; font-weight: 700; text-align: center; line-height: 20px;
}
.av {
  flex: 0 0 auto; width: 36px; height: 36px; border-radius: 18px; display: flex; align-items: center;
  justify-content: center; font-weight: 700; font-size: 12px;
}
.av-ai { background: var(--text); color: #FFFFFF; }
.av-other { background: var(--orange-soft); color: var(--orange); }
.av-me { background: var(--blue-soft); color: var(--blue-dark); font-size: 14px; }
.logo {
  flex: 0 0 auto; width: 32px; height: 32px; border-radius: 8px; background: var(--text); color: #FFFFFF;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-name { font-weight: 700; font-size: 15px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.3; }

/* 登录 */
.login { min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.login-card {
  width: 100%; max-width: 420px; display: grid; background: var(--surface);
  border: 1px solid var(--border); border-radius: 16px; overflow: hidden;
}
.login-intro { display: none; }
.login-form { padding: 28px 24px; display: flex; flex-direction: column; gap: 8px; }
.login-form h2 { font-size: 20px; margin-top: 12px; }
.login-form label:not(.check) { margin-top: 8px; font-weight: 600; font-size: 13px; }
.login-form .btn { margin-top: 4px; }
.check { display: flex; align-items: center; gap: 8px; min-height: 44px; font-size: 13px; color: var(--muted2); cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 0; accent-color: var(--blue); }
.dots { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 12px; color: #D5D9E0; }
.dots li { display: flex; gap: 10px; align-items: baseline; }
.dots li::before { content: ""; flex: 0 0 auto; width: 6px; height: 6px; border-radius: 3px; background: #7C93F0; transform: translateY(-2px); }

/* 整体布局：手机上底部标签栏，电脑上左侧导航 */
.side { display: none; }
.main { padding-bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom)); }
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex;
  height: calc(var(--tabs-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface); border-top: 1px solid var(--border);
}
.tab {
  position: relative; flex: 1 1 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; font-size: 12px; color: var(--muted); text-decoration: none;
}
.tab[aria-current="page"] { color: var(--blue); font-weight: 600; }
.tab .badge { position: absolute; top: 4px; left: calc(50% + 8px); min-width: 18px; line-height: 18px; font-size: 11px; padding: 0 5px; }
.view { padding: 16px; display: flex; flex-direction: column; gap: 16px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; }
.page-head p { margin-top: 4px; }
.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px;
  display: flex; flex-direction: column; gap: 12px; min-width: 0;
}
.panel-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px; }
.empty { padding: 32px 16px; text-align: center; color: var(--muted); }

/* 对话 */
.view.chat { padding: 0; gap: 0; height: calc(100vh - var(--tabs-h)); height: calc(100dvh - var(--tabs-h) - env(safe-area-inset-bottom)); }
.chat .page-head { display: none; }
.chat-box { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; background: var(--surface); }
.chat-head {
  display: flex; align-items: center; gap: 12px; min-height: 60px;
  padding: 10px max(16px, calc(50% - 440px)); border-bottom: 1px solid var(--border);
}
.col-tight { display: flex; flex-direction: column; line-height: 1.35; min-width: 0; }
.msgs {
  flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  padding: 16px max(16px, calc(50% - 440px)); background: var(--bg);
  display: flex; flex-direction: column; gap: 14px;
}
.divider { align-self: center; padding: 2px 10px; border-radius: 10px; background: #E9EBEF; color: var(--muted2); font-size: 12px; }
.who { color: var(--muted); font-size: 12px; }
.msg.mine { align-self: flex-end; max-width: 85%; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.msg.left { display: flex; gap: 10px; align-items: flex-start; max-width: 100%; }
.msg .col { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.bubble {
  max-width: 640px; padding: 10px 14px; border-radius: 14px 14px 14px 4px; background: var(--surface);
  border: 1px solid var(--border); line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere;
}
.mine .bubble { border: 0; border-radius: 14px 14px 4px 14px; background: var(--blue); color: #FFFFFF; }
.typing { padding: 6px max(16px, calc(50% - 440px)); background: var(--bg); color: var(--muted); font-size: 13px; }
.composer { border-top: 1px solid var(--border); padding: 10px max(16px, calc(50% - 440px)) 12px; display: flex; flex-direction: column; gap: 8px; }
.quick { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.send-row { display: flex; gap: 10px; align-items: flex-end; }
.send-row .input { flex: 1 1 auto; min-width: 0; }
.send-row .btn { flex: 0 0 auto; min-height: 48px; padding: 0 20px; }

/* 任务卡片：对话和任务页共用 */
.card {
  width: 100%; max-width: 640px; padding: 14px 16px; border-radius: 12px; background: var(--surface);
  border: 1px solid var(--border); display: flex; flex-direction: column; gap: 10px;
}
.card.s-draft { border-color: var(--blue-line); }
.card.s-approval, .card.s-stopped { border-color: var(--orange-line); }
.card-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.card-head .meta { color: var(--muted); font-size: 13px; }
.ins { min-height: 76px; resize: vertical; }
.ins-text { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.6; font-weight: 600; }
.note { padding: 8px 12px; border-radius: 8px; background: var(--bg); color: var(--muted2); font-size: 13px; }
.result { padding: 8px 12px; border-radius: 8px; font-weight: 600; white-space: pre-wrap; overflow-wrap: anywhere; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.live {
  display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 8px;
  background: var(--bg); color: inherit; text-decoration: none;
}
.live:hover { color: inherit; background: var(--line); }
.live img {
  flex: 0 0 auto; width: 48px; aspect-ratio: 9 / 20; object-fit: cover;
  border: 3px solid var(--text); border-radius: 8px; background: var(--line);
}
.live span { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.live small { color: var(--muted); font-size: 13px; }
.live em { flex: 0 0 auto; font-style: normal; color: var(--blue); font-size: 13px; font-weight: 600; }
.task-list { display: grid; gap: 12px; align-items: start; }
.task-list .card { max-width: none; }
.filters { display: flex; flex-wrap: wrap; gap: 6px; }

/* 设备 */
.banner {
  display: flex; flex-direction: column; gap: 2px; padding: 12px 16px; border-radius: 12px;
  background: var(--blue-soft); border: 1px solid var(--blue-line); color: var(--blue-dark); overflow-wrap: anywhere;
}
.banner span:not(.muted) { color: var(--text); }
.dev-body { display: grid; justify-items: center; gap: 12px; }
.screen {
  position: relative; width: min(100%, 340px, calc((100vh - 230px) * 0.45)); min-width: 200px; aspect-ratio: 9 / 20;
  border: 6px solid var(--text); border-radius: 24px; overflow: hidden; background: #1F2229;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.screen img { display: block; width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.screen.takeover { border-color: var(--blue); cursor: crosshair; touch-action: none; }
.shot-err {
  position: absolute; left: 12px; right: 12px; bottom: 12px; padding: 8px 10px; border-radius: 8px;
  background: rgba(20, 22, 27, .82); color: #FFFFFF; font-size: 13px;
}
.hint { color: var(--blue-dark); font-size: 13px; font-weight: 600; }
.tap-dot {
  position: absolute; width: 28px; height: 28px; margin: -14px 0 0 -14px; border-radius: 50%;
  border: 3px solid var(--blue); background: rgba(41, 82, 227, .25); pointer-events: none;
  animation: tap .6s ease-out forwards;
}
@keyframes tap { to { opacity: 0; transform: scale(1.8); } }
@media (prefers-reduced-motion: reduce) { .tap-dot { animation-duration: 1ms; } }
/* 手机上：返回、回桌面在画面上面，打字在下面；电脑上都在画面右边 */
.take-keys, .take-type { justify-self: stretch; display: flex; flex-direction: column; gap: 8px; }
.take-keys { order: -1; }

/* 我的 */
.me-row { display: flex; align-items: center; gap: 12px; }
.me-row .col-tight b { font-size: 16px; }

/* 提示 */
.offline {
  position: fixed; top: 0; left: 0; right: 0; z-index: 30; padding: 8px 16px; text-align: center;
  background: var(--orange-soft); color: var(--orange); font-size: 13px; font-weight: 600;
}
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabs-h) + 16px + env(safe-area-inset-bottom)); z-index: 30;
  transform: translateX(-50%); width: max-content; max-width: calc(100% - 32px); padding: 10px 16px;
  border-radius: 10px; background: var(--text); color: #FFFFFF; font-size: 13px; font-weight: 600;
}

@media (max-width: 899px) {
  .input { font-size: 16px; } /* iPhone 上小于 16px 会自动放大页面 */
  .card-head .meta { flex-basis: 100%; }
}

@media (min-width: 900px) {
  .mobile-only { display: none; }
  .login-card { max-width: 880px; grid-template-columns: 1fr 1fr; }
  .login-intro { display: flex; flex-direction: column; gap: 20px; padding: 40px; background: var(--text); color: #FFFFFF; }
  .login-intro h1 { font-size: 26px; }
  .login-intro .logo { background: #FFFFFF; color: var(--text); }
  .login-form { padding: 40px; }
  .login-form h2 { margin-top: 0; }

  .app { display: grid; grid-template-columns: 220px minmax(0, 1fr); height: 100vh; height: 100dvh; }
  .side {
    display: flex; flex-direction: column; gap: 20px; padding: 20px 14px; min-height: 0;
    background: var(--surface); border-right: 1px solid var(--border);
  }
  .side .brand { padding: 0 8px; }
  .nav { display: flex; flex-direction: column; gap: 2px; }
  .nav-item {
    display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 10px; border-radius: 8px;
    color: var(--text); text-decoration: none; font-weight: 500;
  }
  .nav-item:hover { background: var(--bg); color: var(--text); }
  .nav-item[aria-current="page"] { background: var(--blue-soft); color: var(--blue-dark); }
  .nav-item span:first-of-type { flex: 1 1 auto; }
  .side-user { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 12px 8px 0; border-top: 1px solid var(--line); }
  .side-user .col-tight { flex: 1 1 auto; }
  .tabs { display: none; }
  .main { height: 100vh; height: 100dvh; overflow: auto; padding: 24px 32px 32px; min-width: 0; }
  .view { padding: 0; }
  h1 { font-size: 24px; }
  .view.chat { height: 100%; gap: 16px; }
  .chat .page-head { display: flex; }
  .chat-box { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
  .chat-head { min-height: 64px; }
  .task-list { grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr)); }
  .dev-body { grid-template-columns: auto minmax(0, 420px); grid-template-rows: auto 1fr; align-items: start; justify-items: stretch; gap: 16px 24px; }
  .screen { grid-column: 1; grid-row: 1 / 3; width: min(340px, calc((100vh - 260px) * 0.45)); } /* 整个手机画面不用滚动就能看全 */
  .take-keys { order: 0; }
  .toast { bottom: 24px; }
}
