* { box-sizing: border-box; }

:root {
  /* Brand */
  --ifm-color-primary: #0CC0DF;
  --loft-ai-gradient-start: #1BF2E3;
  --loft-ai-gradient-end: #AC86F7;

  --ifm-color-primary-dark: #29784c;
  --ifm-color-primary-darker: #277148;
  --ifm-color-primary-darkest: #205d3b;
  --ifm-color-primary-light: #33925d;
  --ifm-color-primary-lighter: #359962;
  --ifm-color-primary-lightest: #3cad6e;

  /* Surfaces */
  --bg-page: #f4f6f7;
  --bg-card: #ffffff;
  --bg-card-hover: #fafbfc;
  --bg-sidebar: #0b1220;
  --bg-sidebar-hover: #131f31;
  --bg-input: #ffffff;
  --bg-subtle: #eef2f3;
  --bg-subtle-hover: #e2e8ea;

  /* Text */
  --text-primary: #0b1220;
  --text-secondary: #66757e;
  --text-muted: #8a97a0;
  --text-on-sidebar: #cbd5da;
  --text-on-sidebar-muted: #8a97a0;

  /* Borders / shadows */
  --border-color: #d8dee2;
  --border-color-subtle: #eef1f2;
  --border-sidebar: #1c2836;
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.08);

  /* Status colors */
  --color-danger-bg: #fdecea;
  --color-danger-text: #c0392b;
  --color-danger-bg-hover: #fadbd8;
  --color-success-text: #1a7f4b;
  --badge-draft-bg: #fff3cd;
  --badge-draft-text: #8a6d1a;
  --badge-sent-bg: #d4f4e2;
  --badge-sent-text: #1a7f4b;
}

:root[data-theme='dark'] {
  --ifm-color-primary: #0CC0DF;
  --ifm-color-primary-dark: #21af90;
  --ifm-color-primary-darker: #1fa588;
  --ifm-color-primary-darkest: #1a8870;
  --ifm-color-primary-light: #29d5b0;
  --ifm-color-primary-lighter: #32d8b4;
  --ifm-color-primary-lightest: #4fddbf;

  --bg-page: #0b1220;
  --bg-card: #131f31;
  --bg-card-hover: #17253a;
  --bg-sidebar: #070c14;
  --bg-sidebar-hover: #131f31;
  --bg-input: #0e1726;
  --bg-subtle: #182234;
  --bg-subtle-hover: #202d42;

  --text-primary: #eef2f3;
  --text-secondary: #9fb0b8;
  --text-muted: #718293;
  --text-on-sidebar: #cbd5da;
  --text-on-sidebar-muted: #718293;

  --border-color: #263141;
  --border-color-subtle: #1c2836;
  --border-sidebar: #1c2836;
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.35);

  --color-danger-bg: rgba(192, 57, 43, 0.16);
  --color-danger-text: #ef6a5c;
  --color-danger-bg-hover: rgba(192, 57, 43, 0.26);
  --color-success-text: #3cd88c;
  --badge-draft-bg: rgba(255, 195, 0, 0.16);
  --badge-draft-text: #e0b23a;
  --badge-sent-bg: rgba(60, 216, 140, 0.16);
  --badge-sent-text: #3cd88c;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --ifm-color-primary: #0CC0DF;
    --ifm-color-primary-dark: #21af90;
    --ifm-color-primary-darker: #1fa588;
    --ifm-color-primary-darkest: #1a8870;
    --ifm-color-primary-light: #29d5b0;
    --ifm-color-primary-lighter: #32d8b4;
    --ifm-color-primary-lightest: #4fddbf;

    --bg-page: #0b1220;
    --bg-card: #131f31;
    --bg-card-hover: #17253a;
    --bg-sidebar: #070c14;
    --bg-sidebar-hover: #131f31;
    --bg-input: #0e1726;
    --bg-subtle: #182234;
    --bg-subtle-hover: #202d42;

    --text-primary: #eef2f3;
    --text-secondary: #9fb0b8;
    --text-muted: #718293;
    --text-on-sidebar: #cbd5da;
    --text-on-sidebar-muted: #718293;

    --border-color: #263141;
    --border-color-subtle: #1c2836;
    --border-sidebar: #1c2836;
    --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.35);

    --color-danger-bg: rgba(192, 57, 43, 0.16);
    --color-danger-text: #ef6a5c;
    --color-danger-bg-hover: rgba(192, 57, 43, 0.26);
    --color-success-text: #3cd88c;
    --badge-draft-bg: rgba(255, 195, 0, 0.16);
    --badge-draft-text: #e0b23a;
    --badge-sent-bg: rgba(60, 216, 140, 0.16);
    --badge-sent-text: #3cd88c;
  }
}

