/* =========================================================
   Base & Design Tokens
   ========================================================= */

:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-subtle: #f9f9f9;
  --surface-hover: #f1f1f1;
  --text: #111111;
  --text-secondary: #333333;
  --text-muted: #666666;
  --border: #e7e7e7;
  --border-strong: #d1d1d1;
  --border-focus: #111111;
  --accent: #111111;
  --accent-hover: #333333;
  --accent-light: #f4f4f4;

  --user-bubble: #111111;
  --ai-bubble: transparent;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
  --shadow-popover: 0 8px 24px rgba(0, 0, 0, 0.1);
  --shadow-input: 0 2px 12px rgba(0, 0, 0, 0.03);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-pill: 9999px;

  --max-width: 820px;
  --sidebar-width: 260px;
  --transition: 180ms ease;
}

[data-theme="dark"] {
  --bg: #121212;
  --surface: #1e1e1e;
  --surface-subtle: #181818;
  --surface-hover: #262626;
  --text: #f3f3f3;
  --text-secondary: #c8c8c8;
  --text-muted: #888888;
  --border: #2c2c2c;
  --border-strong: #3d3d3d;
  --border-focus: #ffffff;
  --accent: #ffffff;
  --accent-hover: #e0e0e0;
  --accent-light: #282828;

  --user-bubble: #282828;
  --ai-bubble: transparent;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-popover: 0 8px 24px rgba(0, 0, 0, 0.5);
  --shadow-input: 0 2px 12px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .topbar {
  background: rgba(18, 18, 18, 0.94);
}

[data-theme="dark"] .composer {
  background: linear-gradient(
    to bottom,
    rgba(18, 18, 18, 0),
    rgba(18, 18, 18, 0.92) 24%,
    #121212 50%
  );
}

[data-theme="dark"] .btn-submit,
[data-theme="dark"] .send-button,
[data-theme="dark"] .view-btn-primary {
  color: #121212 !important;
  background: #ffffff !important;
}

[data-theme="dark"] .settings-avatar,
[data-theme="dark"] .profile-avatar {
  background: #2a2a2a;
  color: #f0f0f0;
}

body[data-font-size="small"] {
  font-size: 13px;
}

body[data-font-size="large"] {
  font-size: 15.5px;
}

body[data-spacing="compact"] .messages {
  gap: 16px;
  padding: 18px 0;
}

body[data-spacing="compact"] .message__bubble {
  padding: 8px 12px;
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
  scroll-behavior: smooth;
}

body {
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI",
    Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
textarea,
input,
select {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

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


/* =========================================================
   App Layout
   ========================================================= */

.app-container {
  display: flex;
  height: 100vh;
  width: 100%;
  overflow: hidden;
}

.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg);
  position: relative;
  transition: margin-left var(--transition);
}


/* =========================================================
   Sidebar
   ========================================================= */

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  height: 100%;
  background: var(--surface-subtle);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: width var(--transition), transform var(--transition);
  z-index: 30;
  overflow: hidden;
}

.sidebar.collapsed {
  width: 0;
  border-right-color: transparent;
}

.sidebar__header {
  height: 64px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.sidebar__header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.icon-button {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}

.icon-button:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.sidebar__search {
  padding: 0 16px 12px;
  flex-shrink: 0;
}

.sidebar__search.hidden {
  display: none;
}

.search-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: border-color var(--transition);
}

.search-input:focus {
  border-color: var(--border-strong);
}

.sidebar__scroll {
  flex: 1;
  overflow-y: auto;
  padding: 12px 12px 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.sidebar__scroll::-webkit-scrollbar {
  width: 6px;
}

.sidebar__scroll::-webkit-scrollbar-thumb {
  background: #d1d1d1;
  border-radius: 4px;
}

.sidebar__nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
  transition: background var(--transition), color var(--transition);
}

.nav-item:hover {
  background: var(--surface-hover);
}

