/* =========================================================================
   DSH Remote — H5/PWA 客户端样式
   设计目标：iPhone Safari 优先的玻璃拟态 IM 风格（参考 docs/ui-reference.jpg）
   - 浅色：柔和蓝灰渐变背景 + 白色玻璃 + 近黑用户气泡 + 浅灰助手气泡
   - 深色：近黑背景 + 深色玻璃 + 蓝色用户气泡 + 深灰助手气泡
   - 全部使用 CSS 变量，切换 html[data-theme]
   ========================================================================= */

/* ------------------------------ 主题变量 ------------------------------ */
:root {
  color-scheme: light;

  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Segoe UI",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Cascadia Mono",
    "Roboto Mono", monospace;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --app-h: 100dvh;
  --font-scale: 1;
  --chat-font: calc(15.5px * var(--font-scale));

  --bg: #edf1f6;
  --bg-gradient: linear-gradient(168deg, #f4f7fb 0%, #e9eef5 44%, #e4eaf3 100%);
  --composer-fade: rgba(234, 239, 246, 0.94);
  --text: #10141a;
  --text-2: #495463;
  --text-3: #8b95a4;
  --line: rgba(17, 24, 39, 0.08);
  --line-strong: rgba(17, 24, 39, 0.16);

  --glass: rgba(255, 255, 255, 0.56);
  --glass-strong: rgba(255, 255, 255, 0.8);
  --glass-border: rgba(255, 255, 255, 0.72);
  --card: rgba(255, 255, 255, 0.64);
  --card-solid: #ffffff;
  --sheet-bg: rgba(250, 252, 255, 0.94);
  --backdrop: rgba(10, 14, 20, 0.34);

  --shadow-soft: 0 8px 28px rgba(20, 32, 50, 0.08), 0 1px 2px rgba(20, 32, 50, 0.04);
  --shadow-chip: 0 2px 10px rgba(20, 32, 50, 0.06), inset 0 1px 0 rgba(255, 255, 255, 0.65);
  --shadow-sheet: 0 24px 70px rgba(15, 23, 42, 0.24);
  --shadow-pop: 0 12px 36px rgba(15, 23, 42, 0.18);

  --bubble-user-bg: #0c0f14;
  --bubble-user-fg: #f8fafc;
  --bubble-assistant-bg: rgba(233, 237, 243, 0.94);
  --bubble-assistant-fg: #141920;
  --bubble-assistant-border: rgba(255, 255, 255, 0.55);

  --chip-bg: rgba(228, 233, 240, 0.9);
  --chip-bg-hover: rgba(219, 226, 235, 0.96);
  --chip-fg: #3d4756;
  --chip-border: rgba(255, 255, 255, 0.5);

  --code-bg: rgba(17, 24, 39, 0.055);
  --code-border: rgba(17, 24, 39, 0.055);
  --code-inline-bg: rgba(17, 24, 39, 0.075);
  --link: #1f6feb;

  --green: #34c759;
  --green-fg: #137a37;
  --green-soft: rgba(52, 199, 89, 0.14);
  --red: #ff3b30;
  --red-fg: #c0271d;
  --red-soft: rgba(255, 59, 48, 0.12);
  --amber: #ff9f0a;
  --amber-fg: #986000;
  --amber-soft: rgba(255, 159, 10, 0.15);

  --btn-primary-bg: #0d1117;
  --btn-primary-fg: #f8fafc;
  --btn-secondary-bg: rgba(17, 24, 39, 0.07);
  --send-bg: #0c0f14;
  --send-fg: #ffffff;
  --seg-bg: rgba(17, 24, 39, 0.06);
  --seg-active: #ffffff;
  --switch-bg: rgba(17, 24, 39, 0.16);
  --switch-on: #34c759;
  --toast-bg: rgba(17, 24, 39, 0.92);
  --toast-fg: #ffffff;
  --focus: #2f6df6;

  --term-bg: #090d13;
  --term-fg: #d6e2f0;
}

html[data-theme="dark"] {
  color-scheme: dark;

  --bg: #07090c;
  --bg-gradient: linear-gradient(168deg, #0c1016 0%, #090b0f 48%, #0a0d12 100%);
  --composer-fade: rgba(8, 11, 15, 0.94);
  --text: #e8edf4;
  --text-2: #a7b2c0;
  --text-3: #74808f;
  --line: rgba(255, 255, 255, 0.07);
  --line-strong: rgba(255, 255, 255, 0.14);

  --glass: rgba(28, 33, 41, 0.58);
  --glass-strong: rgba(34, 40, 49, 0.8);
  --glass-border: rgba(255, 255, 255, 0.09);
  --card: rgba(23, 27, 34, 0.62);
  --card-solid: #161a21;
  --sheet-bg: rgba(19, 23, 29, 0.95);
  --backdrop: rgba(0, 0, 0, 0.52);

  --shadow-soft: 0 8px 30px rgba(0, 0, 0, 0.38);
  --shadow-chip: 0 2px 10px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  --shadow-sheet: 0 24px 70px rgba(0, 0, 0, 0.58);
  --shadow-pop: 0 12px 36px rgba(0, 0, 0, 0.45);

  --bubble-user-bg: #2f6cf0;
  --bubble-user-fg: #f7faff;
  --bubble-assistant-bg: rgba(31, 36, 43, 0.94);
  --bubble-assistant-fg: #e9eef5;
  --bubble-assistant-border: rgba(255, 255, 255, 0.055);

  --chip-bg: rgba(29, 34, 42, 0.82);
  --chip-bg-hover: rgba(37, 43, 52, 0.9);
  --chip-fg: #b8c2d0;
  --chip-border: rgba(255, 255, 255, 0.055);

  --code-bg: rgba(0, 0, 0, 0.34);
  --code-border: rgba(255, 255, 255, 0.06);
  --code-inline-bg: rgba(255, 255, 255, 0.09);
  --link: #79b0ff;

  --green: #3ddc84;
  --green-fg: #5be396;
  --green-soft: rgba(61, 220, 132, 0.15);
  --red: #ff6961;
  --red-fg: #ff9089;
  --red-soft: rgba(255, 105, 97, 0.16);
  --amber: #ffb340;
  --amber-fg: #ffc46b;
  --amber-soft: rgba(255, 179, 64, 0.16);

  --btn-primary-bg: #eef3fa;
  --btn-primary-fg: #0b0e13;
  --btn-secondary-bg: rgba(255, 255, 255, 0.08);
  --send-bg: #eef3fa;
  --send-fg: #0b0e13;
  --seg-bg: rgba(255, 255, 255, 0.07);
  --seg-active: rgba(255, 255, 255, 0.16);
  --switch-bg: rgba(255, 255, 255, 0.18);
  --switch-on: #34c759;
  --toast-bg: rgba(238, 243, 250, 0.95);
  --toast-fg: #0b0e13;
}

/* ------------------------------ 基础 ------------------------------ */
*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

html {
  background: var(--bg);
}

body {
  position: fixed;
  inset: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
  user-select: none;
  -webkit-user-select: none;
}

button,
input,
textarea,
select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

button {
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

button:disabled {
  cursor: default;
}

a {
  color: var(--link);
}

p {
  margin: 0;
}

code,
pre {
  font-family: var(--font-mono);
}

input,
textarea {
  -webkit-appearance: none;
  appearance: none;
  border-radius: 0;
}

:focus {
  outline: none;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.mono {
  font-family: var(--font-mono);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.icon {
  display: block;
  flex: none;
  pointer-events: none;
}

/* ------------------------------ App 容器 ------------------------------ */
.app {
  position: fixed;
  left: 0;
  right: 0;
  top: var(--vv-top, 0px);
  height: var(--app-h, 100dvh);
  overflow: hidden;
  background: var(--bg);
  isolation: isolate;
}

.bg-orbs {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  background: var(--bg-gradient);
  z-index: 0;
}

.bg-orbs .orb {
  position: absolute;
  display: block;
  border-radius: 50%;
  filter: blur(72px);
  will-change: transform;
}

.orb-1 {
  width: 68vw;
  height: 68vw;
  left: -18vw;
  top: -14vh;
  background: radial-gradient(circle at 40% 40%, rgba(116, 168, 255, 0.55), rgba(116, 168, 255, 0));
}

.orb-2 {
  width: 62vw;
  height: 62vw;
  right: -22vw;
  top: 18vh;
  background: radial-gradient(circle at 50% 50%, rgba(255, 196, 143, 0.42), rgba(255, 196, 143, 0));
}

.orb-3 {
  width: 72vw;
  height: 72vw;
  left: 8vw;
  bottom: -30vh;
  background: radial-gradient(circle at 50% 50%, rgba(150, 220, 200, 0.4), rgba(150, 220, 200, 0));
}

html[data-theme="dark"] .orb-1 {
  background: radial-gradient(circle at 40% 40%, rgba(43, 92, 220, 0.3), rgba(43, 92, 220, 0));
}

html[data-theme="dark"] .orb-2 {
  background: radial-gradient(circle at 50% 50%, rgba(126, 71, 220, 0.2), rgba(126, 71, 220, 0));
}

html[data-theme="dark"] .orb-3 {
  background: radial-gradient(circle at 50% 50%, rgba(16, 148, 168, 0.18), rgba(16, 148, 168, 0));
}

.bg-grain {
  position: absolute;
  inset: 0;
  background: radial-gradient(120% 55% at 50% -12%, rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0) 62%);
  opacity: 0.75;
}

html[data-theme="dark"] .bg-grain {
  background: radial-gradient(120% 55% at 50% -12%, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0) 62%);
  opacity: 1;
}

.view {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  z-index: 1;
}

.overlay-view {
  z-index: 20;
  background: var(--bg);
  background-image: var(--bg-gradient);
}

.topbar-spacer {
  width: 42px;
  height: 42px;
  flex: none;
}

/* ------------------------------ 顶栏 ------------------------------ */
.topbar {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 9px;
  padding: calc(var(--safe-top) + 8px) calc(14px + var(--safe-right)) 6px calc(14px + var(--safe-left));
  position: relative;
  z-index: 6;
  transition: padding-top 0.22s ease;
}

.circle-btn {
  width: 42px;
  height: 42px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  color: var(--text);
  box-shadow: var(--shadow-chip);
  -webkit-backdrop-filter: blur(20px) saturate(170%);
  backdrop-filter: blur(20px) saturate(170%);
  transition: transform 0.14s ease, background 0.18s ease, opacity 0.2s ease;
}

.circle-btn:active {
  transform: scale(0.93);
  background: var(--glass-strong);
}

.circle-btn:disabled {
  opacity: 0.42;
}

.topbar-center {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 64%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 5px 16px 6px;
  border-radius: 21px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-chip);
  -webkit-backdrop-filter: blur(20px) saturate(170%);
  backdrop-filter: blur(20px) saturate(170%);
  color: var(--text);
  text-align: center;
  transition: transform 0.14s ease;
}

button.topbar-center:active {
  transform: scale(0.985);
}

.topbar-title {
  display: block;
  width: 100%;
  font-size: 16px;
  font-weight: 650;
  letter-spacing: -0.01em;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-sub {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  font-size: 11px;
  line-height: 1.2;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.status-dot {
  width: 6px;
  height: 6px;
  flex: none;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 3px var(--green-soft);
  transition: background 0.2s ease, box-shadow 0.2s ease;
}

.status-dot.is-warn {
  background: var(--amber);
  box-shadow: 0 0 0 3px var(--amber-soft);
}

.status-dot.is-bad {
  background: var(--red);
  box-shadow: 0 0 0 3px var(--red-soft);
}

/* 连接提示条 */
.conn-banner {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 65;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: calc(var(--safe-top) + 7px) 16px 7px;
  font-size: 12.5px;
  color: var(--amber-fg);
  background: color-mix(in srgb, var(--amber) 18%, var(--bg));
  border-bottom: 1px solid var(--line);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
}

@supports not (background: color-mix(in srgb, red 50%, blue)) {
  .conn-banner {
    background: var(--amber-soft);
  }
}

.conn-banner.is-bad {
  color: var(--red-fg);
  background: var(--red-soft);
}

.conn-banner-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  animation: pulse 1.4s ease-in-out infinite;
}

.conn-banner-text {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conn-banner-btn {
  flex: none;
  font-size: 12px;
  font-weight: 600;
  color: inherit;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid currentColor;
  opacity: 0.9;
}

.app.has-banner .topbar {
  padding-top: calc(var(--safe-top) + 32px);
}

.app.has-banner .view-pair .pair-scroll {
  padding-top: calc(var(--safe-top) + 52px);
}

/* ------------------------------ 通用按钮 ------------------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 10px 18px;
  border-radius: 16px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: transform 0.12s ease, opacity 0.2s ease, background 0.2s ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.45;
}

.btn-primary {
  background: var(--btn-primary-bg);
  color: var(--btn-primary-fg);
  box-shadow: 0 8px 20px rgba(13, 17, 23, 0.16);
}

html[data-theme="dark"] .btn-primary {
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.4);
}

.btn-secondary {
  background: var(--btn-secondary-bg);
  color: var(--text);
}

.btn-danger {
  background: var(--red-soft);
  color: var(--red-fg);
}

.btn-ghost {
  background: var(--btn-secondary-bg);
  color: var(--text-2);
}

.btn-block {
  width: 100%;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 600;
  box-shadow: var(--shadow-chip);
  -webkit-backdrop-filter: blur(16px) saturate(160%);
  backdrop-filter: blur(16px) saturate(160%);
}

.chip:active {
  transform: scale(0.96);
}

.chip-accent {
  background: var(--btn-primary-bg);
  color: var(--btn-primary-fg);
  border-color: transparent;
}

.chip-icon {
  display: inline-flex;
}

.icon-btn {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--text-2);
  flex: none;
}

.icon-btn:active {
  background: var(--btn-secondary-bg);
}

.link-btn {
  font-size: 13px;
  font-weight: 600;
  color: var(--link);
  padding: 6px 8px;
  border-radius: 9px;
  flex: none;
}

.link-btn:active {
  background: var(--btn-secondary-bg);
}

/* ------------------------------ 配对页 ------------------------------ */
.view-pair {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.pair-scroll {
  width: 100%;
  max-width: 440px;
  margin: 0 auto;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 22px;
  padding: calc(var(--safe-top) + 34px) 22px calc(var(--safe-bottom) + 26px);
}

.pair-hero {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.pair-logo {
  width: 74px;
  height: 74px;
  display: grid;
  place-items: center;
  border-radius: 22px;
  color: #ffffff;
  background: linear-gradient(150deg, #1b2430 0%, #0c0f14 70%);
  box-shadow: 0 14px 34px rgba(13, 17, 23, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.16);
}

html[data-theme="dark"] .pair-logo {
  background: linear-gradient(150deg, #f1f5fa 0%, #cfd9e6 100%);
  color: #0b0e13;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.pair-title {
  margin: 4px 0 0;
  font-size: 29px;
  line-height: 1.15;
  font-weight: 750;
  letter-spacing: -0.03em;
}

.pair-sub {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text-2);
  max-width: 300px;
}

.pair-card {
  display: flex;
  flex-direction: column;
  gap: 13px;
  padding: 18px 16px 16px;
  border-radius: 26px;
  background: var(--card);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-soft);
  -webkit-backdrop-filter: blur(26px) saturate(170%);
  backdrop-filter: blur(26px) saturate(170%);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-2);
  padding-left: 3px;
}

.field-hint {
  font-weight: 400;
  color: var(--text-3);
}

.input {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  font-size: 16px;
  color: var(--text);
  background: var(--glass-strong);
  border: 1px solid var(--line);
  border-radius: 14px;
  transition: border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

.input::placeholder {
  color: var(--text-3);
}

.input:focus {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgba(47, 109, 246, 0.16);
}

.input-code {
  font-family: var(--font-mono);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 17px;
}

.form-error {
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--red-fg);
  background: var(--red-soft);
  border-radius: 11px;
  padding: 9px 11px;
  white-space: pre-line;
}

.pair-hint {
  margin: 1px 0 0;
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--text-3);
  text-align: center;
}

.pair-hint code {
  font-size: 10.5px;
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--code-inline-bg);
}

.pair-footer {
  text-align: center;
  font-size: 11px;
  color: var(--text-3);
}

.machine-panel {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.machine-panel-title {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-2);
  padding-left: 4px;
}

.machine-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.machine-card {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 12px 13px;
  border-radius: 18px;
  background: var(--card);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-soft);
}

.machine-card.is-active {
  border-color: var(--focus);
}

.machine-card-icon {
  width: 38px;
  height: 38px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--code-bg);
  color: var(--text-2);
}

.machine-card-main {
  flex: 1;
  min-width: 0;
}

.machine-card-name {
  font-size: 14px;
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.machine-card-sub {
  font-size: 11px;
  color: var(--text-3);
  font-family: var(--font-mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.machine-card-actions {
  display: flex;
  gap: 4px;
  flex: none;
}

.mini-btn {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  padding: 6px 10px;
  border-radius: 9px;
  background: var(--btn-secondary-bg);
}

.mini-btn.is-danger {
  color: var(--red-fg);
  background: var(--red-soft);
}

/* ------------------------------ 会话列表 ------------------------------ */
.home-toolbar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px calc(14px + var(--safe-right)) 8px calc(14px + var(--safe-left));
}

.home-toolbar .home-machine {
  margin-left: auto;
  font-size: 11.5px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 45%;
  font-family: var(--font-mono);
}

.session-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  padding: 2px calc(14px + var(--safe-right)) calc(26px + var(--safe-bottom)) calc(14px + var(--safe-left));
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.session-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 13px;
  border-radius: 21px;
  background: var(--card);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-soft);
  -webkit-backdrop-filter: blur(22px) saturate(165%);
  backdrop-filter: blur(22px) saturate(165%);
  transition: transform 0.14s ease, background 0.16s ease;
  text-align: left;
  width: 100%;
}

.session-item:active {
  transform: scale(0.986);
  background: var(--glass-strong);
}

.session-avatar {
  width: 46px;
  height: 46px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 15px;
  color: #ffffff;
  background: linear-gradient(150deg, #263241 0%, #10151c 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14);
}

html[data-theme="dark"] .session-avatar {
  background: linear-gradient(150deg, #2d3542 0%, #1a2029 100%);
  color: #dbe7f5;
}

.session-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.session-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.session-title {
  flex: 1;
  min-width: 0;
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.session-time {
  flex: none;
  font-size: 10.5px;
  color: var(--text-3);
}

.session-preview {
  font-size: 12px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.session-foot {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 1px;
  min-height: 19px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
  color: var(--text-3);
  background: var(--code-inline-bg);
}

.status-pill.is-busy {
  color: var(--green-fg);
  background: var(--green-soft);
}

.status-pill.is-error {
  color: var(--red-fg);
  background: var(--red-soft);
}

.session-unread {
  margin-left: auto;
  min-width: 19px;
  height: 19px;
  padding: 0 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  font-size: 10.5px;
  font-weight: 700;
  color: #ffffff;
  background: #2f6cf0;
}

.session-offline {
  margin-left: auto;
  font-size: 10px;
  color: var(--text-3);
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid var(--line);
}

.empty-state {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 30px 26px calc(60px + var(--safe-bottom));
  text-align: center;
  color: var(--text-3);
}

.empty-icon {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  border-radius: 22px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  color: var(--text-2);
  box-shadow: var(--shadow-chip);
  margin-bottom: 4px;
}

.empty-title {
  font-size: 16px;
  font-weight: 650;
  color: var(--text);
}

.empty-desc {
  font-size: 12.5px;
  line-height: 1.55;
  max-width: 260px;
}

.empty-state .btn {
  margin-top: 10px;
}

/* ------------------------------ 聊天 ------------------------------ */
.view-chat {
  overflow: hidden;
}

.chat-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  padding: 4px calc(12px + var(--safe-right)) 6px calc(12px + var(--safe-left));
  scroll-behavior: auto;
}

.message-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding-bottom: 4px;
}

.msg-row {
  display: flex;
  width: 100%;
}

.msg-row.is-new {
  animation: msg-in 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}

.msg-row.row-user {
  flex-direction: column;
  align-items: flex-end;
}

.msg-row.row-assistant,
.msg-row.row-activity {
  justify-content: flex-start;
}

.msg-row.row-system {
  justify-content: center;
}

.bubble {
  max-width: 84%;
  min-width: 0;
  padding: 9px 14px;
  font-size: var(--chat-font);
  line-height: 1.55;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.bubble-user {
  background: var(--bubble-user-bg);
  color: var(--bubble-user-fg);
  border-radius: 21px 21px 7px 21px;
  white-space: pre-wrap;
  box-shadow: 0 2px 10px rgba(12, 15, 20, 0.16);
  user-select: text;
  -webkit-user-select: text;
}

.bubble-user.is-pending {
  opacity: 0.72;
}

.bubble-user.is-failed {
  background: var(--red-soft);
  color: var(--red-fg);
  box-shadow: none;
}

.bubble-assistant {
  max-width: 92%;
  background: var(--bubble-assistant-bg);
  color: var(--bubble-assistant-fg);
  border: 1px solid var(--bubble-assistant-border);
  border-radius: 21px 21px 21px 7px;
  box-shadow: 0 2px 12px rgba(20, 32, 50, 0.05);
  user-select: text;
  -webkit-user-select: text;
}

html[data-theme="dark"] .bubble-assistant {
  box-shadow: none;
}

.user-meta {
  display: flex;
  align-items: center;
  gap: 5px;
  height: 14px;
  padding-right: 4px;
  margin-top: 3px;
  font-size: 10px;
  color: var(--text-3);
}

.user-meta-pending {
  opacity: 0.85;
}

.user-meta-time {
  font-variant-numeric: tabular-nums;
}

.user-meta-ticks {
  font-size: 9.5px;
  letter-spacing: -2.5px;
  padding-right: 2px;
  color: var(--text-3);
}

.user-meta-failed {
  color: var(--red-fg);
  font-weight: 600;
}

/* Markdown */
.md {
  font-size: var(--chat-font);
  line-height: 1.62;
  overflow-wrap: anywhere;
  min-width: 0;
}

.md > *:first-child {
  margin-top: 0;
}

.md > *:last-child {
  margin-bottom: 0;
}

.md p {
  margin: 0 0 0.52em;
}

.md p:last-child {
  margin-bottom: 0;
}

.md-h {
  margin: 0.72em 0 0.34em;
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: -0.01em;
}

.md-h1 {
  font-size: 1.16em;
}

.md-h2 {
  font-size: 1.09em;
}

.md-h3,
.md-h4,
.md-h5,
.md-h6 {
  font-size: 1.02em;
}

.md-list {
  margin: 0.24em 0 0.55em;
  padding-left: 1.35em;
}

.md-list:last-child {
  margin-bottom: 0;
}

.md-list li {
  margin: 0.14em 0;
}

.md-list li::marker {
  color: var(--text-3);
}

.md-quote {
  margin: 0.4em 0;
  padding: 0.08em 0 0.08em 0.75em;
  border-left: 3px solid var(--line-strong);
  color: var(--text-2);
}

.md-hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 0.8em 0;
}

.md-inline-code {
  font-size: 0.87em;
  padding: 1.5px 5px;
  border-radius: 6px;
  background: var(--code-inline-bg);
  overflow-wrap: anywhere;
}

.md-link {
  color: var(--link);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
}

.md-code {
  margin: 0.52em 0;
  border-radius: 13px;
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  overflow: hidden;
  max-width: 100%;
}

.md-code-open {
  opacity: 0.92;
}

.md-code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 5px 8px 4px 11px;
  color: var(--text-3);
  font-size: 10.5px;
  font-family: var(--font-mono);
}

.md-code-lang {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.md-code-copy {
  flex: none;
  width: 26px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  color: var(--text-3);
}

.md-code-copy:active {
  background: var(--btn-secondary-bg);
}

.md-code-copy.is-copied {
  color: var(--green-fg);
}

.md-code-pre {
  margin: 0;
  padding: 2px 12px 11px;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}

.md-code-body {
  display: block;
  font-size: 12.5px;
  line-height: 1.6;
  white-space: pre;
  color: var(--text);
}

.stream-cursor {
  display: inline-block;
  width: 2px;
  height: 1.02em;
  margin-left: 2px;
  vertical-align: -0.14em;
  border-radius: 2px;
  background: currentColor;
  animation: blink 1.05s steps(2, start) infinite;
}

/* 思考 / 工具 灰色胶囊行 */
.activity {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  border-radius: 18px;
  background: var(--chip-bg);
  border: 1px solid var(--chip-border);
  box-shadow: var(--shadow-chip);
  overflow: hidden;
  transition: background 0.18s ease;
  -webkit-backdrop-filter: blur(14px) saturate(150%);
  backdrop-filter: blur(14px) saturate(150%);
}

html[data-theme="dark"] .activity {
  -webkit-backdrop-filter: blur(12px) saturate(130%);
  backdrop-filter: blur(12px) saturate(130%);
}

.activity-head {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 40px;
  padding: 9px 10px 9px 12px;
  text-align: left;
  color: var(--chip-fg);
  font-size: 13px;
  line-height: 1.35;
}

.activity-head:active {
  background: var(--chip-bg-hover);
}

.activity-icon {
  flex: none;
  font-size: 15px;
  line-height: 1;
  filter: grayscale(0.1) saturate(0.85);
}

.activity-text {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  letter-spacing: -0.005em;
}

.activity-text.mono {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: -0.01em;
}

.activity-badge {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  font-weight: 650;
  line-height: 1;
  padding: 3px 7px;
  border-radius: 999px;
  white-space: nowrap;
}

.activity-badge.badge {
  color: var(--text-3);
  background: rgba(120, 130, 145, 0.14);
}

.activity-badge.is-done {
  color: var(--green-fg);
  background: var(--green-soft);
}

.activity-badge.is-running {
  color: var(--text-2);
  background: rgba(120, 130, 145, 0.16);
}

.activity-badge.is-error {
  color: var(--red-fg);
  background: var(--red-soft);
}

.activity-badge.is-muted {
  color: var(--text-3);
  background: rgba(120, 130, 145, 0.13);
}

.activity-chevron {
  flex: none;
  display: inline-flex;
  color: var(--text-3);
  transition: transform 0.24s cubic-bezier(0.22, 1, 0.36, 1);
}

.activity[data-open="true"] .activity-chevron {
  transform: rotate(180deg);
}

.activity-body {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.26s cubic-bezier(0.22, 1, 0.36, 1);
}

.activity[data-open="true"] .activity-body {
  grid-template-rows: 1fr;
}

.activity-body-inner {
  overflow: hidden;
  min-height: 0;
}

.live-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--green);
  animation: pulse 1.3s ease-in-out infinite;
}

.thinking-full {
  padding: 0 13px 12px;
  font-size: 12.8px;
  line-height: 1.66;
  color: var(--text-2);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 42vh;
  overflow-y: auto;
  user-select: text;
  -webkit-user-select: text;
}

.tool-body {
  padding: 0 11px 10px;
}

.tool-output {
  margin: 0;
  padding: 9px 10px;
  max-height: 190px;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 11px;
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.55;
  white-space: pre;
  color: var(--text);
  user-select: text;
  -webkit-user-select: text;
}

.tool-output.is-expanded {
  max-height: 58vh;
}

.tool-empty {
  padding: 8px 10px;
  border-radius: 11px;
  background: var(--code-bg);
  color: var(--text-3);
  font-size: 11.5px;
}

.tool-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 7px;
  min-height: 22px;
}

