/* ══════════════════════════════════════════
   UNIFIED TOKEN SYSTEM
   Light (default) + 3 LuxDev dark variants
══════════════════════════════════════════ */

:root {
  /* Light theme — Agnamo original */
  --text: #0E0E0E;
  --text-sec: rgba(14,14,14,0.44);
  --text-mid: rgba(14,14,14,0.65);
  --bg: #FAFAFA;
  --surface: #F2EDE3;
  --border: rgba(14,14,14,0.09);
  --hover: rgba(14,14,14,0.04);
  --primary: #0A84FF;
  --primary-s: #0A84FF;
  --accent: #0A84FF;
  --danger: #FF3B30;
  --success: #2DB84B;
  --gradient: linear-gradient(315deg, #AECADD 0%, #DDE9F2 40%, #FAFAFA 100%);
  --app-grad: none;
  --glass: rgba(255,255,255,0.58);
  --glass-border: rgba(255,255,255,0.6);
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --shadow-sm: 0 1px 3px rgba(14,14,14,0.06);
  --shadow-md: 0 4px 16px rgba(14,14,14,0.08);
  --shadow-lg: 0 8px 32px rgba(14,14,14,0.10);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --transition: 0.3s;
}

/* Dark theme — LuxDev default (purple) */
[data-theme="dark"] {
  --text: #e2e2e8;
  --text-sec: #6b6b80;
  --text-mid: #a0a0b8;
  --bg: #0f0f13;
  --surface: #18181f;
  --border: #2a2a38;
  --hover: #1e1e2a;
  --primary: #a78bfa;
  --primary-s: #c4b5fd;
  --accent: #a78bfa;
  --danger: #f87171;
  --success: #4ade80;
  --gradient: none;
  --app-grad:
    radial-gradient(900px 520px at 18% -10%, rgba(99,102,241,.14), transparent 60%),
    radial-gradient(900px 520px at 90% 10%, rgba(167,139,250,.10), transparent 55%);
  --glass: rgba(255,255,255,0.06);
  --glass-border: rgba(255,255,255,0.08);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.2);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.25);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.3);
}

/* LUDVIG 2 — deep navy + orange */
[data-theme="ludvig2"] {
  --text: #e7eef8;
  --text-sec: #9fb2d3;
  --text-mid: #7a93be;
  --bg: #0b1123;
  --surface: #121d36;
  --border: #2a3e66;
  --hover: #1b2a4d;
  --primary: #ff8a1c;
  --primary-s: #ffad66;
  --accent: #ff8a1c;
  --danger: #f87171;
  --success: #4ade80;
  --gradient: none;
  --app-grad:
    radial-gradient(900px 520px at 12% -8%, rgba(255,138,28,.24), transparent 60%),
    radial-gradient(900px 520px at 90% 8%, rgba(56,189,248,.18), transparent 55%),
    radial-gradient(1000px 680px at 18% 120%, rgba(99,102,241,.16), transparent 60%),
    radial-gradient(700px 520px at 82% 120%, rgba(14,165,233,.10), transparent 65%);
  --glass: rgba(255,255,255,0.06);
  --glass-border: rgba(255,255,255,0.08);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.2);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.25);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.3);
}

/* Teal — LuxDev teal variant */
[data-theme="teal"] {
  --text: #f0fdfc;
  --text-sec: #5eead4;
  --text-mid: #99f6e4;
  --bg: #042f2e;
  --surface: #0f4c4a;
  --border: #134e4a;
  --hover: #115e59;
  --primary: #2dd4bf;
  --primary-s: #5eead4;
  --accent: #2dd4bf;
  --danger: #f87171;
  --success: #4ade80;
  --gradient: none;
  --app-grad:
    radial-gradient(900px 520px at 12% -10%, rgba(45,212,191,.22), transparent 60%),
    radial-gradient(900px 520px at 90% 10%, rgba(59,130,246,.14), transparent 55%),
    radial-gradient(900px 600px at 18% 120%, rgba(236,72,153,.06), transparent 60%);
  --glass: rgba(255,255,255,0.06);
  --glass-border: rgba(255,255,255,0.08);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.2);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.25);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.3);
}