.nav-item.active {
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.nav-item svg {
  color: var(--text-secondary);
}

.sidebar__section {
  display: flex;
  flex-direction: column;
}

.sidebar__section-title {
  margin: 0 0 8px 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.chat-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chat-item {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition);
  font-size: 13px;
  color: var(--text-secondary);
}

.chat-item:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.chat-item.active {
  background: var(--surface);
  color: var(--text);
  font-weight: 500;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.chat-item-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.chat-item-actions {
  display: none;
  align-items: center;
  gap: 2px;
}

.chat-item:hover .chat-item-actions {
  display: flex;
}

.chat-action-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: grid;
  place-items: center;
  transition: background var(--transition), color var(--transition);
}

.chat-action-btn:hover {
  color: var(--text);
  background: rgba(0, 0, 0, 0.06);
}

.sidebar__empty-state {
  padding: 12px;
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}

.sidebar__footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface-subtle);
}

.profile-button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition);
  text-align: left;
}

.profile-button:hover {
  background: var(--surface-hover);
}

.profile-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #e8e8e8;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.profile-name {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.profile-icon {
  color: var(--text-secondary);
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 25;
  opacity: 0;
  transition: opacity var(--transition);
}


/* =========================================================
   Top navigation (Main App)
   ========================================================= */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 64px;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.topbar__inner {
  width: 100%;
  height: 100%;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topbar__left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar__title {
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
}

.menu-button {
  display: none;
}

.expand-button.hidden {
  display: none;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  text-decoration: none;
}

.brand__mark {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  font-size: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

.brand__logo {
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  padding: 0;
  object-fit: contain;
  flex-shrink: 0;
  display: block;
}

.new-chat-button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  color: var(--text-secondary);
  background: var(--surface);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition:
    color var(--transition),
    border-color var(--transition),
    background var(--transition),
    transform var(--transition);
}

.new-chat-button:hover {
  color: var(--text);
  border-color: var(--text);
  background: var(--surface-subtle);
}

.new-chat-button:active {
  transform: translateY(1px);
}

.new-chat-button span:first-child {
  font-size: 18px;
  font-weight: 400;
  line-height: 12px;
}

/* Hugging Face Model Hub / Library Manager */
.hf-models-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.hf-model-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  gap: 12px;
  transition: background var(--transition), border-color var(--transition);
}

.hf-model-item.is-default {
  border-color: var(--text);
  background: var(--surface-hover);
}

.hf-model-item__left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.hf-model-item__info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 2px;
}

.hf-model-item__name-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.hf-model-item__name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
}

.hf-model-tag {
  font-size: 11px;
  padding: 1px 6px;
  border-radius: var(--radius-pill);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

.hf-model-item__id {
  font-size: 11.5px;
  color: var(--text-muted);
  font-family: monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hf-model-item__actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.btn-set-default {
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-secondary);
  border-radius: var(--radius-pill);
  font-size: 11px;
  padding: 4px 9px;
  cursor: pointer;
  transition: all var(--transition);
  font-weight: 500;
}

.btn-set-default:hover {
  border-color: var(--text);
  color: var(--text);
}

.btn-set-default.active {
  background: var(--text);
  color: var(--bg) !important;
  border-color: var(--text);
  font-weight: 600;
}

.btn-delete-model {
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: grid;
  place-items: center;
  transition: color var(--transition), background var(--transition);
}

.btn-delete-model:hover {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
}

.topbar__right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-auth-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-auth-login {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 16px;
  background: #0d0d0d;
  color: #ffffff !important;
  border: 1px solid #0d0d0d;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition), opacity var(--transition);
  white-space: nowrap;
}

.btn-auth-login:hover {
  background: #2a2a2a;
  border-color: #2a2a2a;
}

.btn-auth-login:active {
  transform: translateY(1px);
}

.btn-auth-signup {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 15px;
  background: var(--surface-subtle);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), transform var(--transition);
  white-space: nowrap;
}

