/* FSM LiveChat — UI v1.18 (fast + modern) */
:root {
  --bg: #0c0e12;
  --bg2: #12161d;
  --surface: #161b22;
  --surface2: #1c222c;
  --line: #2a3140;
  --line2: #363e4f;
  --text: #eef1f5;
  --mute: #8b95a5;
  --accent: #e74b3f;
  --accent2: #ff6f61;
  --accent-dim: rgba(231, 75, 63, 0.12);
  --ok: #3ecf8e;
  --warn: #f0b429;
  --danger: #ff5c5c;
  --radius: 12px;
  --radius-lg: 16px;
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", sans-serif;
  --display: var(--font);
  --shadow: 0 12px 36px rgba(0, 0, 0, 0.28);
  --ease: 0.15s ease;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  background-image:
    radial-gradient(900px 420px at 0% -5%, rgba(231, 75, 63, 0.09), transparent 55%),
    radial-gradient(700px 360px at 100% 0%, rgba(50, 80, 140, 0.12), transparent 50%);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
a { color: var(--accent2); text-decoration: none; }
a:hover { text-decoration: underline; }
.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem 1rem;
}
.auth-shell--wide { padding: 1.5rem; }
.auth-card {
  width: min(420px, 100%);
  background: linear-gradient(165deg, var(--surface2) 0%, var(--surface) 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 2rem 1.6rem 1.6rem;
  box-shadow: var(--shadow);
}
.auth-card--wide { width: min(480px, 100%); }
.auth-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.1rem;
}
.auth-brand img {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  flex-shrink: 0;
}
.auth-brand .eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.68rem;
  color: var(--mute);
  margin: 0 0 0.15rem;
  font-weight: 700;
}
.auth-card .eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.72rem;
  color: var(--mute);
  margin: 0 0 0.4rem;
  font-weight: 700;
}
.auth-card h1 {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.65rem;
  letter-spacing: -0.02em;
  margin: 0 0 0.35rem;
  line-height: 1.2;
}
.auth-card .sub { color: var(--mute); margin: 0 0 1.25rem; font-size: 0.92rem; }
label { display: block; font-size: 0.82rem; color: var(--mute); margin: 0.75rem 0 0.35rem; font-weight: 600; }
input, select, textarea {
  width: 100%;
  background: var(--bg2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  padding: 0.72rem 0.85rem;
  font: inherit;
  transition: border-color var(--ease);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: rgba(231, 75, 63, 0.65);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
textarea { min-height: 110px; resize: vertical; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: 0;
  border-radius: 10px;
  padding: 0.72rem 1.05rem;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
  background: linear-gradient(180deg, var(--accent2), var(--accent));
  color: #fff;
  transition: filter var(--ease), transform var(--ease), opacity var(--ease);
}
.btn:hover { filter: brightness(1.06); text-decoration: none; color: #fff; }
.btn:active { transform: translateY(1px); }
.btn-block { width: 100%; margin-top: 1rem; }
.btn-ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
}
.btn-ghost:hover { border-color: var(--line2); filter: none; color: var(--text); }
.btn-sm { padding: 0.4rem 0.7rem; font-size: 0.85rem; border-radius: 8px; }
.btn-primary { background: linear-gradient(180deg, var(--accent2), var(--accent)); color: #fff; }
.alert {
  border-radius: 10px;
  padding: 0.7rem 0.85rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}
.alert-error { background: rgba(255, 92, 92, 0.12); border: 1px solid rgba(255, 92, 92, 0.35); }
.alert-ok { background: rgba(62, 207, 142, 0.12); border: 1px solid rgba(62, 207, 142, 0.35); }
.hint { color: var(--mute); font-size: 0.82rem; margin-top: 1rem; text-align: center; }

/* App shell */
.app-shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar {
  background: rgba(12, 14, 18, 0.94);
  border-right: 1px solid var(--line);
  padding: 1.1rem 0.85rem 1.25rem;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.brand-lockup {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  text-decoration: none;
  color: inherit;
  margin: 0 0.25rem 1.15rem 0.2rem;
  padding: 0.15rem;
  border-radius: 12px;
}
.brand-lockup:hover { text-decoration: none; }
.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  flex-shrink: 0;
  display: block;
}
.brand-text { min-width: 0; padding-top: 0.1rem; }
.sidebar .logo {
  font-family: var(--display);
  font-size: 1.12rem;
  font-weight: 750;
  letter-spacing: -0.02em;
  margin: 0;
  line-height: 1.15;
  display: block;
}
.sidebar .logo span { color: var(--accent2); }
.sidebar .mini {
  color: var(--mute);
  font-size: 0.72rem;
  margin: 0.2rem 0 0;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar .mini strong { color: #c8d0dc; font-weight: 650; }
.nav a {
  display: block;
  color: #c5ccd8;
  text-decoration: none;
  padding: 0.58rem 0.75rem;
  border-radius: 10px;
  margin-bottom: 0.15rem;
  border: 1px solid transparent;
  font-size: 0.9rem;
  font-weight: 550;
  transition: background var(--ease), color var(--ease), border-color var(--ease);
}
.nav a:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  text-decoration: none;
}
.nav a.active {
  background: var(--accent-dim);
  border-color: rgba(231, 75, 63, 0.28);
  color: #fff;
  text-decoration: none;
}
.main { padding: 1.35rem 1.4rem 2.5rem; min-width: 0; }
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.15rem;
  flex-wrap: wrap;
}
.topbar h1 {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.55rem;
  letter-spacing: -0.02em;
  margin: 0;
}
.topbar p { margin: 0.25rem 0 0; color: var(--mute); font-size: 0.9rem; }
.grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 0.9rem;
}
.card {
  background: rgba(22, 27, 34, 0.92);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.05rem 1.1rem;
  box-shadow: 0 6px 20px rgba(0,0,0,0.12);
}
.card h2, .card h3 { margin: 0 0 0.75rem; font-size: 1.02rem; font-weight: 650; }
.span-3 { grid-column: span 3; }
.span-4 { grid-column: span 4; }
.span-5 { grid-column: span 5; }
.span-6 { grid-column: span 6; }
.span-7 { grid-column: span 7; }
.span-8 { grid-column: span 8; }
.span-12 { grid-column: span 12; }
.stat-num {
  font-family: var(--display);
  font-size: 2rem;
  font-weight: 750;
  line-height: 1;
  letter-spacing: -0.03em;
}
.stat-label { color: var(--mute); font-size: 0.85rem; margin-top: 0.35rem; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 0.92rem; min-width: 520px; }
th, td { text-align: left; padding: 0.7rem 0.5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--mute); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; }
.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-ok { background: rgba(62,207,142,.15); color: var(--ok); }
.badge-off { background: rgba(255,92,92,.12); color: var(--danger); }
.badge-info { background: rgba(255,255,255,.08); color: var(--mute); }
.codebox {
  background: #0c0f14;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.85rem;
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.85rem; }
.muted { color: var(--mute); }
.footer-note { margin-top: 2rem; color: var(--mute); font-size: 0.8rem; }
.row-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.conv-top-actions {
  align-items: center;
  gap: 0.65rem;
}
.ai-chat-toggle-form {
  display: inline-flex;
  margin: 0;
}
.ai-chat-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.45rem 0.75rem 0.45rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(18, 22, 29, 0.9);
  color: var(--text);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.ai-chat-toggle:hover {
  filter: brightness(1.06);
}
.ai-chat-toggle.is-on {
  border-color: rgba(34, 197, 94, 0.45);
  background: rgba(34, 197, 94, 0.1);
  color: #86efac;
}
.ai-chat-toggle.is-off {
  border-color: rgba(148, 163, 184, 0.35);
  color: #94a3b8;
}
.ai-chat-toggle-track {
  position: relative;
  width: 2.25rem;
  height: 1.25rem;
  border-radius: 999px;
  background: #3a4452;
  flex-shrink: 0;
  transition: background 0.15s ease;
}
.ai-chat-toggle.is-on .ai-chat-toggle-track {
  background: #16a34a;
}
.ai-chat-toggle-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: calc(1.25rem - 4px);
  height: calc(1.25rem - 4px);
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  transition: transform 0.15s ease;
}
.ai-chat-toggle.is-on .ai-chat-toggle-knob {
  transform: translateX(1rem);
}
.switch-line {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-top: 0.75rem;
  font-size: 0.9rem;
  color: var(--text);
  cursor: pointer;
}
.switch-line input[type="checkbox"] {
  width: 1.05rem;
  height: 1.05rem;
  min-width: 1.05rem;
  accent-color: var(--accent);
  margin: 0;
  cursor: pointer;
}

