/* BaiZe chat surface — quiet, product-first visual system. */
:root {
  --bg: #0c0e14;
  --card: #151922;
  --card-hover: #1d2230;
  --border: rgba(148, 163, 184, 0.16);
  --text: #f2f4f8;
  --text-secondary: #a8b0c0;
  --text-muted: #737d90;
  --accent: #7972ff;
  --accent-hover: #675ff2;
  --accent-soft: rgba(121, 114, 255, 0.12);
  --accent-light: rgba(121, 114, 255, 0.1);
  --user-bubble: #6962ed;
  --success: #25b985;
  --error: #ef6673;
  --sidebar-bg: #10131b;
  --surface-raised: rgba(21, 25, 34, 0.94);
  --shadow-soft: 0 18px 45px rgba(0, 0, 0, 0.2);
  --shadow-card: 0 10px 30px rgba(0, 0, 0, 0.16);
  --radius: 18px;
  --radius-sm: 12px;
  --radius-lg: 24px;
  --transition: 180ms cubic-bezier(.2, .8, .2, 1);
  --padding-bubble: 15px 18px;
}

[data-theme="light"] {
  --bg: #f6f7fb;
  --card: #ffffff;
  --card-hover: #eef0f6;
  --border: rgba(37, 45, 66, 0.1);
  --text: #171a26;
  --text-secondary: #626a7b;
  --text-muted: #9299a8;
  --accent: #655ef3;
  --accent-hover: #554ee0;
  --accent-soft: rgba(101, 94, 243, 0.1);
  --accent-light: rgba(101, 94, 243, 0.08);
  --user-bubble: #625ce8;
  --success: #13a878;
  --error: #df4d5b;
  --sidebar-bg: #fbfbfd;
  --surface-raised: rgba(255, 255, 255, 0.94);
  --shadow-soft: 0 18px 50px rgba(43, 48, 69, 0.1);
  --shadow-card: 0 10px 30px rgba(43, 48, 69, 0.07);
}

html,
body {
  letter-spacing: -0.006em;
  background: var(--bg);
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 68% 10%, rgba(121, 114, 255, 0.06), transparent 32%),
    radial-gradient(circle at 90% 78%, rgba(69, 191, 157, 0.035), transparent 28%);
}

button:focus-visible,
textarea:focus-visible,
select:focus-visible,
[role="button"]:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--accent) 72%, white);
  outline-offset: 2px;
}

.app {
  isolation: isolate;
}

.sidebar {
  width: 286px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  box-shadow: none;
  overflow: hidden;
}

.sidebar-header {
  align-items: center;
  padding: 20px 18px 14px;
}

.sidebar-header .sb-brand {
  gap: 11px;
}

.sidebar-header .sb-avatar,
.welcome .logo {
  background: linear-gradient(145deg, #7771ff 0%, #514bcf 100%);
  color: #fff;
  box-shadow: 0 12px 26px rgba(101, 94, 243, 0.25), inset 0 1px 0 rgba(255,255,255,.22);
  font-weight: 750;
  letter-spacing: -.08em;
}

.sidebar-header .sb-avatar {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  font-size: 17px;
  padding-right: 2px;
}

.sidebar-header .sb-title {
  font-size: 15px;
  font-weight: 700;
}

.sidebar-header .sb-subtitle {
  margin-top: 2px;
  font-size: 10.5px;
  letter-spacing: .02em;
}

.sidebar-close,
.menu-btn,
.topbar-btn,
.theme-toggle-btn,
.topbar-call-btn {
  border: 1px solid transparent;
  box-shadow: none;
}

.sidebar-close {
  border-radius: 9px;
}

.sidebar-new-chat,
.sidebar-office-task {
  min-height: 42px;
  margin: 2px 12px 5px;
  padding: 10px 12px;
  border-radius: 11px;
  font-size: 13px;
  color: var(--text-secondary);
}

.sidebar-new-chat {
  width: calc(100% - 24px);
  color: var(--text);
  background: var(--accent-soft);
}

.sidebar-new-chat:hover {
  background: color-mix(in srgb, var(--accent) 16%, transparent);
}

.sidebar-new-chat .nc-icon,
.sidebar-office-task .ot-icon {
  width: 24px;
  height: 24px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  color: var(--accent);
  opacity: 1;
  font-size: 16px;
  font-weight: 600;
}

.sidebar-office-task .ot-icon {
  color: var(--text-secondary);
  background: color-mix(in srgb, var(--text-muted) 10%, transparent);
}

.sidebar-new-chat .nc-plus,
.sidebar-office-task .ot-plus {
  font-size: 16px;
}

.sidebar-divider {
  margin: 9px 16px;
  opacity: 1;
}

.sidebar-tools-header {
  padding: 8px 17px 5px !important;
}

.sidebar-tools-title {
  color: var(--text-muted);
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.sidebar-tools-list {
  padding: 0 12px !important;
}

.tool-item {
  min-height: 38px;
  margin-bottom: 2px !important;
  padding: 8px 10px !important;
  border-radius: 10px !important;
  color: var(--text-secondary);
}

.tool-item:hover {
  background: var(--card-hover);
}

.tool-item > span:last-child {
  color: inherit !important;
  font-size: 12.5px !important;
}

.tool-symbol {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  margin-right: 8px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--text-muted) 10%, transparent);
  color: var(--text-secondary);
  font-size: 14px;
}