body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  background: var(--bg-page);
  color: var(--text-primary);
  display: flex;
  min-height: 100vh;
  transition: background 0.2s ease, color 0.2s ease;
}

h1, h2, h3, .brand-title {
  font-family: 'Space Grotesk', 'Inter', sans-serif;
  letter-spacing: -0.01em;
}

.eyebrow {
  font-family: 'Space Grotesk', 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: var(--ifm-color-primary);
  margin-bottom: 4px;
}

/* ---------- Sidebar ---------- */

.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--bg-sidebar);
  color: #fff;
  min-height: 100vh;
  padding: 24px 16px;
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 4px 8px 22px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--border-sidebar);
}

.sidebar .brand-logo-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(27, 242, 227, 0.14), rgba(172, 134, 247, 0.14));
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar .brand-logo {
  width: 24px;
  height: auto;
}

.sidebar .brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.3;
}

.sidebar .brand-title {
  background: linear-gradient(90deg, var(--loft-ai-gradient-start), var(--loft-ai-gradient-end));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-weight: 800;
  font-size: 19px;
  letter-spacing: 1.5px;
}

.sidebar .brand-subtitle {
  color: var(--text-on-sidebar-muted);
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 1.4px;
  text-transform: uppercase;
}

.nav-links {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: 7px;
  color: var(--text-on-sidebar);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-link svg {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  opacity: 0.75;
}

.nav-link:hover {
  background: var(--bg-sidebar-hover);
  color: #fff;
}

.nav-link:hover svg { opacity: 1; }

.nav-link.active {
  background: linear-gradient(90deg, var(--loft-ai-gradient-start), var(--loft-ai-gradient-end));
  color: #0b1220;
  font-weight: 700;
}

.nav-link.active svg { opacity: 1; }

.sidebar-footer {
  position: relative;
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--border-sidebar);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.icon-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  padding: 0;
  border-radius: 8px;
  border: 1px solid var(--border-sidebar);
  background: transparent;
  color: var(--text-on-sidebar);
  cursor: pointer;
}

.icon-toggle:hover {
  background: var(--bg-sidebar-hover);
  color: #fff;
}

.icon-toggle svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.user-menu {
  display: contents;
}

.user-menu-popover {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  right: 0;
  width: auto;
  min-width: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.28);
  padding: 14px;
  z-index: 20;
  opacity: 0;
  transform: translateY(6px) scale(0.98);
  transform-origin: bottom center;
  transition: opacity 0.14s ease, transform 0.14s ease;
  pointer-events: none;
}

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

.user-menu-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 12px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--border-color-subtle);
}

.user-menu-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--loft-ai-gradient-start), var(--loft-ai-gradient-end));
  color: #0b1220;
  font-size: 14px;
  font-weight: 700;
}

.user-menu-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.user-menu-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  color: var(--text-muted);
}

.user-menu-email {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-menu-logout {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--color-danger-text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.user-menu-logout:hover {
  background: var(--color-danger-bg);
}

.user-menu-logout svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

/* ---------- Main content ---------- */

.content {
  flex: 1;
  padding: 32px;
  max-width: 1200px;
}

.page-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}

.page-header h1 {
  margin: 0;
  font-size: 24px;
}

.page-header .subtitle {
  color: var(--text-secondary);
  font-size: 14px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color-subtle);
  border-radius: 12px;
  padding: 24px;
  box-shadow: var(--shadow-card);
  margin-bottom: 24px;
}

.card h2 {
  margin-top: 0;
  font-size: 16px;
}

/* ---------- Stat tiles ---------- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-tile {
  background: var(--bg-card);
  border: 1px solid var(--border-color-subtle);
  border-radius: 12px;
  padding: 20px;
  box-shadow: var(--shadow-card);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.stat-tile:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.1);
}

.stat-tile .value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
}

.stat-tile .label {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* ---------- Forms ---------- */