.tool-meta {
  font-size: 10px;
  color: var(--text-3);
  font-family: var(--font-mono);
  overflow-wrap: anywhere;
}

.tool-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 2px;
}

.tool-copy,
.tool-expand {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-3);
  padding: 4px 7px;
  border-radius: 8px;
}

.tool-copy:active,
.tool-expand:active {
  background: var(--btn-secondary-bg);
}

.tool-copy.is-copied {
  color: var(--green-fg);
}

/* 系统行 / 错误 / 分隔线 */
.msg-row.is-highlight .bubble,
.msg-row.is-highlight .activity {
  box-shadow: 0 0 0 2px var(--focus), var(--shadow-chip);
}

.chat-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 46px 24px 24px;
  text-align: center;
  color: var(--text-3);
}

.chat-empty .empty-icon {
  margin-bottom: 2px;
}

.system-line {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 92%;
  padding: 6px 11px;
  border-radius: 999px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  color: var(--text-2);
  font-size: 11.5px;
  box-shadow: var(--shadow-chip);
}

.system-line-icon {
  font-size: 12px;
  line-height: 1;
}

.system-line-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.system-line-status {
  flex: none;
  font-size: 10px;
  font-weight: 650;
  color: var(--text-3);
}

.system-line-status.is-pending {
  color: var(--amber-fg);
}