.sidebar-history-section {
  padding: 2px 10px 10px;
}

.history-list {
  gap: 3px;
  max-height: none;
}

.history-item {
  min-height: 39px;
  padding: 9px 11px;
  border-radius: 10px;
  color: var(--text-secondary);
  font-size: 12.5px;
}

.history-item::before {
  left: 4px;
  width: 2px;
}

.history-item.active {
  background: var(--accent-soft);
  color: var(--text);
}

.history-item.active::before {
  height: 15px;
}

.sidebar-bottom {
  padding: 12px 14px 14px;
  background: color-mix(in srgb, var(--sidebar-bg) 92%, var(--card));
}

.sidebar-select {
  min-height: 40px;
  border-radius: 11px;
  background-color: var(--card);
  border-color: var(--border);
}

.sidebar-user-row {
  margin-top: 10px;
  padding-top: 10px;
}

.sidebar-user-info .user-dot {
  width: 6px;
  height: 6px;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--success) 12%, transparent);
}

.main {
  background: transparent;
}

.topbar {
  min-height: 64px;
  padding: 11px 20px;
  border-bottom-color: var(--border);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(18px) saturate(140%);
}

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

.topbar-actions {
  gap: 7px;
}

.menu-btn,
.topbar-btn,
.theme-toggle-btn,
.topbar-call-btn {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background: color-mix(in srgb, var(--card) 78%, transparent);
  border-color: var(--border);
  color: var(--text-secondary);
  font-size: 16px;
}

.topbar-call-btn {
  color: var(--success);
  background: color-mix(in srgb, var(--success) 9%, var(--card));
}

.topbar-call-btn:hover,
.topbar-btn:hover,
.theme-toggle-btn:hover,
.menu-btn:hover {
  transform: translateY(-1px);
  color: var(--text);
  background: var(--card-hover);
  border-color: color-mix(in srgb, var(--accent) 24%, var(--border));
}

.chat-area {
  padding: 28px clamp(18px, 4vw, 56px) 18px;
  scrollbar-gutter: stable;
}

.messages,
.welcome {
  width: min(100%, 940px);
  margin-inline: auto;
}

.welcome {
  min-height: calc(100vh - 228px);
  padding: 7vh 20px 56px;
  gap: 0;
}

.welcome .logo {
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 0 18px;
  border-radius: 21px;
  padding-right: 4px;
  font-size: 27px;
  animation: none;
}

.welcome-kicker {
  margin-bottom: 7px;
  color: var(--accent);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: .16em;
}

.welcome h1 {
  font-size: clamp(25px, 2.5vw, 34px);
  font-weight: 720;
  letter-spacing: -.035em;
}

.welcome p.welcome-subtitle {
  margin: 8px 0 0;
  color: var(--text-secondary);
  font-size: 13px;
}

.mode-toggle {
  margin-top: 24px;
  padding: 4px;
  border-radius: 14px;
  background: color-mix(in srgb, var(--card) 86%, transparent);
  box-shadow: 0 8px 24px rgba(0,0,0,.04);
}

.mode-toggle-btn {
  min-width: 104px;
  justify-content: center;
  padding: 9px 16px;
  border-radius: 10px;
}

.mode-toggle-btn.active {
  background: var(--card);
  box-shadow: 0 3px 10px rgba(0,0,0,.08);
}

.mode-toggle-desc {
  margin-top: 10px !important;
  font-size: 11.5px !important;
}

.messages {
  gap: 18px;
  padding-bottom: 18px;
}

.message {
  animation-duration: .22s;
}

.bubble {
  font-size: 14.5px;
  line-height: 1.72;
}

