/* 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;
  }
}

.memory-graph-toolbar {
  display: flex;
  min-height: 30px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--text-secondary);
  font-size: 12px;
}

.memory-motion-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
}

.memory-motion-toggle input {
  accent-color: #818cf8;
}

.memory-graph-legend {
  margin: 3px 0 7px;
  color: var(--text-secondary);
  font-size: 11px;
  line-height: 1.35;
}

.memory-graph-projection-error {
  display: grid;
  min-height: 100%;
  place-items: center;
  padding: 24px;
  color: #fca5a5;
  font-size: 13px;
  text-align: center;
}

.memory-graph-node {
  transform-box: fill-box;
  transform-origin: center;
  transition: filter 160ms ease, opacity 160ms ease, stroke-width 160ms ease;
  will-change: auto;
}

.memory-graph-node[data-motion-active="true"] {
  will-change: transform;
}

.memory-graph-node:hover,
.memory-graph-node.is-hovered {
  filter: brightness(1.18) drop-shadow(0 0 7px rgba(129, 140, 248, .5));
}

.memory-graph-node.is-selected {
  filter: brightness(1.2) drop-shadow(0 0 9px rgba(255, 255, 255, .48));
  stroke-width: 2.5;
}

.memory-graph-node.is-related {
  stroke-width: 1.8;
}

.memory-graph-node.is-dimmed {
  opacity: .34;
}

.memory-graph-node[data-memory-state="pending"] {
  stroke-dasharray: 3 2;
}

.memory-graph-node[data-memory-state="syncing"] {
  stroke-dasharray: 2 2;
  animation: memory-projection-pulse 1.8s ease-in-out infinite;
}

#memoryGraph[data-reduced-motion="true"] .memory-graph-node[data-memory-state="syncing"] {
  animation: none;
}

.memory-graph-node[data-memory-state="review"] {
  stroke-dasharray: 1 3;
}

.memory-graph-node[data-memory-state="projection-failed"] {
  stroke-width: 2.4;
  stroke-dasharray: 5 2;
}

.memory-graph-node:focus-visible {
  outline: none;
  stroke: #ffffff;
  stroke-width: 3;
  filter: drop-shadow(0 0 0.35rem rgba(129, 140, 248, .95));
}

.memory-graph-edge {
  transition: opacity 160ms ease, stroke-width 160ms ease;
}

.memory-graph-edge.is-dimmed {
  opacity: .16;
}

.memory-graph-edge.is-related {
  opacity: .9;
  stroke-width: 1.8;
}

@keyframes memory-projection-pulse {
  0%, 100% { stroke-opacity: .38; }
  50% { stroke-opacity: .92; }
}

@media (prefers-reduced-motion: reduce) {
  .memory-graph-node,
  .memory-graph-edge {
    transition: none;
    will-change: auto;
  }

  .memory-graph-node[data-memory-state="syncing"] {
    animation: none;
  }
}

/* 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-remove {
  grid-column: auto !important;
  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 #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 #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;
  }
}

/* 2026-08 chat workspace refinement: quiet navigation and a stable composer. */
.sidebar {
  width: 272px;
  background: color-mix(in srgb, var(--sidebar-bg) 96%, transparent);
}

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

.sidebar-new-chat {
  min-height: 44px;
  margin-inline: 12px;
  width: calc(100% - 24px);
  padding-inline: 13px;
  border: 1px solid transparent;
  border-radius: 13px;
}

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

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

.sidebar-tools-header {
  padding: 7px 10px 8px !important;
}

.sidebar-tools-title {
  font-size: 10px;
  font-weight: 680;
  letter-spacing: .12em;
}

.sidebar-tools-list {
  display: grid;
  gap: 4px;
  padding: 0 !important;
}

.sidebar-tool-group {
  min-width: 0;
}

.sidebar-tool-group > summary {
  list-style: none;
}

.sidebar-tool-group > summary::-webkit-details-marker {
  display: none;
}

.tool-item {
  width: 100%;
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 !important;
  padding: 7px 9px !important;
  border: 1px solid transparent;
  border-radius: 12px !important;
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  transition: color var(--transition), background var(--transition), border-color var(--transition);
}

.tool-item:hover,
.sidebar-tool-group[open] > .tool-item-primary {
  border-color: color-mix(in srgb, var(--border) 80%, transparent);
  background: color-mix(in srgb, var(--card-hover) 72%, transparent);
  color: var(--text);
}

.tool-item[hidden] {
  display: none;
}

.tool-symbol {
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  margin: 0;
  border: 1px solid color-mix(in srgb, var(--border) 72%, transparent);
  border-radius: 9px;
  background: color-mix(in srgb, var(--card) 72%, transparent);
  color: var(--text-secondary);
  font-size: 13px;
}

.tool-label {
  min-width: 0;
  flex: 1;
  color: inherit !important;
  font-size: 13px !important;
  font-weight: 560;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tool-chevron {
  flex: 0 0 auto;
  margin-left: auto;
  color: var(--text-muted) !important;
  font-size: 17px !important;
  line-height: 1;
  transition: transform var(--transition);
}

.sidebar-tool-group[open] .tool-chevron {
  transform: rotate(90deg);
}

.sidebar-tool-children {
  position: relative;
  display: grid;
  gap: 2px;
  margin: 4px 0 5px 18px;
  padding-left: 13px;
}

.sidebar-tool-children::before {
  content: '';
  position: absolute;
  left: 0;
  top: 4px;
  bottom: 4px;
  width: 1px;
  background: color-mix(in srgb, var(--border) 82%, transparent);
}

.tool-item-child {
  min-height: 38px;
  padding: 5px 8px !important;
  border-radius: 10px !important;
  font-size: 12.5px;
}

.tool-item-child .tool-symbol {
  flex-basis: 24px;
  width: 24px;
  height: 24px;
  border: 0;
  background: transparent;
  font-size: 12px;
}

.tool-item-child .tool-label {
  font-size: 12.5px !important;
  font-weight: 520;
}

.tool-badge {
  display: none;
  min-width: 18px;
  height: 18px;
  margin-left: auto;
  padding: 0 5px;
  border-radius: 999px;
  background: #ef4444;
  color: #fff !important;
  font: 650 10px/18px system-ui, sans-serif !important;
  text-align: center;
}

.sidebar-divider {
  margin: 9px 18px;
  opacity: .72;
}

.input-bar {
  padding-top: 10px;
  background: linear-gradient(180deg, transparent 0, color-mix(in srgb, var(--bg) 97%, transparent) 24%);
}

.composer-tools-row {
  margin-bottom: 8px;
}

.input-wrapper {
  min-height: 58px;
  padding: 8px;
  border-radius: 20px;
  box-shadow: 0 14px 42px rgba(15, 23, 42, .075);
}

.input-wrapper:focus-within {
  transform: translateY(-1px);
  box-shadow: 0 18px 48px color-mix(in srgb, var(--accent) 9%, rgba(15, 23, 42, .08));
}

.input-mode-select {
  flex: 0 0 96px;
  width: 96px;
  min-width: 96px;
  min-height: 40px;
  justify-content: flex-start;
  gap: 6px;
  padding: 7px 9px;
  box-sizing: border-box;
}

.input-mode-select > .mode-icon {
  flex: 0 0 16px;
  width: 16px;
  text-align: center;
}

.input-mode-select > #inputModeLabel {
  flex: 0 0 28px;
  width: 28px;
  text-align: left;
}

.input-mode-select > .mode-arrow {
  flex: 0 0 10px;
  width: 10px;
  margin-left: auto;
  text-align: center;
}