.btn-auth-signup:hover {
  background: var(--surface-hover);
  border-color: var(--text);
}

.btn-auth-signup:active {
  transform: translateY(1px);
}

[data-theme="dark"] .btn-auth-login {
  background: #ffffff;
  color: #121212 !important;
  border-color: #ffffff;
}

[data-theme="dark"] .btn-auth-login:hover {
  background: #e5e5e5;
  border-color: #e5e5e5;
}

/* Authentication View (Log In / Sign Up) */
.auth-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 520px;
  padding: 36px 12px;
  width: 100%;
}

.auth-card {
  width: 100%;
  max-width: 440px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
  box-shadow: var(--shadow-md);
  animation: fade-in 220ms ease both;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.auth-card.hidden {
  display: none !important;
}

.auth-card__header {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.auth-card__icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  margin-bottom: 6px;
}

.auth-card__header h2 {
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
  margin: 0;
  letter-spacing: -0.02em;
}

.auth-card__header p {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.45;
  max-width: 340px;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.auth-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.auth-link-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  padding: 0;
  transition: color var(--transition);
}

.auth-link-btn:hover {
  color: var(--text);
  text-decoration: underline;
}

.auth-password-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.auth-password-input {
  padding-right: 40px !important;
}

.auth-toggle-pwd {
  position: absolute;
  right: 6px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition), background var(--transition);
}

.auth-toggle-pwd:hover {
  color: var(--text);
  background: var(--surface-hover);
}

.btn-auth-primary {
  width: 100%;
  padding: 11px 16px;
  background: var(--accent);
  color: var(--bg) !important;
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity var(--transition), transform var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-auth-primary:hover {
  opacity: 0.92;
}

.btn-auth-primary:active {
  transform: translateY(1px);
}

[data-theme="dark"] .btn-auth-primary {
  background: #ffffff;
  color: #121212 !important;
  border-color: #ffffff;
}

.auth-switch-text {
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  padding-top: 4px;
}

.auth-switch-btn {
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  margin-left: 4px;
  text-decoration: underline;
}

.auth-switch-btn:hover {
  opacity: 0.8;
}


/* =========================================================
   Main chat area & Dynamic View Sections
   ========================================================= */

.chat {
  flex: 1;
  width: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

.chat__inner {
  width: min(100% - 32px, var(--max-width));
  flex: 1;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding-bottom: 24px;
}

/* Dynamic Inline View Container */
.view-section {
  display: none;
  width: 100%;
  flex-direction: column;
  animation: fade-in 220ms ease both;
}

.view-section.active {
  display: flex;
}

/* Common View Headers */
.view-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 36px 0 20px;
  gap: 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}

.view-header__text h2 {
  margin: 0 0 6px;
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
}

.view-header__text p {
  margin: 0;
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.view-btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--accent);
  color: #ffffff;
  border: 1px solid var(--accent);
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition:
    background var(--transition),
    transform var(--transition);
}

.view-btn-primary:hover {
  background: var(--accent-hover);
}

.view-btn-primary:active {
  transform: translateY(1px);
}

/* Filter Pills */
.filter-pills-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.filter-pill {
  padding: 6px 14px;
  font-size: 12.5px;
  font-weight: 500;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
  transition:
    background var(--transition),
    color var(--transition),
    border-color var(--transition);
}

.filter-pill:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.filter-pill.active {
  background: var(--text);
  color: #ffffff;
  border-color: var(--text);
}

/* View Search Box */
.view-search-box {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  margin-bottom: 18px;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.view-search-box:focus-within {
  border-color: var(--text);
  box-shadow: var(--shadow-sm);
}

.view-search-box svg {
  color: var(--text-muted);
  flex-shrink: 0;
}

.view-search-input {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  box-shadow: none;
  font-size: 14px;
  color: var(--text);
}

.view-search-input:focus,
.view-search-input:focus-visible {
  outline: none !important;
  box-shadow: none !important;
}

.view-results-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.search-result-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition:
    background var(--transition),
    border-color var(--transition),
    transform var(--transition);
}