/* ── Tag colors (from LuxDev) ── */
/* Used via .tag-active, .tag-archive, etc. */

/* ── Transition for theme switching ── */
html {
  transition: background var(--transition, 0.3s), color var(--transition, 0.3s);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, "SF Pro Display", "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  background-image: var(--app-grad);
  background-attachment: fixed;
  color: var(--text);
  overflow: hidden;
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition, 0.3s), color var(--transition, 0.3s);
}

input,
textarea,
button,
select {
  font-family: inherit;
}

::-webkit-scrollbar {
  width: 0;
  height: 0;
}

@media (min-width: 1024px) {
  ::-webkit-scrollbar {
    width: 6px;
  }

  ::-webkit-scrollbar-track {
    background: transparent;
  }

  ::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
  }

  ::-webkit-scrollbar-thumb:hover {
    background: var(--text-sec);
  }
}

#app {
  width: 100%;
  max-width: 430px;
  height: 100dvh;
  max-height: 932px;
  display: flex;
  flex-direction: column;
  background: var(--gradient, var(--bg));
  overflow: hidden;
  position: relative;
  transition: background var(--transition, 0.3s);
}

.auth-screen {
  width: 100%;
  max-width: 430px;
  height: 100dvh;
  max-height: 932px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--gradient, var(--bg));
  background-image: var(--app-grad);
}

.auth-form {
  width: 100%;
  padding: 28px 24px;
  border-radius: var(--radius-xl);
  background: var(--glass);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(40px);
  -webkit-backdrop-filter: blur(40px);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.auth-eyebrow {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-sec);
}

.auth-title {
  font-size: 28px;
  line-height: 1.05;
  letter-spacing: -0.04em;
  color: var(--text);
}

.auth-description,
.auth-hint {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-mid);
}

.auth-input {
  width: 100%;
  min-height: 46px;
  padding: 0 14px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  outline: none;
}

.auth-input:focus {
  border-color: var(--accent);
}

.auth-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 4px;
}

.auth-btn {
  width: 100%;
  min-height: 48px;
  border: none;
  border-radius: var(--radius-md);
  background: var(--primary);
  color: #FFF;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  cursor: pointer;
  transition: transform 0.1s, filter 0.2s;
}

.auth-btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.auth-btn:active:not(:disabled) {
  transform: scale(0.99);
}

.auth-error {
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: rgba(255, 59, 48, 0.08);
  border: 1px solid rgba(255, 59, 48, 0.18);
  color: var(--danger);
  font-size: 13px;
  line-height: 1.5;
}

.auth-toggle-link {
  align-self: flex-start;
  padding: 0;
  background: none;
  border: none;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.auth-toggle-link:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

@media (min-width: 431px) {
  #app,
  .auth-screen {
    border-radius: var(--radius-xl);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.12);
  }
}

.topbar {
  height: 52px;
  padding: 0 20px;
  padding-top: var(--safe-t);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  position: relative;
  z-index: 10;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
}

.topbar-btn {
  width: 36px;
  height: 36px;
  border-radius: 18px;
  background: var(--glass);
  border: 1px solid var(--border);
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.1s, background 0.15s;
}

.topbar-btn:active {
  transform: scale(0.92);
  background: var(--hover);
}

.topbar-spacer {
  width: 36px;
}

.user-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 4px 10px 4px 4px;
  border-radius: 999px;
  background: var(--glass);
  border: 1px solid var(--border);
}

.user-indicator-avatar {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  color: var(--text);
  font-size: 11px;
  font-weight: 700;
  overflow: hidden;
}

.user-indicator-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.user-indicator-label {
  max-width: 148px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  color: var(--text-mid);
}

.content-frame {
  flex: 1;
  overflow: hidden;
  background: var(--glass);
  backdrop-filter: blur(40px);
  -webkit-backdrop-filter: blur(40px);
  border-top: 1px solid var(--glass-border);
  margin: 0 8px;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  position: relative;
}