.input-mode-select .mode-dropdown {
  min-width: 176px;
  padding: 6px;
  border-radius: 14px;
  box-shadow: 0 18px 50px rgba(15, 23, 42, .16);
}

.input-mode-select .mode-option {
  min-height: 40px;
  padding: 9px 11px;
  border-radius: 10px;
}

.attach-btn,
.send-btn {
  flex: 0 0 40px;
}

.input-wrapper textarea {
  min-width: 0;
  padding-inline: 8px;
}

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

@media (max-width: 767px) {
  .sidebar {
    width: min(88vw, 316px);
  }

  .sidebar-tools-section {
    padding-inline: 9px;
  }

  .input-wrapper {
    min-height: 56px;
    padding: 7px;
  }

  .input-mode-select {
    flex-basis: 88px;
    width: 88px;
    min-width: 88px;
    padding-inline: 7px;
  }
}

/* 2026-08 workspace panels: compact, content-led management surfaces. */
.workspace-modal {
  padding: 24px !important;
  background: rgba(10, 14, 24, .46) !important;
  backdrop-filter: blur(14px) saturate(112%);
}

body .workspace-modal > .workspace-modal-card {
  box-sizing: border-box;
  border: 1px solid color-mix(in srgb, var(--border) 78%, transparent) !important;
  border-radius: 24px !important;
  background: color-mix(in srgb, var(--card) 98%, transparent) !important;
  box-shadow: 0 28px 90px rgba(15, 23, 42, .24) !important;
}

.workspace-modal-eyebrow {
  margin-bottom: 5px;
  color: var(--accent);
  font-size: 9px;
  font-weight: 750;
  letter-spacing: .16em;
  line-height: 1;
}

.workspace-modal-card h3 {
  letter-spacing: -.035em;
}

.workspace-modal-card .mobile-sheet-close {
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  border: 1px solid transparent !important;
  border-radius: 13px !important;
  background: color-mix(in srgb, var(--text-muted) 7%, transparent) !important;
  color: var(--text-secondary) !important;
  font-size: 22px !important;
  line-height: 1;
  transition: background var(--transition), color var(--transition), transform var(--transition);
}

.workspace-modal-card .mobile-sheet-close:hover {
  background: color-mix(in srgb, var(--text-muted) 13%, transparent) !important;
  color: var(--text) !important;
  transform: rotate(4deg);
}

body #naturalCompanionModal > .natural-companion-card {
  width: min(760px, calc(100vw - 48px)) !important;
  height: auto !important;
  min-height: 440px;
  max-height: min(720px, calc(100dvh - 48px)) !important;
  padding: 28px !important;
  overflow: hidden;
}

.natural-companion-heading {
  flex: 0 0 auto;
}

.natural-companion-tabs {
  align-self: flex-start;
  gap: 4px !important;
  margin: 22px 0 12px !important;
  padding: 4px;
  border: 1px solid color-mix(in srgb, var(--border) 82%, transparent);
  border-radius: 14px;
  background: color-mix(in srgb, var(--bg) 70%, transparent);
}

.natural-companion-tabs button {
  min-height: 38px;
  padding: 8px 15px !important;
  border: 0 !important;
  border-radius: 10px !important;
  background: transparent !important;
  color: var(--text-muted) !important;
  font-weight: 620 !important;
}

.natural-companion-tabs button.active {
  background: var(--card) !important;
  color: var(--text) !important;
  box-shadow: 0 5px 18px rgba(15, 23, 42, .09);
}

.natural-companion-status {
  min-height: 16px !important;
  margin: 0 2px 12px !important;
  color: var(--text-muted) !important;
  font-size: 11px !important;
}

.natural-companion-status:empty {
  display: none;
}

#naturalCompanionBody {
  min-height: 0;
  padding: 2px 3px 3px;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--text-muted) 25%, transparent) transparent;
}

.natural-companion-list-head {
  display: flex !important;
  align-items: center;
  justify-content: space-between;
  gap: 16px !important;
  margin: 0 0 14px !important;
}

.natural-companion-list-head h4 {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 14px !important;
  font-weight: 680;
}

.natural-companion-count {
  display: inline-grid;
  min-width: 22px;
  height: 22px;
  place-items: center;
  padding: 0 6px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 9%, transparent);
  color: var(--accent);
  font-size: 11px;
}

.natural-companion-secondary-action {
  min-height: 36px;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  font-size: 12px;
  font-weight: 610;
  cursor: pointer;
}

.natural-companion-secondary-action:hover {
  border-color: color-mix(in srgb, var(--accent) 35%, var(--border));
  background: color-mix(in srgb, var(--accent) 5%, transparent);
  color: var(--text);
}

.natural-companion-empty {
  min-height: 238px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 8px;
  box-sizing: border-box;
  padding: 32px !important;
  border: 1px dashed color-mix(in srgb, var(--border) 88%, transparent);
  border-radius: 18px;
  background: color-mix(in srgb, var(--bg) 55%, transparent);
  color: var(--text-muted);
}

.natural-companion-empty-icon {
  display: grid;
  width: 44px;
  height: 44px;
  margin-bottom: 3px;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--accent) 14%, var(--border));
  border-radius: 15px;
  background: color-mix(in srgb, var(--accent) 7%, var(--card));
  color: var(--accent);
  font-size: 20px;
}

.natural-companion-empty strong {
  color: var(--text);
  font-size: 14px;
  font-weight: 670;
}

.natural-companion-empty small {
  max-width: 360px;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.65;
  text-align: center;
}

.natural-companion-card-item {
  padding: 16px !important;
  border-color: color-mix(in srgb, var(--border) 82%, transparent) !important;
  border-radius: 15px !important;
  background: color-mix(in srgb, var(--bg) 62%, transparent) !important;
}

body #skillsModal > .skills-modal-card {
  width: min(820px, calc(100vw - 48px)) !important;
  max-height: min(760px, calc(100dvh - 48px)) !important;
  padding: 28px !important;
  overflow: hidden;
}

#skillsList {
  min-height: 150px !important;
  max-height: min(470px, 55dvh);
  margin: 20px -3px 16px 0 !important;
  padding: 0 7px 0 0;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--text-muted) 25%, transparent) transparent;
}

.skill-card {
  padding: 18px !important;
  border-color: color-mix(in srgb, var(--border) 82%, transparent) !important;
  border-radius: 17px !important;
  background: color-mix(in srgb, var(--bg) 62%, transparent) !important;
}

.skill-card-head strong {
  display: block;
  font-size: 16px;
  letter-spacing: -.025em;
}

.skill-status {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 7px !important;
  color: var(--success) !important;
}

.skill-status::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 12%, transparent);
}

.skill-auto {
  padding: 6px 9px !important;
  border: 1px solid color-mix(in srgb, var(--accent) 12%, transparent);
  background: color-mix(in srgb, var(--accent) 7%, transparent) !important;
  color: var(--accent) !important;
  font-weight: 620;
}

.skill-description {
  margin-top: 14px !important;
  color: var(--text-secondary) !important;
  line-height: 1.72 !important;
}

.skill-chip {
  padding: 5px 8px !important;
  border-color: color-mix(in srgb, var(--border) 86%, transparent) !important;
  background: var(--card) !important;
  color: var(--text-muted);
}

.skill-example {
  position: relative;
  min-height: 42px;
  padding: 10px 38px 10px 12px !important;
  border-color: color-mix(in srgb, var(--border) 80%, transparent) !important;
  border-radius: 11px !important;
  background: var(--card) !important;
  font-size: 12.5px;
}

.skill-example::after {
  content: '↗';
  position: absolute;
  top: 50%;
  right: 13px;
  color: var(--text-muted);
  transform: translateY(-50%);
}