.search-result-card:hover {
  background: var(--surface-subtle);
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

.search-result-card__info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.search-result-card__title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

.search-result-card__snippet {
  font-size: 12px;
  color: var(--text-muted);
}

/* Library Grid */
.library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}

.library-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition:
    border-color var(--transition),
    box-shadow var(--transition),
    transform var(--transition);
}

.library-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
  transform: translateY(-2px);
}

.library-card__top {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}

.library-card__icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.library-card__meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.library-card__name {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}

.library-card__sub {
  font-size: 11px;
  color: var(--text-muted);
}

.library-card__actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.library-card__attach-btn {
  padding: 4px 10px;
  font-size: 11.5px;
  font-weight: 500;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition:
    background var(--transition),
    color var(--transition);
}

.library-card__attach-btn:hover {
  background: var(--text);
  color: #ffffff;
}

/* Projects Grid */
.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 14px;
}

.project-card {
  display: flex;
  flex-direction: column;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition:
    border-color var(--transition),
    box-shadow var(--transition),
    transform var(--transition);
}

.project-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
  transform: translateY(-2px);
}

.project-card__title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 6px;
}

.project-card__desc {
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.4;
  margin: 0 0 16px;
}

.project-card__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: auto;
}

/* Plugins Grid */
.plugins-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 14px;
}

.plugin-card {
  display: flex;
  flex-direction: column;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: border-color var(--transition);
}

.plugin-card__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.plugin-card__title {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text);
}

.plugin-card__desc {
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.4;
  margin: 0 0 16px;
}

/* Profile / Settings Layout */
.profile-cards-layout {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.settings-card {
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.settings-card-title {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.settings-profile-header {
  display: flex;
  align-items: center;
  gap: 16px;
}

.settings-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: #e8e8e8;
  color: var(--text);
  font-size: 20px;
  font-weight: 600;
  display: grid;
  place-items: center;
}

.settings-user-info h3 {
  margin: 0 0 4px;
  font-size: 16px;
  font-weight: 600;
}

.settings-user-info span {
  font-size: 13px;
  color: var(--text-muted);
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.settings-row strong {
  display: block;
  font-size: 13.5px;
  color: var(--text);
}

.settings-row small {
  display: block;
  font-size: 11.5px;
  color: var(--text-muted);
}

.settings-select {
  padding: 6px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  outline: none;
}

.btn-secondary-danger {
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid #ffccd5;
  background: #fff5f7;
  color: #d63349;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition);
}

.btn-secondary-danger:hover {
  background: #ffe3e8;
}

.profile-tab-pane {
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: fade-in 180ms ease both;
}

.profile-tab-pane.hidden {
  display: none !important;
}

.help-shortcut-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.help-shortcut-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.help-shortcut-label {
  color: var(--text-secondary);
  font-weight: 500;
}

.help-kbd-group {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-muted);
}

.help-kbd {
  display: inline-block;
  padding: 3px 7px;
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1;
  color: var(--text);
  background-color: var(--surface-subtle);
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.08);
}

.faq-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.faq-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.faq-item strong {
  font-size: 13.5px;
  color: var(--text);
}

.faq-item p {
  margin: 0;
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.faq-item code {
  background: var(--surface-hover);
  padding: 2px 5px;
  border-radius: 4px;
  font-size: 11.5px;
}

.account-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  background: #e6f7ec;
  color: #0d8a3c;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid #b8ebc9;
}

.btn-logout {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  font-size: 12.5px;
  font-weight: 500;
  border: 1px solid #ffccd5;
  background: #fff5f7;
  color: #d63349;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition), transform var(--transition);
}

.btn-logout:hover {
  background: #ffe3e8;
}

.btn-logout:active {
  transform: translateY(1px);
}

/* Switch Control */
.switch-control {
  position: relative;
  display: inline-block;
  width: 38px;
  height: 20px;
}

.switch-control input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: #d1d1d1;
  transition: var(--transition);
  border-radius: 20px;
}