.tab-panel {
  display: none;
  flex-direction: column;
  height: 100%;
  width: 100%;
  position: absolute;
  inset: 0;
}

.tab-panel.active {
  display: flex;
  animation: fadeIn 0.2s ease;
}

.settings-overlay {
  position: absolute;
  inset: 0;
  z-index: 200;
  background:
    linear-gradient(180deg, rgba(8, 12, 24, 0.92) 0%, rgba(16, 24, 42, 0.9) 100%);
  backdrop-filter: blur(40px);
  -webkit-backdrop-filter: blur(40px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.28);
  display: none;
  flex-direction: column;
}

.settings-overlay.open {
  display: flex;
  animation: slideUp 0.28s ease;
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
  }

  to {
    transform: translateY(0);
  }
}

.settings-header {
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
  flex-shrink: 0;
}

.settings-header h3 {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.close-btn {
  font-size: 14px;
  font-weight: 500;
  color: var(--accent);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
}

.close-btn:active {
  opacity: 0.5;
}

.pill-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 0 calc(14px + var(--safe-b));
  background: var(--glass);
  backdrop-filter: blur(40px);
  -webkit-backdrop-filter: blur(40px);
  margin: 0 8px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.pill-track {
  display: flex;
  background: var(--hover);
  border-radius: 22px;
  padding: 3px;
}

.pill-tab {
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-sec);
  background: none;
  border: none;
  border-radius: 19px;
  cursor: pointer;
  transition: color 0.2s, background 0.2s, font-weight 0.2s;
  position: relative;
  z-index: 1;
  letter-spacing: -0.01em;
}

.pill-tab:active {
  transform: scale(0.97);
}

.pill-tab.active {
  color: var(--text);
  font-weight: 600;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.35;
  }
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
  }

  to {
    transform: translateX(0);
  }
}

.model-bar {
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  background: var(--glass);
  flex-shrink: 0;
}

.model-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  letter-spacing: -0.01em;
}

.model-dropdown {
  position: absolute;
  top: 44px;
  left: 16px;
  right: 16px;
  background: var(--surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 50;
  overflow: hidden;
  border: 1px solid var(--border);
  display: none;
}

.model-dropdown.open {
  display: block;
  animation: fadeUp 0.15s ease;
}

.model-option {
  width: 100%;
  padding: 11px 16px;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  transition: background 0.12s;
}

.model-option:active {
  background: var(--surface);
}

.model-option:last-child {
  border-bottom: none;
}

.model-option.selected {
  color: var(--accent);
  font-weight: 600;
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.msg {
  max-width: 82%;
  padding: 11px 16px;
  font-size: 14px;
  line-height: 1.5;
  letter-spacing: -0.01em;
  animation: fadeUp 0.3s ease both;
}

.msg.user {
  align-self: flex-end;
  background: var(--primary);
  color: #FFF;
  border-radius: 18px 18px 4px 18px;
}

.msg.assistant {
  align-self: flex-start;
  background: var(--surface);
  color: var(--text);
  border-radius: 18px 18px 18px 4px;
}

.input-bar {
  padding: 10px 16px 12px;
  flex-shrink: 0;
  background: var(--glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
}

.input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 6px 6px 6px 16px;
}

.input-row input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 15px;
  background: transparent;
  color: var(--text);
}

.input-row input::placeholder {
  color: var(--text-sec);
}

.send-btn {
  width: 36px;
  height: 36px;
  border-radius: 18px;
  border: none;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.1s;
}

.send-btn:active {
  transform: scale(0.92);
}

.page-header {
  padding: 16px 20px 12px;
  flex-shrink: 0;
}

.page-header h2 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.page-header p {
  font-size: 13px;
  color: var(--text-sec);
  margin-top: 3px;
}

.scroll-area {
  flex: 1;
  overflow-y: auto;
}

.tile-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 0 20px 24px;
}

.tile {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  border: none;
  padding: 0;
  text-align: left;
  aspect-ratio: 1;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.25s, transform 0.15s;
}