.row-error .error-line {
  display: inline-flex;
  align-items: flex-start;
  gap: 6px;
  max-width: 94%;
  padding: 7px 12px;
  border-radius: 14px;
  background: var(--red-soft);
  color: var(--red-fg);
  font-size: 12px;
  line-height: 1.5;
  user-select: text;
  -webkit-user-select: text;
}

.error-icon {
  flex: none;
  margin-top: 1px;
  display: inline-flex;
}

.error-text {
  min-width: 0;
  overflow-wrap: anywhere;
}

.msg-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 6px 0 2px;
  color: var(--text-3);
  font-size: 10.5px;
}

.msg-divider::before,
.msg-divider::after {
  content: "";
  height: 1px;
  flex: 1;
  max-width: 74px;
  background: var(--line);
}

.history-tip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 0 10px;
  font-size: 11.5px;
  color: var(--text-3);
}

.typing-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 14px 12px;
  color: var(--text-3);
  font-size: 12px;
}

.typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.typing-dots i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.45;
  animation: typing 1.1s ease-in-out infinite;
}

.typing-dots i:nth-child(2) {
  animation-delay: 0.14s;
}

.typing-dots i:nth-child(3) {
  animation-delay: 0.28s;
}

.spinner {
  width: 13px;
  height: 13px;
  flex: none;
  border-radius: 50%;
  border: 1.8px solid var(--line-strong);
  border-top-color: var(--text-2);
  animation: spin 0.8s linear infinite;
}