.message.user .bubble {
  max-width: min(72%, 700px);
  border-radius: 18px 18px 6px 18px;
  background: linear-gradient(145deg, var(--accent), color-mix(in srgb, var(--accent) 82%, #3d34a8));
  box-shadow: 0 10px 24px color-mix(in srgb, var(--accent) 18%, transparent);
}

.message.assistant .bubble {
  width: auto;
  max-width: min(82%, 780px);
  border: 1px solid var(--border);
  border-radius: 18px 18px 18px 6px;
  background: color-mix(in srgb, var(--card) 92%, transparent);
  box-shadow: var(--shadow-card);
}

.bubble-content pre {
  background: color-mix(in srgb, #080a0f 88%, var(--card));
  border: 1px solid var(--border);
}

.msg-footer {
  gap: 8px;
  color: var(--text-muted);
}

.input-bar {
  padding: 7px 24px max(18px, env(safe-area-inset-bottom, 18px));
  border-top: 0;
  background: linear-gradient(180deg, transparent 0, color-mix(in srgb, var(--bg) 94%, transparent) 25%);
}

.composer-tools-row,
.composer-row,
.image-preview-bar {
  width: min(100%, 940px);
  margin-inline: auto;
}

.composer-tools-row {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 36px;
  margin-bottom: 7px;
  padding: 0 6px;
  overflow: hidden;
}

.permission-mode-row {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  min-height: 32px;
  gap: 2px;
  margin: 0;
  padding: 2px;
  border: 1px solid color-mix(in srgb, var(--border) 86%, transparent);
  border-radius: 11px;
  background: color-mix(in srgb, var(--card) 70%, transparent);
  font-size: 11px;
}

.permission-mode-label {
  margin: 0 4px 0 6px;
  color: var(--text-muted);
  font-weight: 560;
}

.permission-mode-btn {
  min-height: 26px;
  padding: 4px 8px;
  border-color: transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
}

.permission-mode-btn:hover {
  color: var(--text-secondary);
  background: var(--card-hover);
}

.permission-mode-btn.active {
  border-color: color-mix(in srgb, var(--accent) 18%, transparent);
  background: var(--surface-raised);
  color: var(--accent);
  box-shadow: 0 2px 8px rgba(15, 23, 42, .06);
}

.composer-tools-divider {
  flex: 0 0 1px;
  width: 1px;
  height: 18px;
  background: var(--border);
}

.composer-row {
  gap: 8px;
}

.input-wrapper {
  min-height: 56px;
  padding: 7px 8px 7px 9px;
  border: 1px solid color-mix(in srgb, var(--border) 90%, transparent);
  border-radius: 19px;
  background: var(--surface-raised);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(16px);
  transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
}

.input-wrapper:focus-within {
  border-color: color-mix(in srgb, var(--accent) 52%, var(--border));
  box-shadow: 0 18px 50px color-mix(in srgb, var(--accent) 10%, rgba(0,0,0,.08));
}

.input-wrapper textarea {
  min-height: 38px;
  padding: 8px 6px;
  font-size: 14px;
}

.input-mode-select {
  min-height: 38px;
  padding: 7px 10px;
  border-color: transparent;
  border-radius: 12px;
  background: transparent;
  font-size: 12.5px;
}

.input-mode-select:hover {
  border-color: transparent;
  background: var(--card-hover);
}

.attach-btn,
.send-btn {
  width: 40px;
  height: 40px;
  border-radius: 13px;
}

.attach-btn {
  background: transparent;
  font-size: 15px;
}

.send-btn {
  background: var(--accent);
  font-size: 21px;
  font-weight: 500;
}

.send-btn:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.send-btn:disabled {
  background: color-mix(in srgb, var(--text-muted) 12%, var(--card));
  color: var(--text-muted);
}

.pair-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(7, 10, 18, .48);
  backdrop-filter: blur(8px);
}

.pair-modal-card {
  width: min(440px, 100%);
  max-height: min(760px, calc(100vh - 40px));
  overflow-y: auto;
  padding: 26px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: var(--surface-raised);
  color: var(--text);
  box-shadow: 0 30px 90px rgba(0, 0, 0, .25);
}

.pair-modal-heading {
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
}

.pair-modal-heading h3 {
  margin: 0 0 3px;
  font-size: 19px;
  line-height: 1.25;
}

.pair-modal-heading p {
  margin: 0;
  color: var(--text-muted);
  font-size: 12.5px;
  line-height: 1.45;
}

.pair-modal-icon {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 20px;
  font-weight: 750;
}

.pair-code-panel {
  margin-top: 20px;
  padding: 20px;
  border: 1px solid color-mix(in srgb, var(--accent) 12%, var(--border));
  border-radius: 15px;
  background: var(--accent-soft);
  text-align: center;
}

.pair-code-display {
  overflow: hidden;
  color: var(--accent);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: clamp(29px, 8vw, 36px);
  font-weight: 800;
  letter-spacing: .16em;
  text-indent: .16em;
  white-space: nowrap;
  user-select: all;
  cursor: pointer;
}

.pair-status {
  min-height: 20px;
  margin: 12px 0 0;
  color: var(--text-muted);
  font-size: 12.5px;
  text-align: center;
}

.new-pairing-details {
  margin-top: 14px;
  padding: 0 14px 14px;
  border: 1px solid var(--border);
  border-radius: 15px;
  background: color-mix(in srgb, var(--card) 72%, transparent);
}

.new-pairing-details summary {
  padding: 13px 0;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 680;
  cursor: pointer;
  list-style-position: inside;
}

.new-pairing-hint {
  margin: 0 0 10px;
  color: var(--text-muted);
  font-size: 12px;
  text-align: center;
}

.refresh-pair-code-button {
  display: block;
  min-height: 36px;
  margin: 10px auto 0;
  padding: 7px 13px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  color: var(--text-secondary);
  cursor: pointer;
}

.paired-phones-section {
  margin: 0;
  padding: 0;
}

.pair-modal-phones {
  max-height: 220px;
  margin-top: 18px;
  overflow-y: auto;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 15px;
  background: color-mix(in srgb, var(--card) 72%, transparent);
}

.paired-phones-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
}

.paired-phones-header > div {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 2px;
}

.paired-phones-header strong {
  color: var(--text-secondary);
  font-size: 12.5px;
  font-weight: 700;
}

.paired-phones-header span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.paired-phones-refresh {
  width: 24px;
  height: 24px;
  border-radius: 7px;
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
}

.paired-phones-refresh:hover {
  background: var(--card-hover);
  color: var(--text);
}

.paired-phone-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 8px;
  align-items: center;
  padding: 9px 9px 9px 10px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: color-mix(in srgb, var(--card) 72%, transparent);
}

