/* ── cnxt Design System ── */

:root {
  --bg: #fafbfc;
  --surface: #ffffff;
  --border: #e2e6ed;
  --border-light: #eef1f5;
  --text: #1a1d23;
  --text-secondary: #5f6b7a;
  --text-muted: #8f99a8;
  --brand: #4f46e5;
  --brand-hover: #4338ca;
  --brand-soft: #eef2ff;
  --brand-ring: rgba(79, 70, 229, 0.15);
  --success: #059669;
  --success-soft: #ecfdf5;
  --warning: #d97706;
  --warning-soft: #fffbeb;
  --error: #dc2626;
  --error-soft: #fef2f2;
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 4px 20px rgba(0,0,0,0.04);
  --transition: 0.15s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

.hidden { display: none !important; }

/* Top bar */
.topbar {
  display: flex; align-items: center; gap: 24px;
  padding: 0 28px; height: 60px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}

.topbar-logo {
  font-weight: 700; font-size: 1.05rem;
  letter-spacing: -0.02em; white-space: nowrap;
  display: flex; align-items: center; gap: 8px;
}

.topbar-logo-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--brand); flex-shrink: 0;
}

.topbar-nav { display: flex; gap: 2px; flex: 1; }

.nav-link {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 14px; border-radius: var(--radius-sm);
  font-size: 0.875rem; font-weight: 500;
  color: var(--text-secondary); cursor: pointer;
  border: none; background: none;
  transition: background var(--transition), color var(--transition);
}
.nav-link:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.nav-link-active { color: var(--brand); background: var(--brand-soft); }

.nav-badge {
  font-size: 0.6875rem; padding: 1px 7px; border-radius: 999px;
  background: var(--brand); color: #fff; font-weight: 600;
}

.topbar-right { display: flex; align-items: center; gap: 14px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 18px; border: none; border-radius: var(--radius-sm);
  font-size: 0.875rem; font-weight: 600; cursor: pointer;
  transition: all var(--transition); white-space: nowrap; line-height: 1.4;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 1px 2px rgba(79,70,229,0.25); }
.btn-primary:hover:not(:disabled) { background: var(--brand-hover); }

.btn-secondary { background: var(--surface); color: var(--text); border: 1.5px solid var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--bg); }

.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover:not(:disabled) { background: var(--bg); color: var(--text); }

.btn-sm { padding: 5px 12px; font-size: 0.8125rem; }
.btn-xs { padding: 3px 10px; font-size: 0.75rem; }

/* Main content */
.main-content { flex: 1; max-width: 780px; width: 100%; margin: 0 auto; padding: 36px 24px 60px; }

.view { animation: fadeIn 0.2s ease; }
.view.hidden { display: none; }

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

/* Card */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 28px; box-shadow: var(--shadow-sm);
}

.card-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; margin-bottom: 20px;
}

.card-title { font-size: 1.125rem; font-weight: 600; letter-spacing: -0.01em; }
.card-subtitle { font-size: 0.875rem; color: var(--text-muted); margin-top: 2px; }

/* Compose */
.compose-textarea {
  width: 100%; border: 1.5px solid var(--border); border-radius: var(--radius);
  padding: 16px; font-size: 1rem; font-family: inherit; line-height: 1.6;
  resize: vertical; min-height: 120px; color: var(--text); background: var(--bg);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.compose-textarea::placeholder { color: var(--text-muted); }
.compose-textarea:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 4px var(--brand-ring);
}

.compose-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; margin-top: 16px; flex-wrap: wrap;
}

.platform-toggles { display: flex; flex-wrap: wrap; gap: 6px; }

.platform-chip {
  display: flex; align-items: center; gap: 5px;
  padding: 5px 13px; border: 1.5px solid var(--border);
  border-radius: 999px; font-size: 0.8125rem; font-weight: 500;
  cursor: pointer; user-select: none;
  color: var(--text-secondary); background: var(--surface);
  transition: all var(--transition);
}
.platform-chip:hover { border-color: #cdd3dc; color: var(--text); }
.platform-chip input { display: none; }

.platform-chip.selected {
  border-color: var(--brand); background: var(--brand-soft); color: var(--brand);
}
.platform-chip.disabled { opacity: 0.5; cursor: not-allowed; }

.platform-icon { font-size: 1rem; line-height: 1; }

.compose-actions { display: flex; align-items: center; gap: 14px; }

.char-count { font-size: 0.8125rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.char-count.warning { color: var(--warning); }
.char-count.danger { color: var(--error); font-weight: 600; }

/* Feedback */
.feedback {
  margin-top: 18px; padding: 14px 18px; border-radius: var(--radius);
  font-size: 0.875rem; font-weight: 500; display: none;
  animation: fadeIn 0.2s ease;
}
.feedback.visible { display: block; }
.feedback.error { background: var(--error-soft); color: var(--error); border: 1px solid #fecaca; }
.feedback.success { background: var(--success-soft); color: var(--success); border: 1px solid #a7f3d0; }

.feedback-results { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }

.feedback-result-item { display: flex; align-items: center; gap: 8px; font-size: 0.8125rem; }

/* History */
.history-list { display: flex; flex-direction: column; gap: 16px; }

.history-item {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px 24px;
  box-shadow: var(--shadow-sm); transition: box-shadow var(--transition);
}
.history-item:hover { box-shadow: var(--shadow); }

.history-text { font-size: 0.9375rem; line-height: 1.6; margin-bottom: 14px; }

.history-meta { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }

.history-platforms { display: flex; gap: 4px; }

.history-platform-badge {
  font-size: 0.6875rem; font-weight: 600; padding: 2px 8px;
  border-radius: 999px; background: var(--brand-soft); color: var(--brand);
}
.history-platform-badge.failed { background: var(--error-soft); color: var(--error); }

.history-date { font-size: 0.75rem; color: var(--text-muted); }
.history-link { font-size: 0.75rem; font-weight: 500; margin-left: auto; }

/* Accounts */
.account-list { display: flex; flex-direction: column; gap: 2px; }

.account-item {
  display: flex; align-items: center; gap: 16px;
  padding: 16px 20px; border-radius: var(--radius);
  transition: background var(--transition);
}
.account-item:hover { background: var(--bg); }

.account-item-icon {
  width: 44px; height: 44px; display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius); font-size: 1.25rem;
  background: var(--bg); border: 1px solid var(--border-light); flex-shrink: 0;
}

.account-item-info { flex: 1; min-width: 0; }
.account-item-name { font-weight: 600; font-size: 0.9375rem; }
.account-item-status { font-size: 0.8125rem; color: var(--text-muted); margin-top: 1px; }
.account-item-status.connected { color: var(--success); }

/* Empty state */
.empty-state { text-align: center; padding: 56px 24px; }
.empty-state-icon { font-size: 2.5rem; margin-bottom: 12px; opacity: 0.6; }
.empty-state-text { color: var(--text-muted); font-size: 0.9375rem; }

/* Responsive */
@media (max-width: 640px) {
  .topbar { padding: 0 16px; gap: 12px; }
  .nav-link { padding: 6px 10px; font-size: 0.8125rem; }
  .main-content { padding: 24px 14px; }
  .card { padding: 20px; }
  .compose-toolbar { flex-direction: column; align-items: stretch; }
  .compose-actions { justify-content: space-between; }
  .history-item { padding: 16px 18px; }
}