.scroll-bottom {
  position: absolute;
  right: calc(14px + var(--safe-right));
  bottom: calc(var(--composer-h, 78px) + 10px);
  z-index: 8;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--text);
  background: var(--glass-strong);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-pop);
  -webkit-backdrop-filter: blur(20px) saturate(170%);
  backdrop-filter: blur(20px) saturate(170%);
  animation: pop-in 0.18s ease;
}

.scroll-bottom:active {
  transform: scale(0.92);
}

.scroll-bottom-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: #2f6cf0;
  color: #fff;
  font-size: 9.5px;
  font-weight: 700;
  display: grid;
  place-items: center;
}

/* ------------------------------ 输入栏 ------------------------------ */
.composer-wrap {
  flex: none;
  position: relative;
  z-index: 7;
  padding: 4px calc(12px + var(--safe-right)) calc(8px + var(--safe-bottom)) calc(12px + var(--safe-left));
  background: linear-gradient(to top, var(--composer-fade) 34%, rgba(255, 255, 255, 0));
}

html[data-theme="dark"] .composer-wrap {
  background: linear-gradient(to top, var(--composer-fade) 34%, rgba(0, 0, 0, 0));
}

.composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.composer-menu {
  flex: none;
  height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0 13px 0 11px;
  border-radius: 22px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-chip);
  -webkit-backdrop-filter: blur(20px) saturate(170%);
  backdrop-filter: blur(20px) saturate(170%);
  transition: transform 0.13s ease, background 0.18s ease;
}