label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin: 16px 0 6px;
  color: var(--text-secondary);
}

label:first-child { margin-top: 0; }

input[type="text"], input[type="search"], input[type="email"], input[type="password"], textarea, select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  background: var(--bg-input);
  color: var(--text-primary);
}

input[type="text"]:focus, input[type="search"]:focus, input[type="email"]:focus, input[type="password"]:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--ifm-color-primary);
  box-shadow: 0 0 0 3px rgba(12, 192, 223, 0.14);
}

#bodyHtml {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.7;
  scrollbar-width: thin;
  scrollbar-color: var(--border-color) transparent;
}

#bodyHtml::-webkit-scrollbar {
  width: 6px;
}

#bodyHtml::-webkit-scrollbar-track {
  background: transparent;
}

#bodyHtml::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 999px;
}

.hint {
  font-size: 12px;
  color: var(--text-muted);
  margin: 6px 0 0;
}

.row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 700px) {
  .row-2 { grid-template-columns: 1fr; }
}

/* ---------- Form sections ---------- */

.form-section {
  padding: 22px 0;
  border-bottom: 1px solid var(--border-color-subtle);
}

.form-section:first-child {
  padding-top: 0;
}

.form-section:last-of-type {
  border-bottom: none;
  padding-bottom: 22px;
}

.form-section-title {
  font-family: 'Space Grotesk', 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.3px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.optional-tag {
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
  color: var(--text-muted);
  background: var(--bg-subtle);
  padding: 2px 8px;
  border-radius: 999px;
  text-transform: uppercase;
}

.form-section label:first-of-type:not(.segmented-option) {
  margin-top: 16px;
}

.radio-row {
  display: flex;
  gap: 20px;
  align-items: center;
  margin: 8px 0;
}

.radio-row label {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-primary);
}

.radio-row input[type="radio"] {
  width: auto;
}

/* ---------- Buttons ---------- */

.actions {
  display: flex;
  gap: 12px;
  margin-top: 20px;
  flex-wrap: wrap;
}

button {
  padding: 10px 20px;
  border-radius: 7px;
  border: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: filter 0.15s ease, background 0.15s ease, transform 0.1s ease;
}

button:active:not(:disabled) {
  transform: scale(0.98);
}

button:focus-visible {
  outline: 2px solid var(--ifm-color-primary);
  outline-offset: 2px;
}

button.primary {
  background: linear-gradient(90deg, var(--loft-ai-gradient-start), var(--loft-ai-gradient-end));
  color: #0b1220;
}

button.primary:hover { filter: brightness(0.94); }

button.secondary {
  background: var(--bg-subtle);
  color: var(--text-primary);
}

button.secondary:hover { background: var(--bg-subtle-hover); }

button.danger {
  background: var(--color-danger-bg);
  color: var(--color-danger-text);
}

button.danger:hover { background: var(--color-danger-bg-hover); }

button.small {
  padding: 6px 12px;
  font-size: 13px;
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ---------- Tables ---------- */

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th, td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-color-subtle);
}