.tile:active {
  transform: scale(0.96);
}

.tile.running {
  box-shadow: 0 0 0 2.5px var(--accent), var(--shadow-md);
}

.tile-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0) 30%, rgba(0, 0, 0, 0.55) 100%);
}

.tile-status {
  position: absolute;
  top: 12px;
  right: 12px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 4px;
  display: inline-block;
}

.status-dot.pulse {
  animation: pulse 1.5s ease infinite;
  box-shadow: 0 0 8px var(--accent);
}

.tile-content {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 16px;
}

.tile-name {
  font-size: 15px;
  font-weight: 700;
  color: #FFF;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.tile-desc {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.72);
  margin-top: 3px;
}

.agent-card {
  padding: 14px 20px;
  width: 100%;
  border: none;
  text-align: left;
  background: transparent;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: background 0.12s;
}

.agent-card:active {
  background: var(--hover);
}

.agent-swatch {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.agent-info {
  flex: 1;
  min-width: 0;
}

.agent-info .name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}

.agent-info .meta {
  font-size: 12px;
  color: var(--text-sec);
  margin-top: 2px;
}

.detail-panel {
  position: absolute;
  inset: 0;
  z-index: 100;
  background: var(--glass);
  backdrop-filter: blur(40px);
  -webkit-backdrop-filter: blur(40px);
  display: none;
  flex-direction: column;
  animation: slideIn 0.25s ease;
}

.detail-panel.open {
  display: flex;
}

.detail-header {
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.back-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
}

.back-btn:active {
  opacity: 0.5;
}

.detail-header h3 {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.detail-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.field-group {
  margin-bottom: 20px;
}

.field-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-sec);
  margin-bottom: 6px;
}

.field-input {
  width: 100%;
  padding: 11px 14px;
  font-size: 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--glass);
  color: var(--text);
  outline: none;
  transition: border-color 0.2s;
}

.field-input:focus {
  border-color: var(--accent);
}

textarea.field-input {
  resize: vertical;
  min-height: 80px;
  line-height: 1.5;
}

select.field-input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2.5' xmlns='http://www.w3.org/2000/svg'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pill {
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  background: var(--glass);
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s;
}

.pill.active {
  background: var(--primary);
  color: #FFF;
  border-color: var(--primary);
}

.pill:active {
  transform: scale(0.95);
}

.save-btn {
  width: 100%;
  padding: 12px;
  font-size: 14px;
  font-weight: 600;
  border: 1.5px solid var(--accent);
  border-radius: var(--radius-md);
  background: var(--accent);
  color: #FFF;
  cursor: pointer;
}

.save-btn:disabled {
  opacity: 0.6;
}

.save-btn:active {
  transform: scale(0.99);
}

.danger-btn {
  width: 100%;
  padding: 12px;
  font-size: 14px;
  font-weight: 500;
  border: 1.5px solid var(--danger);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--danger);
  cursor: pointer;
  margin-top: 12px;
}

.danger-btn:active {
  background: rgba(255, 59, 48, 0.08);
}

.error-note {
  margin-top: 10px;
  font-size: 12px;
  color: var(--danger);
}

.section-header {
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
}

.sec-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.02em;
}

.sec-count {
  font-size: 12px;
  color: var(--text-sec);
  margin-top: 1px;
}

.sec-chevron {
  transition: transform 0.2s;
}

.section-header.open .sec-chevron {
  transform: rotate(90deg);
}

.section-body {
  display: none;
  padding: 0 20px 14px;
  background: rgba(6, 10, 20, 0.12);
}

.section-body.open {
  display: block;
  animation: fadeUp 0.2s ease;
}

.account-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 12px;
}

.account-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
}

.account-avatar {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  flex-shrink: 0;
  background: var(--surface);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 700;
  overflow: hidden;
}

.account-avatar-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.account-copy {
  min-width: 0;
}

.account-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.account-email,
.account-expiry {
  font-size: 12px;
  color: var(--text-sec);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-signout {
  margin-top: 0;
}

.conn-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
}