.paired-phone-card + .paired-phone-card {
  margin-top: 8px;
}

.paired-phone-name {
  overflow: hidden;
  color: var(--text-secondary);
  font-size: 11.5px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.paired-phone-meta,
.paired-phones-empty,
.paired-phones-error {
  color: var(--text-muted);
  font-size: 10px;
  line-height: 1.4;
}

.paired-phone-remove {
  grid-row: 1 / span 2;
  grid-column: 2;
  min-width: 44px;
  height: 28px;
  padding: 0 9px;
  border: 1px solid color-mix(in srgb, var(--error) 22%, var(--border));
  border-radius: 8px;
  background: transparent;
  color: var(--error);
  font-size: 10.5px;
  font-weight: 650;
}

.paired-phone-remove:hover {
  background: color-mix(in srgb, var(--error) 10%, transparent);
  color: var(--error);
}

.paired-phones-empty,
.paired-phones-error {
  padding: 4px 2px;
}

.paired-phones-error {
  color: var(--error);
}

.pair-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 18px;
}

.pair-modal-actions button {
  min-height: 38px;
  padding: 8px 15px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 12.5px;
  font-weight: 620;
}

.pair-modal-actions button:hover {
  background: var(--card-hover);
  color: var(--text);
}

.pair-modal-actions .pair-modal-close {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.pair-modal-actions .pair-modal-close:hover {
  background: var(--accent-hover);
  color: #fff;
}

.approval-dialog {
  background: rgba(7, 10, 18, .48);
  backdrop-filter: blur(8px);
}

.approval-card {
  border-radius: 22px;
  background: var(--surface-raised);
  box-shadow: 0 30px 90px rgba(0,0,0,.25);
}

.dialog-symbol {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  margin-bottom: 16px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--error) 10%, var(--card));
  color: var(--error);
  font-size: 18px;
}

.approval-actions button {
  min-height: 38px;
  padding: 8px 15px;
  border-radius: 11px;
}

.approval-actions .danger {
  border-color: var(--error);
  background: var(--error);
  color: #fff;
}

#pairModal,
#connectModal,
#deviceListModal {
  background: rgba(7, 10, 18, .48) !important;
  backdrop-filter: blur(8px);
}

#pairModal > div,
#connectModal > div,
#deviceListModal > div {
  border: 1px solid var(--border) !important;
  border-radius: 22px !important;
  background: var(--card) !important;
  color: var(--text) !important;
  box-shadow: 0 30px 90px rgba(0,0,0,.25) !important;
}

#pairModal h3,
#connectModal h3,
#deviceListModal h3 {
  color: var(--text) !important;
}

#pairModal p,
#connectModal p,
#deviceListModal p {
  color: var(--text-secondary) !important;
}

#pairCodeDisplay {
  color: var(--accent) !important;
}

#pairModal > div > div:nth-of-type(1) {
  background: var(--accent-soft) !important;
}

@media (min-width: 1024px) {
  .sidebar {
    flex: 0 0 286px;
  }

  .chat-area {
    padding-top: 38px;
  }

  .message.assistant .bubble {
    max-width: min(78%, 780px);
  }

  .sidebar-close {
    display: none;
  }
}

@media (max-width: 1023px) {
  .sidebar {
    box-shadow: 22px 0 60px rgba(0,0,0,.18);
  }

  .topbar {
    min-height: 58px;
  }

  .chat-area {
    padding: 22px 18px 12px;
  }

  .input-bar {
    padding-inline: 14px;
  }
}