th {
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

tr:hover td {
  background: var(--bg-card-hover);
}

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

.table-toolbar .search-box {
  flex: 1;
  min-width: 200px;
  max-width: 360px;
}

.pagination {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
  margin-top: 16px;
  font-size: 13px;
  color: var(--text-secondary);
}

/* ---------- Badges ---------- */

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.badge.draft { background: var(--badge-draft-bg); color: var(--badge-draft-text); }
.badge.sent { background: var(--badge-sent-bg); color: var(--badge-sent-text); }

/* ---------- History table extras ---------- */

.subject-cell {
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.date-cell {
  white-space: nowrap;
  font-size: 13px;
  color: var(--text-secondary);
}

.delivery-sent {
  color: var(--color-success-text);
  font-weight: 600;
  font-size: 13px;
}

.delivery-failed {
  color: var(--color-danger-text);
  font-size: 13px;
}

button.delivery-failed {
  background: none;
  border: none;
  cursor: pointer;
  font-weight: 600;
  padding: 0;
  text-decoration: underline;
}

button.delivery-failed:hover {
  color: var(--color-danger-text);
  filter: brightness(1.15);
}

.actions-cell {
  display: flex;
  gap: 6px;
  white-space: nowrap;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 7px;
  background: var(--bg-subtle);
  color: var(--text-secondary);
  border: none;
  cursor: pointer;
  text-decoration: none;
  flex-shrink: 0;
}

.icon-btn svg {
  flex-shrink: 0;
}

.icon-btn svg {
  width: 15px;
  height: 15px;
}

.icon-btn:hover {
  background: var(--bg-subtle-hover);
  color: var(--text-primary);
}

.icon-btn-danger:hover {
  background: var(--color-danger-bg);
  color: var(--color-danger-text);
}

/* ---------- Status / preview ---------- */

.status {
  margin-top: 16px;
  font-size: 13px;
  white-space: pre-wrap;
}

.status.error { color: var(--color-danger-text); }
.status.success { color: var(--color-success-text); }

.preview-panel {
  display: flex;
  flex-direction: column;
}

.preview-subject {
  padding: 10px 14px;
  margin-bottom: 12px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--bg-subtle);
  font-size: 14px;
}

.preview-subject.empty-state {
  padding: 10px 14px;
  text-align: left;
}

.preview-subject strong {
  color: var(--text-secondary);
  font-weight: 600;
  margin-right: 6px;
}

#previewFrame {
  flex: 1;
  min-height: 0;
  width: 100%;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: #fff;
}

/* ---------- Modal ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 24px;
}

.modal-overlay[hidden] {
  display: none;
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.35);
  width: 100%;
  max-width: 480px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  padding: 24px;
}

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

.modal-title {
  font-size: 16px;
  font-weight: 700;
  margin: 0 0 4px;
}

.modal-close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  padding: 0;
  flex-shrink: 0;
}

.modal-close-btn:hover {
  color: var(--text-primary);
}

.failed-recipient-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 4px;
  margin-bottom: 16px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-color) transparent;
}

.failed-recipient-list::-webkit-scrollbar {
  width: 6px;
}

.failed-recipient-list::-webkit-scrollbar-track {
  background: transparent;
}

.failed-recipient-list::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 999px;
}

.failed-recipient-row {
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 13px;
}

.failed-recipient-row:hover {
  background: var(--bg-subtle);
}

.failed-recipient-email {
  color: var(--text-primary);
  font-weight: 600;
}

.failed-recipient-error {
  color: var(--text-muted);
  font-size: 12px;
  margin-top: 2px;
  word-break: break-word;
}

/* ---------- Send progress ---------- */

.send-progress {
  margin-top: 20px;
}

.send-progress-bar-track {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: var(--bg-subtle);
  overflow: hidden;
}

.send-progress-bar-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--loft-ai-gradient-start), var(--loft-ai-gradient-end));
  transition: width 0.35s ease;
  box-shadow: 0 0 12px rgba(27, 242, 227, 0.35);
}

.send-progress-label {
  margin-top: 8px;
  font-size: 13px;
  color: var(--text-secondary);
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: start;
}

@media (max-width: 1000px) {
  .two-col { grid-template-columns: 1fr; }
}

/* ---------- Compose page: sticky preview, normal page scroll ----------
   The page scrolls normally (no trapped/bounded-height container — that
   approach broke when dynamic content grew past its estimate). The
   preview panel just uses position:sticky against the page's own scroll,
   which is the simplest and most robust way to keep it in view. */

body[data-page="compose"] .preview-panel {
  position: sticky;
  top: 24px;
  height: calc(100vh - 48px);
  max-height: calc(100vh - 48px);
  overflow: hidden;
}

@media (max-width: 1000px) {
  body[data-page="compose"] .two-col {
    height: auto;
    min-height: 0;
  }
  body[data-page="compose"] .two-col > .card:first-child {
    overflow-y: visible;
    padding-right: 0;
  }
  body[data-page="compose"] .preview-panel {
    position: static;
    max-height: none;
  }
}

/* ---------- Recipients: segmented control ---------- */

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

#formatSegmented {
  margin-bottom: 16px;
}

@media (max-width: 700px) {
  .segmented { grid-template-columns: 1fr; }
}