.token-stat .stat-label {
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--mute);
  margin: 0 0 0.45rem;
}
.token-stat .token-num {
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  margin: 0.15rem 0;
}
.token-stat.token-used .token-num { color: #f0b429; }
.token-stat.token-left .token-num { color: var(--ok); }
.token-meta { margin: 0.35rem 0 0; font-size: 0.82rem; line-height: 1.45; }
.token-bar {
  margin-top: 0.85rem;
  height: 8px;
  border-radius: 999px;
  background: rgba(255,255,255,0.06);
  overflow: hidden;
}
.token-bar span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--ok), #f0b429 70%, var(--accent));
  min-width: 0;
  transition: width 0.25s ease;
}
@media (max-width: 960px) {
  .token-stat { grid-column: span 12; }
}
.ai-panel { width: 100%; }
.ai-panel > h3 { margin: 0 0 0.5rem; font-size: 1.15rem; }
.ai-panel .ai-help {
  margin: 0 0 1.1rem;
  max-width: none;
  font-size: 0.9rem;
  line-height: 1.55;
}
.ai-panel .ai-help strong { color: var(--text); }
.ai-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
  gap: 1.25rem 1.5rem;
  align-items: start;
  width: 100%;
  margin: 0;
}
.ai-form-col { min-width: 0; width: 100%; }
.ai-form-col label:first-child { margin-top: 0; }
.ai-keys-box {
  width: 100%;
  min-height: 220px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.86rem;
  line-height: 1.45;
  word-break: break-all;
}
.ai-status {
  margin: 0.65rem 0 0;
  font-size: 0.86rem;
  line-height: 1.5;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.55rem;
  align-items: center;
}
.ai-hint { margin: 0.45rem 0 0; font-size: 0.8rem; }
.ai-actions {
  margin-top: 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
}
.ai-steps {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0.75rem 0.9rem;
  background: rgba(12, 15, 20, 0.65);
  border: 1px solid var(--line);
  border-radius: 12px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.55rem;
}
.ai-steps li {
  font-size: 0.8rem;
  color: var(--mute);
  padding: 0.45rem 0.55rem;
  border-radius: 8px;
  background: rgba(255,255,255,0.03);
  border: 1px solid transparent;
}
.ai-steps li b { display: block; color: var(--text); font-size: 0.84rem; margin-bottom: 0.15rem; }
.ai-steps li.is-active {
  border-color: rgba(231, 75, 63, 0.35);
  background: rgba(231, 75, 63, 0.08);
}