@media (max-width: 767px) {
  .sidebar {
    width: min(86vw, 312px);
    max-width: none;
  }

  .welcome {
    min-height: calc(100vh - 210px);
    padding: 7vh 14px 38px;
  }

  .welcome .logo {
    width: 56px;
    height: 56px;
    border-radius: 18px;
    font-size: 24px;
  }

  .welcome h1 {
    font-size: 25px;
  }

  .chat-area {
    padding: 18px 12px 10px;
  }

  .messages {
    gap: 14px;
  }

  .message.user .bubble {
    max-width: 86%;
  }

  .message.assistant .bubble {
    max-width: 92%;
  }

  .bubble {
    padding: 13px 15px;
    font-size: 14px;
  }

  .input-bar {
    padding: 5px 9px max(10px, env(safe-area-inset-bottom, 10px));
  }

  .permission-mode-row {
    overflow-x: auto;
    padding-inline: 5px;
    white-space: nowrap;
  }

  .input-wrapper {
    min-height: 52px;
    padding-left: 6px;
    border-radius: 17px;
  }

  .input-mode-select {
    padding-inline: 8px;
  }

  .input-mode-select #inputModeLabel {
    max-width: 38px;
    overflow: hidden;
  }

  .attach-btn,
  .send-btn {
    width: 38px;
    height: 38px;
  }
}

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

/* 2026-07 refined shell: one quiet hierarchy, task-first composer. */
[data-theme="light"] {
  --bg: #f7f8fa;
  --card: #ffffff;
  --card-hover: #f0f2f6;
  --text: #181a20;
  --text-secondary: #646b78;
  --text-muted: #969ca8;
  --accent: #615df2;
  --accent-hover: #514cdc;
  --accent-soft: rgba(97, 93, 242, .09);
  --sidebar-bg: #fbfbfc;
  --surface-raised: rgba(255, 255, 255, .97);
}

.sidebar {
  width: 252px;
}

.sidebar-header {
  padding: 18px 16px 13px;
}

.sidebar-header .sb-brand {
  gap: 10px;
}

.sidebar-header .sb-avatar,
.welcome .logo {
  overflow: hidden;
  padding: 0;
  border: 0;
  background: transparent;
  color: transparent;
  box-shadow: none;
}

.sidebar-header .sb-avatar {
  width: 36px;
  height: 36px;
  border-radius: 12px;
}

.sidebar-header .sb-avatar img,
.welcome .logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  transform: scale(1.12);
  transform-origin: center;
}

.sidebar-header .sb-avatar img {
  transform: scale(1.16);
}

.nav-page .nav-logo,
.mode-page .mode-logo,
.call-avatar,
.login-brand .logo {
  overflow: hidden;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.nav-page .nav-logo {
  width: 72px;
  height: 72px;
  margin: 0 auto 16px;
  border-radius: 23px;
}

.mode-page .mode-logo {
  width: 54px;
  height: 54px;
  margin: 0 auto 15px;
  border-radius: 18px;
}

.nav-page .nav-logo img,
.mode-page .mode-logo img,
.call-avatar img,
.login-brand .logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  transform: scale(1.12);
}

.call-avatar img {
  transform: scale(1.08);
}

.login-brand {
  justify-content: center;
}

.login-brand .logo {
  flex: 0 0 46px;
  width: 46px;
  height: 46px;
  border-radius: 15px;
}

.login-brand > strong {
  font-size: 17px;
  font-weight: 680;
  letter-spacing: -.025em;
}

.login-heading h2 {
  margin: 8px 0 0;
  text-align: center;
  font-size: 25px;
  font-weight: 650;
  letter-spacing: -.04em;
}

.sidebar-header .sb-title {
  font-size: 15px;
  font-weight: 680;
  letter-spacing: -.025em;
}

.sidebar-new-chat {
  min-height: 40px;
  margin: 2px 10px 6px;
  width: calc(100% - 20px);
  background: transparent;
  color: var(--text-secondary);
}

.sidebar-new-chat:hover {
  background: var(--card-hover);
  color: var(--text);
}

.sidebar-new-chat .nc-icon {
  width: 22px;
  height: 22px;
  border: 0;
  background: transparent;
  color: var(--text-secondary);
}

.welcome {
  min-height: calc(100vh - 238px);
  padding: clamp(48px, 9vh, 96px) 20px 50px;
}

.welcome .logo {
  width: 96px;
  height: 96px;
  margin-bottom: 23px;
  border-radius: 30px;
  filter: none;
}

.welcome h1 {
  font-size: clamp(27px, 2.25vw, 32px);
  font-weight: 650;
  line-height: 1.25;
  letter-spacing: -.045em;
}