.switch-slider:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: var(--transition);
  border-radius: 50%;
}

.switch-control input:checked + .switch-slider {
  background-color: #111111;
}

.switch-control input:checked + .switch-slider:before {
  transform: translateX(18px);
}


/* =========================================================
   Welcome / empty state
   ========================================================= */

.welcome {
  width: 100%;
  margin: auto 0;
  padding: 56px 0 72px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  animation: fade-in 350ms ease both;
}

.welcome.hidden {
  display: none;
}

.welcome__icon {
  width: 52px;
  height: 52px;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.welcome__icon img {
  width: 100%;
  height: 100%;
  padding: 0;
  object-fit: contain;
}

.welcome h1 {
  margin: 0;
  color: var(--text);
  font-size: clamp(25px, 4vw, 32px);
  line-height: 1.2;
  letter-spacing: -0.035em;
  font-weight: 600;
}

.welcome > p {
  max-width: 460px;
  margin: 12px auto 0;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.65;
}

.suggestions {
  width: min(100%, 560px);
  margin-top: 32px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.suggestion {
  min-height: 76px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: flex-start;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  color: var(--text);
  background: var(--surface);
  font-size: 12px;
  line-height: 1.4;
  text-align: left;
  cursor: pointer;
  transition:
    border-color var(--transition),
    background var(--transition),
    transform var(--transition),
    box-shadow var(--transition);
}

.suggestion:hover {
  border-color: var(--text);
  background: var(--surface-subtle);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.suggestion span:last-child {
  align-self: flex-end;
  color: var(--text-muted);
  font-size: 15px;
}


/* =========================================================
   Messages
   ========================================================= */

.messages {
  width: 100%;
  padding: 34px 0 32px;
  display: flex;
  flex-direction: column;
  gap: 26px;
}

.messages:empty {
  display: none;
}

.message {
  display: flex;
  width: 100%;
  animation: message-in 220ms ease both;
}

.message--user {
  justify-content: flex-end;
}

.message--ai {
  justify-content: flex-start;
}

.message__content {
  max-width: min(78%, 680px);
  display: flex;
  flex-direction: column;
}

.message__label {
  margin-bottom: 7px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.01em;
  display: flex;
  align-items: center;
  gap: 6px;
}

.message--user .message__label {
  justify-content: flex-end;
  text-align: right;
}

.message-meta-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: var(--radius-pill);
  background: var(--surface-hover);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.message__bubble {
  padding: 12px 16px;
  font-size: 14px;
  line-height: 1.65;
  overflow-wrap: anywhere;
}

.message--user .message__bubble {
  border-radius: 20px 20px 4px 20px;
  background: var(--user-bubble);
  color: #ffffff;
}

.message--ai .message__bubble {
  padding-left: 0;
  color: var(--text);
}

.message__bubble p {
  margin: 0 0 10px;
}

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

/* User Message Attachment Previews */
.message-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
  justify-content: flex-end;
}

.message-attachment-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  background: #2a2a2a;
  color: #ffffff;
  font-size: 12px;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.message-attachment-thumb {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.2);
}


/* =========================================================
   Typing indicator
   ========================================================= */

.typing {
  display: flex;
  align-items: center;
  gap: 4px;
  width: fit-content;
  min-height: 28px;
  padding-left: 0;
}

.typing span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #9b9b9b;
  animation: typing-bounce 1.2s infinite ease-in-out;
}

.typing span:nth-child(2) {
  animation-delay: 120ms;
}

.typing span:nth-child(3) {
  animation-delay: 240ms;
}


/* =========================================================
   Composer
   ========================================================= */

