/* App dashboard */

.app-shell {
  display: flex;
  height: 100vh;
  background: var(--surface-2);
  overflow: hidden;
}

/* Themed scrollbars */
.chat-messages,
.sidebar-history,
.settings-view {
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.chat-messages::-webkit-scrollbar,
.sidebar-history::-webkit-scrollbar,
.settings-view::-webkit-scrollbar {
  width: 8px;
}

.chat-messages::-webkit-scrollbar-track,
.sidebar-history::-webkit-scrollbar-track,
.settings-view::-webkit-scrollbar-track {
  background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb,
.sidebar-history::-webkit-scrollbar-thumb,
.settings-view::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 99px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

.chat-messages:hover::-webkit-scrollbar-thumb,
.sidebar-history:hover::-webkit-scrollbar-thumb,
.settings-view:hover::-webkit-scrollbar-thumb {
  background: rgba(242, 24, 98, 0.45);
  background-clip: padding-box;
}

/* Sidebar */
.app-sidebar {
  width: 260px;
  flex-shrink: 0;
  background: var(--card-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: width 0.2s, margin 0.2s;
}

.app-sidebar.collapsed {
  width: 68px;
}

.sidebar-top {
  padding: 16px 14px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.app-sidebar.collapsed .sidebar-top {
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  padding: 12px 8px;
}

.sidebar-toggle {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-muted);
  cursor: pointer;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.sidebar-toggle:hover { background: var(--surface-3); }

.app-sidebar.collapsed .sidebar-toggle svg {
  transform: rotate(180deg);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  min-width: 0;
  text-decoration: none;
}

.app-sidebar.collapsed .sidebar-brand {
  justify-content: center;
  width: 100%;
}

.sidebar-nav {
  padding: 0 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: none;
  border-radius: 10px;
  background: transparent;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-muted);
  cursor: pointer;
  text-align: left;
  width: 100%;
}

.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-item:hover { background: var(--surface-3); color: var(--ink); }
.nav-item.active { background: var(--brand-light); color: var(--brand); font-weight: 600; }

.app-sidebar.collapsed .nav-item span,
.app-sidebar.collapsed .history-label,
.app-sidebar.collapsed .account-info { display: none; }

.sidebar-brand .logo-img--color,
.sidebar-brand .logo-img--white {
  height: 28px;
  max-width: 148px;
}

.sidebar-brand .logo-img--icon {
  display: none;
  width: 32px;
  height: 32px;
  object-fit: contain;
}

html[data-theme="light"] .sidebar-brand .logo-img--white { display: none; }
html[data-theme="dark"] .sidebar-brand .logo-img--color { display: none; }

.app-sidebar.collapsed .sidebar-brand .logo-img--color,
.app-sidebar.collapsed .sidebar-brand .logo-img--white {
  display: none !important;
}
.app-sidebar.collapsed .sidebar-brand .logo-img--icon {
  display: block !important;
}

.sidebar-history {
  flex: 1;
  overflow-y: auto;
  padding: 8px 10px;
  margin-top: 8px;
}

.history-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  padding: 8px 12px 6px;
}

.history-item {
  display: block;
  width: 100%;
  padding: 9px 12px;
  border: none;
  border-radius: 8px;
  background: transparent;
  font-family: inherit;
  font-size: 13px;
  color: var(--ink-muted);
  text-align: left;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-item:hover { background: var(--surface-3); color: var(--ink); }
.history-item.active { background: var(--surface-3); color: var(--ink); font-weight: 500; }

.sidebar-footer {
  padding: 12px 10px 14px;
  border-top: 1px solid var(--border);
}

.account-btn {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  transition: background 0.15s, border-color 0.15s;
}

.account-btn:hover {
  background: var(--surface-3);
  border-color: rgba(242, 24, 98, 0.3);
}

.account-avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--brand);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  overflow: hidden;
}

.account-avatar img { width: 100%; height: 100%; object-fit: cover; }

.account-info { min-width: 0; flex: 1; }
.account-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.account-plan { font-size: 11px; color: var(--ink-soft); margin-top: 1px; }

.account-chevron {
  width: 16px;
  height: 16px;
  color: var(--ink-soft);
  flex-shrink: 0;
  transition: transform 0.15s;
}

.account-menu-wrap {
  position: relative;
}

.account-menu-wrap.is-open .account-chevron {
  transform: rotate(180deg);
}

.account-menu {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 8px);
  padding: 6px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
  z-index: 40;
}

