/* ─── Reset ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
button, input, select, textarea { font: inherit; }

/* ─── Tokens ─────────────────────────────────────────── */
:root {
  /* Light palette */
  --bg:           #eef0f7;
  --surface:      #ffffff;
  --surface-2:    #f5f6fb;
  --surface-3:    #eef0f6;
  --border:       #dde1ef;
  --border-light: #eaecf4;
  --text:         #141726;
  --text-2:       #3d4259;
  --muted:        #7880a0;
  --accent:       #5c5ff5;
  --accent-2:     #4547d4;
  --accent-fg:    #ffffff;
  --accent-tint:  #eef0fe;
  --accent-tint2: #dde1fc;
  --success:      #16a34a;
  --success-tint: #dcfce7;
  --danger:       #dc2626;
  --danger-tint:  #fee2e2;
  --warn:         #d97706;
  --warn-tint:    #fef3c7;
  --note-tint:    #fefce8;
  --note-border:  #fde68a;
  --shadow-sm:    0 1px 2px rgba(20,23,38,.06);
  --shadow:       0 1px 4px rgba(20,23,38,.08), 0 4px 12px rgba(20,23,38,.04);
  --shadow-lg:    0 4px 6px rgba(20,23,38,.06), 0 10px 30px rgba(20,23,38,.08);
  --radius-sm:    5px;
  --radius:       8px;
  --radius-lg:    12px;
  --radius-xl:    16px;
  --nav-w:        216px;
  --list-w:       288px;
  --detail-w:     256px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:           #0c0e18;
    --surface:      #13162a;
    --surface-2:    #181b30;
    --surface-3:    #1d2038;
    --border:       #252840;
    --border-light: #1d2038;
    --text:         #e4e7f8;
    --text-2:       #9da3c0;
    --muted:        #636888;
    --accent:       #7c7ff7;
    --accent-2:     #9395f9;
    --accent-tint:  #1a1d3a;
    --accent-tint2: #242748;
    --success:      #22c55e;
    --success-tint: #14532d;
    --danger:       #f87171;
    --danger-tint:  #450a0a;
    --warn:         #fbbf24;
    --warn-tint:    #451a03;
    --note-tint:    #1c1a06;
    --note-border:  #78600f;
    --shadow-sm:    0 1px 2px rgba(0,0,0,.3);
    --shadow:       0 1px 4px rgba(0,0,0,.4), 0 4px 12px rgba(0,0,0,.2);
    --shadow-lg:    0 4px 6px rgba(0,0,0,.4), 0 10px 30px rgba(0,0,0,.3);
  }
}

:root[data-theme="dark"] {
  --bg:           #0c0e18;
  --surface:      #13162a;
  --surface-2:    #181b30;
  --surface-3:    #1d2038;
  --border:       #252840;
  --border-light: #1d2038;
  --text:         #e4e7f8;
  --text-2:       #9da3c0;
  --muted:        #636888;
  --accent:       #7c7ff7;
  --accent-2:     #9395f9;
  --accent-tint:  #1a1d3a;
  --accent-tint2: #242748;
  --success:      #22c55e;
  --success-tint: #14532d;
  --danger:       #f87171;
  --danger-tint:  #450a0a;
  --warn:         #fbbf24;
  --warn-tint:    #451a03;
  --note-tint:    #1c1a06;
  --note-border:  #78600f;
  --shadow-sm:    0 1px 2px rgba(0,0,0,.3);
  --shadow:       0 1px 4px rgba(0,0,0,.4), 0 4px 12px rgba(0,0,0,.2);
  --shadow-lg:    0 4px 6px rgba(0,0,0,.4), 0 10px 30px rgba(0,0,0,.3);
}

/* ─── Base ─────────────────────────────────────────── */
html { height: 100%; }
body {
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  height: 100%;
  -webkit-font-smoothing: antialiased;
}

/* ─── App Shell ─────────────────────────────────────── */
.app { display: flex; height: 100vh; overflow: hidden; }