.mode-toggle {
  margin-top: 22px;
}

.office-task-bar {
  display: flex;
  flex: 1 1 auto;
  width: auto;
  min-width: 0;
  gap: 4px;
  margin: 0;
  padding: 0;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.office-task-bar::-webkit-scrollbar {
  display: none;
}

.office-task-bar.selection-active {
  display: none;
}

.office-task-button {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 520;
  white-space: nowrap;
  transition: color var(--transition), background var(--transition), border-color var(--transition);
}

.office-task-button > span {
  display: inline-grid;
  place-items: center;
  width: 19px;
  height: 19px;
  border-radius: 6px;
  background: color-mix(in srgb, var(--text-muted) 9%, transparent);
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: 700;
}

.office-task-button:hover,
.office-task-button.active {
  border-color: color-mix(in srgb, var(--accent) 16%, var(--border));
  background: var(--accent-soft);
  color: var(--text);
}

.office-task-button.active > span {
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--accent);
}

.selected-office-task {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 6px 9px;
  border: 1px solid color-mix(in srgb, var(--accent) 18%, var(--border));
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 620;
  white-space: nowrap;
}

.selected-office-task:hover {
  background: color-mix(in srgb, var(--accent) 14%, transparent);
}

.input-wrapper {
  flex-wrap: nowrap;
}

.proactive-trigger {
  touch-action: none;
  user-select: none;
  cursor: grab;
  will-change: transform;
}

.proactive-trigger:active {
  cursor: grabbing;
}

@media (min-width: 1024px) {
  .sidebar {
    flex: 0 0 252px;
  }
}

@media (max-width: 767px) {
  .welcome {
    min-height: calc(100vh - 248px);
    padding: 48px 14px 34px;
  }

  .welcome .logo {
    width: 78px;
    height: 78px;
    border-radius: 25px;
  }

  .welcome h1 {
    font-size: 26px;
  }

  .composer-tools-row {
    gap: 7px;
    padding-inline: 3px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
  }

  .composer-tools-row::-webkit-scrollbar {
    display: none;
  }

  .permission-mode-label {
    display: none;
  }

  .permission-mode-row {
    min-height: 30px;
  }

  .office-task-button {
    min-height: 32px;
    padding: 5px 8px;
  }

  .selected-office-task {
    max-width: 108px;
  }

  .selected-office-task #selectedOfficeTaskLabel {
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

/* Mobile feature surfaces: compact sheets, stable controls, no vertical text. */
.mobile-sheet-handle {
  display: none;
}

.mobile-sheet-close {
  display: inline-grid;
  flex: 0 0 auto;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--text-secondary);
  font: 400 25px/1 system-ui, sans-serif;
  cursor: pointer;
}

.mobile-sheet-close:hover {
  background: var(--card-hover);
  color: var(--text);
}

.device-list-card {
  width: min(440px, 92vw);
  max-height: min(760px, 84vh);
  overflow: hidden;
  padding: 24px;
  text-align: left;
}

.device-list-heading {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px;
}

.device-list-heading-icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 13px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 18px;
}

#deviceListModal .device-list-heading h3 {
  margin: 0 0 3px !important;
  font-size: 19px !important;
  line-height: 1.25;
}

#deviceListModal .device-list-heading p {
  margin: 0 !important;
  color: var(--text-muted) !important;
  font-size: 12px !important;
}

.device-list-content {
  max-height: min(440px, 52vh);
  margin-top: 18px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.device-list-empty {
  margin-top: 18px;
  padding: 30px 16px;
  border: 1px dashed var(--border);
  border-radius: 15px;
  color: var(--text-muted);
  text-align: center;
}

#deviceListModal .paired-device-row {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) !important;
  gap: 14px !important;
  align-items: stretch !important;
  margin: 0 0 10px !important;
  padding: 14px !important;
  border: 1px solid var(--border) !important;
  border-radius: 15px !important;
  background: color-mix(in srgb, var(--card) 76%, var(--bg)) !important;
  color: var(--text) !important;
}

.paired-device-summary {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.paired-device-symbol {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 15px;
}

#deviceListModal .paired-device-name {
  overflow: hidden;
  color: var(--text) !important;
  font-size: 13px;
  font-weight: 680;
  line-height: 1.4;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.paired-device-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 11px;
}

.paired-device-status i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.paired-device-status.online {
  color: var(--success);
}

#deviceListModal .paired-device-actions {
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  gap: 8px !important;
  width: 100% !important;
}

#deviceListModal .paired-device-actions button {
  width: 100% !important;
  min-width: 0 !important;
  min-height: 40px !important;
  padding: 8px 10px !important;
  border: 1px solid var(--border) !important;
  border-radius: 11px !important;
  background: var(--card) !important;
  color: var(--text-secondary) !important;
  font-size: 12px !important;
  font-weight: 640;
  line-height: 1.2;
  white-space: nowrap !important;
  writing-mode: horizontal-tb !important;
}