.clean-split {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-start;
  justify-content: space-between;
  width: 100%;
}
.clean-split > div { flex: 1 1 240px; min-width: 0; }

/* Mobile nav toggle */
.nav-toggle {
  display: none;
  position: fixed;
  top: 0.75rem;
  right: 0.75rem;
  z-index: 40;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: 10px;
  padding: 0.55rem 0.75rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow);
}

@media (max-width: 1100px) {
  .span-3 { grid-column: span 6; }
  .span-4 { grid-column: span 6; }
  .span-5, .span-7 { grid-column: span 12; }
  .ai-form { grid-template-columns: 1fr; }
  .ai-steps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 960px) {
  .app-shell { grid-template-columns: 1fr; }
  .nav-toggle { display: inline-flex; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(280px, 86vw);
    height: 100vh;
    z-index: 35;
    transform: translateX(-105%);
    transition: transform 0.2s ease;
    box-shadow: var(--shadow);
  }
  .sidebar.is-open { transform: translateX(0); }
  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 30;
  }
  .sidebar-backdrop.is-open { display: block; }
  .main { padding: 3.5rem 1rem 2rem; }
  .topbar h1 { font-size: 1.55rem; }
  .span-3, .span-4, .span-5, .span-6, .span-7, .span-8, .span-12 { grid-column: span 12; }
  .form-row { grid-template-columns: 1fr; }
  .ai-steps { grid-template-columns: 1fr 1fr; }
  .stat-num { font-size: 1.85rem; }
}