/* ─── Nav ────────────────────────────────────────────── */
.nav {
  width: var(--nav-w);
  min-width: var(--nav-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 16px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.nav-brand-icon {
  width: 30px;
  height: 30px;
  background: var(--accent);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 15px;
  flex-shrink: 0;
}
.nav-brand-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}

.nav-body { flex: 1; overflow-y: auto; padding: 8px 8px; }

.nav-group { margin-bottom: 4px; }
.nav-group-label {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
  padding: 8px 8px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 120ms, color 120ms;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  position: relative;
}
.nav-item:hover { background: var(--surface-3); color: var(--text); }
.nav-item.active {
  background: var(--accent-tint);
  color: var(--accent);
  font-weight: 600;
}
.nav-item-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: .7;
}
.nav-item.active .nav-item-icon { opacity: 1; }

.nav-count {
  margin-left: auto;
  font-size: 11px;
  font-weight: 600;
  background: var(--surface-3);
  color: var(--muted);
  padding: 1px 6px;
  border-radius: 20px;
  min-width: 20px;
  text-align: center;
}
.nav-item.active .nav-count {
  background: var(--accent-tint2);
  color: var(--accent);
}

.nav-footer {
  border-top: 1px solid var(--border);
  padding: 8px 8px;
  flex-shrink: 0;
}

/* ─── Conversation List ──────────────────────────────── */
.conv-list {
  width: var(--list-w);
  min-width: var(--list-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.list-header {
  padding: 12px 12px 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.search-wrap {
  position: relative;
}
.search-icon {
  position: absolute;
  left: 9px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}
.search-input {
  width: 100%;
  padding: 7px 10px 7px 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  background: var(--surface-2);
  color: var(--text);
  transition: border-color 150ms, box-shadow 150ms;
}
.search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}

.list-tabs {
  display: flex;
  padding: 8px 12px 0;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.list-tab {
  flex: 1;
  padding: 6px 8px;
  text-align: center;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  border: none;
  background: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 120ms, border-color 120ms;
  white-space: nowrap;
}
.list-tab:hover { color: var(--text); }
.list-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

.conv-items { flex: 1; overflow-y: auto; }

.conv-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 12px;
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  text-decoration: none;
  color: var(--text);
  transition: background 100ms;
  position: relative;
}
.conv-item:hover { background: var(--surface-2); }
.conv-item.active { background: var(--accent-tint); }
.conv-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}
.conv-item.unread .conv-item-name { font-weight: 700; color: var(--text); }
.conv-item.unread .conv-item-preview { color: var(--text-2); }

.conv-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
  color: #fff;
  margin-top: 1px;
}

.conv-item-body { flex: 1; min-width: 0; }

.conv-item-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 6px;
  margin-bottom: 2px;
}
.conv-item-name {
  font-size: 13px;
  font-weight: 600;
  truncate: true;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.conv-item-time {
  font-size: 11px;
  color: var(--muted);
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}
.conv-item-preview {
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.4;
  margin-bottom: 5px;
}
.conv-item-meta {
  display: flex;
  gap: 4px;
  align-items: center;
  flex-wrap: wrap;
}

.unread-indicator {
  width: 7px;
  height: 7px;
  background: var(--accent);
  border-radius: 50%;
  flex-shrink: 0;
  margin-left: auto;
  margin-top: 6px;
}

/* ─── Conversation View ──────────────────────────────── */
.conv-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--surface-2);
  min-width: 0;
}

.conv-header {
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.conv-header-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}
.conv-header-info { flex: 1; min-width: 0; }
.conv-header-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.conv-header-meta {
  font-size: 11.5px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 1px;
}
.header-dot { width: 3px; height: 3px; border-radius: 50%; background: var(--border); }
.conv-header-actions { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }

/* ─── Timeline ───────────────────────────────────────── */
.conv-timeline {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.msg-group { display: flex; flex-direction: column; gap: 2px; margin-bottom: 12px; }
.msg-group-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.msg-group-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}
.msg-group-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
}
.msg-group-time {
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.msg-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}
.msg-row.outbound { flex-direction: row-reverse; }
.msg-row.centered { justify-content: center; }
.msg-spacer { width: 26px; flex-shrink: 0; }