.composer-menu:active {
  transform: scale(0.95);
  background: var(--glass-strong);
}

.composer-menu-label {
  white-space: nowrap;
}

@media (max-width: 359px) {
  .composer-menu {
    width: 44px;
    padding: 0;
    justify-content: center;
  }

  .composer-menu-label {
    display: none;
  }
}

.composer-input {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: flex-end;
  gap: 2px;
  min-height: 44px;
  padding: 3px 6px 3px 3px;
  border-radius: 23px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-chip);
  -webkit-backdrop-filter: blur(22px) saturate(170%);
  backdrop-filter: blur(22px) saturate(170%);
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.composer-input:focus-within {
  border-color: var(--glass-border);
}

.composer-attach {
  flex: none;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--text-2);
  transition: transform 0.12s ease, background 0.16s ease;
}

.composer-attach:active {
  transform: scale(0.9);
  background: var(--btn-secondary-bg);
}

.composer-text {
  flex: 1;
  min-width: 0;
  display: block;
  height: 38px;
  max-height: 124px;
  padding: 9px 2px 8px;
  font-size: 16px;
  line-height: 1.4;
  color: var(--text);
  background: transparent;
  border: 0;
  resize: none;
  overflow-y: auto;
  outline: none;
  user-select: text;
  -webkit-user-select: text;
}

.composer-text::placeholder {
  color: var(--text-3);
}

.send-btn {
  width: 44px;
  height: 44px;
  background: var(--send-bg);
  color: var(--send-fg);
  border-color: transparent;
  box-shadow: 0 9px 22px rgba(12, 15, 20, 0.22);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  transition: transform 0.13s ease, opacity 0.18s ease, background 0.18s ease;
}