@media (max-width: 520px) {
  .ai-steps { grid-template-columns: 1fr; }
  .card { padding: 0.95rem; }
  .btn { width: 100%; }
  .ai-actions .btn { width: 100%; }
  .row-actions .btn { width: auto; }
  table { font-size: 0.84rem; min-width: 460px; }
  .settings-actions .btn { width: 100%; }
  .cta-add { width: 100%; }
}

/* —— Settings identity / CTA form (responsive) —— */
.settings-dual {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1rem;
  align-items: stretch;
}
.settings-identity {
  max-width: none;
  min-width: 0;
}
.settings-rules {
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100%;
  border-color: rgba(231, 75, 63, 0.35);
  box-shadow: 0 0 0 1px rgba(231, 75, 63, 0.08), 0 10px 30px rgba(0,0,0,0.18);
}
.settings-rules h3 {
  margin: 0 0 0.4rem;
}
.settings-rules-lead {
  margin: 0 0 0.85rem;
}
.rules-prompt-input {
  flex: 1 1 auto;
  width: 100%;
  min-height: 320px;
  height: 100%;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.86rem;
  line-height: 1.5;
  padding: 0.9rem 1rem;
  background: #0c0f14;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.rules-prompt-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(231, 75, 63, 0.18);
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.settings-actions-bar {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-start;
  align-items: center;
  padding: 1rem 1.15rem;
}
.settings-field {
  margin: 0 0 1.15rem;
}
.settings-field:last-of-type {
  margin-bottom: 0;
}
.settings-field > label {
  margin-top: 0;
  font-weight: 600;
  color: var(--text);
}
.settings-field--half {
  max-width: 360px;
}
.field-hint {
  margin: 0.35rem 0 0;
  color: var(--mute);
  font-size: 0.78rem;
  line-height: 1.4;
}
.sub-label {
  margin-top: 0.65rem;
  font-size: 0.82rem;
}
.banner-upload {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem;
  align-items: flex-start;
}
.banner-preview {
  flex: 0 0 auto;
  background: #0f1217;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px;
  max-width: 100%;
}
.banner-preview img {
  display: block;
  max-width: min(240px, 70vw);
  max-height: 96px;
  width: auto;
  height: auto;
  object-fit: contain;
}
.banner-fields {
  flex: 1 1 220px;
  min-width: 0;
}
.banner-fields input[type="file"] {
  width: 100%;
  max-width: 100%;
}
.avatar-upload {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem;
  align-items: center;
}
.avatar-preview {
  flex: 0 0 56px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid var(--line);
  background: #0f1217;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(0,0,0,0.25);
}
.avatar-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.avatar-fallback {
  font-size: 0.95rem;
  font-weight: 700;
  color: #111;
  background: var(--accent);
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.avatar-fields {
  flex: 1 1 200px;
  min-width: 0;
}
.avatar-fields input[type="file"] {
  width: 100%;
  max-width: 100%;
}
.settings-actions {
  margin-top: 1.35rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}
.cta-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin: 0.55rem 0 0.65rem;
}
.cta-row {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr) minmax(0, 1.4fr) 44px;
  gap: 0.55rem;
  align-items: end;
  padding: 0.75rem;
  background: rgba(12, 15, 20, 0.55);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.cta-cell {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
}
.cta-lab {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--mute);
  line-height: 1.2;
}
.cta-lab--hide {
  visibility: hidden;
  user-select: none;
}
.cta-cell input {
  width: 100%;
  min-width: 0;
  margin: 0;
}
.cta-cell--act {
  align-items: stretch;
}
.cta-cell--act .cta-remove {
  width: 100%;
  min-width: 40px;
  height: 42px;
  padding: 0;
  font-size: 1.25rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
}
.cta-add {
  margin-top: 0.15rem;
}