.conn-row:last-child {
  border-bottom: none;
}

.section-body.open .conn-row:first-child,
.section-body.open .mcp-row:first-child,
.section-body.open .pref-row:first-child {
  border-top-left-radius: 12px;
  border-top-right-radius: 12px;
}

.section-body.open .conn-row:last-child,
.section-body.open .mcp-row:last-child,
.section-body.open .pref-row:last-child {
  border-bottom-left-radius: 12px;
  border-bottom-right-radius: 12px;
}

.conn-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.conn-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
}

.conn-icon.on {
  background: var(--surface);
  color: var(--text);
}

.conn-icon.off {
  background: var(--hover);
  color: var(--text-sec);
}

.conn-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

.conn-status {
  font-size: 11px;
}

.conn-status.on {
  color: var(--success);
}

.conn-status.off {
  color: var(--text-sec);
}

.toggle {
  width: 44px;
  height: 26px;
  border-radius: 13px;
  border: none;
  padding: 0;
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
  transition: background 0.25s;
}

.toggle.on {
  background: var(--accent);
}

.toggle.off {
  background: var(--border);
}

.toggle-knob {
  width: 22px;
  height: 22px;
  border-radius: 11px;
  background: #FFF;
  position: absolute;
  top: 2px;
  transition: left 0.25s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.toggle.on .toggle-knob {
  left: 20px;
}

.toggle.off .toggle-knob {
  left: 2px;
}

.mcp-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
}

.mcp-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.mcp-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

.mcp-url {
  font-size: 11px;
  color: var(--text-sec);
  font-family: "SF Mono", monospace;
}

.add-btn {
  margin-top: 12px;
  width: 100%;
  padding: 11px;
  border-radius: var(--radius-md);
  border: 1.5px dashed var(--border);
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-sec);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

.add-btn:active {
  border-color: var(--accent);
  color: var(--accent);
}

.pref-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid var(--border);
}

.pref-label {
  font-size: 14px;
  color: var(--text);
}

.pref-value {
  font-size: 13px;
  color: var(--text-sec);
  display: flex;
  align-items: center;
  gap: 4px;
}