.composer {
  position: sticky;
  bottom: 0;
  z-index: 10;
  flex-shrink: 0;
  padding: 12px 0 18px;
  background: linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0),
    rgba(255, 255, 255, 0.92) 24%,
    #ffffff 50%
  );
}

.composer.hidden {
  display: none !important;
}

.composer__inner {
  width: min(100% - 32px, var(--max-width));
  margin: 0 auto;
}

/* Token Usage Progress Bars */
.token-usage-bar-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: 100%;
  margin-bottom: 8px;
  padding: 0 4px;
}

.token-usage-card {
  display: flex;
  flex-direction: column;
  background: transparent;
  border: none;
  padding: 0;
  box-shadow: none;
}

.token-progress-track {
  width: 100%;
  height: 4px;
  background: var(--border-strong);
  border-radius: 9999px;
  overflow: hidden;
  position: relative;
}

.token-progress-fill {
  height: 100%;
  background: var(--text);
  border-radius: 9999px;
  width: 0%;
  transition: width 350ms cubic-bezier(0.4, 0, 0.2, 1), background-color 300ms ease;
}

.token-progress-fill.limit-warning {
  background: #f59e0b;
}

.token-progress-fill.limit-reached {
  background: #ef4444;
}

[data-theme="dark"] .token-remaining-pill.limit-warning {
  background: rgba(245, 158, 11, 0.2);
  color: #fbbf24;
  border-color: rgba(245, 158, 11, 0.4);
}

[data-theme="dark"] .token-remaining-pill.limit-reached {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.4);
}

.composer-form {
  width: 100%;
}

.input-wrapper {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 54px;
  padding: 6px 8px;
  border: 1px solid var(--border-strong);
  border-radius: 24px;
  background: var(--surface);
  box-shadow: var(--shadow-input);
  transition:
    border-color var(--transition),
    box-shadow var(--transition);
}

.input-wrapper:focus-within {
  border-color: #999999;
  box-shadow:
    0 1px 3px rgba(0, 0, 0, 0.04),
    0 8px 24px rgba(0, 0, 0, 0.06);
}

/* Metadata / Active Badges Area */
.composer-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 2px 8px 0;
}

.composer-meta:empty {
  display: none;
}

.meta-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1;
  animation: fade-in 180ms ease both;
}

.meta-badge.hidden {
  display: none;
}

.web-search-badge {
  background: #f0f4ff;
  color: #1a56db;
  border: 1px solid #c3d9ff;
}

.meta-badge__remove {
  border: none;
  background: transparent;
  color: inherit;
  cursor: pointer;
  padding: 0;
  font-size: 14px;
  line-height: 1;
  display: grid;
  place-items: center;
  opacity: 0.7;
  transition: opacity var(--transition);
}

.meta-badge__remove:hover {
  opacity: 1;
}

/* Attachments Preview inside composer */
.attachments-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 6px 8px 4px;
}

.attachments-preview.hidden {
  display: none;
}

.attachment-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text);
  max-width: 220px;
  animation: fade-in 180ms ease both;
  position: relative;
}

.attachment-chip__thumb {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid var(--border);
}

.attachment-chip__icon {
  display: grid;
  place-items: center;
  color: var(--text-muted);
  flex-shrink: 0;
}

.attachment-chip__details {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.attachment-chip__name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
}

.attachment-chip__size {
  font-size: 10px;
  color: var(--text-muted);
}

.attachment-chip__remove {
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  font-size: 14px;
  line-height: 1;
  display: grid;
  place-items: center;
  transition: color var(--transition), background var(--transition);
}

.attachment-chip__remove:hover {
  color: var(--text);
  background: var(--surface-hover);
}

/* Composer Controls Row */
.composer-row {
  display: flex;
  align-items: center;
  width: 100%;
  gap: 4px;
}

.composer-action-container {
  position: relative;
  display: flex;
  align-items: center;
}

.composer-btn {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition:
    background var(--transition),
    color var(--transition),
    transform var(--transition);
  flex-shrink: 0;
  position: relative;
}