.skills-empty {
  min-height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 7px;
  background: color-mix(in srgb, var(--bg) 54%, transparent);
}

.skills-empty > span {
  margin-bottom: 4px;
  color: var(--accent);
  font-size: 22px;
}

.skills-empty strong {
  color: var(--text);
  font-size: 14px;
}

.skills-empty small {
  color: var(--text-muted);
  font-size: 12px;
  text-align: center;
}

.skill-install-panel {
  flex: 0 0 auto;
  padding: 0 !important;
  border: 1px solid color-mix(in srgb, var(--border) 82%, transparent) !important;
  border-radius: 15px;
  background: color-mix(in srgb, var(--bg) 48%, transparent);
  overflow: hidden;
}

.skill-install-panel > summary {
  min-height: 54px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 15px;
  list-style: none;
  color: var(--text);
  font-size: 13px;
  font-weight: 660;
  cursor: pointer;
}

.skill-install-panel > summary::-webkit-details-marker {
  display: none;
}

.skill-install-panel > summary small {
  margin-left: auto;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 500;
}

.skill-install-panel > summary::after {
  content: '⌄';
  color: var(--text-muted);
  font-size: 16px;
  transition: transform var(--transition);
}

.skill-install-panel[open] > summary::after {
  transform: rotate(180deg);
}

.skill-install-form {
  padding: 14px 15px 0;
  border-top: 1px solid color-mix(in srgb, var(--border) 72%, transparent);
}

.skill-install-form input {
  height: 44px;
  box-sizing: border-box;
  border-radius: 11px !important;
  background: var(--card) !important;
}

.skill-install-form button {
  min-width: 96px;
  border-radius: 11px !important;
  font-weight: 650;
}

#skillInstallHint {
  margin: 8px 15px 14px !important;
  line-height: 1.55;
}

body #memoryModal > .memory-modal-card {
  width: min(1060px, calc(100vw - 48px)) !important;
  height: auto !important;
  min-height: 440px;
  max-height: min(760px, calc(100dvh - 48px)) !important;
  padding: 28px !important;
  overflow: hidden;
}

body #memoryModal[data-memory-mode="view"] > .memory-modal-card {
  height: min(760px, calc(100dvh - 48px)) !important;
}

body #memoryModal:not([data-memory-mode="view"]) > .memory-modal-card {
  min-height: min(500px, calc(100dvh - 48px));
}

.memory-mode-tabs {
  flex: 0 0 auto;
  gap: 4px !important;
  margin: 22px 0 14px !important;
  padding: 4px !important;
  border: 1px solid color-mix(in srgb, var(--border) 82%, transparent);
  border-radius: 14px;
  background: color-mix(in srgb, var(--bg) 70%, transparent);
  overflow-x: auto;
  scrollbar-width: none;
}

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

#memoryModal .memory-mode-btn {
  min-height: 38px;
  padding: 8px 14px !important;
  border: 0 !important;
  border-radius: 10px !important;
  background: transparent !important;
  color: var(--text-muted) !important;
  font-size: 12.5px;
  font-weight: 620;
  white-space: nowrap;
}

#memoryModal .memory-mode-btn.active {
  background: var(--card) !important;
  color: var(--text) !important;
  box-shadow: 0 5px 18px rgba(15, 23, 42, .09);
}

.memory-graph-toolbar {
  min-height: 34px;
  margin-bottom: 8px;
  padding: 0 2px;
}

#memoryViewPane {
  position: relative;
}

.memory-motion-toggle {
  font-size: 11px !important;
}

#memoryMotionStatus {
  font-size: 11px;
}

.memory-graph-legend {
  position: absolute;
  z-index: 3;
  top: 0;
  right: 2px;
  margin-top: 0;
  color: var(--text-muted);
  font-size: 11px;
}

.memory-graph-legend > summary {
  padding: 6px 9px;
  border-radius: 8px;
  list-style: none;
  cursor: pointer;
}

.memory-graph-legend > summary::-webkit-details-marker {
  display: none;
}

.memory-graph-legend[open] {
  width: min(310px, calc(100% - 80px));
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--card);
  box-shadow: 0 14px 34px rgba(15, 23, 42, .14);
}

.memory-graph-legend[open] > span {
  display: block;
  padding: 2px 8px 6px;
  line-height: 1.55;
}

#memoryModal #memoryGraph {
  border-color: color-mix(in srgb, #64748b 28%, transparent) !important;
  border-radius: 18px !important;
  background:
    radial-gradient(circle at 50% 44%, rgba(99, 102, 241, .10), transparent 34%),
    linear-gradient(145deg, #151820, #11131a) !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .035);
}

#memorySearchPane > div,
#memoryFocusPane > div,
#memorySharePane > div,
#memoryLearnPane > div {
  width: min(100%, 760px);
  box-sizing: border-box;
}

#memorySearchPane input,
#memoryFocusPane input,
#memoryFocusPane select,
#memorySharePane input,
#memorySharePane textarea,
#memoryLearnPane input {
  border-radius: 11px !important;
}

#memorySharePane > div,
#memoryLearnPane > div {
  padding: 22px !important;
  border-color: color-mix(in srgb, var(--border) 82%, transparent) !important;
  border-radius: 17px !important;
  background: color-mix(in srgb, var(--bg) 55%, transparent) !important;
}

@media (max-width: 720px) {
  .workspace-modal {
    align-items: flex-end !important;
    padding: 0 !important;
  }

  html.mobile-web body #naturalCompanionModal.workspace-modal > .natural-companion-card.workspace-modal-card,
  html.mobile-web body #skillsModal.workspace-modal > .skills-modal-card.workspace-modal-card,
  html.mobile-web body #memoryModal.workspace-modal > .memory-modal-card.workspace-modal-card {
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 8px 16px calc(16px + env(safe-area-inset-bottom, 0px)) !important;
    border-right: 0 !important;
    border-bottom: 0 !important;
    border-left: 0 !important;
    border-radius: 24px 24px 0 0 !important;
    box-shadow: 0 -18px 60px rgba(15, 23, 42, .2) !important;
  }

  html.mobile-web body #naturalCompanionModal.workspace-modal > .natural-companion-card.workspace-modal-card {
    height: auto !important;
    min-height: min(520px, 82dvh);
    max-height: 88dvh !important;
  }

  html.mobile-web body #skillsModal.workspace-modal > .skills-modal-card.workspace-modal-card {
    height: auto !important;
    max-height: 88dvh !important;
  }

  html.mobile-web body #memoryModal.workspace-modal > .memory-modal-card.workspace-modal-card {
    height: auto !important;
    min-height: 64dvh;
    max-height: 92dvh !important;
    padding-inline: 14px !important;
  }

  html.mobile-web body #memoryModal.workspace-modal[data-memory-mode="view"] > .memory-modal-card.workspace-modal-card {
    height: 92dvh !important;
  }

  .workspace-modal-eyebrow {
    display: none;
  }

  .natural-companion-tabs,
  .memory-mode-tabs {
    margin-top: 12px !important;
  }

  .natural-companion-empty {
    min-height: 230px;
  }

  #skillsList {
    max-height: min(49dvh, 410px);
    margin-top: 12px !important;
  }

  .skill-install-panel > summary small {
    display: none;
  }

  .skill-install-form {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 7px !important;
  }

  .skill-install-form button {
    min-width: 82px;
    padding-inline: 11px !important;
  }

  html.mobile-web .memory-mode-tabs {
    margin-inline: 0 !important;
    padding: 4px !important;
  }

  html.mobile-web #memoryModal .memory-mode-btn {
    min-height: 36px !important;
    padding: 7px 11px !important;
  }

  .memory-graph-toolbar {
    min-height: 30px;
  }

  .memory-graph-legend {
    right: 24px;
    top: 0;
    margin-top: 0;
  }

  html.mobile-web #memoryModal #memoryGraph {
    height: clamp(300px, 52dvh, 440px) !important;
  }
}