.segmented-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  margin: 0;
  border: 1.5px solid var(--border-color);
  border-radius: 10px;
  cursor: pointer;
  background: var(--bg-card);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.segmented-option:hover {
  border-color: var(--text-muted);
}

.segmented-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  margin: 0;
}

.segmented-option,
.segmented-option * {
  text-decoration: none;
}

.segmented-option:has(input:checked) {
  border-color: var(--ifm-color-primary);
  background: var(--bg-subtle);
}

.segmented-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border-radius: 8px;
  background: var(--bg-subtle);
  color: var(--text-secondary);
}

.segmented-option:has(input:checked) .segmented-icon {
  background: linear-gradient(135deg, var(--loft-ai-gradient-start), var(--loft-ai-gradient-end));
  color: #0b1220;
}

.segmented-icon svg {
  width: 17px;
  height: 17px;
}

.segmented-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.segmented-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
}

.segmented-compact .segmented-option {
  padding: 10px 12px;
}

.segmented-compact .segmented-title {
  font-size: 13px;
}

.segmented-compact .segmented-subtitle {
  white-space: normal;
}

.segmented-inline {
  display: inline-flex;
  grid-template-columns: none;
  margin-top: 0;
  gap: 6px;
}

.segmented-inline .segmented-option {
  padding: 6px 14px;
  border-radius: 999px;
  min-width: 52px;
  justify-content: center;
  flex-shrink: 0;
}

.segmented-inline .segmented-option .segmented-title {
  line-height: 1;
}

.segmented-inline .segmented-title {
  font-size: 13px;
  font-weight: 500;
}

.segmented-inline .segmented-option:has(input:checked) .segmented-title {
  font-weight: 700;
}

.segmented-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- Structured content builder ---------- */

.highlight-blocks {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 12px;
  margin-bottom: 14px;
}

.highlight-block {
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 14px;
  background: var(--bg-subtle);
  position: relative;
}

.highlight-block-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.highlight-block-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--loft-ai-gradient-start), var(--loft-ai-gradient-end));
  color: #0b1220;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}

.highlight-block-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  letter-spacing: 0.3px;
  text-transform: uppercase;
  flex: 1;
}

.highlight-block input[type="text"],
.highlight-block textarea {
  background: var(--bg-input);
  margin-bottom: 8px;
}

.highlight-block textarea {
  min-height: 56px;
}

.highlight-bullets {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 8px;
}

.highlight-bullets:empty {
  margin-bottom: 0;
}

.highlight-bullet-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.bullet-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
}

.highlight-bullet-input {
  flex: 1;
  padding: 7px 10px;
  font-size: 13px;
}

.remove-bullet-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  padding: 0;
  border-radius: 50%;
  background: var(--border-color);
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1;
}

.remove-bullet-btn:hover {
  background: var(--color-danger-bg);
  color: var(--color-danger-text);
}

.add-bullet-btn {
  font-size: 12.5px;
}

.remove-block-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  padding: 0;
}

.remove-block-btn:hover {
  color: var(--color-danger-text);
}

/* ---------- Subscriber picker ---------- */

.picker-wrap {
  margin-top: 16px;
}

.selected-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.selected-chips:empty {
  display: none;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 6px 5px 12px;
  border-radius: 999px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  font-size: 13px;
  color: var(--text-primary);
}

.chip button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  padding: 0;
  border-radius: 50%;
  background: var(--border-color);
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1;
}

.chip button:hover {
  background: var(--color-danger-bg);
  color: var(--color-danger-text);
}

.picker-list {
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 6px;
  margin-top: 10px;
}

.picker-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: 6px;
  font-size: 14px;
  color: var(--text-primary);
  cursor: pointer;
}

.picker-row:hover {
  background: var(--bg-subtle);
}

.picker-row input {
  width: auto;
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 32px;
  font-size: 14px;
}

.refresh-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.refresh-btn svg {
  width: 15px;
  height: 15px;
  transition: transform 0.4s ease;
}

.refresh-btn.spinning svg {
  animation: spin 0.6s linear;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.link-button {
  background: none;
  border: none;
  color: var(--ifm-color-primary);
  cursor: pointer;
  font-weight: 600;
  padding: 0;
  font-size: 14px;
}