@media (max-width: 960px) {
  .settings-dual {
    grid-template-columns: 1fr;
  }
  .rules-prompt-input {
    min-height: 240px;
  }
}

@media (max-width: 800px) {
  .cta-row {
    grid-template-columns: 1fr 1fr;
  }
  .cta-cell--url {
    grid-column: 1 / -1;
  }
  .cta-cell--act {
    grid-column: 1 / -1;
  }
  .cta-cell--act .cta-remove {
    width: auto;
    min-width: 48px;
    align-self: flex-end;
  }
  .cta-lab--hide {
    display: none;
  }
  .settings-field--half {
    max-width: none;
  }
}

@media (max-width: 520px) {
  .cta-row {
    grid-template-columns: 1fr;
    padding: 0.7rem;
  }
  .cta-cell--url,
  .cta-cell--act {
    grid-column: auto;
  }
  .cta-cell--act .cta-remove {
    width: 100%;
  }
  .banner-preview img {
    max-width: 100%;
  }
  .settings-actions-bar .btn {
    width: 100%;
  }
}

/* Connect dropdown */
.nav-dropdown {
  margin: 0.15rem 0 0.35rem;
}
.nav-dropdown-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 0.5rem;
  color: var(--text);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 0.65rem 0.75rem;
  margin-bottom: 0.15rem;
  font: inherit;
  font-size: 1rem;
  text-align: left;
  cursor: pointer;
}
.nav-dropdown-toggle:hover,
.nav-dropdown-toggle.is-active {
  background: rgba(231, 75, 63, 0.1);
  border-color: rgba(231, 75, 63, 0.25);
}
.nav-dropdown-caret {
  width: 0.55rem;
  height: 0.55rem;
  border-right: 2px solid var(--mute);
  border-bottom: 2px solid var(--mute);
  transform: rotate(45deg);
  transition: transform 0.18s ease;
  flex-shrink: 0;
  margin-top: -0.15rem;
}
.nav-dropdown.is-open .nav-dropdown-caret {
  transform: rotate(-135deg);
  margin-top: 0.15rem;
  border-color: var(--accent);
}
.nav-dropdown-menu {
  display: none;
  padding: 0 0 0.2rem;
}
.nav-dropdown.is-open .nav-dropdown-menu {
  display: block;
}
.nav a.nav-sub {
  padding-left: 1.15rem;
  font-size: 0.9rem;
  opacity: 0.92;
}
.inbox-live-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #4ade80;
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid rgba(34, 197, 94, 0.35);
  border-radius: 999px;
  padding: 0.2rem 0.55rem;
}
.inbox-live-badge.is-err {
  color: #f87171;
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.35);
}
.inbox-live-badge.is-ok {
  color: #4ade80;
}