html[data-theme="dark"] .send-btn {
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.45);
}

.send-btn:active {
  transform: scale(0.93);
}

.send-btn:disabled {
  opacity: 0.35;
  box-shadow: none;
}

.send-btn.is-stop {
  background: var(--red-soft);
  color: var(--red-fg);
  box-shadow: none;
}

.composer-tip {
  padding: 7px 4px 0;
  font-size: 11px;
  text-align: center;
  color: var(--amber-fg);
}

.view-chat.is-offline .composer-text {
  opacity: 0.55;
}

/* 审批 / 提问浮层卡（在输入栏上方） */
.approval-layer {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 56vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 2px 2px 8px;
  overscroll-behavior: contain;
}

.approval-card {
  background: var(--sheet-bg);
  border: 1px solid var(--glass-border);
  border-radius: 23px;
  padding: 14px 15px 13px;
  box-shadow: var(--shadow-pop);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  backdrop-filter: blur(28px) saturate(180%);
  animation: sheet-in 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  flex: none;
}

.approval-head {
  display: flex;
  align-items: flex-start;
  gap: 9px;
}

.approval-icon {
  flex: none;
  font-size: 17px;
  line-height: 1.3;
}

.approval-titles {
  flex: 1;
  min-width: 0;
}

.approval-title {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}

.approval-subtitle {
  margin-top: 2px;
  font-size: 11px;
  color: var(--text-3);
}

.approval-detail {
  margin: 10px 0 0;
  padding: 9px 10px;
  max-height: 132px;
  overflow: auto;
  border-radius: 11px;
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--text-2);
  user-select: text;
  -webkit-user-select: text;
}

.approval-options {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.approval-option {
  flex: 1 1 0;
  min-width: 0;
  min-height: 43px;
  padding: 9px 10px;
  border-radius: 14px;
  font-size: 13.5px;
  font-weight: 650;
}

.approval-error {
  margin-top: 9px;
  font-size: 11.5px;
  color: var(--red-fg);
  background: var(--red-soft);
  border-radius: 9px;
  padding: 7px 9px;
}

.approval-countdown {
  margin-top: 8px;
  font-size: 10.5px;
  color: var(--text-3);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.approval-card.is-expired {
  opacity: 0.72;
}

.question-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 10px;
  max-height: 42vh;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.question-header {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
  margin-bottom: 3px;
}

.question-text {
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.45;
  margin-bottom: 7px;
  overflow-wrap: anywhere;
}

.question-options {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.question-option {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  width: 100%;
  padding: 9px 11px;
  border-radius: 13px;
  background: var(--btn-secondary-bg);
  border: 1px solid transparent;
  text-align: left;
  transition: background 0.16s ease, border-color 0.16s ease;
}

.question-option.is-selected {
  border-color: var(--focus);
  background: rgba(47, 109, 246, 0.1);
}

.question-marker {
  flex: none;
  width: 20px;
  height: 20px;
  margin-top: 1px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1.5px solid var(--line-strong);
  color: var(--text-3);
}

.question-option.is-selected .question-marker {
  border-color: var(--focus);
  background: var(--focus);
  color: #fff;
}

.question-option-body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.question-option-label {
  font-size: 13px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.question-option-desc {
  font-size: 11px;
  color: var(--text-3);
  line-height: 1.45;
}

.question-empty {
  font-size: 11.5px;
  color: var(--text-3);
}

/* ------------------------------ 设置 ------------------------------ */
.view-settings {
  background: transparent;
}

.settings-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  padding: 2px 0 calc(30px + var(--safe-bottom));
}

.settings-section-title {
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: 0.05em;
  color: var(--text-3);
  padding: 14px 26px 7px;
}

.settings-group {
  margin: 0 14px;
  border-radius: 20px;
  background: var(--card);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-soft);
  -webkit-backdrop-filter: blur(22px) saturate(165%);
  backdrop-filter: blur(22px) saturate(165%);
  overflow: hidden;
}

.settings-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 54px;
  padding: 11px 15px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.settings-row:last-child {
  border-bottom: 0;
}

.settings-row-button:active {
  background: var(--btn-secondary-bg);
}

.settings-main {
  flex: 1;
  min-width: 0;
}

.settings-label {
  font-size: 14.5px;
  font-weight: 550;
  line-height: 1.35;
}

.settings-sub {
  font-size: 11.5px;
  color: var(--text-3);
  line-height: 1.4;
  margin-top: 2px;
  overflow-wrap: anywhere;
}

.settings-row.danger .settings-label {
  color: var(--red-fg);
}

.settings-chevron {
  flex: none;
  color: var(--text-3);
  display: inline-flex;
}

.settings-value {
  flex: none;
  font-size: 13px;
  color: var(--text-3);
  font-family: var(--font-mono);
}

.settings-badge {
  flex: none;
  font-size: 10.5px;
  font-weight: 650;
  padding: 3px 8px;
  border-radius: 999px;
  color: var(--text-3);
  background: rgba(120, 130, 145, 0.14);
}

.settings-badge.is-online {
  color: var(--green-fg);
  background: var(--green-soft);
}

.settings-badge.is-offline {
  color: var(--red-fg);
  background: var(--red-soft);
}

.settings-about {
  padding: 18px 26px 6px;
  font-size: 11px;
  line-height: 1.7;
  color: var(--text-3);
  text-align: center;
}

.segmented {
  flex: none;
  display: flex;
  gap: 2px;
  padding: 3px;
  border-radius: 12px;
  background: var(--seg-bg);
}

.segmented button {
  padding: 5px 9px;
  border-radius: 9px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-2);
  transition: background 0.16s ease, color 0.16s ease;
}

.segmented button.is-active {
  background: var(--seg-active);
  color: var(--text);
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.1);
}

.switch {
  flex: none;
  width: 48px;
  height: 29px;
  border-radius: 999px;
  background: var(--switch-bg);
  position: relative;
  transition: background 0.2s ease;
}

.switch-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 25px;
  height: 25px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 2px 5px rgba(15, 23, 42, 0.25);
  transition: transform 0.2s cubic-bezier(0.22, 1, 0.36, 1);
}

.switch[aria-checked="true"] {
  background: var(--switch-on);
}

.switch[aria-checked="true"] .switch-knob {
  transform: translateX(19px);
}

/* ------------------------------ 文件浏览 ------------------------------ */
.breadcrumb {
  flex: none;
  display: flex;
  align-items: center;
  gap: 2px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 4px calc(14px + var(--safe-right)) 6px calc(14px + var(--safe-left));
  scrollbar-width: none;
}

.breadcrumb::-webkit-scrollbar {
  display: none;
}

.crumb {
  flex: none;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  padding: 5px 7px;
  border-radius: 8px;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--font-mono);
}