.bubble {
  max-width: 68%;
  padding: 9px 13px;
  font-size: 13.5px;
  line-height: 1.55;
  word-break: break-word;
}
.bubble-inbound {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 3px 14px 14px 14px;
  color: var(--text);
  box-shadow: var(--shadow-sm);
}
.bubble-outbound {
  background: var(--accent);
  border-radius: 14px 3px 14px 14px;
  color: #fff;
}
.bubble-note {
  background: var(--note-tint);
  border: 1px dashed var(--note-border);
  border-radius: var(--radius);
  color: var(--text-2);
  font-size: 13px;
  max-width: 80%;
}

.msg-time {
  font-size: 10.5px;
  color: var(--muted);
  margin-top: 3px;
  padding: 0 4px;
  font-variant-numeric: tabular-nums;
}
.msg-row.outbound .msg-time { text-align: right; }

.timeline-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
  color: var(--muted);
  font-size: 11.5px;
}
.timeline-divider::before,
.timeline-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ─── Composer ───────────────────────────────────────── */
.composer {
  flex-shrink: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 12px 16px 14px;
}

.composer-tabs {
  display: flex;
  gap: 2px;
  margin-bottom: 10px;
}
.composer-tab {
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 500;
  border-radius: 20px;
  border: none;
  cursor: pointer;
  background: none;
  color: var(--muted);
  transition: background 120ms, color 120ms;
}
.composer-tab:hover { background: var(--surface-2); color: var(--text-2); }
.composer-tab.active {
  background: var(--accent-tint);
  color: var(--accent);
  font-weight: 600;
}

.composer-box {
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  transition: border-color 150ms, box-shadow 150ms;
  overflow: hidden;
}
.composer-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}

.composer-textarea {
  width: 100%;
  border: none;
  background: none;
  padding: 10px 12px;
  font-size: 13.5px;
  resize: none;
  min-height: 64px;
  max-height: 200px;
  color: var(--text);
  line-height: 1.5;
}
.composer-textarea:focus { outline: none; }
.composer-textarea::placeholder { color: var(--muted); }

.composer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px 6px 12px;
  border-top: 1px solid var(--border-light);
  background: var(--surface-2);
}
.composer-hint {
  font-size: 11px;
  color: var(--muted);
}