.footer {
  padding: 24px 20px;
  text-align: center;
  font-size: 11px;
  color: var(--text-sec);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ══════════════════════════════════════════
   TAG / STATUS SYSTEM (from LuxDev)
══════════════════════════════════════════ */

.tag {
  display: inline-block;
  font-size: 0.65rem;
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 600;
  letter-spacing: 0.04em;
}
.tag-active     { background: rgba(74,222,128,.12); color: #4ade80; border: 1px solid rgba(74,222,128,.3); }
.tag-archive    { background: rgba(250,204,21,.10); color: #facc15; border: 1px solid rgba(250,204,21,.28); }
.tag-deprecated { background: rgba(248,113,113,.10); color: #f87171; border: 1px solid rgba(248,113,113,.28); }
.tag-workshop   { background: rgba(96,165,250,.10); color: #60a5fa; border: 1px solid rgba(96,165,250,.28); }
.tag-agent      { background: rgba(192,132,252,.10); color: #c084fc; border: 1px solid rgba(192,132,252,.28); }
.tag-db         { background: rgba(34,211,238,.10); color: #22d3ee; border: 1px solid rgba(34,211,238,.28); }
.tag-planned    { background: rgba(129,140,248,.10); color: #818cf8; border: 1px solid rgba(129,140,248,.28); }

.dot-active   { background: #4ade80; }
.dot-complete { background: #60a5fa; }
.dot-planned  { background: #818cf8; }

/* ══════════════════════════════════════════
   THEME SWITCHER (in settings)
══════════════════════════════════════════ */

.theme-switcher-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 0;
}

.theme-swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2.5px solid transparent;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s;
  flex-shrink: 0;
}
.theme-swatch:active { transform: scale(0.92); }
.theme-swatch.active { border-color: var(--text); transform: scale(1.05); }

.swatch-light    { background: linear-gradient(135deg, #AECADD, #FAFAFA); }
.swatch-dark     { background: radial-gradient(circle at 35% 35%, #a78bfa, #0f0f13); }
.swatch-ludvig2  { background: radial-gradient(circle at 35% 35%, #ff8a1c, #0b1123); }
.swatch-teal     { background: radial-gradient(circle at 35% 35%, #2dd4bf, #042f2e); }

.theme-swatch-label {
  font-size: 12px;
  color: var(--text-sec);
  margin-top: 4px;
  text-align: center;
}

/* ══════════════════════════════════════════
   RESPONSIVE — Desktop Enhancement
══════════════════════════════════════════ */

/* ── Tablet / small desktop (769px+) ── */
@media (min-width: 769px) {
  #app,
  .auth-screen {
    max-width: 900px;
    max-height: none;
  }

  .tile-grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  }

  .msg {
    max-width: 70%;
  }

  .messages {
    padding: 20px 28px;
  }

  .input-bar {
    padding: 12px 24px 14px;
  }

  .page-header {
    padding: 20px 28px 14px;
  }

  .tile-grid {
    padding: 0 28px 28px;
  }
}

/* ── Full desktop (1024px+) ── */
@media (min-width: 1024px) {
  body {
    overflow: auto;
  }

  #app,
  .auth-screen {
    max-width: 1120px;
    height: 100dvh;
    max-height: none;
    border-radius: 0;
    box-shadow: none;
  }

  .topbar {
    height: 56px;
    padding: 0 32px;
  }

  .topbar-title {
    font-size: 20px;
  }

  .content-frame {
    margin: 0 16px;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  }

  .pill-bar {
    margin: 0 16px;
  }

  .pill-tab {
    padding: 9px 24px;
    font-size: 14px;
  }

  .messages {
    padding: 24px 32px;
    gap: 12px;
  }

  .msg {
    max-width: 60%;
    padding: 12px 18px;
    font-size: 15px;
  }

  .input-bar {
    padding: 14px 32px 16px;
  }

  .input-row {
    max-width: 720px;
  }

  .input-row input {
    font-size: 15px;
  }

  .page-header {
    padding: 24px 32px 16px;
  }

  .page-header h2 {
    font-size: 24px;
  }

  .tile-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    padding: 0 32px 32px;
  }

  .tile {
    aspect-ratio: 4 / 3;
  }

  .agent-card {
    padding: 16px 32px;
  }

  .detail-body {
    padding: 24px 32px;
  }

  .detail-header {
    padding: 16px 32px;
  }

  .scroll-area {
    padding: 0;
  }

  .settings-header {
    padding: 16px 32px;
  }

  .section-header {
    padding: 16px 32px;
  }

  .section-body {
    padding: 0 32px 16px;
  }

  .field-group {
    margin-bottom: 24px;
  }

  .field-input {
    padding: 12px 16px;
    font-size: 15px;
  }

  .ld-header {
    padding: 20px 28px 0;
  }

  .ld-tab-bar {
    padding: 14px 28px 0;
  }

  .ld-scroll {
    padding: 20px 24px 32px;
  }

  /* Config split-panel: list + detail side by side */
  #panelConfig {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
  }

  #panelConfig.active {
    display: flex;
  }

  #panelConfig > .page-header {
    width: 100%;
    flex-shrink: 0;
  }

  #panelConfig > .scroll-area {
    width: 340px;
    flex-shrink: 0;
    border-right: 1px solid var(--border);
  }

  #panelConfig > .detail-panel {
    position: relative;
    flex: 1;
    min-width: 0;
    animation: none;
  }

  #panelConfig > .detail-panel.open {
    display: flex;
  }

  /* Settings overlay becomes side panel on desktop */
  .settings-overlay {
    max-width: 480px;
    right: 0;
    left: auto;
    border-left: 1px solid var(--border);
  }
}

/* ── Wide desktop (1280px+) ── */
@media (min-width: 1280px) {
  #app,
  .auth-screen {
    max-width: 1400px;
  }

  .tile-grid {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  }

  .msg {
    max-width: 55%;
  }

  .input-row {
    max-width: 800px;
  }
}

/* ── Hover states for pointer devices ── */
@media (hover: hover) and (pointer: fine) {
  .topbar-btn:hover {
    background: var(--hover);
  }

  .auth-btn:hover:not(:disabled) {
    filter: brightness(1.08);
  }

  .auth-toggle-link:hover:not(:disabled) {
    opacity: 0.75;
  }

  .pill-tab:hover:not(.active) {
    color: var(--text-mid);
    background: var(--hover);
  }

  .tile:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
  }

  .agent-card:hover {
    background: var(--hover);
  }

  .model-option:hover {
    background: var(--hover);
  }

  .send-btn:hover {
    filter: brightness(1.1);
  }

  .save-btn:hover:not(:disabled) {
    filter: brightness(1.08);
  }

  .danger-btn:hover {
    background: rgba(255, 59, 48, 0.06);
  }

  .pill:hover:not(.active) {
    border-color: var(--text-sec);
  }

  .close-btn:hover {
    opacity: 0.7;
  }

  .add-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
  }

  .ld-tab:hover:not(.active) {
    color: var(--text-mid);
    background: var(--hover);
  }

  .ld-card:hover {
    border-color: var(--accent);
  }

  .toggle:hover {
    filter: brightness(1.1);
  }

  .section-header:hover {
    background: rgba(255, 255, 255, 0.04);
  }

  .theme-swatch:hover:not(.active) {
    transform: scale(1.1);
  }
}

/* ══════════════════════════════════════════
   LUXDEV TAB — integrated map view
══════════════════════════════════════════ */

.ld-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.ld-header {
  padding: 16px 20px 0;
  flex-shrink: 0;
}

.ld-header h2 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--accent);
}

.ld-header p {
  font-size: 12px;
  color: var(--text-sec);
  margin-top: 3px;
}

/* Sub-tab bar */
.ld-tab-bar {
  display: flex;
  gap: 4px;
  padding: 12px 20px 0;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.ld-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-sec);
  cursor: pointer;
  border: none;
  background: none;
  border-radius: 8px 8px 0 0;
  border: 1px solid transparent;
  border-bottom: none;
  position: relative;
  bottom: -1px;
  transition: color 0.15s, background 0.15s;
}

.ld-tab:active {
  transform: scale(0.97);
}

.ld-tab.active {
  color: var(--accent);
  background: var(--surface);
  border-color: var(--border);
  border-bottom-color: var(--surface);
}

.ld-tab svg {
  width: 14px;
  height: 14px;
}

/* Scroll area */
.ld-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 16px 16px 24px;
}

/* Card grid */
.ld-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

@media (min-width: 560px) {
  .ld-grid {
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  }
}

/* Cards */
.ld-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: background 0.3s, border-color 0.3s;
}

.ld-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  transition: border-color 0.3s;
}

.ld-card-icon {
  flex-shrink: 0;
  color: var(--accent);
  transition: color 0.3s;
}

.ld-card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: -0.01em;
  transition: color 0.3s;
}