@media (max-width: 420px) {
  .natural-companion-list-head {
    align-items: flex-start;
  }

  .natural-companion-secondary-action {
    font-size: 11px;
  }

  .skill-card {
    padding: 15px !important;
  }

  .skill-auto {
    padding-inline: 7px !important;
  }
}

/* Compact shared-memory workspace */
#memoryModal .memory-form-pane {
  padding: 8px 2px 2px !important;
  scrollbar-width: thin;
}

#memoryModal .memory-pane-card {
  width: min(100%, 820px) !important;
  margin: 8px auto 16px !important;
  padding: 0 !important;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--border) 88%, transparent) !important;
  border-radius: 18px !important;
  background: color-mix(in srgb, var(--card) 92%, var(--bg)) !important;
  box-shadow: 0 14px 40px rgba(15, 23, 42, .055);
}

#memoryModal .memory-learn-card {
  width: min(100%, 700px) !important;
}

#memoryModal .memory-pane-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 21px 24px 19px;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 76%, transparent);
}

#memoryModal .memory-pane-card-head h4 {
  margin: 0;
  color: var(--text);
  font-size: 17px;
  font-weight: 720;
  letter-spacing: -.02em;
}

#memoryModal .memory-pane-card-head p {
  margin: 6px 0 0;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.55;
}

#memoryModal .memory-pane-card-head > span {
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--accent);
  font-size: 16px;
}

#memoryModal .memory-form-section {
  padding: 17px 24px;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
}

#memoryModal .memory-form-label {
  margin-bottom: 11px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
}

#memoryModal .memory-choice-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

#memoryModal .memory-choice,
#memoryModal .memory-category-group label {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  gap: 7px;
  box-sizing: border-box;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
}

#memoryModal .memory-choice {
  padding: 7px 11px;
}

#memoryModal .memory-choice:has(input:checked),
#memoryModal .memory-category-group label:has(input:checked) {
  border-color: color-mix(in srgb, var(--accent) 35%, var(--border));
  background: color-mix(in srgb, var(--accent-soft) 76%, var(--card));
  color: var(--text);
}

#memoryModal .memory-choice input,
#memoryModal .memory-category-group input {
  width: 14px;
  height: 14px;
  margin: 0;
  accent-color: var(--accent);
}

#memoryModal .memory-category-groups {
  display: grid;
  gap: 13px;
}

#memoryModal .memory-category-group {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: start;
  gap: 10px;
}

#memoryModal .memory-category-group > span {
  padding-top: 9px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 650;
}

#memoryModal .memory-category-group > div {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

#memoryModal .memory-category-group label {
  padding: 7px 10px;
}

#memoryModal .memory-access-section {
  display: grid;
  gap: 11px;
}

#memoryModal .memory-access-section .memory-form-label {
  margin-bottom: 0;
}

#memoryModal .memory-field {
  display: grid;
  gap: 6px;
}

#memoryModal .memory-field > span {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 650;
}

#memoryModal .memory-field input,
#memoryModal .memory-field textarea {
  width: 100%;
  min-height: 44px;
  box-sizing: border-box;
  margin: 0 !important;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: 11px !important;
  outline: none;
  background: var(--bg);
  color: var(--text);
  font: 12px/1.45 ui-monospace, SFMono-Regular, Consolas, monospace;
}

#memoryModal .memory-field textarea {
  min-height: 68px;
  resize: vertical;
}

#memoryModal .memory-field input:focus,
#memoryModal .memory-field textarea:focus {
  border-color: color-mix(in srgb, var(--accent) 60%, var(--border));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 10%, transparent);
}

#memoryModal .memory-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 17px 24px 0;
}

#memoryModal .memory-form-actions button {
  min-height: 40px;
  padding: 9px 14px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--card);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 680;
  cursor: pointer;
}

#memoryModal .memory-form-actions .memory-action-primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

#memoryModal .memory-form-actions .memory-action-danger {
  border-color: color-mix(in srgb, var(--error) 32%, var(--border));
  color: var(--error);
}

#memoryModal .memory-form-hint {
  min-height: 18px;
  padding: 10px 24px 18px;
  color: var(--text-muted);
  font-size: 11px;
}

#memoryModal .memory-form-hint:empty {
  min-height: 0;
  padding-top: 0;
}

@media (max-width: 720px) {
  html.mobile-web #memoryModal .memory-pane-card {
    margin-top: 2px !important;
    border-radius: 15px !important;
  }

  html.mobile-web #memoryModal .memory-pane-card-head,
  html.mobile-web #memoryModal .memory-form-section {
    padding: 15px 16px;
  }

  html.mobile-web #memoryModal .memory-pane-card-head p {
    max-width: 250px;
  }

  html.mobile-web #memoryModal .memory-category-group {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  html.mobile-web #memoryModal .memory-category-group > span {
    padding-top: 0;
  }

  html.mobile-web #memoryModal .memory-form-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 15px 16px 0;
  }

  html.mobile-web #memoryModal .memory-learn-actions {
    grid-template-columns: 1fr;
  }

  html.mobile-web #memoryModal .memory-form-actions .memory-action-primary {
    grid-column: 1 / -1;
  }

  html.mobile-web #memoryModal .memory-form-hint {
    padding-inline: 16px;
  }
}

/* 2026-08-14 composer selection fix and unified phone layout. */
.composer-context-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: min(100%, 940px);
  min-height: 32px;
  margin: 0 auto 7px;
  padding: 0 7px;
  overflow: hidden;
}

.composer-context-row.hidden {
  display: none;
}

.composer-context-label {
  flex: 0 0 auto;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 620;
}

.composer-context-row .selected-office-task {
  min-width: 0;
  min-height: 30px;
  max-width: 260px;
  padding: 5px 9px;
  border-radius: 999px;
}

.composer-context-row #selectedOfficeTaskLabel {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.input-wrapper,
.input-wrapper textarea {
  min-width: 0;
}

.input-wrapper textarea:focus-visible {
  outline: none;
}