.composer-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.composer-btn:active {
  transform: scale(0.94);
}

.plus-btn {
  font-size: 18px;
}

.plus-btn.active {
  background: var(--surface-hover);
  color: var(--text);
}

/* Plus Dropdown Popover Menu */
.plus-menu {
  position: absolute;
  bottom: calc(100% + 12px);
  left: 0;
  z-index: 50;
  width: 240px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-popover);
  display: flex;
  flex-direction: column;
  gap: 2px;
  opacity: 0;
  transform: translateY(6px) scale(0.98);
  pointer-events: none;
  transition:
    opacity var(--transition),
    transform var(--transition);
}

.plus-menu.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.plus-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: none;
  background: transparent;
  color: var(--text);
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
  transition: background var(--transition);
}

.plus-menu-item:hover {
  background: var(--surface-hover);
}

.plus-menu-item__icon {
  display: grid;
  place-items: center;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.plus-menu-item__text {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.plus-menu-item__text strong {
  font-size: 13px;
  font-weight: 500;
  line-height: 1.3;
}

.plus-menu-item__text small {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.2;
}

.plus-menu-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 6px;
}

.plus-menu-item__toggle {
  display: inline-flex;
  align-items: center;
}

.toggle-switch {
  width: 28px;
  height: 16px;
  background: #d4d4d4;
  border-radius: var(--radius-pill);
  position: relative;
  transition: background var(--transition);
}

.toggle-switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 12px;
  height: 12px;
  background: #ffffff;
  border-radius: 50%;
  transition: transform var(--transition);
}

.plus-menu-item.active .toggle-switch {
  background: #111111;
}

.plus-menu-item.active .toggle-switch::after {
  transform: translateX(12px);
}

/* Center Input Area */
.message-input {
  flex: 1;
  max-height: 180px;
  min-height: 24px;
  margin: 0;
  padding: 8px 6px;
  border: 0;
  outline: none;
  box-shadow: none;
  resize: none;
  color: var(--text);
  background: transparent;
  font-size: 14px;
  line-height: 20px;
  overflow-y: auto;
}

.message-input:focus,
.message-input:focus-visible {
  outline: none !important;
  box-shadow: none !important;
}

.message-input::placeholder {
  color: #999999;
}

/* Right Actions Container */
.composer-right-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

/* Voice Button */
.voice-btn {
  color: var(--text-secondary);
}

.voice-btn.recording {
  color: #e53e3e;
  background: rgba(229, 62, 62, 0.1);
}

.voice-pulse-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid #e53e3e;
  opacity: 0;
  pointer-events: none;
}

.voice-btn.recording .voice-pulse-ring {
  animation: pulse-ring 1.4s infinite ease-out;
}

@keyframes pulse-ring {
  0% {
    transform: scale(0.9);
    opacity: 0.8;
  }
  100% {
    transform: scale(1.4);
    opacity: 0;
  }
}

/* Send Button */
.send-button {
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: #ffffff;
  background: var(--accent);
  cursor: pointer;
  transition:
    background var(--transition),
    opacity var(--transition),
    transform var(--transition);
}

.send-button:hover:not(:disabled) {
  background: var(--accent-hover);
}

.send-button:active:not(:disabled) {
  transform: scale(0.95);
}

.send-button:disabled {
  opacity: 0.25;
  cursor: default;
}

.composer-hint {
  margin: 8px 0 0;
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.4;
  text-align: center;
}


/* =========================================================
   Toast Notification
   ========================================================= */

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #1f1f1f;
  color: #ffffff;
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  box-shadow: var(--shadow-md);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity var(--transition),
    transform var(--transition);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}


/* =========================================================
   Focus accessibility
   ========================================================= */

button:focus-visible,
a:focus-visible,
select:focus-visible {
  outline: 2px solid #555555;
  outline-offset: 2px;
}


/* =========================================================
   Animations
   ========================================================= */