/* Messenger split — list | chat */
.main--messenger {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 0px);
  max-height: 100vh;
  overflow: hidden;
}
.main--messenger .topbar {
  flex-shrink: 0;
  margin-bottom: 0.75rem;
}
.msg-meta-bar {
  flex-shrink: 0;
  margin-bottom: 0.75rem !important;
  padding: 0.65rem 0.9rem !important;
}
.messenger-layout {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(240px, 38%) 1fr;
  gap: 0.75rem;
  height: min(720px, calc(100vh - 180px));
}
.messenger-list,
.messenger-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  margin: 0;
  padding: 0;
}
.messenger-list-head {
  flex-shrink: 0;
  padding: 0.75rem 0.9rem;
  border-bottom: 1px solid var(--line);
  font-weight: 700;
  font-size: 0.92rem;
}
.messenger-pane-head {
  flex-shrink: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.75rem 0.9rem;
  border-bottom: 1px solid var(--line);
  font-weight: 700;
  font-size: 0.92rem;
}
.messenger-pane-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
  margin-left: auto;
}
.messenger-block-btn {
  color: #fecaca !important;
  background: rgba(239, 68, 68, 0.14) !important;
  border: 1px solid rgba(239, 68, 68, 0.55) !important;
  border-radius: 8px !important;
  padding: 0.35rem 0.7rem !important;
  font-weight: 700 !important;
  font-size: 0.8rem !important;
}
.messenger-block-btn:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.24) !important;
}
.messenger-block-btn.is-blocked {
  color: #6ee7a0 !important;
  background: rgba(34, 197, 94, 0.12) !important;
  border-color: rgba(34, 197, 94, 0.5) !important;
}
.messenger-block-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.badge-blocked {
  display: inline-block;
  margin-left: 0.25rem;
  padding: 0.08rem 0.4rem;
  border-radius: 4px;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #fecaca;
  background: rgba(239, 68, 68, 0.18);
  border: 1px solid rgba(239, 68, 68, 0.45);
  vertical-align: middle;
}
/* display di atas menimpa [hidden] UA stylesheet — wajib override */
.badge-blocked[hidden],
.badge-blocked.is-hidden {
  display: none !important;
}
.messenger-list-scroll,
.messenger-pane-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}
.messenger-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  text-align: left;
  border: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  background: transparent;
  color: var(--text);
  padding: 0.7rem 0.85rem;
  cursor: pointer;
  font: inherit;
}
.messenger-item:hover {
  background: rgba(231, 75, 63, 0.08);
}
.messenger-item.is-active {
  background: rgba(231, 75, 63, 0.14);
  border-left: 3px solid var(--accent, #e74b3f);
}
.messenger-item-avatar {
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #2a3140;
  color: #e8ecf2;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
}
.messenger-item-body {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}
.messenger-item-name {
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.messenger-item-meta {
  font-size: 0.72rem;
  display: flex;
  flex-direction: column;
  gap: 0.08rem;
  line-height: 1.25;
  margin-top: 0.2rem;
}
.messenger-item-badges {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem;
  margin-top: 0.28rem;
  max-width: 100%;
}
.messenger-badge {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.2;
  border-radius: 999px;
  padding: 0.18rem 0.48rem;
  border: 1px solid transparent;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.messenger-badge--channel {
  color: #6ee7a0;
  background: rgba(34, 197, 94, 0.14);
  border-color: rgba(34, 197, 94, 0.45);
  letter-spacing: 0.04em;
  animation: none;
  box-shadow: none;
}
.messenger-badge--channel.is-facebook,
.messenger-badge--channel.is-whatsapp {
  color: #6ee7a0;
  background: rgba(34, 197, 94, 0.14);
  border-color: rgba(34, 197, 94, 0.45);
}
.messenger-badge--ip {
  color: #93c5fd;
  background: rgba(59, 130, 246, 0.14);
  border-color: rgba(59, 130, 246, 0.4);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 600;
  letter-spacing: 0;
}
.messenger-badge--geo {
  color: #fcd34d;
  background: rgba(234, 179, 8, 0.12);
  border-color: rgba(234, 179, 8, 0.4);
  max-width: min(100%, 220px);
}
.messenger-badge--blocked {
  color: #fecaca;
  background: rgba(239, 68, 68, 0.18);
  border-color: rgba(239, 68, 68, 0.55);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 0.62rem;
  font-weight: 800;
}
.messenger-item.is-ip-blocked {
  border-left: 3px solid rgba(239, 68, 68, 0.75);
}
@keyframes fsmChannelPulse {
  0%, 100% {
    color: #4ade80;
    border-color: rgba(34, 197, 94, 0.4);
    background: rgba(34, 197, 94, 0.1);
  }
  50% {
    color: #bbf7d0;
    border-color: rgba(74, 222, 128, 0.55);
    background: rgba(34, 197, 94, 0.14);
  }
}
    box-shadow: 0 0 10px 1px rgba(34, 197, 94, 0.35);
    background: rgba(34, 197, 94, 0.22);
  }
}
@media (prefers-reduced-motion: reduce) {
  .messenger-badge--channel {
    animation: none;
  }
}
.messenger-item-side {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.35rem;
  align-self: flex-start;
  padding-top: 0.1rem;
}
.messenger-item-time {
  flex-shrink: 0;
  font-size: 0.72rem;
}
.conv-ai-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 999px;
  padding: 0.18rem 0.4rem 0.18rem 0.22rem;
  background: rgba(15, 18, 22, 0.7);
  cursor: pointer;
  user-select: none;
  font: inherit;
  color: #94a3b8;
  line-height: 1;
}
.conv-ai-toggle:hover {
  filter: brightness(1.08);
}
.conv-ai-toggle.is-on {
  border-color: rgba(34, 197, 94, 0.55);
  color: #6ee7a0;
  background: rgba(34, 197, 94, 0.12);
}
.conv-ai-toggle.is-off {
  border-color: rgba(148, 163, 184, 0.35);
  color: #94a3b8;
}
.conv-ai-toggle-track {
  position: relative;
  width: 26px;
  height: 14px;
  border-radius: 999px;
  background: #3a4250;
  flex-shrink: 0;
}
.conv-ai-toggle.is-on .conv-ai-toggle-track {
  background: #22c55e;
}
.conv-ai-toggle-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}
.conv-ai-toggle.is-on .conv-ai-toggle-knob {
  transform: translateX(12px);
}
.conv-ai-toggle-text {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.conv-ai-toggle.is-busy {
  opacity: 0.55;
  pointer-events: none;
}
.messenger-empty,
.messenger-placeholder {
  padding: 1.5rem 1rem;
  text-align: center;
  color: var(--mute);
}
.messenger-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 280px;
  gap: 0.35rem;
}
.messenger-pane-body {
  padding: 0.85rem;
  background: #12161d;
}
.messenger-composer {
  flex-shrink: 0;
  border-top: 1px solid var(--line);
  padding: 0.65rem 0.85rem 0.85rem;
  background: #161b24;
}
.messenger-composer.is-disabled {
  opacity: 0.55;
  pointer-events: none;
}
.messenger-composer-hint {
  margin: 0 0 0.45rem;
  font-size: 0.78rem;
  line-height: 1.35;
}
.messenger-composer-form {
  display: flex;
  gap: 0.55rem;
  align-items: flex-end;
}
.messenger-composer-field {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
}
.messenger-composer-form textarea {
  width: 100%;
  flex: 1 1 auto;
  min-height: 44px;
  max-height: 140px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #0f1319;
  color: var(--text);
  padding: 0.55rem 0.7rem;
  font: inherit;
  line-height: 1.4;
}
.messenger-composer-form textarea:focus {
  outline: none;
  border-color: rgba(231, 75, 63, 0.55);
}
.tag-picker {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 6px);
  z-index: 40;
  max-height: 240px;
  overflow: auto;
  border: 1px solid var(--line, #2b303b);
  border-radius: 12px;
  background: #141820;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  padding: 0.35rem;
}
.tag-picker-head {
  font-size: 0.72rem;
  font-weight: 700;
  color: #9aa3ad;
  padding: 0.35rem 0.5rem 0.45rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  margin-bottom: 0.25rem;
}
.tag-picker-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.12rem;
  width: 100%;
  text-align: left;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #e8ecf2;
  padding: 0.45rem 0.55rem;
  cursor: pointer;
  font: inherit;
}
.tag-picker-item:hover,
.tag-picker-item.is-active {
  background: rgba(231, 75, 63, 0.14);
}
.tag-picker-cmd {
  font-weight: 800;
  color: #fca5a5;
  font-size: 0.88rem;
}
.tag-picker-title {
  font-size: 0.8rem;
  color: #e8ecf2;
}
.tag-picker-prev {
  font-size: 0.72rem;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.messenger-send-btn {
  flex: 0 0 auto;
  min-width: 5.5rem;
  align-self: stretch;
}
.messenger-composer-status {
  margin: 0.4rem 0 0;
  font-size: 0.75rem;
}
.messenger-composer-status.is-err {
  color: var(--danger, #e74b3f);
}
.inbox-msg {
  margin-bottom: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  max-width: 92%;
}
.inbox-msg.is-user {
  background: rgba(231, 75, 63, 0.12);
  margin-left: 0;
  margin-right: auto;
}
.inbox-msg.is-bot {
  background: #1a1f28;
  margin-left: auto;
  margin-right: 0;
}
.inbox-msg-meta {
  font-size: 0.75rem;
  margin-bottom: 4px;
}
.inbox-msg-text {
  white-space: pre-wrap;
  word-break: break-word;
}

@media (max-width: 900px) {
  .messenger-layout {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 70vh;
  }
  .messenger-list {
    max-height: 42vh;
  }
  .messenger-pane {
    min-height: 48vh;
  }
  .main--messenger {
    max-height: none;
    overflow: auto;
  }
}
.badge-off {
  background: rgba(148, 163, 184, 0.12);
  color: #94a3b8;
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.75rem;
  font-weight: 700;
  display: inline-block;
}

/* Nada dering */
.ringtone-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0.65rem;
}
.ringtone-card {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--line, #2b303b);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.ringtone-card:hover {
  border-color: rgba(231, 75, 63, 0.45);
}
.ringtone-card.is-selected {
  border-color: rgba(231, 75, 63, 0.75);
  background: rgba(231, 75, 63, 0.08);
}
.ringtone-card input[type=radio] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.ringtone-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.ringtone-card-head strong {
  font-size: 0.9rem;
}

/* Hashtag */
.hashtag-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.hashtag-row {
  padding: 0.85rem;
  border: 1px solid var(--line, #2b303b);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
}
.hashtag-row-top {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: flex-start;
  margin-bottom: 0.55rem;
}
.hashtag-tag-wrap {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}
.hashtag-slash {
  color: var(--danger, #e74b3f);
  font-weight: 800;
  font-size: 1.1rem;
}
.hashtag-row textarea {
  width: 100%;
  min-height: 110px;
  resize: vertical;
}
.hashtag-row label {
  display: block;
  font-size: 0.8rem;
  color: var(--mute, #9aa3ad);
  margin-bottom: 0.25rem;
}
.hashtag-row input[type=text] {
  width: 100%;
}

/* Tombol aktifkan suara notifikasi */
.fsm-ring-unlock {
  position: fixed;
  z-index: 2147483001;
  right: 14px;
  bottom: 14px;
  padding: 0.55rem 0.85rem;
  border-radius: 999px;
  border: 1px solid rgba(231, 75, 63, 0.55);
  background: #1a1d23;
  color: #fecaca;
  font: 700 12px/1.2 system-ui, sans-serif;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}
.fsm-ring-unlock:hover {
  background: rgba(231, 75, 63, 0.18);
}
.fsm-ring-unlock.is-on {
  color: #6ee7a0;
  border-color: rgba(34, 197, 94, 0.55);
}