@media (max-width: 767px) {
  html,
  body {
    width: 100%;
    max-width: 100%;
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
  }

  .app {
    width: 100%;
    height: 100dvh;
    min-height: 100dvh;
    overflow: hidden;
  }

  .main {
    width: 100%;
    min-width: 0;
    height: 100dvh;
  }

  .topbar {
    flex: 0 0 56px;
    min-height: 56px;
    height: 56px;
    padding: 0 10px;
    border-bottom-color: color-mix(in srgb, var(--border) 72%, transparent);
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: blur(18px);
  }

  .menu-btn,
  .topbar-btn,
  .topbar-call-btn,
  .theme-toggle-btn {
    width: 40px;
    min-width: 40px;
    height: 40px;
    border-radius: 12px;
  }

  .menu-btn {
    display: grid;
    place-items: center;
  }

  .topbar-title {
    min-width: 0;
    font-size: 17px;
    letter-spacing: -.02em;
  }

  .topbar-actions {
    gap: 6px;
  }

  .chat-area {
    min-height: 0;
    padding: 0 9px;
    overscroll-behavior: contain;
    scrollbar-width: none;
  }

  .chat-area::-webkit-scrollbar {
    display: none;
  }

  .welcome {
    box-sizing: border-box;
    min-height: 0;
    height: 100%;
    padding: clamp(38px, 8vh, 72px) 14px 112px;
  }

  .welcome .logo {
    width: 68px;
    height: 68px;
    margin-bottom: 17px;
    border-radius: 22px;
  }

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

  .mode-toggle {
    width: min(100%, 286px);
    margin-top: 19px;
    padding: 4px;
    border-radius: 15px;
  }

  .mode-toggle-btn {
    flex: 1 1 0;
    min-height: 43px;
    padding: 8px 11px;
    border-radius: 11px;
  }

  .mode-toggle-desc {
    margin-top: 9px;
    font-size: 12px;
  }

  .messages {
    width: 100%;
    gap: 12px;
    padding: 14px 1px 7px;
  }

  .message {
    max-width: 96%;
  }

  .message.user {
    max-width: 88%;
  }

  .message .bubble,
  .message.user .bubble,
  .message.assistant .bubble {
    max-width: 100%;
    padding: 11px 13px;
    border-radius: 15px;
    font-size: 14px;
    line-height: 1.65;
    overflow-wrap: anywhere;
  }

  .message .bubble pre,
  .message .bubble table {
    max-width: 100%;
    overflow-x: auto;
  }

  .message .bubble img {
    max-width: 100%;
    height: auto;
  }

  .input-bar {
    flex: 0 0 auto;
    z-index: 30;
    padding: 6px 8px calc(8px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid color-mix(in srgb, var(--border) 65%, transparent);
    background: color-mix(in srgb, var(--bg) 91%, transparent);
    backdrop-filter: blur(20px);
  }

  .composer-tools-row,
  .composer-context-row,
  .composer-row,
  .image-preview-bar {
    width: 100%;
  }

  .composer-tools-row {
    min-height: 32px;
    gap: 6px;
    margin-bottom: 6px;
    padding: 0 2px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

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

  .permission-mode-row {
    min-height: 30px;
    padding: 2px;
    border-radius: 10px;
  }

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

  .permission-mode-btn {
    min-height: 26px;
    padding: 4px 8px;
    font-size: 11px;
    white-space: nowrap;
  }

  .composer-tools-divider {
    height: 18px;
  }

  .office-task-bar {
    min-width: max-content;
    gap: 3px;
  }

  .office-task-button {
    min-height: 30px;
    gap: 5px;
    padding: 4px 7px;
    border-radius: 9px;
    font-size: 11px;
  }

  .office-task-button > span {
    width: 17px;
    height: 17px;
    border-radius: 5px;
    font-size: 9px;
  }

  .composer-context-row {
    min-height: 29px;
    gap: 6px;
    margin-bottom: 5px;
    padding: 0 3px;
  }

  .composer-context-label {
    font-size: 10px;
  }

  .composer-context-row .selected-office-task {
    min-height: 28px;
    max-width: calc(100% - 58px);
    padding: 4px 8px;
    font-size: 11px;
  }

  .composer-row {
    gap: 0;
  }

  .input-wrapper {
    display: grid;
    grid-template-columns: 40px 40px minmax(0, 1fr) 40px;
    align-items: end;
    width: 100%;
    min-height: 54px;
    gap: 2px;
    padding: 6px;
    border-radius: 18px;
  }

  .input-mode-select {
    align-self: end;
    justify-content: center;
    width: 40px;
    min-width: 40px;
    height: 40px;
    min-height: 40px;
    padding: 0;
    border-radius: 12px;
  }

  .input-mode-select > #inputModeLabel,
  .input-mode-select > .mode-arrow {
    display: none;
  }

  .input-mode-select > .mode-icon {
    flex: 0 0 auto;
    width: auto;
    margin: 0;
    font-size: 16px;
  }

  .input-mode-select .mode-dropdown {
    right: auto;
    bottom: calc(100% + 10px);
    left: 0;
    min-width: 184px;
  }

  .attach-btn,
  .send-btn {
    align-self: end;
    width: 40px;
    height: 40px;
    border-radius: 12px;
  }

  .input-wrapper textarea {
    align-self: stretch;
    width: 100%;
    min-height: 40px;
    max-height: 112px;
    padding: 9px 5px;
    font-size: 16px;
    line-height: 1.4;
  }

  .stop-btn {
    align-self: end;
    width: 42px;
    height: 42px;
    margin-left: 5px;
    border-radius: 13px;
  }

  .image-preview-bar {
    gap: 7px;
    margin-bottom: 6px;
    overflow-x: auto;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 10020;
    width: min(86vw, 312px);
    height: 100dvh;
    max-height: 100dvh;
    border-right: 1px solid var(--border);
    box-shadow: 20px 0 60px rgba(15, 23, 42, .18);
  }

  .sidebar-header {
    min-height: 70px;
    padding: calc(12px + env(safe-area-inset-top, 0px)) 14px 10px;
  }

  .sidebar-header .sb-avatar {
    width: 43px;
    height: 43px;
  }

  .sidebar-close {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
  }

  .sidebar-new-chat {
    min-height: 44px;
    margin-inline: 10px;
    width: calc(100% - 20px);
  }

  .sidebar-tools-section {
    padding-inline: 10px;
  }

  .sidebar-tool-group > summary,
  .tool-item-primary {
    min-height: 48px;
    border-radius: 13px;
  }

  .sidebar-history-section {
    min-height: 0;
  }

  .sidebar-bottom {
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  }

  .sidebar-overlay {
    z-index: 10010;
    background: rgba(15, 23, 42, .36);
    backdrop-filter: blur(3px);
  }

  body:has(.sidebar.open) .proactive-trigger,
  body:has(.sidebar.open) .proactive-panel {
    opacity: 0;
    pointer-events: none;
  }

  .proactive-trigger {
    top: auto !important;
    right: 12px !important;
    bottom: calc(116px + env(safe-area-inset-bottom, 0px)) !important;
    width: 46px;
    height: 46px;
  }

  .proactive-panel {
    top: auto !important;
    right: 8px !important;
    bottom: calc(170px + env(safe-area-inset-bottom, 0px)) !important;
    width: calc(100vw - 16px) !important;
    max-height: min(62dvh, 520px) !important;
    border-radius: 18px;
  }

  .login-overlay {
    padding: max(14px, env(safe-area-inset-top, 0px)) 14px max(14px, env(safe-area-inset-bottom, 0px));
  }

  .login-card {
    width: min(100%, 420px);
    max-height: calc(100dvh - 28px);
    padding: 24px 19px;
    border-radius: 22px;
    overflow-y: auto;
  }

  .approval-dialog,
  .pair-modal,
  .workspace-modal,
  #deviceListModal {
    align-items: flex-end !important;
    justify-content: center !important;
    padding: 0 !important;
    backdrop-filter: blur(6px);
  }

  .approval-card,
  .pair-modal-card,
  body .workspace-modal > .workspace-modal-card,
  #deviceListModal > .device-list-card {
    box-sizing: border-box !important;
    width: 100% !important;
    max-width: none !important;
    max-height: 90dvh !important;
    margin: 0 !important;
    border-right: 0 !important;
    border-bottom: 0 !important;
    border-left: 0 !important;
    border-radius: 23px 23px 0 0 !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    box-shadow: 0 -18px 54px rgba(15, 23, 42, .2) !important;
  }

  .approval-card {
    padding: 22px 17px calc(17px + env(safe-area-inset-bottom, 0px));
  }

  .approval-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .approval-actions button {
    min-height: 44px;
  }

  .pair-modal-card {
    padding: 11px 16px calc(16px + env(safe-area-inset-bottom, 0px));
  }

  body .workspace-modal > .workspace-modal-card {
    height: min(90dvh, 780px) !important;
    padding: 9px 14px calc(14px + env(safe-area-inset-bottom, 0px)) !important;
  }

  html body #memoryModal.workspace-modal > .memory-modal-card.workspace-modal-card,
  html body #skillsModal.workspace-modal > .skills-modal-card.workspace-modal-card,
  html body #naturalCompanionModal.workspace-modal > .natural-companion-card.workspace-modal-card {
    box-sizing: border-box !important;
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 9px 14px calc(14px + env(safe-area-inset-bottom, 0px)) !important;
    border-right: 0 !important;
    border-bottom: 0 !important;
    border-left: 0 !important;
    border-radius: 23px 23px 0 0 !important;
    overflow-x: hidden !important;
    box-shadow: 0 -18px 54px rgba(15, 23, 42, .2) !important;
  }

  html body #memoryModal.workspace-modal > .memory-modal-card.workspace-modal-card {
    height: min(90dvh, 780px) !important;
    min-height: 0 !important;
    max-height: 90dvh !important;
  }

  html body #skillsModal.workspace-modal > .skills-modal-card.workspace-modal-card,
  html body #naturalCompanionModal.workspace-modal > .natural-companion-card.workspace-modal-card {
    height: auto !important;
    min-height: 0 !important;
    max-height: 90dvh !important;
  }

  #skillsModal > .skills-modal-card {
    height: auto !important;
  }

  .workspace-modal-card h3 {
    font-size: 20px !important;
  }

  .workspace-modal-eyebrow {
    margin-bottom: 5px;
    font-size: 9px;
  }

  #deviceListModal > .device-list-card {
    padding: 10px 15px calc(15px + env(safe-area-inset-bottom, 0px)) !important;
  }

  #deviceListModal .paired-device-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  #deviceListModal .paired-device-actions .device-action-remove {
    grid-column: auto !important;
  }

  .memory-mode-tabs {
    overflow-x: auto !important;
    overflow-y: hidden !important;
    scrollbar-width: none;
  }

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

  #memoryModal .memory-mode-btn {
    flex: 0 0 auto !important;
    white-space: nowrap;
  }

  #memoryModal #memoryGraph {
    min-height: 280px !important;
    height: clamp(280px, 47dvh, 400px) !important;
  }

  #memorySharePane input,
  #memorySharePane textarea,
  #memoryLearnPane input,
  #memoryLearnPane textarea,
  #skillSourceInput {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    font-size: 16px !important;
  }

  #screenPreviewPanel {
    right: 9px !important;
    left: 9px !important;
    width: auto !important;
    max-height: min(60dvh, 480px) !important;
  }
}