.account-menu[hidden] {
  display: none !important;
}

.account-menu button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
}

.account-menu button:hover {
  background: var(--surface-3);
}

.account-menu button svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--ink-soft);
}

.account-menu-danger {
  color: #dc2626 !important;
}

.account-menu-danger svg {
  color: #dc2626 !important;
}

.app-sidebar.collapsed .account-chevron { display: none; }
.app-sidebar.collapsed .account-menu { display: none !important; }

/* Main */
.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  position: relative;
}

.app-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: var(--nav-bg);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-soft);
  gap: 12px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.topbar-menu-btn {
  display: none;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  place-items: center;
  flex-shrink: 0;
}

.topbar-menu-btn svg {
  width: 18px;
  height: 18px;
}

.topbar-title { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 10px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

.topbar-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  min-width: 36px;
  padding: 0 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}

.topbar-icon-btn svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.topbar-icon-btn:hover {
  background: var(--surface-2, rgba(255,255,255,0.06));
  border-color: var(--accent, #F21862);
}

.topbar-logout span {
  line-height: 1;
}

@media (max-width: 640px) {
  .topbar-logout span { display: none; }
  .topbar-logout { padding: 0; width: 36px; }
}

.extension-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  margin: 12px 24px 0;
  background: var(--brand-light);
  border: 1px solid rgba(242, 24, 98, 0.2);
  border-radius: 12px;
  font-size: 13px;
  color: var(--ink-muted);
}

.extension-banner strong { color: var(--ink); }
.extension-banner .btn { padding: 8px 14px; font-size: 12px; margin-left: auto; flex-shrink: 0; }

/* Chat view */
.chat-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.chat-empty {
  max-width: 720px;
  margin: 0 auto;
  text-align: center;
  padding: 48px 20px 32px;
}

.chat-empty h2 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink-muted);
  margin-bottom: 28px;
}

.prompt-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  max-width: 640px;
  margin: 0 auto;
}

.prompt-card {
  padding: 16px 18px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  text-align: left;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink-muted);
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.prompt-card:hover {
  border-color: rgba(242, 24, 98, 0.4);
  box-shadow: 0 4px 16px -8px var(--brand-glow);
  color: var(--ink);
}

.msg {
  max-width: 720px;
  margin: 0 auto 20px;
  display: flex;
  gap: 12px;
}

.msg.user { flex-direction: row-reverse; }

.msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
}

.msg.user .msg-avatar {
  background: var(--brand);
  color: #fff;
}

.msg.assistant .msg-avatar {
  background: var(--brand-light);
  color: var(--brand);
}

.msg-body {
  max-width: 85%;
  padding: 14px 16px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.65;
}

.msg.user .msg-body {
  background: var(--brand);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.msg.assistant .msg-body {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  color: var(--ink);
}

.msg-body p { margin-bottom: 8px; }
.msg-body p:last-child { margin-bottom: 0; }

/* Rendered markdown */
.msg-body h1, .msg-body h2, .msg-body h3, .msg-body h4 {
  font-weight: 700;
  line-height: 1.3;
  margin: 14px 0 8px;
  color: var(--ink);
}
.msg-body h1 { font-size: 1.25em; }
.msg-body h2 { font-size: 1.15em; }
.msg-body h3 { font-size: 1.05em; }
.msg-body h4 { font-size: 1em; }
.msg-body h1:first-child, .msg-body h2:first-child, .msg-body h3:first-child { margin-top: 0; }

.msg-body strong { font-weight: 700; }
.msg-body em { font-style: italic; }

.msg-body ul, .msg-body ol {
  margin: 8px 0 10px;
  padding-left: 1.4em;
}
.msg-body li { margin: 4px 0; }
.msg-body li > p { margin: 0; }

.msg-body code {
  font-family: ui-monospace, 'Cascadia Code', 'Consolas', monospace;
  font-size: 0.9em;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 5px;
}

.msg-body pre {
  margin: 10px 0;
  padding: 12px 14px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow-x: auto;
}
.msg-body pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 12px;
  line-height: 1.5;
}