.ld-card-body {
  padding: 8px 12px 12px;
}

/* Notion card accent stripe */
.ld-notion-card .ld-card-header {
  border-left: 3px solid var(--accent);
  padding-left: 11px;
}

/* Section label */
.ld-section-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-sec);
  margin-bottom: 4px;
  margin-top: 8px;
  transition: color 0.3s;
}

/* Items */
.ld-item {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding: 2px 0;
  font-size: 12px;
  color: var(--text-mid);
  line-height: 1.4;
  flex-wrap: wrap;
}

/* ══════════════════════════════════════════
   TOAST NOTIFICATION
══════════════════════════════════════════ */

.toast-notification {
  position: fixed;
  bottom: calc(24px + var(--safe-b));
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  background: var(--surface, #18181f);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 9999;
  white-space: nowrap;
  max-width: calc(100vw - 48px);
}

.toast-notification.toast-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ══════════════════════════════════════════
   CHAT: EMPTY SEND FEEDBACK
══════════════════════════════════════════ */

.input-row.input-error,
#chatInput.input-error {
  border-color: var(--danger, #ef4444);
  transition: border-color 0.15s;
}

/* ══════════════════════════════════════════
   MCP: INLINE ADD FORM
══════════════════════════════════════════ */

.mcp-add-form {
  margin-top: 12px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.mcp-add-input {
  flex: 1;
  min-width: 80px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  outline: none;
}

.mcp-add-input::placeholder {
  color: var(--text-sec);
}

.mcp-add-confirm,
.mcp-add-cancel {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

.mcp-add-confirm {
  background: var(--primary);
  color: #fff;
}

.mcp-add-cancel {
  background: var(--hover);
  color: var(--text-sec);
  border: 1px solid var(--border);
}

/* Hover states for MCP/pref interactive rows */
@media (hover: hover) and (pointer: fine) {
  .mcp-row:hover,
  .pref-row:hover {
    background: var(--hover);
  }

  .mcp-add-confirm:hover {
    filter: brightness(1.1);
  }

  .mcp-add-cancel:hover {
    border-color: var(--text-sec);
  }
}

/* ══════════════════════════════════════════
   LD-CARD: informational hover state
   (pointer-device only, no cursor change)
══════════════════════════════════════════ */

/* Note: .ld-card:hover is already defined inside @media (hover: hover)
   above — no duplicate needed here */

.ld-item-icon {
  flex-shrink: 0;
  margin-top: 1px;
  color: var(--text-sec);
}

.ld-dim {
  color: var(--text-sec);
  font-size: 0.9em;
}

/* Sub-items */
.ld-sub-item {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding: 1px 0 1px 18px;
  font-size: 11px;
  color: var(--text-sec);
  line-height: 1.4;
  width: 100%;
}

.ld-sub-icon {
  flex-shrink: 0;
  margin-top: 1px;
  color: var(--text-sec);
  opacity: 0.6;
}

/* Status dots */
.ld-status-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-right: 4px;
  flex-shrink: 0;
  margin-top: 4px;
}

/* Divider */
.ld-divider {
  height: 1px;
  background: var(--border);
  margin: 8px 0;
  transition: background 0.3s;
}

/* ══════════════════════════════════════════
   TOAST NOTIFICATIONS
══════════════════════════════════════════ */

.toast-notification {
  position: fixed;
  bottom: calc(24px + var(--safe-b, 0px));
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  background: var(--bg, #1a1a1a);
  color: var(--text, #f5f5f5);
  border: 1px solid var(--border, #333);
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 13px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 9999;
}

.toast-notification.toast-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ══════════════════════════════════════════
   CHAT — EMPTY SEND FEEDBACK
══════════════════════════════════════════ */

.input-row.input-error,
#chatInput.input-error {
  border-color: var(--danger, #ef4444);
  transition: border-color 0.15s;
}

/* ══════════════════════════════════════════
   SETTINGS — MCP ADD FORM
══════════════════════════════════════════ */

.mcp-add-form {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mcp-add-input {
  flex: 1;
  min-width: 80px;
  padding: 8px 10px;
  background: var(--hover);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
}

.mcp-add-input::placeholder {
  color: var(--text-sec);
}

.mcp-add-confirm,
.mcp-add-cancel {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-size: 13px;
  cursor: pointer;
}

.mcp-add-confirm {
  background: var(--primary);
  color: #fff;
}

.mcp-add-cancel {
  background: var(--hover);
  color: var(--text-sec);
}

@media (hover: hover) {
  .mcp-add-confirm:hover {
    filter: brightness(1.1);
  }

  .mcp-add-cancel:hover {
    border-color: var(--text-sec);
  }
}

/* ══════════════════════════════════════════
   LUXDEV CARDS — hover state (non-media-query fallback)
══════════════════════════════════════════ */

/* Note: .ld-card:hover is already defined inside @media (hover: hover)
   above — no duplicate needed here */