/* ─── Detail Panel ───────────────────────────────────── */
.detail-panel {
  width: var(--detail-w);
  min-width: var(--detail-w);
  background: var(--surface);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.detail-section {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-light);
}
.detail-section-title {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  margin-bottom: 10px;
}
.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 7px;
  font-size: 12.5px;
}
.detail-label { color: var(--muted); flex-shrink: 0; }
.detail-value {
  font-weight: 500;
  color: var(--text);
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ─── Badges & Status ────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .01em;
  white-space: nowrap;
}
.badge-open    { background: #dbeafe; color: #1d4ed8; }
.badge-pending { background: var(--warn-tint); color: #92400e; }
.badge-resolved { background: var(--success-tint); color: #166534; }
.badge-inbox {
  background: var(--surface-3);
  color: var(--muted);
  border: 1px solid var(--border);
  font-weight: 500;
}
.badge-email   { background: #e0f2fe; color: #0369a1; }
.badge-generic { background: #f3e8ff; color: #7c3aed; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .badge-open    { background: #1e3a5f; color: #60a5fa; }
  :root:not([data-theme="light"]) .badge-resolved { background: #14532d; color: #86efac; }
  :root:not([data-theme="light"]) .badge-pending { background: #451a03; color: #fbbf24; }
  :root:not([data-theme="light"]) .badge-email   { background: #0c2a3f; color: #38bdf8; }
  :root:not([data-theme="light"]) .badge-generic { background: #2e1065; color: #c084fc; }
}
:root[data-theme="dark"] .badge-open    { background: #1e3a5f; color: #60a5fa; }
:root[data-theme="dark"] .badge-resolved { background: #14532d; color: #86efac; }
:root[data-theme="dark"] .badge-pending { background: #451a03; color: #fbbf24; }
:root[data-theme="dark"] .badge-email   { background: #0c2a3f; color: #38bdf8; }
:root[data-theme="dark"] .badge-generic { background: #2e1065; color: #c084fc; }

/* ─── Buttons ────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: background 120ms, box-shadow 120ms, opacity 120ms;
  white-space: nowrap;
  letter-spacing: -0.01em;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  color: var(--accent-fg);
}
.btn-primary:hover { background: var(--accent-2); }

.btn-secondary {
  background: var(--surface-3);
  color: var(--text-2);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--border); color: var(--text); }

.btn-ghost {
  background: none;
  color: var(--muted);
  padding: 6px 10px;
}
.btn-ghost:hover { background: var(--surface-3); color: var(--text); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: .88; }

.btn-sm { padding: 4px 10px; font-size: 12px; border-radius: 5px; }
.btn-xs { padding: 2px 8px; font-size: 11px; border-radius: 4px; }

.btn-icon {
  width: 30px; height: 30px;
  padding: 0;
  border-radius: var(--radius-sm);
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 120ms, color 120ms;
  font-size: 14px;
}
.btn-icon:hover { background: var(--surface-3); color: var(--text); }

/* ─── Status chip ────────────────────────────────────── */
.status-dot {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 500;
}
.status-dot::before {
  content: '';
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--muted);
}
.status-dot.open::before   { background: #3b82f6; }
.status-dot.resolved::before { background: var(--success); }
.status-dot.pending::before  { background: var(--warn); }

/* ─── Forms ──────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 6px;
}
.form-hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}
.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 8px 11px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  background: var(--surface);
  color: var(--text);
  transition: border-color 150ms, box-shadow 150ms;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}
.form-input::placeholder { color: var(--muted); }
.form-textarea { resize: vertical; min-height: 80px; line-height: 1.5; }
.form-select { cursor: pointer; }

/* ─── Card ───────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-header {
  padding: 13px 18px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-body { padding: 18px; }
.card-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  background: var(--surface-2);
  border-radius: 0 0 var(--radius) var(--radius);
}

/* ─── Table ──────────────────────────────────────────── */
.table { width: 100%; border-collapse: collapse; }
.table th {
  padding: 10px 16px;
  text-align: left;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  border-bottom: 1.5px solid var(--border);
  background: var(--surface-2);
}
.table td {
  padding: 11px 16px;
  border-bottom: 1px solid var(--border-light);
  font-size: 13px;
  color: var(--text);
  vertical-align: middle;
}
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: var(--surface-2); }

/* ─── Alert ──────────────────────────────────────────── */
.alert {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 14px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.alert-error  { background: var(--danger-tint); color: var(--danger); border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent); }
.alert-success { background: var(--success-tint); color: var(--success); border: 1px solid color-mix(in srgb, var(--success) 30%, transparent); }
.alert-info   { background: var(--accent-tint); color: var(--accent); border: 1px solid var(--accent-tint2); }

/* ─── Tags ───────────────────────────────────────────── */
.tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  background: var(--accent-tint);
  color: var(--accent);
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
}

/* ─── Avatar ─────────────────────────────────────────── */
.avatar {
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}
.avatar-lg { width: 40px; height: 40px; font-size: 15px; }
.avatar-md { width: 32px; height: 32px; font-size: 12px; }
.avatar-sm { width: 26px; height: 26px; font-size: 10px; }
.avatar-xs { width: 22px; height: 22px; font-size: 9px; }

/* ─── Settings Layout ────────────────────────────────── */
.settings-shell { display: flex; height: 100vh; }
.settings-nav {
  width: 200px;
  min-width: 200px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.settings-nav-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  flex-shrink: 0;
}
.settings-nav-back {
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 4px;
  font-weight: 500;
  transition: color 120ms;
}
.settings-nav-back:hover { color: var(--text); }

.settings-nav-body { flex: 1; overflow-y: auto; padding: 8px; }
.settings-nav-label {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
  padding: 8px 8px 4px;
}

.settings-main {
  flex: 1;
  overflow-y: auto;
  background: var(--bg);
}
.settings-content {
  max-width: 760px;
  padding: 28px 32px;
}
.settings-page-header {
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.settings-page-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}
.settings-page-desc {
  font-size: 13px;
  color: var(--muted);
  margin-top: 3px;
}

/* ─── Login Page ─────────────────────────────────────── */
.login-page {
  display: flex;
  height: 100vh;
  background: var(--bg);
  overflow: hidden;
}
.login-left {
  flex: 1;
  background: var(--accent);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px;
  position: relative;
  overflow: hidden;
}
.login-left::before {
  content: '';
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle cx='30' cy='30' r='1' fill='%23ffffff' fill-opacity='.08'/%3E%3C/svg%3E") repeat;
}
.login-left-content { position: relative; z-index: 1; text-align: center; color: #fff; max-width: 360px; }
.login-logo-icon {
  width: 52px; height: 52px;
  background: rgba(255,255,255,.15);
  backdrop-filter: blur(8px);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  margin: 0 auto 18px;
  border: 1px solid rgba(255,255,255,.2);
}
.login-headline {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin-bottom: 12px;
}
.login-sub {
  font-size: 14px;
  opacity: .75;
  line-height: 1.6;
}
.login-right {
  width: 420px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  background: var(--surface);
}
.login-form-wrap { width: 100%; }
.login-form-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  margin-bottom: 6px;
}
.login-form-sub {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 28px;
}

/* ─── Code / Mono ────────────────────────────────────── */
code, .mono {
  font-family: 'JetBrains Mono', 'Fira Code', Consolas, monospace;
  font-size: 12px;
  background: var(--surface-3);
  padding: 1px 5px;
  border-radius: 4px;
  color: var(--text-2);
}
pre.code-block {
  background: var(--surface-3);
  border: 1px solid var(--border);
  padding: 14px 16px;
  border-radius: var(--radius);
  font-family: 'JetBrains Mono', Consolas, monospace;
  font-size: 12px;
  overflow-x: auto;
  line-height: 1.6;
  color: var(--text-2);
}

/* ─── Empty state ────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--muted);
  text-align: center;
  padding: 40px;
  gap: 10px;
}
.empty-icon {
  width: 52px; height: 52px;
  border-radius: 14px;
  background: var(--surface-3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  margin-bottom: 4px;
}
.empty-title { font-size: 15px; font-weight: 600; color: var(--text-2); }
.empty-desc { font-size: 13px; color: var(--muted); max-width: 260px; line-height: 1.5; }

/* ─── Utilities ──────────────────────────────────────── */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.ml-auto { margin-left: auto; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.w-full { width: 100%; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.text-muted { color: var(--muted); }
.text-sm { font-size: 12px; }
.font-bold { font-weight: 700; }
.divider { border: none; border-top: 1px solid var(--border); margin: 14px 0; }


/* ─── HTMX ───────────────────────────────────────────── */
.htmx-indicator { opacity: 0; transition: opacity 200ms; }
.htmx-request .htmx-indicator { opacity: 1; }
.htmx-request.htmx-indicator { opacity: 1; }
.hidden { display: none; }

/* ─── Responsive ─────────────────────────────────────── */
@media (max-width: 1100px) { .detail-panel { display: none; } }
@media (max-width: 768px) {
  .conv-list { display: none; }
  :root { --nav-w: 52px; }
  .nav-item span { display: none; }
  .nav-group-label { display: none; }
}
/* ─── Back-compat aliases ───────────────────────────── */
.settings-title { font-size: 20px; font-weight: 700; letter-spacing: -0.02em; color: var(--text); margin-bottom: 20px; }
.layout { display: flex; height: 100vh; overflow: hidden; }

/* ─── Composer note mode ─────────────────────────────── */
.composer.note-mode .composer-box {
  border-color: var(--note-border);
  background: var(--note-tint);
}
.composer.note-mode .composer-textarea { background: transparent; }
.composer.note-mode .composer-footer { border-top-color: var(--note-border); background: transparent; }
.composer.note-mode .btn-primary { background: var(--warn); }
.composer.note-mode .btn-primary:hover { opacity: .88; }