.msg-body blockquote {
  margin: 10px 0;
  padding: 10px 14px;
  border-left: 3px solid var(--brand);
  background: var(--surface-2);
  border-radius: 0 8px 8px 0;
  color: var(--ink-muted);
}

.msg-body blockquote p {
  margin: 0 0 8px;
}

.msg-body blockquote p:last-child {
  margin-bottom: 0;
}

.msg-body a {
  color: var(--brand);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.msg-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 14px 0;
}

.msg-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.msg-attach-img {
  max-width: 200px;
  max-height: 140px;
  border-radius: 10px;
  border: 1px solid var(--border);
  object-fit: cover;
}

.msg-attach-file {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: rgba(255,255,255,0.12);
  border-radius: 8px;
  font-size: 12px;
}

.msg.user .msg-attach-file { background: rgba(255,255,255,0.15); }

/* Attach preview strip */
.attach-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 14px 0;
}

.attach-preview:not(.hidden) + .chat-textarea { padding-top: 8px; }

.attach-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 12px;
  color: var(--ink-muted);
  max-width: 180px;
}

.attach-item img {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
}

.attach-item .attach-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

.attach-remove {
  width: 20px;
  height: 20px;
  border: none;
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--ink-muted);
  cursor: pointer;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  font-size: 14px;
  line-height: 1;
}
.attach-remove:hover { background: rgba(239,68,68,0.2); color: #f87171; }

.tool-icon-btn {
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--ink-muted);
  cursor: pointer;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.tool-icon-btn:hover {
  background: var(--surface-3);
  color: var(--ink);
  border-color: rgba(242, 24, 98, 0.35);
}
.tool-icon-btn.is-listening {
  background: rgba(242, 24, 98, 0.14);
  color: var(--brand-magenta, #F21862);
  border-color: rgba(242, 24, 98, 0.45);
  box-shadow: 0 0 0 2px rgba(242, 24, 98, 0.2);
}
.tool-icon-btn svg { width: 16px; height: 16px; }

.msg-loading {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink-muted);
  font-size: 14px;
}

.msg.assistant.is-streaming .msg-body::after {
  content: '';
  display: inline-block;
  width: 7px;
  height: 1.05em;
  margin-left: 2px;
  vertical-align: text-bottom;
  background: var(--brand-magenta);
  border-radius: 1px;
  animation: stream-caret 0.9s steps(1) infinite;
}

@keyframes stream-caret {
  50% { opacity: 0; }
}

.msg-spin {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* Input bar */
.chat-input-wrap {
  position: relative;
  z-index: 20;
  padding: 16px 24px 24px;
  background: linear-gradient(180deg, transparent, var(--surface-2) 30%);
}

.chat-input-box {
  max-width: 760px;
  margin: 0 auto;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow-sm);
  /* visible so model picker menu can open above the composer */
  overflow: visible;
}

.chat-input-box:focus-within {
  border-color: rgba(242, 24, 98, 0.5);
  box-shadow: 0 0 0 4px rgba(242, 24, 98, 0.12);
}

.chat-textarea {
  width: 100%;
  min-height: 56px;
  max-height: 160px;
  padding: 16px 18px 8px;
  border: none;
  outline: none;
  resize: none;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.5;
  background: transparent;
  color: var(--ink);
}

.chat-textarea::placeholder { color: var(--ink-soft); }

.chat-input-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px 12px;
  gap: 8px;
  flex-wrap: wrap;
}

.tool-group { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; flex: 1; min-width: 0; }

.tools-primary {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
  min-width: 0;
}

.tools-primary .model-picker {
  min-width: 0;
}

.model-picker {
  position: relative;
  z-index: 5;
}

.model-select-native {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.model-picker-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: min(260px, 58vw);
  padding: 6px 10px 6px 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: linear-gradient(180deg, #fff 0%, #FFF8FB 100%);
  color: var(--heading);
  font-family: inherit;
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
  box-shadow: 0 1px 0 rgba(11, 31, 68, 0.04);
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s, transform 0.15s;
}

.model-picker-trigger:hover {
  border-color: color-mix(in srgb, var(--brand) 40%, var(--border));
  background: var(--brand-light);
  transform: translateY(-1px);
}

.model-picker.is-open .model-picker-trigger {
  border-color: color-mix(in srgb, var(--brand-magenta) 50%, var(--border));
  background: #fff;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 14%, transparent);
  transform: none;
}

.model-picker-mark {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--gradient-brand);
  color: #fff;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: -0.02em;
  box-shadow: 0 4px 10px rgba(210, 10, 114, 0.22);
}