@media (max-width: 390px) {
  .topbar {
    padding-inline: 8px;
  }

  .topbar-actions {
    gap: 4px;
  }

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

  .input-wrapper {
    grid-template-columns: 38px 38px minmax(0, 1fr) 38px;
    gap: 1px;
    padding: 5px;
  }

  .input-mode-select,
  .attach-btn,
  .send-btn {
    width: 38px;
    min-width: 38px;
    height: 38px;
    min-height: 38px;
  }

  .permission-mode-btn {
    padding-inline: 7px;
  }

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

  .composer-context-row .selected-office-task {
    max-width: 100%;
  }

  .workspace-modal-card h3 {
    font-size: 19px !important;
  }
}

@media (max-width: 767px) and (max-height: 620px) {
  .welcome {
    padding: 20px 14px 92px;
  }

  .welcome .logo {
    width: 54px;
    height: 54px;
    margin-bottom: 10px;
  }

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

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

  .mode-toggle-desc {
    margin-top: 6px;
  }
}

/* 2026-08-14 Apple-inspired shell and interactive memory constellation. */
:root {
  --apple-blue: #0071e3;
  --apple-ease: cubic-bezier(.22, 1, .36, 1);
}

[data-theme="light"] {
  --bg: #f5f5f7;
  --card: rgba(255, 255, 255, .86);
  --card-hover: rgba(0, 0, 0, .045);
  --border: rgba(0, 0, 0, .085);
  --text: #1d1d1f;
  --text-secondary: #626268;
  --text-muted: #8a8a91;
  --accent: #0071e3;
  --accent-hover: #0077ed;
  --accent-soft: rgba(0, 113, 227, .09);
  --accent-light: rgba(0, 113, 227, .07);
  --user-bubble: #0071e3;
  --sidebar-bg: rgba(250, 250, 252, .82);
  --surface-raised: rgba(255, 255, 255, .88);
  --shadow-soft: 0 18px 60px rgba(0, 0, 0, .075);
  --shadow-card: 0 10px 36px rgba(0, 0, 0, .06);
}

html body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: -.012em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

[data-theme="light"] body::before {
  background:
    radial-gradient(circle at 68% 18%, rgba(73, 127, 255, .075), transparent 31%),
    radial-gradient(circle at 86% 82%, rgba(82, 196, 180, .05), transparent 28%),
    linear-gradient(180deg, rgba(255,255,255,.36), transparent 34%);
}

body .sidebar {
  width: 276px;
  border-right-color: color-mix(in srgb, var(--border) 72%, transparent);
  background: color-mix(in srgb, var(--sidebar-bg) 92%, transparent);
  backdrop-filter: saturate(160%) blur(24px);
}

body .sidebar-header {
  padding: 22px 18px 15px;
}

body .sidebar-header .sb-title {
  font-size: 16px;
  font-weight: 670;
  letter-spacing: -.025em;
}

body .sidebar-header .sb-avatar,
body .welcome .logo {
  background: rgba(255, 255, 255, .62);
  border: 1px solid rgba(255, 255, 255, .76);
  box-shadow: 0 14px 34px rgba(31, 35, 48, .09);
}

body .sidebar-new-chat,
body .sidebar-tool-group > summary,
body .tool-item-primary {
  border-radius: 14px;
  transition: background 180ms ease, color 180ms ease, transform 180ms ease;
}

body .sidebar-new-chat:hover,
body .sidebar-tool-group > summary:hover,
body .tool-item-primary:hover {
  transform: translateY(-1px);
}

body .main {
  background:
    radial-gradient(circle at 54% 18%, color-mix(in srgb, var(--accent) 6%, transparent), transparent 34%),
    radial-gradient(circle at 88% 85%, rgba(54, 189, 168, .035), transparent 29%),
    var(--bg);
}

body .topbar {
  height: 64px;
  min-height: 64px;
  padding-inline: 18px;
  border-bottom-color: color-mix(in srgb, var(--border) 70%, transparent);
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: saturate(180%) blur(26px);
}

body .topbar-title {
  font-size: 18px;
  font-weight: 660;
  letter-spacing: -.03em;
}

body .topbar-btn,
body .topbar-call-btn,
body .theme-toggle-btn,
body .menu-btn {
  border-color: color-mix(in srgb, var(--border) 76%, transparent);
  border-radius: 14px;
  background: color-mix(in srgb, var(--card) 72%, transparent);
  box-shadow: 0 5px 18px rgba(0, 0, 0, .035);
  backdrop-filter: blur(18px);
}

body .welcome {
  padding-top: clamp(54px, 10vh, 116px);
}

body .welcome .logo {
  width: 92px;
  height: 92px;
  margin-bottom: 22px;
  border-radius: 29px;
}

body .welcome h1 {
  font-size: clamp(34px, 3vw, 44px);
  font-weight: 680;
  letter-spacing: -.055em;
}

body .mode-toggle {
  width: 278px;
  padding: 5px;
  border: 1px solid color-mix(in srgb, var(--border) 72%, transparent);
  border-radius: 18px;
  background: color-mix(in srgb, var(--card) 72%, transparent);
  box-shadow: 0 15px 40px rgba(0, 0, 0, .06);
  backdrop-filter: saturate(170%) blur(22px);
}