.crumb.is-current {
  color: var(--text);
  background: var(--btn-secondary-bg);
}

.crumb-sep {
  flex: none;
  color: var(--text-3);
  font-size: 11px;
  padding: 0 1px;
}

.files-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  padding: 2px calc(14px + var(--safe-right)) calc(24px + var(--safe-bottom)) calc(14px + var(--safe-left));
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.file-item {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  min-height: 52px;
  padding: 9px 13px;
  border-radius: 16px;
  background: var(--card);
  border: 1px solid var(--glass-border);
  text-align: left;
  transition: transform 0.13s ease, background 0.16s ease;
}

.file-item:active {
  transform: scale(0.99);
  background: var(--glass-strong);
}

.file-icon {
  flex: none;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--code-inline-bg);
  color: var(--text-2);
}

.file-icon.is-dir {
  color: var(--amber-fg);
  background: var(--amber-soft);
}

.file-main {
  flex: 1;
  min-width: 0;
}

.file-name {
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-sub {
  font-size: 10.5px;
  color: var(--text-3);
  font-family: var(--font-mono);
  margin-top: 1px;
}

.file-chevron {
  flex: none;
  color: var(--text-3);
  display: inline-flex;
}

/* ------------------------------ 编辑器 ------------------------------ */
.editor-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 2px calc(10px + var(--safe-right)) calc(6px + var(--safe-bottom)) calc(10px + var(--safe-left));
  gap: 4px;
}

.editor-text {
  flex: 1;
  min-height: 0;
  width: 100%;
  padding: 13px 14px;
  border-radius: 18px;
  background: var(--card-solid);
  border: 1px solid var(--line);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.58;
  tab-size: 2;
  resize: none;
  white-space: pre;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  box-shadow: var(--shadow-soft);
  user-select: text;
  -webkit-user-select: text;
}

html[data-theme="dark"] .editor-text {
  background: var(--card-solid);
}

.editor-status {
  flex: none;
  height: 20px;
  padding: 0 6px;
  font-size: 10.5px;
  line-height: 20px;
  color: var(--text-3);
  font-family: var(--font-mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.editor-status.is-dirty {
  color: var(--amber-fg);
}

.editor-status.is-error {
  color: var(--red-fg);
}

.editor-status.is-saved {
  color: var(--green-fg);
}

/* ------------------------------ 终端 ------------------------------ */
.view-terminal {
  background: var(--term-bg);
  color: var(--term-fg);
}

.terminal-topbar .circle-btn {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.08);
  color: #dbe7f5;
  box-shadow: none;
}

.terminal-topbar .topbar-center {
  background: rgba(255, 255, 255, 0.055);
  border-color: rgba(255, 255, 255, 0.07);
  color: #eaf2fb;
  box-shadow: none;
}

.terminal-topbar .topbar-sub {
  color: rgba(214, 226, 240, 0.5);
}

.term-output {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  padding: 6px 14px 10px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--term-fg);
  user-select: text;
  -webkit-user-select: text;
}

.term-error {
  color: #ff8a80;
}

.term-keys {
  flex: none;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 6px calc(12px + var(--safe-right)) 0 calc(12px + var(--safe-left));
  scrollbar-width: none;
}

.term-keys::-webkit-scrollbar {
  display: none;
}

.term-key {
  flex: none;
  height: 30px;
  padding: 0 11px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.07);
  color: rgba(224, 234, 246, 0.82);
  font-size: 11px;
  font-family: var(--font-mono);
}

.term-key:active {
  background: rgba(255, 255, 255, 0.16);
}

.term-input-row {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px calc(12px + var(--safe-right)) calc(10px + var(--safe-bottom)) calc(12px + var(--safe-left));
}

.term-prompt {
  flex: none;
  font-family: var(--font-mono);
  font-size: 13px;
  color: #63e6a4;
}

.term-input {
  flex: 1;
  min-width: 0;
  height: 42px;
  padding: 0 12px;
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--term-fg);
  font-family: var(--font-mono);
  font-size: 14px;
  outline: none;
  user-select: text;
  -webkit-user-select: text;
}

.term-input::placeholder {
  color: rgba(214, 226, 240, 0.32);
}

.term-input:focus {
  border-color: rgba(99, 230, 164, 0.45);
}

.term-send {
  flex: none;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(99, 230, 164, 0.16);
  color: #63e6a4;
  border: 1px solid rgba(99, 230, 164, 0.22);
}

.term-send:active {
  transform: scale(0.93);
}

/* ------------------------------ 抽屉 / Sheet / 搜索 ------------------------------ */
.backdrop {
  position: absolute;
  inset: 0;
  z-index: 40;
  background: var(--backdrop);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  animation: fade-in 0.2s ease;
}

.sheet-backdrop {
  z-index: 41;
}

.drawer {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 42;
  width: min(86%, 348px);
  display: flex;
  flex-direction: column;
  gap: 13px;
  padding: calc(var(--safe-top) + 16px) 14px calc(var(--safe-bottom) + 18px);
  background: var(--sheet-bg);
  border-right: 1px solid var(--glass-border);
  border-radius: 0 26px 26px 0;
  box-shadow: 26px 0 70px rgba(10, 15, 25, 0.22);
  -webkit-backdrop-filter: blur(32px) saturate(180%);
  backdrop-filter: blur(32px) saturate(180%);
  animation: drawer-in 0.26s cubic-bezier(0.22, 1, 0.36, 1);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.drawer-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 2px 4px;
}

.drawer-logo {
  width: 42px;
  height: 42px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 13px;
  background: var(--btn-primary-bg);
  color: var(--btn-primary-fg);
}

.drawer-head-text {
  flex: 1;
  min-width: 0;
}