.model-picker-mark.is-gemini {
  background: linear-gradient(135deg, #6B0FB3, #0B1F44);
  box-shadow: 0 4px 10px rgba(107, 15, 179, 0.22);
}

.model-picker-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.model-picker-chevron {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  color: var(--ink-soft);
  transition: transform 0.18s ease, color 0.15s;
}

.model-picker.is-open .model-picker-chevron {
  transform: rotate(180deg);
  color: var(--brand-magenta);
}

.model-picker-menu {
  position: absolute;
  left: 0;
  bottom: calc(100% + 10px);
  width: min(320px, calc(100vw - 40px));
  max-height: 340px;
  overflow-y: auto;
  padding: 8px;
  border: 1px solid color-mix(in srgb, var(--brand-magenta) 12%, var(--border));
  border-radius: 16px;
  background:
    linear-gradient(180deg, #fff 0%, #FFFCFD 100%);
  box-shadow:
    0 18px 48px rgba(11, 31, 68, 0.16),
    0 2px 0 rgba(255, 255, 255, 0.8) inset;
  z-index: 40;
  animation: model-picker-in 0.16s ease-out;
}

@keyframes model-picker-in {
  from { opacity: 0; transform: translateY(6px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.model-picker-menu[hidden] { display: none !important; }

.model-picker-heading {
  padding: 8px 10px 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.model-picker-section + .model-picker-section {
  margin-top: 4px;
  padding-top: 6px;
  border-top: 1px solid var(--border);
}

.model-picker-section-title {
  padding: 6px 10px 4px;
  font-size: 11px;
  font-weight: 650;
  color: var(--brand-purple);
}

.model-picker-empty {
  padding: 12px 10px;
  font-size: 13px;
  color: var(--ink-muted);
}

.model-picker-option {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: var(--heading);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s, box-shadow 0.12s;
}

.model-picker-option:hover {
  background: var(--brand-light);
  border-color: color-mix(in srgb, var(--brand) 18%, transparent);
}

.model-picker-option.is-selected {
  background: linear-gradient(135deg, #FFF1F6 0%, #F7F0FC 100%);
  border-color: color-mix(in srgb, var(--brand-magenta) 28%, transparent);
  color: var(--brand-magenta);
  box-shadow: 0 1px 0 rgba(210, 10, 114, 0.06);
}

.model-picker-option-icon {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: var(--gradient-brand);
  color: #fff;
  font-size: 9px;
  font-weight: 800;
}

.model-picker-option-icon.is-gemini {
  background: linear-gradient(135deg, #6B0FB3, #0B1F44);
}

.model-picker-option-text {
  min-width: 0;
  flex: 1;
}

.model-picker-option-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.model-picker-option-name {
  display: block;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 650;
}

.model-picker-badge {
  flex-shrink: 0;
  padding: 2px 7px;
  border-radius: 999px;
  background: #FFF1F6;
  color: var(--brand-magenta);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.model-picker-option.is-selected .model-picker-badge {
  background: rgba(210, 10, 114, 0.12);
}

.model-picker-option-meta {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-muted);
}

.model-picker-option.is-selected .model-picker-option-meta {
  color: color-mix(in srgb, var(--brand-magenta) 65%, var(--ink-muted));
}

.model-picker-check {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--brand-magenta);
  opacity: 0;
  transform: scale(0.85);
  transition: opacity 0.12s, transform 0.12s;
}

.model-picker-check svg {
  width: 16px;
  height: 16px;
  display: block;
}

.model-picker-option.is-selected .model-picker-check {
  opacity: 1;
  transform: scale(1);
}

html[data-theme="dark"] .model-picker-trigger {
  background: linear-gradient(180deg, var(--surface-3) 0%, color-mix(in srgb, var(--brand) 8%, var(--surface-3)) 100%);
  color: var(--ink);
}

html[data-theme="dark"] .model-picker-menu {
  background: linear-gradient(180deg, var(--card-bg) 0%, color-mix(in srgb, var(--brand) 6%, var(--card-bg)) 100%);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.5);
}

html[data-theme="dark"] .model-picker-option:hover {
  background: rgba(242, 24, 98, 0.12);
}

html[data-theme="dark"] .model-picker-option.is-selected {
  background: rgba(242, 24, 98, 0.18);
  border-color: rgba(210, 10, 114, 0.35);
}

html[data-theme="dark"] .model-picker-badge {
  background: rgba(242, 24, 98, 0.18);
}

.rewrite-group,
.length-group,
.tone-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.tone-group .tool-chip {
  font-size: 11px;
  padding: 6px 8px;
}

.rewrite-group .tool-chip[data-rewrite="humanize"] {
  background: color-mix(in srgb, var(--brand) 12%, var(--surface-2));
  border-color: color-mix(in srgb, var(--brand) 28%, var(--border));
  color: var(--brand);
  font-weight: 650;
}

.tool-chip {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-muted);
  cursor: pointer;
}

.tool-chip.active {
  background: var(--brand-light);
  border-color: rgba(242, 24, 98, 0.35);
  color: var(--brand);
}

.tool-chip.is-locked,
.tool-chip:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-send {
  width: 38px;
  height: 38px;
  border: none;
  border-radius: 10px;
  background: var(--brand);
  color: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.btn-send:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-send svg { width: 18px; height: 18px; }

/* Settings view */
.settings-view {
  flex: 1;
  overflow-y: auto;
  padding: 32px 24px;
}

.settings-inner {
  max-width: 640px;
  margin: 0 auto;
}

.settings-inner h1 {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 24px;
}

.settings-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 16px;
}

.settings-card h2 {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-soft);
  font-size: 14px;
}

.settings-row:last-child { border-bottom: none; padding-bottom: 0; }
.settings-row .label { color: var(--ink-muted); }
.settings-row .value { font-weight: 600; text-align: right; }

.usage-bar-wrap {
  margin: 10px 0 8px;
  height: 8px;
  background: var(--surface-3);
  border-radius: 99px;
  overflow: hidden;
}

.usage-bar-fill {
  height: 100%;
  background: var(--gradient-brand);
  border-radius: 99px;
  transition: width 0.3s;
}

.usage-remaining {
  margin: 0 0 14px;
  font-size: 13px;
  color: var(--ink-muted);
}

.usage-upgrade-hint {
  margin: 12px 0 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--brand-magenta);
}

.usage-upgrade-hint.hidden { display: none !important; }

.settings-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  margin-top: 16px;
}

.plan-features {
  margin: 0;
  padding-left: 18px;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.6;
}

.billing-interval-toggle {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--brand) 5%, var(--surface, #fff));
}

.billing-interval-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  font: inherit;
  font-size: 12.5px;
  font-weight: 650;
  padding: 8px 12px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.billing-interval-btn.is-active {
  background: var(--gradient-brand, linear-gradient(135deg, #F21862, #6B0FB3));
  color: #fff;
}

.billing-save {
  font-size: 10px;
  font-weight: 750;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.22);
}

.billing-interval-btn:not(.is-active) .billing-save {
  background: color-mix(in srgb, #6B0FB3 16%, #fff);
  color: #6B0FB3;
}

.billing-price-line {
  margin: 0;
  font-size: 13px;
  color: var(--ink-soft);
}

.top-upgrade-btn {
  padding: 8px 14px !important;
  font-size: 13px !important;
  border-radius: 10px !important;
}

.upgrade-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 4px 0;
}

.upgrade-card p { margin: 0; }
.upgrade-card-sub { color: var(--ink-soft); font-size: 13px; }
.upgrade-card .btn { align-self: flex-start; }

.btn-danger {
  background: rgba(239, 68, 68, 0.1);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
  padding: 10px 16px;
  border-radius: 10px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.btn-danger:hover { background: rgba(239, 68, 68, 0.18); }

html[data-theme="light"] .btn-danger {
  background: #fef2f2;
  color: #b91c1c;
  border-color: #F9C4C0;
}

html[data-theme="light"] .btn-danger:hover { background: #fee2e2; }

.security-note {
  margin-top: 0;
  margin-bottom: 14px;
  padding: 12px 14px;
  background: var(--surface-2);
  border-radius: 10px;
  font-size: 13px;
  color: var(--ink-muted);
  line-height: 1.55;
}

.password-box {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--border-soft);
}

.password-box h3 {
  font-size: 14px;
  font-weight: 700;
  margin: 0 0 10px;
}

.settings-field {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
}

.settings-field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-muted);
}

.settings-field input {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
}

.settings-field input:focus {
  outline: none;
  border-color: rgba(242, 24, 98, 0.45);
  box-shadow: 0 0 0 3px rgba(242, 24, 98, 0.12);
}

.pw-field {
  position: relative;
  display: flex;
  align-items: center;
}

.pw-field input {
  padding-right: 44px;
}

.pw-field.has-generate input {
  padding-right: 76px;
}

.pw-toggle,
.pw-generate {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-muted);
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
}

.pw-toggle { right: 8px; }
.pw-generate { right: 40px; }

.pw-toggle:hover,
.pw-generate:hover {
  background: var(--surface-3);
  color: var(--brand);
}

.pw-toggle svg,
.pw-generate svg {
  width: 16px;
  height: 16px;
}

.pw-toggle .hidden { display: none !important; }

.pw-hints {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
  display: grid;
  gap: 3px;
}

.pw-hints li {
  font-size: 12px;
  color: var(--ink-soft);
  padding-left: 16px;
  position: relative;
}

.pw-hints li::before {
  content: '○';
  position: absolute;
  left: 0;
}

.pw-hints li.is-met { color: #15803d; }
.pw-hints li.is-met::before { content: '●'; color: #15803d; }
.pw-hints li.is-fail { color: #b91c1c; }

.settings-email-inline {
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--ink-muted);
}

.settings-email-inline strong {
  color: var(--ink);
  font-weight: 650;
}

.password-msg {
  margin: 0 0 4px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--ink-muted);
}

.password-msg.is-error { color: #dc2626; }
.password-msg.is-ok { color: #15803d; }

.hidden { display: none !important; }

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(11, 31, 68, 0.35);
  z-index: 45;
  border: none;
  padding: 0;
  cursor: pointer;
}

.sidebar-backdrop.is-open {
  display: block;
}

@media (max-width: 768px) {
  .app-sidebar {
    position: fixed;
    z-index: 50;
    height: 100%;
    left: 0;
    width: min(280px, 86vw);
    transform: translateX(-105%);
    transition: transform 0.2s ease;
    box-shadow: none;
  }
  .app-sidebar.open {
    transform: translateX(0);
    box-shadow: 8px 0 32px rgba(11, 31, 68, 0.18);
  }
  /* Mobile drawer always uses expanded branding, not collapsed strip */
  .app-sidebar.collapsed {
    width: min(280px, 86vw);
  }
  .app-sidebar.collapsed .sidebar-top {
    flex-direction: row;
    justify-content: space-between;
    padding: 16px 14px 12px;
  }
  .app-sidebar.collapsed .sidebar-brand .logo-img--icon {
    display: none !important;
  }
  html[data-theme="light"] .app-sidebar.collapsed .sidebar-brand .logo-img--color {
    display: block !important;
  }
  html[data-theme="dark"] .app-sidebar.collapsed .sidebar-brand .logo-img--white {
    display: block !important;
  }
  .app-sidebar.collapsed .nav-item span,
  .app-sidebar.collapsed .history-label,
  .app-sidebar.collapsed .account-info,
  .app-sidebar.collapsed .account-chevron {
    display: revert;
  }
  .app-sidebar.collapsed .account-info {
    display: block;
  }
  .app-sidebar.collapsed .account-menu {
    display: block;
  }
  .app-sidebar.collapsed .account-menu[hidden] {
    display: none !important;
  }
  .topbar-menu-btn { display: grid; }
  .app-topbar { padding: 12px 14px; }
  .prompt-grid { grid-template-columns: 1fr; }

  .chat-input-wrap { padding: 12px 12px 16px; }
  .chat-input-tools {
    flex-wrap: nowrap;
    align-items: center;
  }
  .tool-group {
    flex: 1;
    min-width: 0;
    flex-wrap: wrap;
  }
  .tools-primary {
    width: 100%;
    justify-content: flex-start;
  }
  .tools-primary .model-picker {
    flex: 1;
    min-width: 0;
  }
  .tools-primary .model-picker-trigger {
    max-width: 100%;
    width: 100%;
  }
  .rewrite-group,
  .length-group,
  .tone-group {
    order: 2;
    width: 100%;
  }
  .btn-send {
    order: 0;
    margin-left: auto;
  }
  /* Keep send on the primary row: restructure via grid */
  .chat-input-tools {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "primary send"
      "rewrite rewrite"
      "tone tone"
      "length length";
    align-items: center;
    gap: 8px;
  }
  .tool-group {
    display: contents;
  }
  .tools-primary { grid-area: primary; }
  .rewrite-group { grid-area: rewrite; width: auto; }
  .tone-group { grid-area: tone; width: auto; }
  .length-group { grid-area: length; width: auto; }
  .btn-send { grid-area: send; margin-left: 0; }
}

/* Agent tasks page */
.agent-view {
  flex: 1;
  overflow-y: auto;
  padding: 32px 24px;
}

.agent-inner {
  max-width: 760px;
  margin: 0 auto;
}

.agent-page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.agent-page-head h1 {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0 0 6px;
}

.agent-page-sub {
  margin: 0;
  font-size: 14px;
  color: var(--ink-muted);
  line-height: 1.45;
  max-width: 48ch;
}

.agent-page-actions {
  display: flex;
  gap: 8px;
}

.agent-brief-card h2 {
  margin-bottom: 4px;
}

.agent-brief-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.agent-hint {
  margin: 0;
  font-size: 13px;
  color: var(--ink-muted);
  line-height: 1.4;
}

.agent-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}

.agent-toggle input {
  width: 16px;
  height: 16px;
  accent-color: var(--brand-magenta, #F21862);
}

.agent-task-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 14px;
}

.agent-task-tabs[hidden] {
  display: none !important;
}

.agent-task-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--ink-muted);
  border-radius: 999px;
  padding: 8px 12px;
  font: inherit;
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.agent-task-tab:hover {
  border-color: rgba(242, 24, 98, 0.35);
  color: var(--ink);
}

.agent-task-tab.is-active {
  border-color: rgba(242, 24, 98, 0.45);
  color: var(--ink);
  background: rgba(242, 24, 98, 0.08);
}

.agent-task-tab--overdue.is-active {
  border-color: rgba(248, 113, 113, 0.55);
  color: #b91c1c;
  background: rgba(248, 113, 113, 0.12);
}

.agent-task-tab-count {
  font-size: 11px;
  font-weight: 700;
  min-width: 1.4em;
  text-align: center;
  color: inherit;
  opacity: 0.75;
  background: rgba(20, 21, 28, 0.06);
  border-radius: 999px;
  padding: 1px 7px;
}

.agent-task-tab.is-active .agent-task-tab-count {
  opacity: 1;
  background: rgba(242, 24, 98, 0.12);
}

.agent-sections {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.agent-section {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px 12px;
}

.agent-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 700;
}

.agent-section-count {
  font-size: 12px;
  font-weight: 650;
  color: var(--ink-muted);
  background: var(--surface-3, rgba(255,255,255,0.06));
  border-radius: 999px;
  padding: 2px 8px;
}

.agent-task-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.agent-task {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 0;
  border-top: 1px solid var(--border-soft);
}

.agent-task:first-child {
  border-top: none;
  padding-top: 0;
}

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

.agent-task-title {
  margin: 0 0 4px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.35;
}

.agent-task-meta {
  margin: 0;
  font-size: 12px;
  color: var(--ink-muted);
  line-height: 1.4;
}

.agent-task-meta a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.agent-task-actions {
  display: flex;
  flex-shrink: 0;
  gap: 8px;
}

.agent-task-actions .btn {
  padding: 6px 12px;
  font-size: 12px;
}

.agent-empty {
  padding: 28px 20px;
  text-align: center;
  color: var(--ink-muted);
  font-size: 14px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

@media (max-width: 640px) {
  .agent-view { padding: 20px 16px; }
  .agent-brief-row { flex-direction: column; }
  .agent-task-tabs { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .agent-task-tab { flex: 0 0 auto; }
  .agent-task { flex-direction: column; }
  .agent-task-actions { width: 100%; }
  .agent-task-actions .btn { flex: 1; }
}