#deviceListModal .paired-device-actions .device-action-control {
  border-color: var(--accent) !important;
  background: var(--accent) !important;
  color: #fff !important;
}

#deviceListModal .paired-device-actions .device-action-remove {
  grid-column: 1 / -1;
  border-color: color-mix(in srgb, var(--error) 26%, var(--border)) !important;
  color: var(--error) !important;
}

.device-list-footer {
  display: grid;
  grid-template-columns: .75fr 1.25fr;
  gap: 9px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.device-list-footer button {
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
}

.device-list-footer .device-list-primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.screen-preview-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 32px;
  padding: 6px 10px;
  border: 1px solid #475569;
  border-radius: 9px;
  background: #1e293b;
  color: #f8fafc;
  font-size: 12px;
  line-height: 1;
  white-space: nowrap;
  writing-mode: horizontal-tb;
  cursor: pointer;
}

.screen-preview-close {
  width: 34px;
  padding-inline: 0;
  font-size: 20px;
}

.screen-preview-stage {
  position: relative;
}

.screen-preview-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 10px;
  color: #94a3b8;
  font-size: 12px;
}

.screen-preview-spinner {
  width: 22px;
  height: 22px;
  border: 2px solid rgba(148, 163, 184, .25);
  border-top-color: #a5b4fc;
  border-radius: 50%;
  animation: screen-preview-spin .8s linear infinite;
}

.screen-preview-panel[data-preview-state="ready"] .screen-preview-placeholder {
  display: none;
}

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

.skills-empty {
  padding: 22px 16px;
  border: 1px dashed var(--border);
  border-radius: 14px;
  color: var(--text-muted);
  text-align: center;
}