@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes message-in {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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


/* =========================================================
   Modal Dialogs & Popups
   ========================================================= */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
  padding: 16px;
}

.modal-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  width: 100%;
  max-width: 440px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-popover);
  display: flex;
  flex-direction: column;
  transform: translateY(12px) scale(0.97);
  transition: transform var(--transition);
  overflow: hidden;
}

.modal-backdrop.open .modal-card {
  transform: translateY(0) scale(1);
}

.modal-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-card__title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
}

.modal-card__title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.modal-card__form {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

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

.form-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

.label-optional {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: normal;
}

.form-input,
.form-textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 13.5px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.form-input:focus,
.form-textarea:focus {
  border-color: var(--text);
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.05);
}

.form-textarea {
  resize: vertical;
  min-height: 72px;
}

.modal-card__actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 4px;
}

.btn-cancel {
  padding: 8px 14px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}

.btn-cancel:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.btn-submit {
  padding: 8px 16px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #ffffff;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition);
}

.btn-submit:hover {
  background: var(--accent-hover);
}

.btn-submit:active {
  transform: translateY(1px);
}


/* =========================================================
   Mobile / Responsive
   ========================================================= */

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: -280px;
    bottom: 0;
    z-index: 40;
    transition: transform var(--transition);
  }

  .sidebar.open {
    transform: translateX(280px);
  }

  .sidebar-backdrop.show {
    display: block;
    opacity: 1;
  }

  .menu-button {
    display: grid;
  }

  #collapseSidebarButton {
    display: none;
  }

  .app-main {
    margin-left: 0 !important;
  }
}

@media (max-width: 640px) {
  .topbar {
    height: 58px;
  }

  .topbar__inner {
    padding: 0 12px;
  }

  .chat__inner,
  .composer__inner {
    width: min(100% - 20px, var(--max-width));
  }

  .new-chat-button {
    padding: 8px 10px;
  }

  .new-chat-button span:last-child {
    display: none;
  }

  .view-header {
    padding-top: 24px;
    flex-direction: column;
    align-items: stretch;
  }

  .library-grid,
  .projects-grid,
  .plugins-grid {
    grid-template-columns: 1fr;
  }

  .welcome {
    padding: 40px 0 56px;
  }

  .welcome__icon {
    width: 44px;
    height: 44px;
    margin-bottom: 17px;
  }

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

  .welcome > p {
    max-width: 330px;
    font-size: 13px;
  }

  .suggestions {
    grid-template-columns: 1fr;
    margin-top: 24px;
  }

  .suggestion {
    min-height: 56px;
    flex-direction: row;
    align-items: center;
  }

  .suggestion span:last-child {
    align-self: auto;
  }

  .messages {
    padding-top: 20px;
    gap: 20px;
  }

  .message__content {
    max-width: 88%;
  }

  .message__bubble {
    font-size: 14px;
  }

  .composer {
    padding: 8px 0 12px;
  }

  .composer-hint {
    display: none;
  }

  .input-wrapper {
    min-height: 50px;
    border-radius: 20px;
  }

  .plus-menu {
    left: -4px;
    bottom: calc(100% + 8px);
    width: min(calc(100vw - 36px), 250px);
  }
}

@media (max-width: 380px) {
  .brand {
    font-size: 14px;
  }

  .message__content {
    max-width: 92%;
  }
}

@media (max-width: 520px) {
  .btn-auth-signup {
    padding: 6px 10px;
    font-size: 12px;
  }
  .btn-auth-login {
    padding: 6px 12px;
    font-size: 12px;
  }
}


@media (max-width: 420px) {
  .topbar-auth-group {
    gap: 4px;
  }
  .btn-auth-signup {
    padding: 5px 8px;
    font-size: 11.5px;
  }
  .btn-auth-login {
    padding: 5px 10px;
    font-size: 11.5px;
  }
}


/* =========================================================
   Reduced motion
   ========================================================= */

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}