.drawer-title {
  font-size: 15.5px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.drawer-sub {
  font-size: 11px;
  color: var(--text-3);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: var(--font-mono);
}

.drawer-actions {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px;
  border-radius: 17px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
}

.drawer-action {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 44px;
  padding: 0 10px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 550;
  text-align: left;
  color: var(--text);
}

.drawer-action:active {
  background: var(--btn-secondary-bg);
}

.drawer-action .icon {
  color: var(--text-2);
}

.drawer-section-title {
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.05em;
  color: var(--text-3);
  padding: 4px 4px 0;
}

.drawer-sessions {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.drawer-session {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 9px 10px;
  border-radius: 12px;
  text-align: left;
}

.drawer-session:active {
  background: var(--btn-secondary-bg);
}

.drawer-session.is-active {
  background: var(--btn-secondary-bg);
}

.drawer-session-title {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  font-weight: 550;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.drawer-session-time {
  flex: none;
  font-size: 10px;
  color: var(--text-3);
}

.sheet {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: calc(var(--safe-bottom) + 8px);
  z-index: 43;
  padding: 8px 12px 10px;
  border-radius: 27px;
  background: var(--sheet-bg);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-sheet);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  backdrop-filter: blur(30px) saturate(180%);
  animation: sheet-in 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

.sheet-handle {
  width: 36px;
  height: 4px;
  margin: 2px auto 8px;
  border-radius: 2px;
  background: var(--line-strong);
}

.menu-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
}

.menu-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  padding: 10px 2px 9px;
  border-radius: 16px;
  font-size: 11px;
  font-weight: 550;
  color: var(--text-2);
}

.menu-item:active {
  background: var(--btn-secondary-bg);
}

.menu-icon {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: var(--glass-strong);
  border: 1px solid var(--glass-border);
  color: var(--text);
  box-shadow: var(--shadow-chip);
}

.sheet-cancel {
  width: 100%;
  height: 46px;
  margin-top: 6px;
  border-radius: 16px;
  background: var(--btn-secondary-bg);
  color: var(--text);
  font-size: 14.5px;
  font-weight: 650;
}

.sheet-cancel:active {
  opacity: 0.8;
}

.search-overlay {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  background-image: var(--bg-gradient);
  animation: fade-in 0.16s ease;
}

.search-box {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 7px;
  height: 42px;
  padding: 0 13px;
  border-radius: 21px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-chip);
  -webkit-backdrop-filter: blur(20px) saturate(170%);
  backdrop-filter: blur(20px) saturate(170%);
}

.search-icon {
  flex: none;
  color: var(--text-3);
  display: inline-flex;
}

.search-input {
  flex: 1;
  min-width: 0;
  height: 40px;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 16px;
  outline: none;
}

.search-input::placeholder {
  color: var(--text-3);
}

.search-results {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  padding: 4px calc(14px + var(--safe-right)) calc(24px + var(--safe-bottom)) calc(14px + var(--safe-left));
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.search-result {
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 100%;
  padding: 11px 13px;
  border-radius: 15px;
  background: var(--card);
  border: 1px solid var(--glass-border);
  text-align: left;
}

.search-result:active {
  background: var(--glass-strong);
}

.search-result-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.search-result-kind {
  flex: none;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 2px 6px;
  border-radius: 6px;
  color: var(--text-3);
  background: var(--code-inline-bg);
}

.search-result-title {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-result-time {
  flex: none;
  font-size: 10px;
  color: var(--text-3);
}

.search-result-snippet {
  font-size: 11.5px;
  color: var(--text-3);
  line-height: 1.5;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.search-mark {
  background: var(--amber-soft);
  color: inherit;
  border-radius: 3px;
  padding: 0 1px;
}

.search-empty {
  padding: 40px 20px;
  text-align: center;
  font-size: 12.5px;
  color: var(--text-3);
}

/* ------------------------------ 对话框 / Toast ------------------------------ */
.dialog-layer {
  position: absolute;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--backdrop);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  animation: fade-in 0.16s ease;
}

.dialog {
  width: min(100%, 350px);
  padding: 20px 18px 16px;
  border-radius: 23px;
  background: var(--sheet-bg);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-sheet);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  backdrop-filter: blur(30px) saturate(180%);
  animation: pop-in 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}

.dialog-title {
  font-size: 16.5px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.dialog-text {
  margin-top: 7px;
  font-size: 12.8px;
  line-height: 1.6;
  color: var(--text-2);
  overflow-wrap: anywhere;
  user-select: text;
  -webkit-user-select: text;
}

.dialog-actions {
  display: flex;
  gap: 8px;
  margin-top: 17px;
}

.dialog-btn {
  flex: 1;
  min-height: 43px;
  padding: 9px;
  border-radius: 14px;
  font-size: 13.5px;
  font-weight: 650;
}

.toast-layer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(var(--safe-bottom) + 92px);
  z-index: 80;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  padding: 0 20px;
  pointer-events: none;
}

.toast {
  max-width: 88%;
  padding: 10px 15px;
  border-radius: 14px;
  background: var(--toast-bg);
  color: var(--toast-fg);
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1.45;
  text-align: center;
  box-shadow: var(--shadow-pop);
  animation: toast-in 0.22s cubic-bezier(0.22, 1, 0.36, 1);
  overflow-wrap: anywhere;
}

.toast.is-error {
  background: #b42318;
  color: #fff;
}

.toast.is-success {
  background: #137a37;
  color: #fff;
}

.toast.is-leaving {
  animation: toast-out 0.2s ease forwards;
}

/* ------------------------------ 动画 ------------------------------ */
@keyframes msg-in {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes sheet-in {
  from {
    opacity: 0;
    transform: translateY(22px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes drawer-in {
  from {
    opacity: 0.6;
    transform: translateX(-18px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes pop-in {
  from {
    opacity: 0;
    transform: scale(0.96);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateY(6px);
  }
}

@keyframes blink {
  0%,
  49% {
    opacity: 1;
  }
  50%,
  100% {
    opacity: 0;
  }
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.35;
  }
}

@keyframes typing {
  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  30% {
    transform: translateY(-2.5px);
    opacity: 1;
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ------------------------------ 滚动条 ------------------------------ */
.chat-scroll::-webkit-scrollbar,
.session-list::-webkit-scrollbar,
.settings-scroll::-webkit-scrollbar,
.files-list::-webkit-scrollbar,
.term-output::-webkit-scrollbar,
.md-code-pre::-webkit-scrollbar,
.tool-output::-webkit-scrollbar,
.approval-detail::-webkit-scrollbar {
  width: 0;
  height: 0;
}

/* ------------------------------ 自适应 / 无障碍 ------------------------------ */
@media (max-width: 360px) {
  .circle-btn {
    width: 38px;
    height: 38px;
  }

  .topbar-center {
    padding: 4px 10px 5px;
    border-radius: 19px;
  }

  .topbar-title {
    font-size: 15px;
  }

  .topbar-spacer {
    width: 38px;
    height: 38px;
  }

  .composer {
    gap: 6px;
  }

  .send-btn {
    width: 42px;
    height: 42px;
  }

  .bubble {
    max-width: 90%;
  }

  .menu-icon {
    width: 44px;
    height: 44px;
  }
}

@media (max-width: 520px) {
  /* iOS Safari 在聚焦字号 < 16px 的输入控件时会自动放大页面，这里统一压到 16px */
  .editor-text,
  .term-input {
    font-size: 16px;
  }
}

@media (orientation: landscape) and (max-height: 500px) {
  .topbar {
    padding-top: calc(var(--safe-top) + 4px);
    padding-bottom: 3px;
  }

  .circle-btn {
    width: 36px;
    height: 36px;
  }

  .topbar-spacer {
    width: 36px;
    height: 36px;
  }

  .topbar-center {
    padding: 3px 12px 4px;
  }

  .composer-wrap {
    padding-top: 2px;
  }

  .approval-layer {
    max-height: 44vh;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