body .mode-toggle-btn {
  flex: 1 1 0;
  min-width: 0;
  min-height: 45px;
  border-radius: 14px;
  font-weight: 620;
}

body .mode-toggle-btn.active {
  background: color-mix(in srgb, var(--surface-raised) 94%, white 6%);
  box-shadow: 0 5px 16px rgba(0, 0, 0, .07);
}

body .mode-toggle-desc {
  margin-top: 12px;
  color: var(--text-muted);
  font-size: 12px;
}

body .input-bar {
  padding-bottom: max(18px, env(safe-area-inset-bottom, 18px));
  background: linear-gradient(180deg, transparent 0, color-mix(in srgb, var(--bg) 92%, transparent) 27%);
}

body .composer-tools-row {
  padding: 4px 8px;
  border: 1px solid color-mix(in srgb, var(--border) 68%, transparent);
  border-radius: 15px;
  background: color-mix(in srgb, var(--card) 62%, transparent);
  box-shadow: 0 8px 26px rgba(0, 0, 0, .035);
  backdrop-filter: blur(18px);
}

body .permission-mode-row {
  border: 0;
  background: transparent;
}

body .office-task-button,
body .permission-mode-btn {
  border-radius: 10px;
}

body .input-wrapper {
  min-height: 60px;
  border-color: color-mix(in srgb, var(--border) 85%, transparent);
  border-radius: 22px;
  background: color-mix(in srgb, var(--surface-raised) 89%, transparent);
  box-shadow: 0 18px 55px rgba(0, 0, 0, .08), inset 0 1px 0 rgba(255,255,255,.5);
  backdrop-filter: saturate(175%) blur(24px);
}

body .input-wrapper:focus-within {
  border-color: color-mix(in srgb, var(--accent) 36%, var(--border));
  box-shadow: 0 20px 60px color-mix(in srgb, var(--accent) 9%, rgba(0,0,0,.08)), 0 0 0 3px color-mix(in srgb, var(--accent) 8%, transparent);
}

body .send-btn {
  border-radius: 15px;
  background: var(--accent);
  box-shadow: 0 8px 20px color-mix(in srgb, var(--accent) 24%, transparent);
}

body .message .bubble {
  border-radius: 20px;
}

body .message.assistant .bubble {
  border-color: color-mix(in srgb, var(--border) 76%, transparent);
  background: color-mix(in srgb, var(--card) 82%, transparent);
  box-shadow: 0 10px 34px rgba(0, 0, 0, .04);
  backdrop-filter: blur(18px);
}

body .workspace-modal {
  background: rgba(24, 24, 28, .36) !important;
  backdrop-filter: saturate(145%) blur(18px);
}

html body .workspace-modal > .workspace-modal-card {
  border-color: rgba(255,255,255,.34) !important;
  border-radius: 28px !important;
  background: color-mix(in srgb, var(--card) 94%, transparent) !important;
  box-shadow: 0 32px 100px rgba(0,0,0,.22) !important;
  backdrop-filter: saturate(170%) blur(30px);
}

html body #memoryModal.workspace-modal > .memory-modal-card.workspace-modal-card {
  width: min(1120px, calc(100vw - 56px)) !important;
  max-height: min(820px, calc(100dvh - 56px)) !important;
  padding: 26px !important;
}

#memoryModal .memory-modal-heading h3 {
  font-size: 26px !important;
  font-weight: 690;
  letter-spacing: -.045em;
}

#memoryModal .memory-mode-tabs {
  gap: 4px !important;
  margin: 20px 0 14px !important;
  padding: 4px !important;
  border: 1px solid color-mix(in srgb, var(--border) 72%, transparent);
  border-radius: 16px;
  background: color-mix(in srgb, var(--bg) 66%, transparent);
}

#memoryModal .memory-mode-btn {
  min-height: 42px;
  padding: 8px 16px !important;
  border: 0 !important;
  border-radius: 12px !important;
  background: transparent !important;
  color: var(--text-muted) !important;
  font-weight: 620;
  transition: color 180ms ease, background 180ms ease, box-shadow 180ms ease;
}

#memoryModal .memory-mode-btn.active {
  background: var(--surface-raised) !important;
  color: var(--text) !important;
  box-shadow: 0 5px 16px rgba(0, 0, 0, .07);
}

.memory-view-pane,
.memory-graph-stage {
  min-height: 0;
}

.memory-graph-stage {
  position: relative;
  display: flex;
  flex: 1 1 auto;
  overflow: hidden;
  border-radius: 22px;
  isolation: isolate;
}

#memoryModal #memoryGraph {
  width: 100%;
  height: 100%;
  min-height: 420px !important;
  border-color: rgba(255,255,255,.09) !important;
  border-radius: 22px !important;
  background: #10131a !important;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.045), inset 0 -50px 100px rgba(0,0,0,.18);
}

.memory-graph-guide {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 4;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid rgba(255,255,255,.09);
  border-radius: 999px;
  background: rgba(20, 24, 34, .62);
  color: rgba(242,245,255,.72);
  font-size: 11px;
  font-weight: 560;
  backdrop-filter: blur(18px);
  transition: opacity 180ms ease, transform 180ms ease;
  pointer-events: none;
}

.memory-graph-guide > span {
  color: #8ca4ff;
}

.memory-graph-guide.is-hidden {
  opacity: 0;
  transform: translateY(-5px);
}

.memory-graph-detail {
  position: absolute;
  top: 18px;
  right: 18px;
  bottom: 18px;
  z-index: 6;
  display: flex;
  flex-direction: column;
  width: min(340px, calc(100% - 36px));
  box-sizing: border-box;
  padding: 19px;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 20px;
  background: rgba(245, 247, 252, .91);
  color: #1d1d1f;
  box-shadow: 0 24px 70px rgba(0,0,0,.28);
  backdrop-filter: saturate(165%) blur(28px);
  opacity: 0;
  transform: translateX(18px) scale(.98);
  transform-origin: right center;
  pointer-events: none;
  transition: opacity 220ms ease, transform 320ms var(--apple-ease);
  will-change: opacity, transform;
  contain: layout paint;
}

.memory-graph-detail[hidden] {
  display: none !important;
}

.memory-graph-detail.is-visible,
.memory-graph-detail[aria-hidden="false"] {
  opacity: 1;
  transform: translateX(0) scale(1);
  pointer-events: auto;
}

.memory-graph-detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 13px;
}

.memory-graph-detail-category {
  display: inline-flex;
  align-items: center;
  min-height: 27px;
  padding: 0 9px;
  border-radius: 999px;
  background: rgba(0, 113, 227, .09);
  color: #0066cc;
  font-size: 11px;
  font-weight: 650;
}

.memory-graph-detail-close {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(0,0,0,.055);
  color: #68686d;
  font-size: 19px;
  cursor: pointer;
}

.memory-graph-detail-title {
  margin-bottom: 7px;
  font-size: 21px;
  font-weight: 690;
  line-height: 1.28;
  letter-spacing: -.035em;
  overflow-wrap: anywhere;
}

.memory-graph-detail-meta {
  margin-bottom: 14px;
  color: #85858b;
  font-size: 11px;
}

.memory-graph-detail-content {
  flex: 1 1 auto;
  min-height: 0;
  padding-right: 4px;
  overflow: auto;
  color: #3a3a3f;
  font-size: 13px;
  line-height: 1.72;
  white-space: pre-wrap;
  overscroll-behavior: contain;
}

.memory-graph-detail-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 15px;
}

.memory-graph-detail-links:empty {
  display: none;
}