@media (max-width: 720px) {
  html.mobile-web body #skillsModal,
  html.mobile-web body #memoryModal,
  html.mobile-web body #deviceListModal {
    align-items: flex-end !important;
    justify-content: center !important;
    padding: 0 !important;
    background: rgba(10, 14, 24, .44) !important;
    backdrop-filter: blur(7px);
  }

  html.mobile-web body #skillsModal > .skills-modal-card,
  html.mobile-web body #memoryModal > .memory-modal-card,
  html.mobile-web body #deviceListModal > .device-list-card {
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    border-right: 0 !important;
    border-bottom: 0 !important;
    border-left: 0 !important;
    border-radius: 24px 24px 0 0 !important;
    box-sizing: border-box !important;
    box-shadow: 0 -18px 60px rgba(15, 23, 42, .2) !important;
  }

  html.mobile-web body #skillsModal > .skills-modal-card {
    height: auto !important;
    max-height: min(86dvh, 720px) !important;
    padding: 8px 16px calc(16px + env(safe-area-inset-bottom, 0px)) !important;
    overflow: hidden !important;
  }

  html.mobile-web body #memoryModal > .memory-modal-card {
    height: min(88dvh, 760px) !important;
    max-height: min(88dvh, 760px) !important;
    padding: 8px 14px calc(14px + env(safe-area-inset-bottom, 0px)) !important;
    overflow: hidden !important;
  }

  html.mobile-web body #deviceListModal > .device-list-card {
    max-height: min(86dvh, 680px) !important;
    padding: 8px 16px calc(16px + env(safe-area-inset-bottom, 0px)) !important;
    overflow: hidden !important;
  }

  html.mobile-web .mobile-sheet-handle {
    display: block;
    width: 38px;
    height: 4px;
    margin: 1px auto 9px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--text-muted) 32%, transparent);
  }

  html.mobile-web .mobile-sheet-close {
    width: 40px;
    height: 40px;
    border-radius: 13px;
    background: color-mix(in srgb, var(--text-muted) 8%, transparent);
  }

  html.mobile-web .skills-modal-heading,
  html.mobile-web .memory-modal-heading {
    min-height: 50px;
  }

  html.mobile-web .skills-modal-heading h3,
  html.mobile-web .memory-modal-heading h3 {
    font-size: 20px !important;
    letter-spacing: -.03em;
  }

  html.mobile-web #skillsList {
    flex: 0 1 auto;
    min-height: 0 !important;
    max-height: min(42dvh, 340px);
    margin: 12px 0 !important;
    overscroll-behavior: contain;
  }

  html.mobile-web .skill-install-panel {
    flex: 0 0 auto;
    padding-top: 14px !important;
  }

  html.mobile-web .skill-install-panel > div:nth-of-type(1) {
    align-items: stretch;
  }

  html.mobile-web #skillSourceInput {
    height: 44px;
    font-size: 13px !important;
  }

  html.mobile-web #skillInstallHint {
    max-height: 4.7em;
    overflow-y: auto;
    line-height: 1.55;
  }

  html.mobile-web .memory-mode-tabs {
    position: relative;
    display: flex !important;
    flex: 0 0 auto !important;
    gap: 7px !important;
    margin: 10px -2px 8px !important;
    padding: 2px 2px 7px !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  html.mobile-web .memory-mode-tabs::-webkit-scrollbar {
    display: none;
  }

  html.mobile-web #memoryModal .memory-mode-btn {
    flex: 0 0 auto !important;
    min-width: auto !important;
    min-height: 38px !important;
    padding: 8px 12px !important;
    border-radius: 11px !important;
    font-size: 12px !important;
    scroll-snap-align: start;
    white-space: nowrap !important;
    writing-mode: horizontal-tb !important;
  }

  html.mobile-web #memoryViewPane {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    overflow: auto;
  }

  html.mobile-web #memoryModal #memoryGraph {
    flex: 0 0 auto !important;
    width: 100%;
    height: clamp(280px, 48dvh, 410px) !important;
    min-height: 280px !important;
    border-radius: 15px !important;
  }

  html.mobile-web #memoryGraphDetail {
    margin-top: 8px !important;
    padding: 11px 12px !important;
  }

  html.mobile-web #memorySearchPane > div,
  html.mobile-web #memoryFocusPane > div,
  html.mobile-web #memoryCleanupPane > div,
  html.mobile-web #memorySharePane > div,
  html.mobile-web #memoryLearnPane > div {
    margin-top: 2px !important;
  }

  html.mobile-web #memoryFocusPane > div > div:first-child {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  html.mobile-web #memoryCleanupPane > div > div:first-child {
    flex-wrap: wrap;
  }

  html.mobile-web #memorySharePane > div,
  html.mobile-web #memoryLearnPane > div {
    padding: 14px !important;
  }

  html.mobile-web .device-list-heading {
    min-height: 50px;
  }

  html.mobile-web .device-list-heading-icon {
    width: 38px;
    height: 38px;
  }

  html.mobile-web .device-list-content {
    max-height: min(46dvh, 360px);
    margin-top: 13px;
  }

  html.mobile-web #deviceListModal .paired-device-row {
    gap: 12px !important;
    padding: 13px !important;
    border-radius: 14px !important;
  }

  html.mobile-web .device-list-footer {
    margin-top: 12px;
    padding-top: 12px;
  }

  html.mobile-web #screenPreviewPanel {
    top: calc(76px + env(safe-area-inset-top, 0px)) !important;
    right: 12px !important;
    bottom: auto !important;
    left: 12px !important;
    width: auto !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: min(58dvh, 480px) !important;
    border-radius: 18px !important;
    box-shadow: 0 18px 54px rgba(2, 6, 23, .32) !important;
  }

  html.mobile-web .screen-preview-header {
    display: grid !important;
    grid-template-columns: auto minmax(0, 1fr) auto !important;
    grid-template-rows: auto auto;
    min-height: 58px !important;
    height: auto !important;
    gap: 2px 9px !important;
    padding: 8px 9px 8px 12px !important;
  }

  html.mobile-web .screen-preview-title {
    grid-column: 1;
    grid-row: 1;
    align-self: end;
    font-size: 13px !important;
    white-space: nowrap !important;
  }

  html.mobile-web .screen-preview-status {
    grid-column: 1 / 3 !important;
    grid-row: 2 !important;
    min-width: 0;
    font-size: 10px !important;
  }

  html.mobile-web .screen-preview-actions {
    grid-column: 3 !important;
    grid-row: 1 / 3 !important;
    align-self: center;
    gap: 6px !important;
    margin-left: 0 !important;
  }

  html.mobile-web .screen-preview-action {
    min-height: 36px !important;
    padding: 7px 9px !important;
    border-radius: 10px !important;
    font-size: 11px !important;
    white-space: nowrap !important;
    word-break: keep-all !important;
    writing-mode: horizontal-tb !important;
  }

  html.mobile-web .screen-preview-close {
    width: 36px;
    padding: 0 !important;
    font-size: 19px !important;
  }

  html.mobile-web .screen-preview-stage {
    position: relative;
    width: 100%;
    height: auto !important;
    max-height: min(48dvh, 420px) !important;
    aspect-ratio: 16 / 10;
    align-items: center !important;
  }

  html.mobile-web #screenPreviewImage {
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    max-height: none !important;
    object-fit: contain !important;
  }
}

@media (max-width: 390px) {
  html.mobile-web .skill-install-panel > div:nth-of-type(1) {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 7px !important;
  }

  html.mobile-web #deviceListModal .paired-device-actions button {
    min-height: 38px !important;
  }
}
