/* DeepSeek official design tokens (from chat.deepseek.com capture) */
:root {
  --dsw-static-deepseek-50: #edf3fe;
  --dsw-static-deepseek-100: #e4edfd;
  --dsw-static-deepseek-200: #d3e2ff;
  --dsw-static-deepseek-300: #b7c8fe;
  --dsw-static-deepseek-400: #679efe;
  --dsw-static-deepseek-450: #5686fe;
  --dsw-static-deepseek-500: #3964fe;
  --dsw-static-deepseek-600: #4868b2;
  --dsw-static-neutral-bluish-00: #fff;
  --dsw-static-neutral-bluish-50: #f9fafb;
  --dsw-static-neutral-bluish-60: #f5f6f7;
  --dsw-static-neutral-bluish-75: #f1f3f5;
  --dsw-static-neutral-bluish-100: #ebeef2;
  --dsw-static-neutral-bluish-200: #e1e5ee;
  --dsw-static-neutral-bluish-400: #adb2b8;
  --dsw-static-neutral-bluish-600: #81858c;
  --dsw-static-neutral-bluish-700: #61666b;
  --dsw-static-neutral-bluish-1000: #0f1115;
  --dsw-static-neutral-bluish-800: #292929;

  --dsw-alias-brand-primary: var(--dsw-static-deepseek-500);
  --dsw-alias-brand-text: var(--dsw-static-deepseek-500);
  --dsw-alias-label-primary: var(--dsw-static-neutral-bluish-1000);
  --dsw-alias-label-secondary: var(--dsw-static-neutral-bluish-700);
  --dsw-alias-label-tertiary: var(--dsw-static-neutral-bluish-600);
  --dsw-alias-label-caption: var(--dsw-static-neutral-bluish-400);
  --dsw-alias-label-primary-foreground: #fff;
  --dsw-alias-border-l1: rgba(0,0,0,.04);
  --dsw-alias-border-l2: rgba(0,0,0,.1);
  --dsw-alias-border-l2-darkmode-thin: rgba(0,0,0,.1);
  --dsw-alias-button-elevated-fill: #fff;
  --dsw-alias-button-primary-fill: var(--dsw-alias-brand-primary);
  --dsw-alias-button-primary-hover: var(--dsw-static-deepseek-450);
  --dsw-alias-button-ghost-active-fill: var(--dsw-static-deepseek-50);
  --dsw-alias-button-ghost-active-border: var(--dsw-static-deepseek-300);
  --dsw-alias-button-ghost-active-hover: var(--dsw-static-deepseek-100);
  --dsw-alias-interactive-bg-hover: rgba(38,49,72,.06);
  --dsw-specific-sidebar-fill: var(--dsw-static-neutral-bluish-50);
  --dsw-specific-sidebar-nav-item-hover: var(--dsw-static-neutral-bluish-75);
  --dsw-specific-sidebar-nav-item-active: var(--dsw-static-neutral-bluish-100);
  --dsw-specific-sidebar-nav-item-active-accent: var(--dsw-static-deepseek-100);
  --dsw-specific-input-major: #fff;
  --dsw-specific-bubble: var(--dsw-static-deepseek-50);
  --dsw-specific-bubble-highlight: var(--dsw-static-deepseek-200);
  --dsw-font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", "PingFang SC", "Microsoft YaHei", sans-serif;
  --sidebar-w: 261px;
  --sider-width: 261px;
  --line-height: 24px;
  --input-padding-top: 12px;
  --sider-top-slot-height: 40px;
  --message-list-max-width: 840px;
  --message-list-padding-horizontal: 44px;
  --dsw-alias-label-dimmed: var(--dsw-static-neutral-bluish-200);
  --dsw-alias-brand-primary-invert: var(--dsw-static-deepseek-500);
  --dsw-shadow-lv2: 0 4px 12px 0 rgba(0,0,0,.02), 0 2px 8px 0 rgba(0,0,0,.04);
}
@media not all and (min-width: 1024px) {
  :root {
    --message-list-max-width: 712px;
    --message-list-padding-horizontal: 36px;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--dsw-font-family);
  font-size: 14px;
  line-height: 22px;
  color: var(--dsw-alias-label-primary);
  background: #fff;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; padding: 0; }
a { color: var(--dsw-alias-brand-text); text-decoration: none; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: #d4d4d4; border-radius: 8px; }

/* ========== Login ========== */
.login-page {
  min-height: 100%; min-height: 100dvh; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: calc(40px + env(safe-area-inset-top)) 20px calc(40px + env(safe-area-inset-bottom));
  background: #fff;
}
.login-card { width: 100%; max-width: 400px; }
.login-logo {
  display: flex; justify-content: center; margin-bottom: 40px;
}
.login-logo .wordmark { height: 28px; width: auto; color: var(--dsw-alias-brand-primary); }
.login-tabs { display: flex; gap: 28px; justify-content: center; margin-bottom: 24px; }
.login-tabs button {
  font-size: 15px; color: var(--dsw-alias-label-tertiary); padding-bottom: 8px;
  border-bottom: 2px solid transparent; font-weight: 500;
}
.login-tabs button.active { color: var(--dsw-alias-label-primary); border-bottom-color: var(--dsw-alias-brand-primary); }
.field {
  height: 48px; border: 1px solid var(--dsw-alias-border-l2); border-radius: 100px;
  display: flex; align-items: center; padding: 0 18px; margin-bottom: 14px; background: #fff;
}
.field:focus-within { border-color: var(--dsw-alias-brand-primary); box-shadow: 0 0 0 3px rgba(57,100,254,.12); }
.field input { border: 0; outline: 0; width: 100%; background: transparent; font-size: 15px; }
.field input::placeholder { color: var(--dsw-alias-label-caption); }
.login-hint { font-size: 12px; color: var(--dsw-alias-label-tertiary); line-height: 1.6; margin: 4px 4px 18px; }
.login-hint a { color: var(--dsw-alias-label-primary); text-decoration: underline; }
.btn-primary {
  width: 100%; height: 48px; border-radius: 100px; background: var(--dsw-alias-button-primary-fill);
  color: #fff; font-size: 16px; font-weight: 600;
}
.btn-primary:hover { background: var(--dsw-alias-button-primary-hover); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.login-alt { text-align: center; margin-top: 18px; color: var(--dsw-alias-label-tertiary); font-size: 13px; }
.login-links {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 16px; gap: 12px;
}
.login-links button { color: var(--dsw-alias-brand-primary, #3964fe); font-size: 13px; background: none; }
.phone-field { gap: 8px; }
.phone-cc,
.phone-prefix { flex: none; color: var(--dsw-alias-label-primary, #111); font-size: 15px; font-weight: 500; }
.login-toast-ico { display: flex; flex: none; line-height: 0; }
.field-split { padding-right: 14px; }
.field-split button {
  flex: none; border: 0; border-left: 1px solid #e6e6e6; background: transparent;
  color: var(--dsw-alias-brand-primary, #4d6bfe);
  font-size: 14px; white-space: nowrap; padding: 0 0 0 14px; margin-left: 8px;
}
.field-split button.code-send.waiting,
.field-split button.code-send:disabled { color: #b0b4bc; cursor: default; }
.login-toast {
  position: fixed; left: 50%; top: 28px; z-index: 60;
  transform: translateX(-50%) translateY(-8px);
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px 10px 12px; border-radius: 12px;
  background: #3a3a3c; color: #fff;
  font-size: 14px; opacity: 0; pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}
.login-toast-check {
  width: 18px; height: 18px; border-radius: 50%;
  background: #22c55e; position: relative; flex: none;
}
.login-toast-check::after {
  content: '';
  position: absolute; left: 6px; top: 3px;
  width: 4px; height: 8px;
  border: solid #fff; border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.login-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.login-ok {
  margin-bottom: 12px; padding: 10px 14px; border-radius: 12px;
  background: #ecfdf3; color: #15803d; font-size: 13px;
}
.login-success {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  background: rgba(15, 23, 42, .28); padding: 24px;
}
.login-success[hidden] { display: none !important; }
.login-success-card {
  min-width: min(320px, 100%); padding: 28px 32px; border-radius: 18px;
  background: #fff; text-align: center;
  box-shadow: 0 16px 48px rgba(0,0,0,.16);
}
.login-success-card strong { display: block; font-size: 20px; font-weight: 700; color: #111; }
.login-success-card span { display: block; margin-top: 8px; font-size: 13px; color: #667085; }
.legal-mask {
  position: fixed; inset: 0; z-index: 40; display: none;
  align-items: center; justify-content: center; background: rgba(0,0,0,.28); padding: 20px;
}
.legal-mask.show { display: flex; }
.legal-panel {
  width: min(720px, 100%); max-height: min(82vh, 760px); overflow: auto;
  background: #fff; border-radius: 16px; padding: 22px 22px 18px;
  box-shadow: 0 16px 48px rgba(0,0,0,.16);
}
.legal-doc h4 { margin: 0 0 6px; font-size: 18px; }
.legal-doc h5 { margin: 16px 0 6px; font-size: 14px; }
.legal-doc p { margin: 0 0 8px; font-size: 13.5px; line-height: 1.75; color: #344054; }
.legal-doc .legal-meta { color: #667085; font-size: 12px; }
.legal-panel .btn-primary { margin-top: 8px; }
.otp-code-input {
  width: 120px; height: 32px; border: 1px solid var(--dsw-alias-border-l2, #e5e5e5);
  border-radius: 8px; padding: 0 8px;
}
.login-error {
  display: none; margin-bottom: 12px; padding: 10px 14px; border-radius: 12px;
  background: #fef2f2; color: #ec1313; font-size: 13px;
}
.login-error.show { display: block; }
.login-footer { margin-top: 48px; color: var(--dsw-alias-label-caption); font-size: 12px; }

/* ========== App shell ========== */
.app { display: flex; height: 100%; overflow: hidden; background: #fff; }

.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--dsw-specific-sidebar-fill);
  border-right: 1px solid var(--dsw-alias-border-l1);
  display: flex; flex-direction: column;
  padding: 6px 12px 0;
  position: relative; z-index: 1;
  transition: margin-left .22s ease;
}
.sidebar.collapsed { margin-left: calc(-1 * var(--sidebar-w)); }

.sidebar-top {
  height: 48px;
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px; padding: 15px 0 10px 4px;
  box-sizing: border-box;
}
.brand { display: flex; align-items: center; height: 100%; }
.brand .wordmark { height: 23px; width: auto; display: block; }
.sidebar-actions { display: flex; align-items: center; gap: 0; }
.icon-btn {
  width: 34px; height: 34px; border-radius: 4096px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--dsw-alias-label-primary);
}
.icon-btn:hover { background: var(--dsw-alias-interactive-bg-hover); }
.icon-btn svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; }

/* New chat — exact official shadow pill */
.new-chat-btn {
  height: var(--sider-top-slot-height);
  width: 100%;
  box-sizing: border-box;
  background: var(--dsw-alias-button-elevated-fill);
  border: 1px solid rgba(103,158,254,0);
  border-radius: 100px;
  padding: 0 16px;
  display: flex; align-items: center; gap: 8px;
  font-size: 14px; font-weight: 500; color: var(--dsw-alias-label-primary);
  box-shadow: 0 -2px 2px rgba(72,104,178,.04), 0 2px 2px rgba(106,111,117,.09), 0 1px 2px rgba(72,104,178,.08);
  transition: box-shadow .3s;
  margin-bottom: 0; position: relative; flex-shrink: 0;
}
.new-chat-btn:hover {
  box-shadow: 0 4px 4px rgba(72,104,178,.04), 0 -3px 4px rgba(72,104,178,.04), 0 6px 6px rgba(106,111,117,.1);
}
.new-chat-btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.new-chat-btn::after {
  content: "⌘ J";
  position: absolute; right: 11px;
  font-size: 12px; font-weight: 500;
  color: var(--dsw-alias-label-caption);
  opacity: 0; transition: opacity .2s;
  pointer-events: none;
}
.new-chat-btn:hover::after { opacity: 1; }
@media (max-width: 767px) {
  .new-chat-btn::after { display: none; }
}

.history { flex: 1; overflow: auto; min-height: 0; padding-bottom: 8px; margin-top: 24px; }
.history-empty {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 2px;
  padding: 0 0 14px;
}
.history-empty-label {
  width: 100%;
  margin: 0;
}
.history-empty-item {
  width: 100%;
  height: 40px;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 0 10px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--dsw-alias-label-primary);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background .15s ease;
}
.history-empty-item:hover {
  background: var(--dsw-specific-sidebar-nav-item-hover);
}
.history-empty-item:active {
  background: var(--dsw-specific-sidebar-nav-item-active, rgba(0, 0, 0, 0.05));
}
.history-empty-ico {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  background: color-mix(in srgb, var(--dsw-static-deepseek-100, #4d6bfe) 10%, transparent);
  color: var(--dsw-static-deepseek-100, #4d6bfe);
}
.history-empty-ico svg {
  width: 14px;
  height: 14px;
}
.history-empty-title {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  font-weight: 500;
  line-height: 22px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.history-group-label {
  position: sticky; top: 0; z-index: 2;
  padding: 2px 10px;
  font-size: 12px; font-weight: 500; line-height: 18px;
  color: var(--dsw-alias-label-tertiary);
  background: var(--dsw-specific-sidebar-fill);
  box-shadow: 4px 0 0 var(--dsw-specific-sidebar-fill);
  user-select: none; margin-top: 6px;
}
.history-item {
  height: 40px;
  padding: 9px 6px 9px 10px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: space-between;
  color: var(--dsw-alias-label-primary);
  font-size: 14px; line-height: 22px;
  text-decoration: none; cursor: pointer; position: relative;
}
.history-item:hover { background: var(--dsw-specific-sidebar-nav-item-hover); }
.history-item.active {
  background: var(--dsw-specific-sidebar-nav-item-active-accent);
  color: var(--dsw-alias-brand-primary-invert);
}
.history-item .title {
  flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; line-height: 18px;
  min-width: 0;
}
.history-item .more-fade {
  position: absolute; right: 0; top: 0; bottom: 0;
  width: 56px;
  display: none;
  align-items: center; justify-content: flex-end;
  padding-right: 4px;
  background: linear-gradient(90deg, rgba(241,243,245,0) 0%, rgb(241,243,245) 40.62%);
  border-radius: 0 12px 12px 0;
}
.history-item:hover .more-fade { display: flex; }
.history-item.active .more-fade {
  display: flex;
  background: linear-gradient(90deg, rgba(228,237,253,0) 0%, rgb(228,237,253) 40.62%);
}
.history-item .more {
  width: 28px; height: 28px; border-radius: 8px;
  display: grid; place-items: center; color: var(--dsw-alias-label-tertiary); flex-shrink: 0;
}
.history-item .more:hover { background: rgba(0,0,0,.06); }

.sidebar-user {
  margin-top: auto;
  border-radius: 12px;
  padding: 6px 2px 6px 6px;
  display: flex; align-items: center; gap: 0;
  cursor: pointer; position: relative;
  margin-bottom: 0;
  width: 100%;
}
.sidebar-user:hover { background: var(--dsw-specific-sidebar-nav-item-hover); }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: rgba(0,0,0,.04);
  display: grid; place-items: center;
  font-weight: 500; font-size: 14px; color: var(--dsw-alias-label-tertiary); flex-shrink: 0;
}
.user-meta { min-width: 0; flex: 1; margin-left: 8px; }
.user-meta .email {
  font-size: 14px; color: var(--dsw-alias-label-secondary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.user-menu {
  position: absolute; left: 0; right: 0; bottom: calc(100% + 6px);
  background: #fff; border: 1px solid var(--dsw-alias-border-l2);
  border-radius: 14px;
  box-shadow: rgba(0,0,0,.2) 0 0 1px, rgba(0,0,0,.02) 0 0 4px, rgba(0,0,0,.08) 0 12px 32px;
  padding: 6px; display: none; z-index: 30;
}
.user-menu.show { display: block; }
.user-menu button {
  display: flex; width: 100%; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 10px; color: var(--dsw-alias-label-primary); text-align: left;
}
.user-menu button:hover { background: var(--dsw-specific-sidebar-nav-item-hover); }

/* Main */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; background: #fff; }
.main-top {
  height: 60px; display: flex; align-items: center; gap: 8px;
  padding: 12px 18px 8px; flex-shrink: 0; box-sizing: border-box;
}
.main-top .collapsed-tools { display: none; align-items: center; gap: 4px; }
.sidebar.collapsed ~ .main .collapsed-tools { display: flex; }
.sidebar.collapsed ~ .main .collapsed-tools .icon-btn {
  width: 44px; height: 44px;
}
.chat-title {
  height: 40px;
  display: inline-flex; align-items: center;
  max-width: min(60%, 420px);
  padding: 8px 12px;
  margin-left: -4px;
  border-radius: 22px;
  border: 1px solid transparent;
  font-size: 14px; font-weight: 500; line-height: 22px;
  color: var(--dsw-alias-label-primary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  box-sizing: border-box;
}
.main.chat-mode .chat-title:hover {
  border-color: var(--dsw-alias-border-l2);
  box-shadow: var(--dsw-shadow-lv2);
}
.main-top-right { margin-left: auto; display: flex; gap: 2px; }

.stage {
  flex: 1; min-height: 0; display: flex; flex-direction: column;
}
.chat-scroll { flex: 1; overflow: auto; min-height: 0; }
.home-hero {
  display: none;
  flex-direction: column; align-items: center; justify-content: center;
  width: 100%;
  max-width: var(--message-list-max-width);
  padding: 0 var(--message-list-padding-horizontal);
  text-align: center;
  box-sizing: border-box;
}
.home-hero .home-mark {
  display: none;
  width: 96px;
  height: 96px;
  object-fit: contain;
  margin: 0 0 18px;
  flex-shrink: 0;
}
.home-hero .hello {
  display: flex; align-items: center; justify-content: center; flex-wrap: wrap;
  margin-bottom: 21px;
  font-size: 24px; font-weight: 600; line-height: 32px;
  color: var(--dsw-alias-label-primary);
}
.home-hero .hello .whale {
  width: 34px; height: 25px;
  margin-right: 10px;
  object-fit: contain;
  flex-shrink: 0;
}
@media not all and (min-width: 440px) {
  .home-hero .hello { font-size: 20px; font-weight: 500; line-height: 28px; }
  .home-hero .hello .whale { transform: scale(.88); }
}
.messages {
  width: min(var(--message-list-max-width), 100%);
  margin: 0 auto;
  padding: 12px var(--message-list-padding-horizontal) 28px;
  box-sizing: border-box;
}

/* Home: hero + composer vertically centered as one group */
.main.home-mode .stage {
  justify-content: center; align-items: center;
  padding-bottom: 64px;
}
.main.home-mode .home-hero { display: flex; }
.main.home-mode .chat-scroll { display: none; }
.main.home-mode .composer-wrap {
  width: 100%;
  max-width: var(--message-list-max-width);
  padding: 0 var(--message-list-padding-horizontal);
  margin: 0;
  box-sizing: border-box;
}

/* Chat: messages scroll, composer pinned bottom */
.main.chat-mode .home-hero { display: none !important; }
.main.chat-mode .composer-wrap {
  padding: 0 var(--message-list-padding-horizontal) 20px;
  display: flex; justify-content: center;
}
.main.chat-mode .composer-wrap .composer {
  width: min(var(--message-list-max-width), 100%);
}

/* Messages */
.msg { margin: 0 0 28px; }
.msg-user { display: flex; flex-direction: column; align-items: flex-end; }
.msg-user .bubble {
  max-width: calc(100% - 88px);
  background: var(--dsw-specific-bubble);
  border-radius: 22px;
  padding: 10px 16px;
  font-size: var(--msg-font-size, 16px);
  line-height: 1.5;
  white-space: pre-wrap; word-break: break-word;
}
.msg-assistant .body {
  font-size: var(--msg-font-size, 16px);
  line-height: var(--msg-line-height, 1.75);
  color: var(--dsw-alias-label-primary);
  min-width: 0; overflow-wrap: anywhere; word-break: break-word;
}

/* ===== Markdown (ds-markdown) ===== */
.ds-markdown {
  font-family: var(--dsw-font-family);
  font-size: var(--msg-font-size, 16px);
  line-height: var(--msg-line-height, 1.75);
  color: var(--dsw-alias-label-primary);
}
.ds-markdown > :first-child { margin-top: 0 !important; }
.ds-markdown > :last-child { margin-bottom: 0 !important; }
.ds-markdown .ds-markdown-paragraph { margin: 16px 0; }
.ds-markdown .ds-markdown-paragraph:first-child { margin-top: 0 !important; }
.ds-markdown .ds-markdown-paragraph:last-child { margin-bottom: 0 !important; }
.ds-markdown strong { font-weight: 600; }
.ds-markdown em { font-style: italic; }
.ds-markdown del { color: var(--dsw-alias-label-tertiary); }
.ds-markdown mark {
  background: rgba(57, 100, 254, .12);
  color: inherit;
  border-radius: 3px;
  padding: 0 3px;
}
.ds-markdown h1 { font-weight: 700; font-size: 1.5em; line-height: 1.4; margin: 20px 0 12px; }
.ds-markdown h2 { font-weight: 700; font-size: 1.375em; line-height: 1.45; margin: 20px 0 12px; }
.ds-markdown h3 { font-weight: 700; font-size: 1.25em; line-height: 1.5; margin: 18px 0 10px; }
.ds-markdown h4 { font-weight: 600; font-size: 1em; line-height: 1.75; margin: 16px 0 8px; }
.ds-markdown h5, .ds-markdown h6 {
  font-weight: 600; font-size: 0.94em; line-height: 1.7;
  margin: 14px 0 8px;
  color: var(--dsw-alias-label-secondary);
}
.ds-markdown ul, .ds-markdown ol {
  margin: 16px 0;
  padding-left: 18px;
}
.ds-markdown li:not(:first-child) { margin-top: 6px; }
.ds-markdown li::marker { color: var(--dsw-alias-label-secondary); }
.ds-markdown li > :first-child { margin-top: 0; }
.ds-markdown li > :last-child:not(.md-code-block) { margin-bottom: 0; }
.ds-markdown ul ul, .ds-markdown ol ol, .ds-markdown ul ol, .ds-markdown ol ul {
  margin: 6px 0;
}
.ds-markdown a {
  color: var(--dsw-alias-brand-text);
  text-decoration: none;
}
.ds-markdown a:hover { text-decoration: underline; }
.ds-markdown .md-inline-code,
.ds-markdown code:not(.md-code) {
  background: var(--dsw-alias-markdown-inline-code, var(--dsw-static-neutral-bluish-100));
  border-radius: 6px;
  padding: 2px 6px;
  font: 14px/22px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  word-break: break-word;
}
.ds-markdown .md-hr {
  border: 0;
  border-top: 1px solid var(--dsw-alias-border-l2);
  margin: 20px 0;
}
.ds-markdown .md-quote {
  margin: 16px 0;
  padding: 4px 0 4px 14px;
  border-left: 3px solid var(--dsw-alias-border-l3);
  color: var(--dsw-alias-label-secondary);
}
.ds-markdown .md-quote > :first-child { margin-top: 0; }
.ds-markdown .md-quote > :last-child { margin-bottom: 0; }
.ds-markdown .md-img {
  max-width: 100%;
  border-radius: 12px;
  margin: 8px 0;
  display: block;
}
.ds-markdown .md-fn-ref {
  font-size: 11px;
  color: var(--dsw-alias-label-tertiary);
}

/* Task list */
.ds-markdown .md-task-list { list-style: none; padding-left: 4px; }
.ds-markdown .md-task {
  display: inline-flex; align-items: flex-start; gap: 8px;
  cursor: default;
}
.ds-markdown .md-task input {
  margin-top: 7px; flex-shrink: 0;
  accent-color: var(--dsw-alias-brand-primary);
}

/* Tables */
.ds-markdown .md-table-wrap {
  width: 100%;
  overflow-x: auto;
  margin: 16px 0;
  border-radius: 12px;
  border: 1px solid var(--dsw-alias-border-l2);
}
.ds-markdown .md-table {
  width: 100%;
  border-collapse: collapse;
  font: 15px/25px var(--dsw-font-family);
  min-width: 280px;
}
.ds-markdown .md-table th,
.ds-markdown .md-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--dsw-alias-border-l1);
  text-align: left;
  vertical-align: top;
}
.ds-markdown .md-table th {
  font-weight: 500;
  background: var(--dsw-static-neutral-bluish-50);
  color: var(--dsw-alias-label-secondary);
}
.ds-markdown .md-table tr:last-child td { border-bottom: 0; }

/* Code blocks */
.ds-markdown .md-code-block {
  margin: 16px 0;
  border-radius: 12px;
  overflow: hidden;
  background: var(--dsw-alias-markdown-code-block, var(--dsw-static-neutral-bluish-50));
  border: 1px solid var(--dsw-alias-border-l1);
}
.ds-markdown .md-code-block.md-code-open {
  border-style: dashed;
  opacity: .95;
}
.ds-markdown .md-code-banner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  background: var(--dsw-alias-markdown-code-block-banner, var(--dsw-static-neutral-bluish-50));
  border-bottom: 1px solid var(--dsw-alias-border-l1);
  font-size: 12px;
  color: var(--dsw-alias-label-tertiary);
}
.ds-markdown .md-code-lang {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  text-transform: lowercase;
}
.ds-markdown .md-code-copy {
  height: 26px; padding: 0 10px;
  border-radius: 8px;
  color: var(--dsw-alias-label-secondary);
  font-size: 12px; font-weight: 500;
}
.ds-markdown .md-code-copy:hover {
  background: var(--dsw-alias-interactive-bg-hover);
  color: var(--dsw-alias-label-primary);
}
.ds-markdown .md-code-copy.copied { color: var(--dsw-alias-brand-text); }
.ds-markdown .md-pre {
  margin: 0;
  padding: 14px 16px;
  overflow: auto;
  max-height: min(70vh, 560px);
}
.ds-markdown .md-code {
  background: transparent !important;
  padding: 0 !important;
  border-radius: 0;
  font: 13px/22px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--dsw-alias-label-primary);
  white-space: pre;
  display: block;
}

body.dark .ds-markdown .md-table th { background: #1c1f26; }
body.dark .ds-markdown .md-code-block,
body.dark .ds-markdown .md-code-banner { background: #1c1f26; }
body.dark .ds-markdown mark { background: rgba(57, 100, 254, .22); }

/* ===== Official DeepSeek thinking UI ===== */
@keyframes ds-think-pulse {
  0% { animation-timing-function: ease-out; transform: scale(1); }
  40% { animation-timing-function: linear; transform: scale(1.3); }
  60% { animation-timing-function: ease-out; transform: scale(1.3); }
  100% { transform: scale(1); }
}

.ds-think {
  width: 100%;
  margin: 0 0 16px;
  position: relative;
}

/* Title row: atom icon + 已思考（用时 x 秒） + chevron */
.ds-think-title {
  width: 100%;
  height: 34px;
  max-height: 34px;
  cursor: pointer;
  display: flex;
  align-items: center;
  margin-bottom: 2px;
  user-select: none;
}
.ds-think-title-inner {
  color: var(--dsw-alias-label-secondary);
  flex-grow: 1;
  align-items: center;
  height: 100%;
  display: flex;
  transition: color .2s;
}
.ds-think-title:hover .ds-think-title-inner {
  color: var(--dsw-alias-label-primary);
}
.ds-think-atom {
  width: 16px; height: 16px;
  margin-right: 6px;
  flex-shrink: 0;
  display: inline-flex;
  color: currentColor;
}
.ds-think-atom svg { width: 16px; height: 16px; display: block; }
.ds-think.thinking .ds-think-atom {
  color: var(--dsw-alias-brand-primary);
}
.ds-think-label {
  font: 16px/28px var(--dsw-font-family);
  align-items: center;
  margin-right: 6px;
  display: inline-flex;
}
.ds-think-chevron {
  width: 14px; height: 14px;
  display: inline-flex;
  color: currentColor;
  transition: transform .2s;
}
.ds-think-chevron svg { width: 14px; height: 14px; }
.ds-think.open .ds-think-chevron {
  transform: rotate(180deg);
}

/* Content: left timeline (dot + line) + gray markdown */
.ds-think-content {
  display: none;
  margin: 0;
  padding: 5px 0 5px 22px;
  position: relative;
}
.ds-think.open .ds-think-content,
.ds-think.thinking .ds-think-content {
  display: block;
  padding-bottom: 0;
}

.ds-think-dot-wrap {
  width: 16px; height: 16px;
  position: absolute;
  top: 9px; left: 0;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  user-select: none;
  color: var(--dsw-alias-brand-primary);
}
.ds-think-dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--dsw-alias-brand-primary);
}
.ds-think.thinking .ds-think-dot {
  animation: 1.5s linear infinite ds-think-pulse;
}
.ds-think:not(.thinking) .ds-think-dot {
  background-color: var(--dsw-alias-label-tertiary);
  animation: none;
}

.ds-think-line {
  border-left: 1px solid var(--dsw-alias-label-dimmed);
  height: calc(100% - 24px);
  position: absolute;
  top: 31px;
  left: 7.5px;
  width: 0;
}
.ds-think.open .ds-think-line,
.ds-think.thinking .ds-think-line {
  height: calc(100% - 32px);
}

.ds-think-md {
  font: 14px/24px var(--dsw-font-family);
  color: var(--dsw-alias-label-secondary);
  word-break: break-word;
}
.ds-think-md p {
  margin: 12px 0;
}
.ds-think-md p:first-child { margin-top: 0; }
.ds-think-md p:last-child { margin-bottom: 0; }

/* legacy aliases kept empty to avoid leftover styles */
.think-block, .think-toggle, .think-panel { display: contents; }

/* ===== Compact in-message search row (non-deep) — never expands cards inline ===== */
.search-block {
  width: 100%;
  margin: 0 0 10px;
}
.search-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  max-width: 100%;
  padding: 0;
  color: var(--dsw-alias-label-secondary);
  font: 500 13px/20px var(--dsw-font-family);
  user-select: none;
  transition: color .2s;
  cursor: pointer;
}
.search-toggle:hover { color: var(--dsw-alias-label-primary); }
.search-toggle .search-ico {
  width: 15px; height: 15px; flex-shrink: 0;
  display: inline-flex; color: currentColor;
}
.search-toggle .search-ico svg { width: 15px; height: 15px; display: block; }
.search-block.searching .search-toggle .search-ico {
  color: var(--dsw-alias-brand-primary);
}
.search-toggle .search-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.search-favicons {
  display: inline-flex;
  align-items: center;
  margin-left: 2px;
  user-select: none;
  flex-shrink: 0;
}
.search-favicons .fav {
  position: relative;
  width: 16px; height: 16px; border-radius: 50%;
  overflow: hidden; flex-shrink: 0;
  margin-left: -4px;
  background: var(--dsw-static-neutral-bluish-100);
  box-shadow: 0 0 0 1.5px #fff;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--dsw-alias-label-tertiary);
}
.search-favicons .fav:first-child { margin-left: 0; }
.search-favicons .fav img {
  position: absolute; inset: 0;
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.search-favicons .fav .fb-ico,
.source-row .site-icon .fb-ico {
  display: inline-flex; align-items: center; justify-content: center;
  width: 100%; height: 100%;
}
.search-favicons .fav .fb-ico svg { width: 10px; height: 10px; }
.source-row .site-icon .fb-ico svg { width: 11px; height: 11px; }
.search-empty-tip {
  padding: 16px 4px;
  font-size: 13px;
  color: var(--dsw-alias-label-caption);
}

/* Deep-think tool rows (inside .ds-think-content) — results hidden until drawer */
.ds-think-tools {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 8px 0 4px;
}
.think-tool-row {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--dsw-alias-label-secondary);
  font: 500 13px/20px var(--dsw-font-family);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition: color .15s;
}
.think-tool-row:hover { color: var(--dsw-alias-label-primary); }
.think-tool-row .search-ico,
.think-tool-row .site-icon {
  width: 14px; height: 14px; flex-shrink: 0;
  display: inline-flex; color: currentColor;
  position: relative; border-radius: 50%; overflow: hidden;
}
.think-tool-row .search-ico svg { width: 14px; height: 14px; }
.think-tool-row .site-icon img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
}
.think-tool-label {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  min-width: 0;
}
.think-tool-n {
  flex-shrink: 0;
  color: var(--dsw-alias-label-caption);
  font-weight: 400;
  font-size: 12px;
}
.think-tool-row.loading { opacity: .75; }

/* Sources drawer — overlay, does NOT resize chat column */
.sources-drawer-mask {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, .28);
  z-index: 80;
  opacity: 0; pointer-events: none;
  transition: opacity .2s;
}
.sources-drawer-mask.show { opacity: 1; pointer-events: auto; }
.sources-drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(380px, 92vw);
  z-index: 81;
  background: var(--dsw-specific-bg-elevated, #fff);
  border-left: 1px solid var(--dsw-alias-border-l2);
  box-shadow: -8px 0 32px rgba(0, 0, 0, .08);
  display: flex; flex-direction: column;
  transform: translateX(100%);
  transition: transform .22s ease;
  pointer-events: none;
}
.sources-drawer.show {
  transform: translateX(0);
  pointer-events: auto;
}
.sources-drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--dsw-alias-border-l2);
  flex-shrink: 0;
}
.sources-drawer-title {
  font: 600 15px/22px var(--dsw-font-family);
  color: var(--dsw-alias-label-primary);
}
.sources-drawer-body {
  flex: 1; overflow-y: auto;
  padding: 8px 12px 20px;
  display: flex; flex-direction: column; gap: 4px;
}
.source-row {
  display: block;
  padding: 12px 10px;
  border-radius: 12px;
  text-decoration: none;
  color: inherit;
  transition: background .15s;
}
.source-row:hover { background: var(--dsw-static-neutral-bluish-50); }
.source-row .meta {
  display: flex; align-items: center; gap: 6px; min-width: 0;
}
.source-row .site-icon {
  position: relative;
  width: 16px; height: 16px; border-radius: 50%;
  overflow: hidden; flex-shrink: 0;
  background: var(--dsw-static-neutral-bluish-100);
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--dsw-alias-label-tertiary);
}
.source-row .site-icon img {
  position: absolute; inset: 0;
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.source-row .site-name {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font: 500 12px/17px var(--dsw-font-family);
  color: var(--dsw-alias-label-secondary);
}
.source-row .title {
  margin-top: 6px;
  font: 500 14px/20px var(--dsw-font-family);
  color: var(--dsw-alias-label-primary);
  display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden; word-break: break-word;
}
.source-row .snippet {
  margin-top: 4px;
  font: 400 12px/18px var(--dsw-font-family);
  color: var(--dsw-alias-label-tertiary);
  display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden; word-break: break-word;
}
body.dark .sources-drawer { background: #12141a; }
body.dark .source-row:hover { background: #1c1f26; }
body.dark .search-favicons .fav { box-shadow: 0 0 0 1.5px #12141a; }

.msg-actions {
  position: relative;
  left: -6px;
  width: calc(100% + 6px);
  display: flex; flex-wrap: wrap-reverse; align-items: center;
  gap: 10px;
  padding-top: 12px; padding-bottom: 10px;
  margin-top: 0;
  opacity: 0; transition: opacity .15s;
}
.msg-user .msg-actions {
  left: auto; right: 0; width: auto;
  justify-content: flex-end;
}
.msg:hover .msg-actions,
.msg:focus-within .msg-actions,
.msg-user:hover .msg-actions { opacity: 1; }
/* Hide copy/retry/etc. until the assistant reply finishes streaming */
.msg.streaming .msg-actions {
  display: none !important;
}
.msg-actions button {
  width: 28px; height: 28px; border-radius: 4096px;
  color: var(--dsw-alias-label-tertiary);
  display: inline-flex; align-items: center; justify-content: center;
}
.msg-actions button:hover { background: var(--dsw-alias-interactive-bg-hover); color: var(--dsw-alias-label-primary); }
.msg-actions button.active-vote { color: var(--dsw-alias-brand-text); }
.msg-actions button svg { width: 16px; height: 16px; }

/* Composer — exact official */
.composer-wrap {
  flex-shrink: 0;
  padding: 0 var(--message-list-padding-horizontal) 20px;
  display: flex; justify-content: center;
  width: 100%;
  box-sizing: border-box;
}
.main.home-mode .composer-wrap {
  max-width: var(--message-list-max-width);
  padding: 0 var(--message-list-padding-horizontal) 64px;
}
.composer {
  width: 100%;
  max-width: var(--message-list-max-width);
  cursor: text;
  border: 1px solid var(--dsw-alias-border-l2-darkmode-thin);
  background: var(--dsw-specific-input-major);
  border-radius: 24px;
  display: flex; flex-direction: column;
  position: relative; overflow: hidden;
  box-shadow: 0 4px 12px rgba(0,0,0,.02), 0 2px 2px rgba(72,104,178,.01), 0 30px 60px rgba(72,104,178,.03);
  font-size: 16px; line-height: var(--line-height);
}
.composer textarea {
  width: 100%; border: none; outline: none; resize: none;
  min-height: calc(var(--line-height) * 2 + var(--input-padding-top));
  max-height: 200px;
  padding: var(--input-padding-top) 12px 0 16px;
  background: transparent;
  color: var(--dsw-alias-label-primary);
  caret-color: var(--dsw-alias-brand-text);
  font-size: 16px; line-height: var(--line-height);
  font-family: inherit;
}
.composer textarea::placeholder { color: var(--dsw-alias-label-caption); }
.composer-toolbar {
  display: flex; align-items: center; width: 100%;
  padding: 12px; gap: 8px; overflow: hidden;
}
.composer-toolbar .tools { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1; }
.composer-toolbar .actions { display: flex; align-items: center; gap: 4px; margin-left: auto; flex: none; }

/* Official toggle buttons */
#pillSearch[hidden] { display: none !important; }
.ds-toggle-button {
  --dsl-toggle-button-height: 34px;
  --dsl-toggle-button-padding: 0 12px;
  --dsl-toggle-button-icon-size: 14px;
  box-sizing: border-box; cursor: pointer; user-select: none;
  color: var(--dsw-alias-label-primary);
  border: 1px solid var(--dsw-alias-border-l2);
  padding: var(--dsl-toggle-button-padding);
  height: var(--dsl-toggle-button-height);
  border-radius: 18px;
  outline: none; justify-content: center; align-items: center; gap: 4px;
  font-size: 13px; font-weight: 500;
  transition: border .2s ease, background .2s ease;
  display: inline-flex; position: relative; background: transparent;
}
.ds-toggle-button:hover { background: var(--dsw-alias-interactive-bg-hover); }
.ds-toggle-button.selected {
  background: var(--dsw-alias-button-ghost-active-fill);
  color: var(--dsw-alias-brand-text);
  border-color: var(--dsw-alias-button-ghost-active-border);
}
.ds-toggle-button.selected:hover { background: var(--dsw-alias-button-ghost-active-hover); }
.ds-toggle-button svg {
  width: var(--dsl-toggle-button-icon-size);
  height: var(--dsl-toggle-button-icon-size);
  flex-shrink: 0; display: block;
}
#pillThink.ds-toggle-button {
  padding: 10px;
  margin-right: 10px;
}

.attach-btn {
  width: 34px; height: 34px; border-radius: 4096px;
  color: var(--dsw-alias-label-tertiary);
  display: grid; place-items: center;
}
.attach-btn:hover { background: var(--dsw-alias-interactive-bg-hover); }
.attach-btn svg { width: 18px; height: 18px; }

.send-btn {
  width: 34px; height: 34px; border-radius: 4096px;
  background: var(--dsw-alias-button-primary-fill); color: #fff;
  display: grid; place-items: center;
  transition: background .2s, opacity .2s;
}
.send-btn:hover:not(:disabled) { background: var(--dsw-alias-button-primary-hover); }
.send-btn:disabled {
  background: var(--dsw-alias-button-primary-fill);
  opacity: .4;
  cursor: not-allowed;
}
.send-btn svg { width: 16px; height: 16px; }
.stop-btn {
  width: 34px; height: 34px; border-radius: 4096px;
  background: var(--dsw-alias-label-primary); color: #fff;
  display: none; place-items: center;
}
.stop-btn.show { display: grid; }

/* Modal */
.modal-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,.24);
  display: none; align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.modal-mask.show { display: flex; }
/* Import wizards must sit above settings (classic #settingsModal and liquid #modalOverlay @250) */
#importShareModal.modal-mask,
#importZipModal.modal-mask {
  z-index: 300;
}
.modal {
  width: min(560px, 100%); background: #fff; border-radius: 18px;
  box-shadow: rgba(0,0,0,.2) 0 0 1px, rgba(0,0,0,.02) 0 0 4px, rgba(0,0,0,.08) 0 12px 32px;
  max-height: min(86vh, 760px); display: flex; flex-direction: column; overflow: hidden;
}
.modal.wide { width: min(860px, 100%); }
.modal.admin-shell {
  width: min(1080px, 100%);
  max-height: min(90vh, 860px);
}
.admin-layout {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  min-height: 0;
  flex: 1;
  overflow: hidden;
}
.admin-nav {
  border-right: 1px solid var(--dsw-alias-border-l1);
  background: color-mix(in srgb, var(--dsw-static-neutral-bluish-75, #f5f6f8) 90%, #fff);
  overflow: auto;
  padding: 12px 10px 16px;
}
.admin-nav-group { margin-bottom: 14px; }
.admin-nav-label {
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.04em;
  color: var(--dsw-alias-label-tertiary);
  padding: 4px 10px 6px;
  text-transform: uppercase;
}
.admin-nav-item {
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--dsw-alias-label-secondary);
  cursor: pointer;
  margin-bottom: 2px;
}
.admin-nav-item:hover { background: rgba(0,0,0,.04); color: var(--dsw-alias-label-primary); }
.admin-nav-item.active {
  background: #fff;
  color: var(--dsw-alias-brand-primary, #3964fe);
  box-shadow: 0 1px 2px rgba(0,0,0,.05);
  font-weight: 600;
}
.admin-main {
  overflow: auto;
  padding: 18px 20px 22px;
  min-height: 0;
}
.admin-page { display: none; }
.admin-page.active { display: block; }
.admin-page-head { margin-bottom: 16px; }
.admin-page-head h4 {
  margin: 0 0 6px;
  font-size: 17px;
  font-weight: 650;
}
.admin-page-head p {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--dsw-alias-label-tertiary);
}
.admin-quick-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.admin-quick {
  border: 1px solid var(--dsw-alias-border-l2);
  background: #fff;
  border-radius: 12px;
  padding: 14px 12px;
  text-align: left;
  font-size: 13.5px;
  font-weight: 560;
  color: var(--dsw-alias-label-primary);
  cursor: pointer;
}
.admin-quick:hover {
  border-color: var(--dsw-alias-brand-primary);
  color: var(--dsw-alias-brand-primary);
}
.admin-shell .modal-foot #saveAdmin[hidden] { display: none !important; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px; border-bottom: 1px solid var(--dsw-alias-border-l1);
}
.modal-head h3 { margin: 0; font-size: 16px; font-weight: 600; }
.modal-body { padding: 18px; overflow: auto; }
.form-row { margin-bottom: 16px; }
.form-row label { display: block; font-size: 13px; color: var(--dsw-alias-label-secondary); margin-bottom: 8px; font-weight: 500; }
.form-row input, .form-row textarea, .form-row select {
  width: 100%; border: 1px solid var(--dsw-alias-border-l2); border-radius: 12px;
  padding: 10px 12px; outline: none; background: #fff;
}
.form-row input:focus, .form-row textarea:focus, .form-row select:focus {
  border-color: var(--dsw-alias-brand-primary); box-shadow: 0 0 0 3px rgba(57,100,254,.12);
}
.form-row textarea { min-height: 96px; resize: vertical; }
.switch-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--dsw-alias-border-l1);
}
.switch {
  width: 42px; height: 24px; border-radius: 999px; background: #d4d4d4; position: relative; transition: .2s;
}
.switch.on { background: var(--dsw-alias-brand-primary); }
.switch i {
  position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; transition: .2s;
}
.switch.on i { left: 21px; }
.modal-foot {
  padding: 12px 18px 16px; display: flex; justify-content: flex-end; gap: 8px;
  border-top: 1px solid var(--dsw-alias-border-l1);
}
.btn-ghost {
  height: 36px; padding: 0 14px; border-radius: 10px;
  border: 1px solid var(--dsw-alias-border-l2); background: #fff;
}
.btn-solid {
  height: 36px; padding: 0 14px; border-radius: 10px;
  background: var(--dsw-alias-brand-primary); color: #fff; font-weight: 600;
}
.tabs {
  display: flex; gap: 4px; background: var(--dsw-static-neutral-bluish-75);
  padding: 4px; border-radius: 12px; margin-bottom: 16px;
}
.tabs button { flex: 1; height: 34px; border-radius: 10px; color: var(--dsw-alias-label-secondary); font-weight: 500; }
.tabs button.active { background: #fff; color: var(--dsw-alias-label-primary); box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 18px; }
.stat { border: 1px solid var(--dsw-alias-border-l2); border-radius: 14px; padding: 14px; }
.stat .n { font-size: 22px; font-weight: 700; }
.stat .l { color: var(--dsw-alias-label-tertiary); font-size: 12px; margin-top: 4px; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--dsw-alias-border-l1); }
.badge { display: inline-flex; padding: 2px 8px; border-radius: 999px; font-size: 12px; background: var(--dsw-static-neutral-bluish-75); }
.badge.admin { background: var(--dsw-static-deepseek-50); color: var(--dsw-alias-brand-text); }

.admin-nav-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px;
  margin-left: 6px; border-radius: 999px;
  background: #ef4444; color: #fff;
  font-size: 11px; font-weight: 700; line-height: 1;
  vertical-align: middle;
}
.adm-cache-pending {
  border-color: #fbbf24;
  background: #fffbeb;
}
.adm-models-block label { margin-bottom: 0; }
.adm-models-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 10px;
}
.adm-models-head .adm-models-add {
  height: 32px; padding: 0 12px; border-radius: 10px; font-size: 13px;
  border: 1px solid var(--dsw-alias-border-l2); background: #fff;
  color: var(--dsw-alias-label-primary); cursor: pointer;
}
.adm-models-list { display: flex; flex-direction: column; gap: 10px; }
.adm-model-card {
  border: 1px solid var(--dsw-alias-border-l2);
  border-radius: 14px;
  padding: 12px;
  background: var(--dsw-static-neutral-bluish-50, #f7f8fa);
}
.adm-model-card-top {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-bottom: 10px;
}
.adm-model-card-top .idx {
  font-size: 12px; font-weight: 600; color: var(--dsw-alias-label-tertiary);
}
.adm-flag-row { display: flex; align-items: flex-start; gap: 10px; }
.adm-flag-row label { margin-bottom: 2px; }
.adm-flag-row .switch { flex: 0 0 auto; margin-top: 1px; }
.adm-model-card-actions { display: flex; align-items: center; gap: 8px; }
.adm-model-card-actions .switch { transform: scale(0.9); transform-origin: right center; }
.adm-model-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.adm-model-grid .full { grid-column: 1 / -1; }
.adm-model-grid label {
  display: block; font-size: 11px; color: var(--dsw-alias-label-tertiary);
  margin-bottom: 4px; font-weight: 500;
}
.adm-model-grid input {
  width: 100%; height: 36px; border-radius: 10px; padding: 0 10px;
  border: 1px solid var(--dsw-alias-border-l2); background: #fff;
  font-size: 13px;
}
.adm-model-del {
  border: 0; background: transparent; color: #e5484d;
  font-size: 12px; cursor: pointer; padding: 4px 6px; border-radius: 8px;
}
.adm-model-del:hover { background: rgba(229, 72, 77, 0.08); }

.adm-route-legend {
  margin: 0 0 14px;
  padding: 12px 14px;
  border-radius: 12px;
  background: #eef3ff;
  border: 1px solid #d7e2ff;
}
.adm-route-legend p {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--dsw-alias-label-secondary, #4b5563);
  line-height: 1.45;
}
.adm-route-flow {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  font-size: 12px; font-weight: 600; color: #334155;
}
.adm-route-flow span {
  padding: 5px 10px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid #c9d7ff;
}
.adm-route-flow i {
  width: 18px; height: 2px;
  background: #94a3b8;
  display: inline-block;
  position: relative;
}
.adm-route-flow i::after {
  content: '';
  position: absolute; right: -1px; top: -3px;
  border: 4px solid transparent;
  border-left-color: #94a3b8;
}
.adm-route-mode {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 4px;
  border-radius: 12px;
  background: #e8ecf3;
}
.adm-route-mode-btn {
  height: 34px; border: 0; border-radius: 10px;
  background: transparent; color: #64748b;
  font-size: 13px; font-weight: 600; cursor: pointer;
}
.adm-route-mode-btn.active {
  background: #fff; color: #0f172a;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}
.adm-route-hint {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--dsw-alias-label-tertiary);
  line-height: 1.45;
}
.adm-routes { display: flex; flex-direction: column; gap: 8px; }
.adm-route-row {
  display: grid;
  grid-template-columns: 72px minmax(0, 1.1fr) minmax(0, 1.2fr) auto;
  gap: 6px;
  align-items: center;
  padding: 8px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid var(--dsw-alias-border-l2);
}
.adm-route-badge {
  height: 28px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 8px;
  font-size: 11px; font-weight: 700;
  letter-spacing: 0.02em;
}
.adm-route-badge.primary {
  background: #dbeafe; color: #1d4ed8;
}
.adm-route-badge.backup {
  background: #f1f5f9; color: #475569;
}
.adm-route-row select,
.adm-route-row input[data-rf] {
  width: 100%; height: 34px; border-radius: 10px; padding: 0 10px;
  border: 1px solid var(--dsw-alias-border-l2); background: #fff;
  font-size: 13px;
}
.adm-route-ops { display: flex; gap: 4px; flex-wrap: nowrap; }
.adm-route-ops .btn-ghost {
  height: 30px; min-width: 30px; padding: 0 8px;
  border-radius: 8px; font-size: 12px;
}
.adm-route-ops .btn-ghost:disabled {
  opacity: 0.35; cursor: not-allowed;
}
.adm-add-route {
  margin-top: 8px; height: 32px; padding: 0 12px; border-radius: 10px;
}
.adm-model-grid select {
  width: 100%; height: 36px; border-radius: 10px; padding: 0 10px;
  border: 1px solid var(--dsw-alias-border-l2); background: #fff;
  font-size: 13px;
}
@media (max-width: 720px) {
  .adm-route-row {
    grid-template-columns: 72px 1fr;
  }
  .adm-route-row select,
  .adm-route-row input[data-rf],
  .adm-route-ops { grid-column: 1 / -1; }
}
@media (max-width: 640px) {
  .adm-model-grid { grid-template-columns: 1fr; }
}
.toast {
  position: fixed; top: 18px; left: 50%; transform: translateX(-50%);
  background: var(--dsw-static-neutral-bluish-800); color: #fff;
  padding: 10px 16px; border-radius: 999px; font-size: 13px; z-index: 200;
  opacity: 0; pointer-events: none; transition: .2s;
}
.toast.show { opacity: 1; }

/* ========== Attachments ========== */
.attach-preview {
  display: none; flex-wrap: wrap; gap: 8px;
  padding: 12px 12px 0 16px;
}
.attach-preview.show { display: flex; }
.attach-chip {
  position: relative; display: inline-flex; align-items: center; gap: 6px;
  background: var(--dsw-static-neutral-bluish-50);
  border: 1px solid var(--dsw-alias-border-l2);
  border-radius: 12px; padding: 6px 28px 6px 8px;
  max-width: 220px; font-size: 12px; color: var(--dsw-alias-label-secondary);
}
.attach-chip.image { padding: 0; overflow: hidden; width: 72px; height: 72px; }
.attach-chip.image img { width: 100%; height: 100%; object-fit: cover; display: block; }
.attach-chip.file svg { width: 16px; height: 16px; flex-shrink: 0; }
.attach-chip .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 120px; }
.attach-chip .size { color: var(--dsw-alias-label-caption); }
.attach-chip button {
  position: absolute; top: 2px; right: 2px;
  width: 20px; height: 20px; border-radius: 50%;
  background: rgba(0,0,0,.55); color: #fff;
  display: grid; place-items: center;
}
.attach-chip button svg { width: 12px; height: 12px; }
.composer.drag { border-color: var(--dsw-alias-brand-primary); box-shadow: 0 0 0 3px rgba(57,100,254,.12); }

.msg-atts { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; justify-content: flex-end; }
.msg-att.image img {
  max-width: 220px; max-height: 180px; border-radius: 14px; display: block;
  border: 1px solid var(--dsw-alias-border-l2);
}
.msg-att.file {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 12px; border-radius: 12px;
  background: var(--dsw-static-neutral-bluish-50);
  border: 1px solid var(--dsw-alias-border-l2);
  color: var(--dsw-alias-label-primary); font-size: 13px;
}
.msg-att.file svg { width: 16px; height: 16px; }

body.dark .search-favicons .fav { box-shadow: 0 0 0 1.5px #12141a; }

.edit-area {
  width: min(520px, 100%); min-height: 72px; max-height: 220px;
  border: 1px solid var(--dsw-alias-brand-primary); border-radius: 14px;
  padding: 10px 12px; resize: vertical; outline: none;
  box-shadow: 0 0 0 3px rgba(57,100,254,.12); font-size: 16px; line-height: 28px;
}
.edit-actions { display: flex; gap: 8px; margin-top: 8px; justify-content: flex-end; }

/* ========== Search overlay ========== */
.search-overlay {
  position: fixed; inset: 0; z-index: 120;
  background: rgba(15,17,21,.28);
  display: none; align-items: flex-start; justify-content: center;
  padding: 10vh 16px 24px;
}
.search-overlay.show { display: flex; }
.search-panel-box {
  width: min(560px, 100%); background: #fff; border-radius: 16px;
  box-shadow: rgba(0,0,0,.2) 0 0 1px, rgba(0,0,0,.08) 0 16px 48px;
  overflow: hidden; max-height: 70vh; display: flex; flex-direction: column;
}
.search-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 12px 12px 16px;
  border-bottom: 1px solid var(--dsw-alias-border-l1);
}
.search-bar svg { width: 18px; height: 18px; stroke: var(--dsw-alias-label-tertiary); fill: none; stroke-width: 1.8; flex-shrink: 0; }
.search-bar input {
  flex: 1; border: 0; outline: 0; font-size: 15px; background: transparent;
}
.search-results { overflow: auto; padding: 8px; }
.search-empty {
  padding: 28px 16px; text-align: center;
  color: var(--dsw-alias-label-caption); font-size: 13px;
}
.search-hit {
  width: 100%; text-align: left; padding: 12px; border-radius: 12px;
  display: block;
}
.search-hit:hover { background: var(--dsw-alias-interactive-bg-hover); }
.search-hit .title { font-weight: 500; margin-bottom: 4px; }
.search-hit .snippet { font-size: 12px; color: var(--dsw-alias-label-tertiary); line-height: 1.5; }

/* ========== Context menu ========== */
.ctx-menu {
  position: fixed; z-index: 140; min-width: 148px;
  background: #fff; border: 1px solid var(--dsw-alias-border-l2);
  border-radius: 12px; padding: 6px;
  box-shadow: rgba(0,0,0,.2) 0 0 1px, rgba(0,0,0,.08) 0 12px 32px;
  display: none;
}
.ctx-menu.show { display: block; }
.ctx-menu button {
  display: flex; width: 100%; padding: 10px 12px; border-radius: 8px;
  text-align: left; color: var(--dsw-alias-label-primary);
}
.ctx-menu button:hover { background: var(--dsw-specific-sidebar-nav-item-hover); }
.ctx-menu button.danger { color: #ec1313; }

.modal.sm { width: min(420px, 100%); }
.confirm-text { margin: 0; color: var(--dsw-alias-label-secondary); line-height: 1.6; }

.quota-guide-modal { width: min(520px, calc(100vw - 28px)); max-height: min(86vh, 720px); }
.quota-guide-summary {
  margin: 0 0 14px;
  font-size: 15px;
  line-height: 1.55;
  color: var(--dsw-alias-label-primary);
  font-weight: 600;
}
.quota-guide-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.quota-guide-section {
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--dsw-static-neutral-bluish-50, #f7f8fa);
  border: 1px solid var(--dsw-alias-border-l2);
}
.quota-guide-section h4 {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--dsw-alias-label-primary);
}
.quota-guide-section p,
.quota-guide-section li {
  margin: 0;
  font-size: 13px;
  line-height: 1.55;
  color: var(--dsw-alias-label-secondary);
}
.quota-guide-section ol {
  margin: 0;
  padding-left: 1.2em;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.quota-guide-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  margin-top: 14px;
}
.quota-guide-links a {
  font-size: 13px;
  font-weight: 600;
  color: var(--dsw-alias-brand-text, #4d6bfe);
  text-decoration: none;
}
.quota-guide-links a:hover { text-decoration: underline; }
.btn-solid.danger, .btn-ghost.danger { color: #ec1313; }
.btn-solid.danger { background: #ec1313; color: #fff; }

/* ========== Settings layout ========== */
.settings-modal { width: min(720px, 100%); }
.settings-layout { display: flex; min-height: 360px; max-height: 60vh; }
.settings-nav {
  width: 148px; flex-shrink: 0; padding: 12px 8px;
  border-right: 1px solid var(--dsw-alias-border-l1);
  display: flex; flex-direction: column; gap: 2px;
}
.settings-nav button {
  text-align: left; padding: 10px 12px; border-radius: 10px;
  color: var(--dsw-alias-label-secondary); font-weight: 500;
}
.settings-nav button:hover { background: var(--dsw-alias-interactive-bg-hover); }
.settings-nav button.active {
  background: var(--dsw-static-deepseek-50);
  color: var(--dsw-alias-brand-text);
}
.settings-panes { flex: 1; overflow: auto; padding: 8px 18px 18px; }
.settings-pane { display: none; }
.settings-pane.active { display: block; }
.row-title { font-weight: 500; }
.row-desc { font-size: 12px; color: var(--dsw-alias-label-caption); margin-top: 2px; }
.seg {
  display: flex; gap: 4px; background: var(--dsw-static-neutral-bluish-75);
  padding: 4px; border-radius: 12px;
}
.seg button {
  flex: 1; height: 34px; border-radius: 10px;
  color: var(--dsw-alias-label-secondary); font-weight: 500;
}
.seg button.active {
  background: #fff; color: var(--dsw-alias-label-primary);
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
}

/* iOS-style settings rows (shared; mobile tightens further) */
.settings-ios-card { margin-bottom: 12px; }
.ios-field-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 14px; min-height: 44px; position: relative;
  border-bottom: 1px solid var(--dsw-alias-border-l1);
}
.settings-ios-card > .ios-field-row:last-child,
.settings-ios-card > .ios-check-row:last-child { border-bottom: 0; }
.ios-field-row.switch-row { border-bottom: 1px solid var(--dsw-alias-border-l1); padding: 12px 14px; }
.ios-inline-input,
.ios-inline-select {
  flex: 1; min-width: 0; max-width: 62%;
  border: 0; background: transparent; outline: none;
  text-align: right; font-size: 16px; color: var(--dsw-alias-label-primary);
  padding: 0;
}
.ios-inline-input::placeholder { color: var(--dsw-alias-label-caption); }
.ios-inline-input:disabled { color: var(--dsw-alias-label-tertiary); opacity: 1; }
.ios-block-input {
  width: 100%; box-sizing: border-box; margin-top: 10px;
  border: 1px solid var(--dsw-alias-border-l2); border-radius: 10px;
  padding: 10px 12px; outline: none; background: #fff; font-size: 15px;
}
.ios-block-input:focus {
  border-color: var(--dsw-alias-brand-primary);
  box-shadow: 0 0 0 3px rgba(57,100,254,.12);
}
.ios-stack { display: flex; flex-direction: column; gap: 2px; padding: 14px; width: 100%; box-sizing: border-box; }
.ios-card-btn { align-self: flex-end; margin-top: 10px; }
.ios-check-row {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 12px 14px; min-height: 44px; text-align: left;
  background: transparent; border: 0; border-bottom: 1px solid var(--dsw-alias-border-l1);
  color: var(--dsw-alias-label-primary); font-size: 16px; cursor: pointer;
  position: relative;
}
.ios-check-row .ios-check {
  opacity: 0; color: var(--dsw-alias-brand-primary); font-weight: 700; font-size: 17px;
}
.ios-check-row.active .ios-check { opacity: 1; }
.ios-group-gap { margin-top: 14px; }
.voice-tone-card {
  max-height: min(42vh, 320px);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}
.help-feedback {
  min-height: 96px;
  resize: vertical;
  font-family: inherit;
  line-height: 1.45;
}
.help-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 10px;
  flex-wrap: wrap;
}
.help-actions .btn-ghost,
.help-actions .btn-solid { margin-top: 0; }

.data-card {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px; border: 1px solid var(--dsw-alias-border-l2);
  border-radius: 14px; margin-bottom: 12px;
}
.settings-ios-card > .data-card,
.settings-ios-card.data-card {
  border: 0; border-radius: 0; margin: 0; padding: 12px 14px;
  border-bottom: 1px solid var(--dsw-alias-border-l1);
}
.settings-ios-card > .data-card:last-child { border-bottom: 0; }
.data-card.danger-card { border-color: rgba(236,19,19,.2); }
.data-card.import-share-card {
  align-items: stretch;
  flex-wrap: wrap;
}
.import-entry-list {
  padding: 0 !important;
  overflow: hidden;
}
.settings-ios-card > .import-entry-btn:first-child {
  border-radius: inherit;
  border-top-left-radius: inherit;
  border-top-right-radius: inherit;
}
.settings-ios-card > .import-entry-btn:last-child {
  border-bottom: 0;
  border-bottom-left-radius: inherit;
  border-bottom-right-radius: inherit;
}
.import-entry-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  margin: 0;
  padding: 14px 16px;
  border: 0;
  border-bottom: 1px solid color-mix(in srgb, var(--dsw-alias-fill-tsp-gray-main, #e8e8ed) 90%, transparent);
  background: transparent;
  text-align: left;
  cursor: pointer;
  color: inherit;
  font: inherit;
  transition: background .15s ease;
}
.import-entry-btn:last-child { border-bottom: 0; }
.import-entry-btn:hover { background: color-mix(in srgb, var(--dsw-alias-fill-tsp-gray-main, #f2f3f5) 70%, transparent); }
.import-entry-btn:active { background: color-mix(in srgb, var(--dsw-alias-fill-tsp-gray-main, #ebebef) 90%, transparent); }
.import-entry-ico {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  background: rgba(77, 107, 254, 0.12);
  color: #4d6bfe;
}
.import-entry-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}
.import-entry-copy strong {
  font-size: 15px;
  font-weight: 650;
  line-height: 1.3;
  color: var(--dsw-alias-label-primary, #111);
}
.import-entry-copy em {
  font-style: normal;
  font-size: 12.5px;
  line-height: 1.4;
  color: var(--dsw-alias-label-tertiary, #8b8b93);
}
.import-entry-chev {
  flex-shrink: 0;
  font-size: 20px;
  line-height: 1;
  color: var(--dsw-alias-label-quaternary, #c0c0c7);
}
body.dark .import-entry-copy strong { color: #f3f4f6; }
body.dark .import-entry-btn:hover { background: rgba(255, 255, 255, 0.05); }
.import-panel {
  padding: 16px !important;
}
.import-panel.classic {
  padding: 6px 2px 4px !important;
  gap: 12px;
}
.import-panel-top {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}
.import-panel.classic .import-panel-top { margin-bottom: 4px; }
.import-panel-ico {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  background: rgba(77, 107, 254, 0.12);
  color: #4d6bfe;
}
.import-panel-title {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  padding-top: 1px;
}
.import-panel-title strong {
  font-size: 15px;
  font-weight: 650;
  color: var(--dsw-alias-label-primary, #111);
  line-height: 1.3;
}
.import-panel-title span {
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--dsw-alias-label-tertiary, #8b8b93);
}
.import-guide-block {
  margin: 0 0 12px;
  padding: 12px 12px 10px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--dsw-alias-fill-tsp-gray-main, #f2f3f5) 90%, transparent);
}
.import-guide-block:last-child { margin-bottom: 0; }
.import-guide-h {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 650;
  line-height: 1.35;
  color: var(--dsw-alias-label-primary, #111);
}
.import-guide-platform {
  margin: 10px 0 4px;
  font-size: 12px;
  font-weight: 600;
  color: #4d6bfe;
}
.import-guide-block > .import-guide-platform:first-of-type { margin-top: 0; }
.import-guide-ol,
.import-guide-ul {
  margin: 0;
  padding: 0 0 0 1.15em;
  font-size: 12.5px;
  line-height: 1.65;
  color: var(--dsw-alias-label-secondary, #555);
}
.import-guide-ol li + li,
.import-guide-ul li + li { margin-top: 4px; }
.import-guide-ol strong,
.import-guide-ul strong {
  font-weight: 600;
  color: var(--dsw-alias-label-primary, #222);
}
.import-guide-ol code,
.import-guide-ul code {
  display: inline-block;
  margin-top: 2px;
  padding: 1px 6px;
  border-radius: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11.5px;
  background: rgba(77, 107, 254, 0.08);
  color: #3a56d4;
  word-break: break-all;
}
.import-guide-note .import-guide-ul { padding-left: 1.05em; }
.import-guide-block .import-form { margin-top: 10px; }
.import-guide-secondary {
  opacity: 0.98;
}
.import-zip-modal {
  width: min(560px, calc(100vw - 28px)) !important;
  max-height: min(88vh, 760px);
}
.import-zip-modal-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-top: 4px;
}
.import-zip-lead {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--dsw-alias-label-secondary, #555);
}
.import-zip-lead code {
  font-size: 12px;
  padding: 1px 6px;
  border-radius: 6px;
  background: rgba(77, 107, 254, 0.08);
  color: #3a56d4;
}
.import-zip-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 10px;
}
.import-zip-select {
  width: 100%;
  height: 44px;
  border-radius: 12px;
  border: 1px solid rgba(0,0,0,.08);
  padding: 0 12px;
  font: inherit;
  background: #fff;
}
.import-zip-media {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.import-zip-media-opt {
  text-align: left;
  border: 1px solid rgba(0,0,0,.08);
  border-radius: 14px;
  padding: 12px 14px;
  background: #fff;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
}
.import-zip-media-opt strong {
  font-size: 14px;
  font-weight: 650;
  color: #111;
}
.import-zip-media-opt em {
  font-style: normal;
  font-size: 12px;
  line-height: 1.4;
  color: #8b8b93;
}
.import-zip-media-opt.on {
  border-color: color-mix(in srgb, #4d6bfe 45%, transparent);
  background: color-mix(in srgb, #4d6bfe 8%, #fff);
  box-shadow: 0 0 0 1px color-mix(in srgb, #4d6bfe 18%, transparent);
}
.import-zip-warn {
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(255, 149, 0, 0.12);
  color: #9a5b00;
  font-size: 13px;
  line-height: 1.5;
}
.import-zip-drop {
  border: 1.5px dashed rgba(77, 107, 254, 0.35);
  border-radius: 16px;
  padding: 22px 16px;
  text-align: center;
  background: color-mix(in srgb, #4d6bfe 5%, #fff);
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
}
.import-zip-drop:hover,
.import-zip-drop.drag {
  border-color: #4d6bfe;
  background: color-mix(in srgb, #4d6bfe 10%, #fff);
}
.import-zip-drop.has-file {
  border-style: solid;
  border-color: color-mix(in srgb, #4d6bfe 40%, transparent);
}
.import-zip-drop-ico {
  width: 48px;
  height: 48px;
  margin: 0 auto 10px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  color: #4d6bfe;
  background: color-mix(in srgb, #4d6bfe 12%, #fff);
}
.import-zip-drop-title {
  font-size: 14.5px;
  font-weight: 600;
  color: #1f2430;
  word-break: break-all;
}
.import-zip-drop-sub {
  margin-top: 4px;
  font-size: 12.5px;
  color: #8b8b93;
}
.import-zip-progress {
  font-size: 13px;
  color: #4d6bfe;
  line-height: 1.45;
}
body.dark .import-zip-select,
body.dark .import-zip-media-opt {
  background: #1c1f26;
  border-color: rgba(255,255,255,.1);
  color: #f3f4f6;
}
body.dark .import-zip-media-opt strong { color: #f3f4f6; }
body.dark .import-zip-drop {
  background: rgba(77, 107, 254, 0.1);
  border-color: rgba(138, 160, 255, 0.35);
}
body.dark .import-zip-drop-title { color: #f3f4f6; }
@media (max-width: 560px) {
  .import-zip-grid,
  .import-zip-media { grid-template-columns: 1fr; }
}
.import-zip-controls {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 8px;
  margin: 10px 0 0;
}
.import-zip-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  font-size: 12px;
  color: var(--dsw-alias-label-tertiary, #8b8b93);
}
.import-zip-field select,
.import-zip-field .ios-block-input,
.import-zip-field .input-clean {
  width: 100%;
  margin: 0 !important;
  height: 40px;
}
.import-zip-form {
  margin-top: 10px;
}
.import-zip-form .secondary-btn,
.import-zip-form .btn-ghost {
  flex: none;
  min-width: 88px;
}
@media (max-width: 520px) {
  .import-zip-controls { grid-template-columns: 1fr; }
}
.import-form {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.import-form .import-url-input,
.import-form .ios-block-input {
  flex: 1;
  min-width: 0;
  margin: 0 !important;
}
.import-form .primary-btn,
.import-form .ios-card-btn {
  flex: none;
  width: auto !important;
  min-width: 72px;
  margin: 0 !important;
  padding: 0 16px;
  height: auto;
  align-self: stretch;
}
.import-tip {
  margin-top: 10px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--dsw-alias-label-tertiary, #8b8b93);
}
.import-guide-steps {
  margin: 10px 0 12px;
  padding: 10px 12px 10px 28px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--dsw-alias-fill-tsp-gray-main, #f2f3f5) 88%, transparent);
  color: var(--dsw-alias-label-secondary, #666);
  font-size: 12.5px;
  line-height: 1.65;
}
.import-guide-steps li { margin: 2px 0; }
.import-guide-steps strong { color: var(--dsw-alias-label-primary, #111); font-weight: 600; }

/* Font sizes — driven by --msg-font-size (set in CSS + applyFont) */
:root, html {
  --msg-font-size: 16px;
  --msg-line-height: 1.75;
}
html[data-font="small"] {
  --msg-font-size: 14px;
  --msg-line-height: 1.65;
}
html[data-font="medium"] {
  --msg-font-size: 16px;
  --msg-line-height: 1.75;
}
html[data-font="large"] {
  --msg-font-size: 18px;
  --msg-line-height: 1.8;
}
html[data-ui-theme="liquid"] .msg-assistant .body,
html[data-ui-theme="liquid"] .msg-assistant .ds-markdown,
html[data-ui-theme="liquid"] .msg-user .bubble {
  font-size: var(--msg-font-size);
  line-height: var(--msg-line-height);
}

/* Dark theme */
body.dark .admin-nav {
  background: #171a21;
  border-color: #2a2f3a;
}
body.dark .admin-nav-item:hover { background: rgba(255,255,255,.05); }
body.dark .admin-nav-item.active {
  background: #21262f;
  color: #8ea6ff;
}
body.dark .admin-quick {
  background: #171a21;
  border-color: #2a2f3a;
  color: #e8eaed;
}

body.dark {
  background: #0f1115; color: #e8eaed;
  --dsw-alias-label-primary: #e8eaed;
  --dsw-alias-label-secondary: #b0b4ba;
  --dsw-alias-label-tertiary: #8a8f98;
  --dsw-alias-label-caption: #6b7078;
  --dsw-specific-sidebar-fill: #17191d;
  --dsw-specific-sidebar-nav-item-hover: #22252b;
  --dsw-specific-sidebar-nav-item-active-accent: #1a2744;
  --dsw-specific-input-major: #1c1f26;
  --dsw-specific-bubble: #1a2744;
  --dsw-alias-border-l1: rgba(255,255,255,.06);
  --dsw-alias-border-l2: rgba(255,255,255,.12);
  --dsw-alias-border-l2-darkmode-thin: rgba(255,255,255,.12);
  --dsw-alias-interactive-bg-hover: rgba(255,255,255,.06);
  --dsw-alias-button-elevated-fill: #22252b;
  --dsw-static-neutral-bluish-50: #17191d;
  --dsw-static-neutral-bluish-75: #22252b;
  --dsw-static-neutral-bluish-100: #2a2e36;
  --dsw-static-neutral-bluish-200: #3a3f48;
}
body.dark .app, body.dark .main, body.dark .modal:not(.settings-modal),
body.dark .search-panel-box, body.dark .ctx-menu, body.dark .user-menu { background: #12141a; }
body.dark .composer { box-shadow: none; }
body.dark .seg button.active { background: #2a2e36; }
body.dark .history-empty-ico {
  background: rgba(77, 107, 254, 0.18);
  color: #9db0ff;
}
body.dark .history-empty-item { color: #f3f4f6; }
body.dark .import-panel-title strong { color: #f3f4f6; }
body.dark .import-guide-block { background: rgba(255, 255, 255, 0.05); }
body.dark .import-guide-ol code,
body.dark .import-guide-ul code {
  background: rgba(255, 255, 255, 0.08);
  color: #c5d0ff;
}

/* Settings sheet follows iOS dark palette (not near-black modal fill) */
body.dark {
  --ios-bg: #1c1c1e;
  --ios-fill: #2c2c2e;
  --ios-sep: rgba(84, 84, 88, 0.65);
  --ios-label: #ffffff;
  --ios-secondary: #8e8e93;
  --ios-row: #2c2c2e;
  --ios-row-active: #3a3a3c;
  --ios-close-bg: #3a3a3c;
  --ios-close-fg: #ebebf5;
  --ios-handle: #5a5a5e;
}
body:not(.dark) {
  --ios-label: #000000;
  --ios-secondary: #8e8e93;
  --ios-row: #ffffff;
  --ios-row-active: #ececec;
  --ios-close-bg: #e5e5ea;
  --ios-close-fg: #3a3a3c;
  --ios-handle: #c7c7cc;
}
body.dark .settings-modal {
  background: var(--ios-bg);
  color: var(--ios-label);
  box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.45);
}
body.dark .settings-modal .modal-head,
body.dark .settings-modal .modal-foot {
  background: var(--ios-bg);
  border-color: var(--ios-sep);
}
body.dark .settings-modal .modal-head h3 { color: var(--ios-label); }
body.dark .settings-modal .settings-pane,
body.dark .settings-modal .ios-group,
body.dark .settings-modal .ios-row {
  background: var(--ios-row);
  color: var(--ios-label);
}
body.dark .settings-modal .ios-row:active { background: var(--ios-row-active); }
body.dark .settings-modal .ios-label,
body.dark .settings-modal .ios-ico { color: var(--ios-label); }
body.dark .settings-modal .ios-value,
body.dark .settings-modal .ios-sel,
body.dark .settings-modal .ios-hint,
body.dark .settings-modal .ios-sec-label { color: var(--ios-secondary); }
body.dark .settings-modal .ios-chev { color: #636366; }
body.dark .settings-modal .close-round,
body.dark .settings-modal #closeSettings {
  background: var(--ios-close-bg);
  color: var(--ios-close-fg);
}
body.dark .settings-modal .sheet-handle { background: var(--ios-handle); }
body.dark .settings-modal input,
body.dark .settings-modal select,
body.dark .settings-modal textarea {
  background: #1c1c1e;
  color: var(--ios-label);
  border-color: var(--ios-sep);
}

/* Backdrop for mobile sidebar */
.sidebar-backdrop {
  display: none; position: fixed; inset: 0; z-index: 25;
  background: rgba(15,17,21,.28);
  -webkit-tap-highlight-color: transparent;
}
body.sidebar-open .sidebar-backdrop { display: block; }
.desktop-only { display: inline-flex; }
.desktop-only-flex { display: flex; }
.mobile-only { display: none !important; }
.icon-btn-xl { width: 44px; height: 44px; }
.icon-btn-circle {
  border-radius: 50%;
  background: var(--dsw-static-neutral-bluish-75);
}
.icon-btn-circle:hover { background: var(--dsw-static-neutral-bluish-100); }
.attach-btn .ico-plus { display: none; }
.voice-btn { display: none; }
.sidebar-handle { display: none; }
.sidebar-search { display: none; }
.user-more { display: none; }
.scroll-bottom-btn {
  display: none;
  position: absolute;
  right: 16px;
  bottom: 110px;
  z-index: 5;
  width: 36px; height: 36px;
  border-radius: 50%;
  background: #fff;
  border: 1px solid var(--dsw-alias-border-l2);
  box-shadow: 0 2px 8px rgba(0,0,0,.08);
  color: var(--dsw-alias-label-secondary);
  place-items: center;
}
.scroll-bottom-btn:not([hidden]) { display: grid; }
.scroll-bottom-btn svg { width: 18px; height: 18px; }
.close-round {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--dsw-static-neutral-bluish-100);
}
.ios-settings { display: none; }
.attachment-tray,
.voice-hold-btn,
.voice-wave-pill,
.stage-dimmer { display: none; }
.attach-btn .ico-plus-circle,
.attach-btn .ico-x-circle,
.voice-btn .ico-voice-circle { display: none; }
.batch-footer { display: none; }
.history-check { display: none; }

/* ========== Mobile — iOS native (DeepSeek App) ========== */
@media (max-width: 860px) {
  :root {
    --message-list-max-width: 100%;
    --message-list-padding-horizontal: 18px;
    --mobile-top-h: 48px;
    --vv-offset: 0px;
    --ios-bg: #f2f2f7;
    --ios-fill: #f2f2f7;
    --ios-sep: rgba(60, 60, 67, 0.12);
    --ios-blue: #4b6bfb;
    --ios-card-r: 18px;
    --ios-label: #000000;
    --ios-secondary: #8e8e93;
    --ios-row: #ffffff;
    --ios-row-active: #ececec;
    --ios-close-bg: #e5e5ea;
    --ios-close-fg: #3a3a3c;
    --ios-handle: #c7c7cc;
  }

  html, body {
    height: 100%;
    height: 100dvh;
    overscroll-behavior: none;
    background: #fff;
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", sans-serif;
    -webkit-font-smoothing: antialiased;
  }

  .app {
    height: 100%;
    height: 100dvh;
    max-height: 100dvh;
    padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
    box-sizing: border-box;
    gap: 0;
    background: #fff;
  }

  body.sidebar-open { overflow: hidden; touch-action: none; }
  .desktop-only,
  .desktop-only-flex { display: none !important; }
  .mobile-only { display: flex !important; }

  .sidebar-backdrop {
    background: rgba(0, 0, 0, 0.18);
  }

  /* Sidebar: flush left, only right corners rounded */
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 40;
    width: min(86vw, 320px);
    max-width: min(86vw, 320px);
    height: auto;
    margin-left: 0 !important;
    padding: calc(6px + env(safe-area-inset-top)) 10px calc(8px + env(safe-area-inset-bottom));
    border-radius: 0 var(--ios-card-r) var(--ios-card-r) 0;
    background: #fff;
    border: 0;
    box-shadow: 8px 0 32px rgba(0, 0, 0, 0.12);
    transform: translateX(0);
    transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.2s ease;
    -webkit-overflow-scrolling: touch;
  }
  .sidebar.collapsed {
    transform: translateX(-100%);
    pointer-events: none;
    opacity: 0;
  }
  .sidebar-handle {
    display: flex !important;
    justify-content: center;
    gap: 3px;
    padding: 8px 0 6px;
  }
  .sidebar-handle i {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: #d1d1d6;
  }
  .sidebar-search {
    display: flex !important;
    align-items: center;
    gap: 8px;
    height: 36px;
    padding: 0 12px;
    margin: 2px 2px 8px;
    border-radius: 10px;
    background: var(--ios-fill);
    flex-shrink: 0;
  }
  .sidebar-search svg {
    width: 15px;
    height: 15px;
    color: #8e8e93;
    flex-shrink: 0;
  }
  .sidebar-search input {
    border: 0;
    outline: 0;
    background: transparent;
    width: 100%;
    font-size: 15px;
    color: #000;
  }
  .sidebar-search input::placeholder { color: #8e8e93; }

  .history { margin-top: 0; padding-bottom: 4px; }
  .history-empty { padding: 0 0 10px; gap: 1px; }
  .history-empty-item { height: 44px; padding: 0 8px; border-radius: 12px; }
  .history-empty-ico { width: 28px; height: 28px; border-radius: 9px; }
  .history-empty-ico svg { width: 15px; height: 15px; }
  .history-group-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: transparent;
    box-shadow: none;
    padding: 14px 8px 6px;
    font-size: 13px;
    font-weight: 500;
    color: #8e8e93;
  }
  .hist-filter {
    width: 28px;
    height: 28px;
    border: 0;
    background: transparent;
    display: grid;
    place-items: center;
    color: #8e8e93;
  }
  .hist-filter svg { width: 15px; height: 15px; }
  .new-chat-btn {
    height: 42px;
    margin: 2px 2px 10px;
    border-radius: 12px;
    background: #f2f2f7;
    color: #1c1c1e;
    font-size: 15px;
    font-weight: 500;
    border: 0;
    box-shadow: none;
    transition: background 0.15s ease, transform 0.12s ease;
  }
  .new-chat-btn:active {
    background: #e5e5ea;
    transform: scale(0.985);
  }
  .new-chat-btn svg { color: var(--ios-blue); }

  .history-item {
    min-height: 44px;
    height: auto;
    padding: 11px 10px 11px 12px;
    border-radius: 0 12px 12px 0;
    font-size: 15px;
    font-weight: 400;
    color: #1c1c1e;
    transition: background 0.15s ease;
  }
  .history-item:active { background: #f2f2f7; }
  .history-item.active {
    background: rgba(75, 107, 251, 0.1);
    color: var(--ios-blue);
  }
  .history-item .more-fade {
    display: none;
    background: transparent;
    width: 36px;
  }
  .history-item.active .more-fade {
    display: flex;
    background: transparent;
  }
  .history-item .more { color: inherit; opacity: 0.7; }

  .sidebar-user {
    margin: 4px 0 0;
    padding: 12px 8px;
    border-top: 1px solid var(--ios-sep);
    border-radius: 12px;
    transition: background 0.15s ease;
  }
  .sidebar-user:active { background: #f2f2f7; }
  .sidebar-user .avatar {
    width: 36px;
    height: 36px;
    background: linear-gradient(145deg, #dbe4ff, #e8ecf5);
    color: var(--ios-blue);
    font-size: 14px;
    font-weight: 600;
  }
  .sidebar-user .email {
    font-size: 15px;
    color: #1c1c1e;
    font-weight: 500;
  }
  .user-more {
    display: grid !important;
    width: 32px;
    height: 32px;
    color: #8e8e93;
    border-radius: 50%;
  }
  .user-more:active { background: #e5e5ea; }

  /* Main: edge-to-edge, no outer card radius */
  .main {
    width: 100%;
    min-width: 0;
    background: #fff;
    border-radius: 0;
    overflow: hidden;
    box-shadow: none;
    display: flex;
    flex-direction: column;
  }
  .main-grabber { display: none !important; }

  .main-top {
    height: var(--mobile-top-h);
    min-height: var(--mobile-top-h);
    padding: 2px 10px 2px 8px;
    gap: 6px;
    border-bottom: 0;
    background: #fff;
  }
  .main-top .collapsed-tools {
    display: flex !important;
    flex-shrink: 0;
    gap: 0;
  }
  .main-top .icon-btn-xl,
  .main-top .icon-btn-circle {
    width: 36px;
    height: 36px;
    background: var(--ios-fill);
    border-radius: 50%;
    color: #3a3a3c;
  }
  .main-top .icon-btn-xl svg,
  .main-top .icon-btn-circle svg {
    width: 18px;
    height: 18px;
  }
  .main-top-right {
    display: flex !important;
    gap: 8px;
    flex-shrink: 0;
    margin-left: auto;
  }

  /* Title left beside menu — App layout */
  .chat-title {
    flex: 1;
    min-width: 0;
    max-width: none;
    height: 36px;
    margin: 0;
    padding: 0 2px;
    border: 0 !important;
    box-shadow: none !important;
    background: transparent;
    justify-content: flex-start;
    text-align: left;
    font-size: 16px;
    font-weight: 600;
    color: #1c1c1e;
    gap: 3px;
  }
  .chat-title-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: min(42vw, 180px);
  }
  .chat-title-chev {
    display: none;
    font-size: 9px;
    color: #8e8e93;
    flex-shrink: 0;
    transform: translateY(1px);
  }
  .chat-title.has-title .chat-title-chev { display: inline; }
  .main.home-mode .chat-title { visibility: hidden; }
  .main.chat-mode .chat-title:hover { border: 0; box-shadow: none; }

  .stage {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    position: relative;
    background: #fff;
  }
  /* Empty chat: large DS mark centered, composer pinned to bottom */
  .main.home-mode .stage {
    justify-content: flex-start;
    align-items: stretch;
    padding: 0;
  }
  .main.home-mode .home-hero {
    flex: 1;
    width: 100%;
    max-width: none;
    min-height: 0;
    padding: 0 28px;
    margin: 0;
    justify-content: center;
  }
  .main.home-mode .home-hero .home-mark {
    display: block;
    width: 64px;
    height: 64px;
    margin: 0 0 16px;
    object-fit: contain;
  }
  .main.home-mode .home-hero .hello .whale {
    display: none;
  }
  .home-hero .hello {
    font-size: 20px;
    font-weight: 600;
    line-height: 28px;
    margin-bottom: 0;
    text-align: center;
    color: #1c1c1e;
    letter-spacing: -0.2px;
  }
  .home-hero .hello .whale {
    width: 34px;
    height: 26px;
    transform: none;
    margin-right: 8px;
    vertical-align: -4px;
  }
  .main.home-mode .composer-wrap {
    flex-shrink: 0;
    margin-top: auto !important;
  }

  .chat-scroll {
    flex: 1;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
  }
  .messages {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 8px 18px 28px;
  }
  .msg { margin: 0 0 22px; }
  .msg-assistant .body {
    font-size: 16px;
    line-height: 26px;
    color: #1c1c1e;
  }
  .ds-markdown .ds-markdown-paragraph { margin: 14px 0; }
  .msg-user .bubble {
    max-width: min(86%, 480px);
    border-radius: 18px;
    font-size: 16px;
    line-height: 24px;
    padding: 10px 14px;
    background: #edf3fe;
    border: 0;
  }

  .ds-think-title {
    height: 26px;
    max-height: 26px;
    margin-bottom: 8px;
  }
  .ds-think-atom { display: none; }
  .ds-think-label {
    font-size: 14px;
    font-weight: 400;
    color: #8e8e93;
  }
  .ds-think-chevron {
    color: #c7c7cc;
    width: 12px;
    height: 12px;
  }

  .msg-actions {
    opacity: 1;
    left: 0;
    width: 100%;
    gap: 8px;
    padding-top: 12px;
    padding-bottom: 0;
    overflow-x: auto;
    flex-wrap: nowrap;
    scrollbar-width: none;
  }
  .msg-actions::-webkit-scrollbar { display: none; }
  .msg-user .msg-actions { width: auto; }
  .msg-actions button {
    width: 30px;
    height: 30px;
    background: transparent;
    color: #8e8e93;
  }

  .scroll-bottom-btn {
    bottom: calc(112px + env(safe-area-inset-bottom) + var(--vv-offset, 0px));
    right: 18px;
    width: 34px;
    height: 34px;
    border: 0;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    background: #fff;
    color: #636366;
  }

  /* Composer island */
  .composer-wrap,
  .main.chat-mode .composer-wrap,
  .main.home-mode .composer-wrap {
    width: 100% !important;
    max-width: none !important;
    padding: 0 12px calc(8px + env(safe-area-inset-bottom) + var(--vv-offset, 0px)) !important;
    margin: 0 !important;
  }
  .composer,
  .main.chat-mode .composer-wrap .composer {
    width: 100% !important;
    max-width: none !important;
    border-radius: 24px;
    border: 1px solid rgba(0, 0, 0, 0.045);
    background: #fff;
    box-shadow: 0 4px 20px rgba(15, 17, 21, 0.06);
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
  }
  .composer:focus-within {
    border-color: rgba(75, 107, 251, 0.28);
    box-shadow: 0 6px 24px rgba(57, 100, 254, 0.1);
  }
  .composer textarea {
    font-size: 16px;
    line-height: 22px;
    max-height: 110px;
    padding: 15px 16px 6px;
    min-height: 46px;
  }
  .composer textarea::placeholder { color: #8e8e93; }
  .composer-toolbar {
    padding: 4px 10px 11px;
    flex-wrap: nowrap;
    gap: 8px;
  }
  .composer-toolbar .tools {
    flex: 1;
    min-width: 0;
    gap: 8px;
    overflow: visible;
    mask-image: none;
  }
  .composer-toolbar .actions {
    flex-shrink: 0;
    gap: 8px;
    margin-left: 0;
  }

  #pillThink.ds-toggle-button {
    margin-right: 0;
    padding: 0 13px;
    height: 34px;
    border-radius: 17px;
    border: 1px solid transparent;
    background: #f2f2f7;
    color: #636366;
    font-size: 13px;
    font-weight: 500;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  }
  #pillThink.ds-toggle-button.selected {
    background: rgba(75, 107, 251, 0.1);
    border-color: rgba(75, 107, 251, 0.35);
    color: var(--ios-blue);
  }
  #pillSearch.ds-toggle-button {
    width: 34px;
    height: 34px;
    padding: 0;
    border-radius: 50%;
    justify-content: center;
    border: 1px solid transparent;
    background: #f2f2f7;
    color: #636366;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  }
  #pillSearch .pill-text { display: none; }
  #pillSearch.ds-toggle-button.selected {
    background: rgba(75, 107, 251, 0.1);
    border-color: rgba(75, 107, 251, 0.35);
    color: var(--ios-blue);
  }
  .attach-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: #f2f2f7;
    color: #636366;
    transition: background 0.15s ease, transform 0.12s ease;
  }
  .attach-btn:active { transform: scale(0.94); background: #e5e5ea; }
  .attach-btn .ico-paperclip { display: none; }
  .attach-btn .ico-plus { display: block; width: 16px; height: 16px; }
  .voice-btn {
    display: grid;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    place-items: center;
    background: #f2f2f7;
    color: #636366;
    transition: background 0.15s ease, transform 0.12s ease;
  }
  .voice-btn:active { transform: scale(0.94); background: #e5e5ea; }
  .voice-btn svg { width: 16px; height: 16px; }
  .send-btn,
  .stop-btn {
    width: 34px;
    height: 34px;
    transition: transform 0.12s ease, opacity 0.15s ease;
  }
  .send-btn:active:not(:disabled),
  .stop-btn:active { transform: scale(0.94); }
  body.composer-empty .send-btn { display: none; }
  body:not(.composer-empty) .voice-btn { display: none; }
  body.composer-empty .voice-btn { display: grid; }

  .main-top .icon-btn-xl,
  .main-top .icon-btn-circle {
    transition: background 0.15s ease, transform 0.12s ease;
  }
  .main-top .icon-btn-xl:active,
  .main-top .icon-btn-circle:active {
    transform: scale(0.92);
    background: #f2f2f7;
  }

  /* Settings sheet — iOS Settings */
  .modal-mask {
    align-items: flex-end;
    padding: 0;
    background: rgba(0, 0, 0, 0.28);
  }
  .settings-modal {
    width: 100%;
    max-height: min(92vh, 100%);
    border-radius: 14px 14px 0 0;
    background: var(--ios-bg);
    color: var(--ios-label);
    overflow: hidden;
    box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.12);
    transform: translateY(12px);
    opacity: 0.96;
    transition: transform 0.28s cubic-bezier(0.2, 0.85, 0.2, 1), opacity 0.2s ease;
  }
  #settingsModal.show .settings-modal {
    transform: translateY(0);
    opacity: 1;
  }
  .sheet-handle {
    display: block !important;
    width: 36px;
    height: 5px;
    margin: 8px auto 0;
    border-radius: 100px;
    background: var(--ios-handle);
  }
  .settings-modal .modal-head {
    background: var(--ios-bg);
    border-bottom: 0;
    justify-content: center;
    position: relative;
    padding: 8px 52px 10px;
    min-height: 44px;
  }
  .settings-modal .modal-head h3 {
    font-size: 17px;
    font-weight: 600;
    text-align: center;
    color: var(--ios-label);
  }
  .settings-modal .close-round,
  .settings-modal #closeSettings {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 30px;
    height: 30px;
    background: var(--ios-close-bg);
    color: var(--ios-close-fg);
    font-size: 22px;
    font-weight: 400;
    line-height: 1;
  }
  .settings-back {
    position: absolute;
    left: 6px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 28px;
    line-height: 1;
    width: 40px;
    height: 40px;
    display: none !important;
    color: var(--ios-blue);
  }
  .settings-modal.show-pane .settings-back { display: grid !important; }
  /* Instant-save on mobile: hide foot unless password dirty */
  .settings-modal .modal-foot { display: none !important; }
  .settings-modal.pwd-dirty .modal-foot {
    display: flex !important;
    background: var(--ios-bg);
    border-top: 1px solid var(--ios-sep);
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
  }
  .ios-settings {
    display: block !important;
    padding: 4px 16px calc(28px + env(safe-area-inset-bottom));
    overflow: auto;
    max-height: calc(92vh - 52px);
    -webkit-overflow-scrolling: touch;
  }
  .settings-modal.show-pane .ios-settings { display: none !important; }
  .settings-modal:not(.show-pane) #settingsLayout { display: none !important; }
  .settings-modal.show-pane #settingsLayout {
    display: block !important;
    padding: 0 16px calc(20px + env(safe-area-inset-bottom));
    overflow: auto;
    max-height: calc(92vh - 56px);
  }
  .settings-modal.pwd-dirty.show-pane #settingsLayout {
    max-height: calc(92vh - 110px);
  }
  .settings-modal .settings-nav { display: none !important; }
  .settings-modal .settings-panes {
    width: 100%;
    padding: 0;
    overflow: visible;
  }
  .settings-modal .settings-pane {
    background: transparent;
    border-radius: 0;
    padding: 0;
    color: var(--ios-label);
  }
  .settings-modal .settings-pane .ios-sec-label:first-child { padding-top: 8px; }

  .ios-sec-label {
    font-size: 13px;
    color: var(--ios-secondary);
    padding: 18px 12px 6px;
    text-transform: none;
    letter-spacing: -0.08px;
  }
  .ios-group {
    background: var(--ios-row);
    border-radius: 12px;
    overflow: hidden;
  }
  .ios-row {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    text-align: left;
    background: var(--ios-row);
    color: var(--ios-label);
    border: 0;
    min-height: 48px;
    position: relative;
    -webkit-tap-highlight-color: transparent;
  }
  .ios-row:active { background: var(--ios-row-active); }
  .ios-group .ios-row:not(:last-child)::after {
    content: "";
    position: absolute;
    left: 56px;
    right: 0;
    bottom: 0;
    height: 0.5px;
    background: var(--ios-sep);
  }
  .ios-ico {
    width: 26px;
    height: 26px;
    display: grid;
    place-items: center;
    color: var(--ios-label);
    flex-shrink: 0;
  }
  .ios-ico.ios-ico-tile {
    width: 30px;
    height: 30px;
    border-radius: 7px;
    color: #fff;
  }
  .ios-ico.ios-ico-tile svg { width: 17px; height: 17px; }
  .ios-ico.tile-blue { background: #007aff; }
  .ios-ico.tile-purple { background: #af52de; }
  .ios-ico.tile-teal { background: #30b0c7; }
  .ios-ico.tile-indigo { background: #5856d6; }
  .ios-ico.tile-orange { background: #ff9500; }
  .ios-ico.tile-gray { background: #8e8e93; }
  .ios-ico.tile-pink { background: #ff2d55; }
  .ios-ico.tile-green { background: #34c759; }
  .ios-ico.tile-cyan { background: #32ade6; }
  .ios-ico.tile-slate { background: #636366; }
  .ios-ico.tile-red { background: #ff3b30; }
  .ios-ico svg { width: 20px; height: 20px; }
  .ios-ico-aa {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: -0.6px;
    color: #fff !important;
  }

  .settings-modal .ios-field-row,
  .settings-modal .ios-check-row {
    background: var(--ios-row);
    border-bottom: 0;
    color: var(--ios-label);
  }
  .settings-modal .ios-group .ios-field-row:not(:last-child)::after,
  .settings-modal .ios-group .ios-check-row:not(:last-child)::after {
    content: "";
    position: absolute;
    left: 14px;
    right: 0;
    bottom: 0;
    height: 0.5px;
    background: var(--ios-sep);
  }
  .settings-modal .ios-inline-input,
  .settings-modal .ios-inline-select {
    color: var(--ios-secondary);
    font-size: 16px;
  }
  .settings-modal .ios-block-input {
    background: var(--ios-bg);
    border-color: var(--ios-sep);
    color: var(--ios-label);
  }
  .settings-modal .ios-check-row .ios-check { color: var(--ios-blue); }
  .settings-modal .settings-ios-card > .data-card,
  .settings-modal .settings-ios-card.data-card {
    background: var(--ios-row);
    border-color: transparent;
  }
  .settings-modal .btn-ghost {
    background: transparent;
    border-color: var(--ios-sep);
    color: var(--ios-blue);
    border-radius: 10px;
  }
  .settings-modal .btn-ghost.danger { color: #ff3b30; border-color: rgba(255,59,48,.35); }
  .ios-label {
    flex: 1;
    font-size: 16px;
    color: var(--ios-label);
    text-align: left;
  }
  .ios-value { font-size: 15px; color: var(--ios-secondary); }
  .ios-sel {
    font-size: 10px;
    color: var(--ios-secondary);
    letter-spacing: -1px;
    line-height: 1;
    margin-left: 2px;
  }
  .ios-chev {
    font-size: 18px;
    color: #c7c7cc;
    line-height: 1;
    font-weight: 400;
  }
  body.dark .ios-chev { color: #636366; }
  .ios-hint {
    margin: 8px 12px 0;
    font-size: 13px;
    line-height: 18px;
    color: var(--ios-secondary);
  }

  .sources-drawer { width: 100%; max-width: 100%; border-radius: 0; }
  .search-overlay { padding: max(10vh, env(safe-area-inset-top)) 12px 16px; }
  .search-panel-box { width: 100%; max-height: 78vh; border-radius: 14px; }
  .modal,
  .modal.wide,
  .modal.admin-shell {
    width: 100%;
    max-height: min(92vh, 100%);
    border-radius: 14px 14px 0 0;
  }
  .admin-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
  }
  .admin-nav {
    border-right: 0;
    border-bottom: 1px solid var(--dsw-alias-border-l1);
    display: flex;
    gap: 4px;
    overflow-x: auto;
    padding: 10px;
    -webkit-overflow-scrolling: touch;
  }
  .admin-nav-group {
    display: flex;
    gap: 4px;
    margin: 0;
    flex-shrink: 0;
  }
  .admin-nav-label { display: none; }
  .admin-nav-item {
    width: auto;
    white-space: nowrap;
    padding: 8px 12px;
    font-size: 13px;
    background: rgba(255,255,255,.7);
  }
  .admin-quick-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-main { padding: 14px 14px 18px; }
  .new-chat-btn::after { display: none; }
  .ds-markdown h1 { font-size: 1.35em; line-height: 1.4; }
  .ds-markdown h2 { font-size: 1.2em; line-height: 1.45; }
  .ds-markdown .md-pre { max-height: 45vh; }
}

@media (max-width: 380px) {
  #pillThink .pill-text { font-size: 12px; }
  .home-hero .hello { font-size: 18px; line-height: 26px; }
  .main-top .icon-btn-xl,
  .main-top .icon-btn-circle { width: 34px; height: 34px; }
}