.memory-graph-detail-links > span {
  max-width: 100%;
  padding: 5px 8px;
  overflow: hidden;
  border: 1px solid rgba(0,0,0,.07);
  border-radius: 8px;
  background: rgba(255,255,255,.58);
  color: #68686d;
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.memory-graph-delete-zone {
  flex: 0 0 auto;
  margin-top: 16px;
  padding-top: 13px;
  border-top: 1px solid rgba(0,0,0,.075);
}

.memory-graph-delete-zone[hidden],
.memory-graph-delete-confirm[hidden],
.memory-graph-delete-trigger[hidden] {
  display: none !important;
}

.memory-graph-delete-trigger,
.memory-graph-delete-cancel,
.memory-graph-delete-submit {
  min-height: 38px;
  border-radius: 11px;
  font: inherit;
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
  transition: background-color 160ms ease, border-color 160ms ease, opacity 160ms ease, transform 160ms ease;
}

.memory-graph-delete-trigger {
  width: 100%;
  border: 1px solid rgba(255, 59, 48, .2);
  background: rgba(255, 59, 48, .055);
  color: #d70015;
}

.memory-graph-delete-trigger:hover {
  border-color: rgba(255, 59, 48, .32);
  background: rgba(255, 59, 48, .095);
}

.memory-graph-delete-confirm {
  padding: 12px;
  border: 1px solid rgba(255, 59, 48, .15);
  border-radius: 14px;
  background: rgba(255, 255, 255, .62);
}

.memory-graph-delete-confirm p {
  margin: 0 0 10px;
  color: #6f6f74;
  font-size: 11px;
  line-height: 1.55;
}

.memory-graph-delete-actions {
  display: grid;
  grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr);
  gap: 8px;
}

.memory-graph-delete-cancel {
  border: 1px solid rgba(0,0,0,.09);
  background: rgba(255,255,255,.82);
  color: #3a3a3f;
}

.memory-graph-delete-submit {
  border: 1px solid #ff3b30;
  background: #ff3b30;
  color: #fff;
}

.memory-graph-delete-trigger:active,
.memory-graph-delete-cancel:active,
.memory-graph-delete-submit:active {
  transform: scale(.985);
}

.memory-graph-delete-trigger:disabled,
.memory-graph-delete-cancel:disabled,
.memory-graph-delete-submit:disabled {
  cursor: wait;
  opacity: .52;
}

.memory-graph-delete-status {
  min-height: 0;
  margin-top: 0;
  color: #6f6f74;
  font-size: 10px;
  line-height: 1.45;
}

.memory-graph-delete-status:not(:empty) {
  margin-top: 8px;
}

.memory-graph-delete-status.is-error {
  color: #d70015;
}

.memory-graph-node {
  cursor: pointer;
  outline: none;
  transform-box: fill-box;
  transform-origin: center;
  transition: opacity 180ms ease, filter 180ms ease;
}

.memory-graph-node-core {
  stroke-width: 1.15;
  transition: stroke-width 180ms ease, stroke-opacity 180ms ease;
  pointer-events: none;
}

.memory-graph-hitarea {
  fill: transparent;
  pointer-events: all;
}

.memory-graph-node-aura {
  transform-box: fill-box;
  transform-origin: center;
  animation: memory-node-breathe 4.6s ease-in-out infinite;
  will-change: opacity, transform;
  pointer-events: none;
}

.memory-graph-node-shine {
  pointer-events: none;
}

.memory-graph-node:nth-of-type(3n) .memory-graph-node-aura {
  animation-delay: -1.2s;
}

.memory-graph-node:nth-of-type(4n) .memory-graph-node-aura {
  animation-delay: -2.4s;
}

.memory-graph-node:hover,
.memory-graph-node.is-hovered {
  filter: brightness(1.08);
}

.memory-graph-node.is-selected {
  filter: brightness(1.12);
}

.memory-graph-node.is-selected .memory-graph-node-core {
  stroke-width: 2.6;
  stroke-opacity: 1;
}

.memory-graph-node.is-selected .memory-graph-node-aura {
  opacity: .38;
  animation-duration: 2.1s;
}

.memory-graph-node.is-related .memory-graph-node-core {
  stroke-width: 1.8;
}

.memory-graph-node:focus-visible .memory-graph-node-core {
  stroke: #ffffff;
  stroke-width: 3;
}

.memory-graph-node[data-memory-state="pending"] .memory-graph-node-core,
.memory-graph-node[data-memory-state="syncing"] .memory-graph-node-core,
.memory-graph-node[data-memory-state="review"] .memory-graph-node-core {
  stroke-dasharray: 3 2;
}

.memory-graph-edge {
  stroke: #7c8aab;
  stroke-linecap: round;
}

.memory-graph-edge.is-related {
  stroke: #a9b8ff;
  stroke-width: 2.2;
  opacity: 1;
}

@keyframes memory-node-breathe {
  0%, 100% { opacity: .08; transform: scale(.88); }
  50% { opacity: .24; transform: scale(1.12); }
}

@media (max-width: 767px) {
  body .topbar {
    height: 56px;
    min-height: 56px;
    padding-inline: 9px;
  }

  body .welcome {
    padding-top: clamp(38px, 8vh, 72px);
  }

  body .welcome .logo {
    width: 72px;
    height: 72px;
    border-radius: 23px;
  }

  body .welcome h1 {
    font-size: clamp(25px, 7vw, 29px);
  }

  body .mode-toggle {
    width: min(100%, 286px);
  }

  body .composer-tools-row {
    padding: 2px;
    border: 0;
    border-radius: 11px;
    background: transparent;
    box-shadow: none;
    backdrop-filter: none;
  }

  body .input-wrapper {
    min-height: 54px;
    border-radius: 19px;
  }

  html body #memoryModal.workspace-modal > .memory-modal-card.workspace-modal-card {
    width: 100% !important;
    height: 92dvh !important;
    max-height: 92dvh !important;
    padding: 9px 12px calc(12px + env(safe-area-inset-bottom, 0px)) !important;
    border-radius: 25px 25px 0 0 !important;
  }

  #memoryModal .memory-modal-heading h3 {
    font-size: 21px !important;
  }

  #memoryModal .memory-mode-tabs {
    margin: 10px 0 8px !important;
  }

  #memoryModal #memoryGraph {
    min-height: 330px !important;
    height: 100% !important;
  }

  .memory-graph-stage {
    border-radius: 18px;
  }

  .memory-graph-guide {
    top: 11px;
    left: 11px;
    min-height: 31px;
    padding-inline: 10px;
    font-size: 10px;
  }

  .memory-graph-detail {
    top: auto;
    right: 10px;
    bottom: 10px;
    left: 10px;
    width: auto;
    max-height: 68%;
    padding: 16px;
    border-radius: 18px;
    transform: translateY(18px) scale(.985);
    transform-origin: center bottom;
  }

  .memory-graph-detail.is-visible {
    transform: translateY(0) scale(1);
  }

  .memory-graph-detail-title {
    font-size: 18px;
  }

  .memory-graph-detail-content {
    font-size: 12px;
    line-height: 1.65;
  }

  .memory-graph-delete-zone {
    margin-top: 12px;
    padding-top: 11px;
  }

  .memory-graph-delete-trigger,
  .memory-graph-delete-cancel,
  .memory-graph-delete-submit {
    min-height: 42px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .memory-graph-node-aura {
    animation: none;
  }
}


/* --- master 增量：设备控制按钮 + 移动端记忆清理面板 --- */
#deviceListModal .paired-device-actions .device-action-control {
  border-color: var(--accent) !important;
  background: var(--accent) !important;
  color: #fff !important;
}

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