:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-soft: #f9fbff;
  --border: #e3e6f0;
  --field: #ffffff;
  --text: #0e1026;
  --muted: #5a607a;
  --accent: #00f0c8;
  --accent-2: #6b5cff;
  --shadow: 0 18px 48px rgba(14, 16, 38, 0.08);
  --shadow-soft: 0 8px 24px rgba(14, 16, 38, 0.07);
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 12px;
  /* Century Gothic is not guaranteed on every PC: Montserrat is the wanted
     fallback, Segoe UI the always-present Windows safety net. */
  --font: "Century Gothic", "Montserrat", "Aptos", "Segoe UI", sans-serif;
}

body.dark {
  --bg: #0b0e1c;
  --surface: #131735;
  --surface-soft: #0f132b;
  --border: #262b4a;
  --field: #0f132b;
  --text: #f0f2fa;
  --muted: #9aa0b8;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.26);
  --shadow-soft: 0 8px 24px rgba(0, 0, 0, 0.2);
  /* Corporate-site dark: deep navy with the brand gradient glow
     (#4C6FF5 -> #5D5FEF -> #7E58F2) instead of the light-mode white mix. */
  background:
    radial-gradient(circle at top left, rgba(76, 111, 245, 0.16), transparent 32rem),
    radial-gradient(circle at bottom right, rgba(126, 88, 242, 0.13), transparent 36rem),
    linear-gradient(135deg, #0b0e1c, #10142e);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  font-family: var(--font);
  background:
    radial-gradient(circle at top left, color-mix(in srgb, var(--accent) 16%, transparent), transparent 32rem),
    linear-gradient(135deg, var(--bg), color-mix(in srgb, var(--bg) 82%, #ffffff 18%));
  overflow: hidden;
}

button,
input,
select,
textarea {
  font-family: var(--font);
}

button {
  border: 0;
}

.app-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  height: 100vh;
}

.sidebar {
  padding: 22px;
  border-right: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(18px);
  display: flex;
  flex-direction: column;
  gap: 26px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand img {
  width: 48px;
  height: 48px;
  object-fit: contain;
}

.brand strong {
  display: block;
  font-size: 18px;
}

.brand span,
.welcome-user,
.side-note,
.topbar p,
.panel-heading p,
.card-title p,
.field-label,
.status,
.model-note {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.nav,
.settings-nav,
.settings-subnav {
  display: grid;
  gap: 8px;
}

.nav-item,
.settings-tab {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 10px 12px;
  border-radius: 14px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  text-align: left;
  font-size: 14px;
}

.nav-item:hover,
.settings-tab:hover {
  color: var(--text);
  background: var(--surface-soft);
}

.nav-item.active,
.settings-tab.active {
  color: var(--text);
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 16%, var(--surface)), var(--surface-soft));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 35%, var(--border));
}

.settings-subnav {
  margin: -2px 0 6px 18px;
  padding-left: 12px;
  border-left: 1px solid color-mix(in srgb, var(--accent) 28%, var(--border));
  overflow: hidden;
  max-height: 260px;
  opacity: 1;
  transition: max-height 160ms ease, opacity 160ms ease;
}

.settings-subnav.collapsed {
  max-height: 0;
  opacity: 0;
  pointer-events: none;
}

.settings-subnav .settings-tab {
  min-height: 34px;
  padding: 7px 10px;
  border-radius: 12px;
  font-size: 13px;
}

.welcome-user {
  margin-top: -16px;
  padding-left: 60px;
}

/* Theme toggle flush left, language trigger flush right (card edges below);
   space-between puts the accent picker midway BETWEEN the two neighbours. */
.language-menu {
  margin-top: auto;
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.theme-toggle-btn {
  width: 38px;
  justify-content: center;
  padding: 0;
  font-size: 15px;
}

.accent-quick {
  width: 38px;
  height: 38px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: color-mix(in srgb, var(--surface-soft) 86%, transparent);
  cursor: pointer;
}

.accent-quick:hover {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
}

.language-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface-soft) 86%, transparent);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.language-trigger:hover {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
}

.lang-caret {
  color: var(--muted);
  font-size: 11px;
}

.language-switcher {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  z-index: 80;
  box-shadow: var(--shadow);
  min-width: 200px;
}

.language-switcher.hidden {
  display: none;
}

.language-flag {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 28px;
  border-radius: 10px;
  color: var(--text);
  background: transparent;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
}

.flag-icon {
  display: block;
  width: 21px;
  height: 14px;
  border-radius: 3px;
  box-shadow: inset 0 0 0 1px rgba(14, 16, 38, 0.16);
  overflow: hidden;
}

.flag-gb {
  background:
    linear-gradient(27deg, transparent 44%, #fff 44% 52%, #c8102e 52% 56%, #fff 56% 64%, transparent 64%),
    linear-gradient(153deg, transparent 44%, #fff 44% 52%, #c8102e 52% 56%, #fff 56% 64%, transparent 64%),
    linear-gradient(90deg, transparent 40%, #fff 40% 60%, transparent 60%),
    linear-gradient(0deg, transparent 35%, #fff 35% 65%, transparent 65%),
    linear-gradient(90deg, transparent 45%, #c8102e 45% 55%, transparent 55%),
    linear-gradient(0deg, transparent 42%, #c8102e 42% 58%, transparent 58%),
    #012169;
}

/* Simplified 7-stripe US flag: 2px bands stay crisp at 21×14, the 13-stripe
   original aliased into a blur at this size. */
.flag-us {
  background:
    linear-gradient(#3c3b6e, #3c3b6e) 0 0 / 40% 57.2% no-repeat,
    repeating-linear-gradient(180deg, #b22234 0 2px, #fff 2px 4px);
}

.flag-fr {
  background: linear-gradient(90deg, #0055a4 0 33.33%, #fff 33.33% 66.66%, #ef4135 66.66%);
}

.flag-de {
  background: linear-gradient(180deg, #000 0 33.33%, #dd0000 33.33% 66.66%, #ffce00 66.66%);
}

.flag-es {
  background: linear-gradient(180deg, #aa151b 0 25%, #f1bf00 25% 75%, #aa151b 75%);
}

.flag-it {
  background: linear-gradient(90deg, #009246 0 33.33%, #fff 33.33% 66.66%, #ce2b37 66.66%);
}

.flag-cn {
  background:
    radial-gradient(circle at 25% 28%, #ffde00 0 12%, transparent 13%),
    radial-gradient(circle at 44% 18%, #ffde00 0 4%, transparent 5%),
    radial-gradient(circle at 51% 30%, #ffde00 0 4%, transparent 5%),
    radial-gradient(circle at 50% 46%, #ffde00 0 4%, transparent 5%),
    #de2910;
}

.flag-in {
  background:
    radial-gradient(circle at center, transparent 0 12%, #06038d 13% 15%, transparent 16%),
    linear-gradient(180deg, #ff9933 0 33.33%, #fff 33.33% 66.66%, #138808 66.66%);
}

.flag-ru {
  background: linear-gradient(180deg, #fff 0 33.33%, #0039a6 33.33% 66.66%, #d52b1e 66.66%);
}

.flag-bg {
  background: linear-gradient(180deg, #fff 0 33.33%, #00966e 33.33% 66.66%, #d62612 66.66%);
}

.flag-ae {
  background:
    linear-gradient(90deg, #ce1126 0 25%, transparent 25%),
    linear-gradient(180deg, #00732f 0 33.33%, #fff 33.33% 66.66%, #000 66.66%);
}

.flag-pt {
  background:
    radial-gradient(circle at 40% 50%, #ffe900 0 15%, transparent 16%),
    linear-gradient(90deg, #046a38 0 40%, #da291c 40%);
}

.flag-id {
  background: linear-gradient(180deg, #ce1126 0 50%, #fff 50%);
}

.flag-bd {
  background:
    radial-gradient(circle at 45% 50%, #f42a41 0 28%, transparent 29%),
    #006a4e;
}

.flag-jp {
  background:
    radial-gradient(circle at 50% 50%, #bc002d 0 25%, transparent 26%),
    #fff;
}

.flag-kr {
  background:
    radial-gradient(circle at 50% 50%, transparent 0 25%, #fff 26%),
    linear-gradient(180deg, #cd2e3a 0 50%, #0047a0 50%);
}

.language-flag:hover {
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--border);
}

.language-flag.active {
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 48%, var(--border));
}

.side-note {
  padding: 8px 12px;
  border-radius: 14px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  display: grid;
  gap: 1px;
  text-align: center;
  /* Sit close under the toggle row (the sidebar's 26px gap is too airy here). */
  margin-top: -14px;
  font-size: 11.5px;
}

.version-note {
  color: var(--muted);
  font-size: 11px;
}

.workspace {
  overflow: hidden;
  padding: 24px;
  min-width: 0;
}

.view {
  display: none;
  height: 100%;
}

.view.active {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 26px;
  letter-spacing: 0;
}

h2 {
  font-size: 18px;
  letter-spacing: 0;
}

h3 {
  font-size: 14px;
  letter-spacing: 0;
}

.split-workspace {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
  min-height: 0;
  flex: 1;
  align-items: stretch;
}

.panel,
.settings-card {
  position: relative;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 22px;
  min-height: 0;
  height: 100%;
}

.panel::after {
  content: "";
  position: absolute;
  top: -1px;
  left: 24px;
  width: 92px;
  height: 1px;
  pointer-events: none;
  opacity: 0;
  background: linear-gradient(
    90deg,
    transparent,
    color-mix(in srgb, var(--accent) 45%, transparent),
    rgba(255, 255, 255, 0.9),
    color-mix(in srgb, var(--accent-2) 32%, transparent),
    transparent
  );
  filter: blur(0.25px);
  animation: edge-spark 9s ease-in-out infinite;
}

.output-panel::after {
  animation-delay: 3.4s;
}

.panel-heading,
.card-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.card-title {
  display: block;
}

.card-title.compact {
  margin-top: 4px;
}

.command,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  background: linear-gradient(180deg, var(--surface), var(--surface-soft));
  box-shadow: var(--shadow-soft);
  cursor: pointer;
  white-space: nowrap;
  font-size: 13px;
}

.command:hover,
.icon-button:hover {
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
  transform: translateY(-1px);
}

.command.primary {
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 28%, var(--surface)), color-mix(in srgb, var(--accent-2) 12%, var(--surface)));
  border-color: color-mix(in srgb, var(--accent) 50%, var(--border));
}

.command.subtle {
  box-shadow: none;
}

.icon-button {
  width: 36px;
  height: 36px;
  padding: 0;
}

.toolbar-divider {
  width: 1px;
  height: 26px;
  background: var(--border);
  margin: 0 4px;
}

/* BL-01/02 + extra formatting: right-aligned flag buttons, hidden color input */
.toolbar-flex { flex: 1 1 auto; }

.color-input-hidden {
  width: 0;
  height: 0;
  padding: 0;
  border: none;
  margin: 0;
  opacity: 0;
  position: absolute;
  pointer-events: none;
}

#sensitivityBtn.flag-on { color: var(--accent, #5d5fef); }
#importanceBtn.imp-high { color: #e5484d; }
#importanceBtn.imp-low { color: #3b82f6; }

[data-icon] {
  display: inline-flex;
  width: 18px;
  height: 18px;
  color: currentColor;
}

.file-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  align-self: flex-start;
  max-width: 100%;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 12px;
  line-height: 1.25;
}

.file-pill.empty {
  color: var(--muted);
}

.file-pill svg,
.file-pill [data-icon] {
  width: 14px;
  height: 14px;
  flex: 0 0 14px;
}

.file-pill.loaded {
  color: var(--text);
  border-color: color-mix(in srgb, var(--accent) 28%, var(--border));
  background: color-mix(in srgb, var(--accent) 6%, var(--surface-soft));
}

.field-label {
  margin-top: 2px;
}

.editor,
.small-editor,
input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--field);
  color: var(--text);
  outline: none;
  font-size: 14px;
}

select,
input {
  min-height: 38px;
  padding: 0 12px;
}

select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 16px,
    calc(100% - 12px) 16px;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 34px;
}

.editor:focus,
.small-editor:focus,
input:focus,
select:focus,
textarea:focus {
  border-color: color-mix(in srgb, var(--accent) 70%, var(--border));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent);
}

.input-editor,
.rich-editor {
  flex: 1;
  min-height: 0;
  padding: 16px;
  resize: none;
  line-height: 1.55;
  width: 100%;
}

.rich-editor {
  overflow: auto;
}

.rich-editor:empty::before,
.signature-editor:empty::before {
  content: "AI output will appear here.";
  color: var(--muted);
}

.signature-editor:empty::before {
  content: "Copy & paste your signature here or just type in.";
}

.editor-toolbar,
.action-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.action-row {
  margin-top: auto;
}

/* "Transcript or notes" + auto-detected language on one row */
.label-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.input-lang-badge {
  color: var(--accent, #5d5fef);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

/* File slot in the Step 1 heading: Choose file <-> pill + clear swap */
.file-slot {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.file-slot .file-pill {
  max-width: 300px;
  overflow: hidden;
}

.file-slot .file-pill span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Generation parameters: symmetric 2x2 grid, equal-width selects.
   Left column: Theme / Layout. Right column: Group / Tags. */
.input-panel .gen-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: 18px;
  row-gap: 8px;
  align-items: center;
  margin-top: 0;
}

.gen-cell {
  display: grid;
  grid-template-columns: 92px 1fr;
  align-items: center;
  gap: 8px;
  min-width: 0;
  white-space: nowrap;
  font-size: 13px;
}

/* Right column (Group / Tags): identical label column so both titles and
   both dropdown left edges sit on the same vertical line. */
.gen-grid > .gen-cell:nth-child(even) {
  grid-template-columns: 64px 1fr;
}

/* Titles hug their dropdowns: right-aligned inside the label column, so the
   gap between title and control is always exactly the 8px grid gap. */
.gen-cell > span:first-child {
  justify-self: end;
  text-align: right;
}

/* Mandatory markers: accent asterisk on every gated selector label.
   ::after survives i18n re-rendering of the label text. */
.gen-cell > span:first-child::after {
  content: " *";
  color: var(--accent, #5d5fef);
  font-weight: 700;
}

/* Mandatory-choice gating: greyed out until every visible selector is set */
.command.primary:disabled,
.command.send-accent:disabled {
  opacity: 0.45;
  filter: grayscale(0.6);
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

/* Step 3 left column: title, dropdown box and link share ONE left edge. */
.step3-title { padding-left: 0; }
.mailto-wrap .link-button { margin-left: 0; }

/* Upload CTA mirrors the Generate button (same width, same gradient) */
.upload-cta {
  min-width: 220px;
  justify-content: center;
}

/* The input-info modal message carries \n\n-separated rule paragraphs */
#modalMessage { white-space: pre-line; }

/* Re-wire picker inside the modal (theme/group deletion lifecycle) */
#modalSelect {
  width: 100%;
  margin: 10px 0 4px;
  min-height: 36px;
}

.gt-zone { min-width: 0; }

.gen-cell select { min-width: 0; width: 100%; }

/* Tags cell: two selects share the exact same total width as one select */
.gt-selects {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  min-width: 0;
}

.gt-selects.single { grid-template-columns: 1fr; }

.gt-none {
  /* Spreads across the whole zone the tag dropdowns would occupy — a single
     comfortable line, not a cramped left-hugging block. */
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  width: 100%;
  min-height: 36px;
  font-size: 12px;
  color: var(--text-soft, #7a7f96);
  white-space: nowrap;
  line-height: 1.35;
}

.gt-none .link-button { font-size: 12px; display: inline; }

.context-row .generate-theme-target select {
  max-width: 200px;
}

.context-row .group-target {
  justify-self: end;
}

.context-row .group-target select {
  max-width: 180px;
}

/* Generate button + progress + status, right-aligned in the Step 2 heading */
.generate-control {
  display: grid;
  justify-items: end;
  gap: 5px;
}

.generate-control .command {
  min-width: 220px;
  justify-content: center;
}

.generate-control .status {
  white-space: nowrap;
  font-size: 12px;
  line-height: 1.2;
  text-align: right;
}

.subject-field {
  margin-top: -2px;
}

/* Step 3: Post-Outcome Processing (compact) */
.step3-zone {
  margin-top: auto;
  display: grid;
  gap: 8px;
}

/* Same visual weight as the Step 1 / Step 2 panel titles (h2 = 18px). */
.step3-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0;
  margin: 0;
}

.step3-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

/* Compact dropdown so all six action icons fit on ONE row next to it */
.mailto-wrap { flex: 0 1 260px; min-width: 190px; }

.mailto-wrap { display: grid; gap: 4px; }

.mailto-dd { position: relative; }

/* Neutralize the app-wide input styling for the option checkboxes: without
   this they render as big empty squares that swallow the row. */
.mailto-option input[type="checkbox"] {
  appearance: auto;
  width: 15px;
  height: 15px;
  min-height: 0;
  flex: 0 0 15px;
  margin: 0;
  padding: 0;
  border: none;
  background: none;
  box-shadow: none;
}

.mailto-option > span:not(.mo-sub) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mailto-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text-soft, #7a7f96);
  font-size: 13px;
  cursor: pointer;
  text-align: left;
}

.mailto-trigger.has-selection { color: var(--text); }
.mailto-caret { font-size: 11px; opacity: 0.7; }

.mailto-menu {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 30;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(14, 16, 38, 0.16);
  overflow: hidden;
}

.mailto-search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}

.mailto-search [data-icon] { width: 15px; height: 15px; color: var(--text-soft, #7a7f96); flex: 0 0 15px; }

.mailto-search input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  min-width: 0;
}

.mailto-clear {
  border: none;
  background: transparent;
  color: var(--text-soft, #9aa0b8);
  font-size: 15px;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
}
.mailto-clear:hover { color: var(--text); }

.mailto-options { max-height: 240px; overflow-y: auto; overflow-x: hidden; padding: 4px; }

.mailto-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
}
.mailto-option:hover { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.mailto-option input { accent-color: var(--accent); flex: 0 0 auto; }
.mailto-option .mo-sub { color: var(--text-soft, #7a7f96); font-size: 11.5px; margin-left: auto; white-space: nowrap; }
.mailto-group-head {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-soft, #7a7f96);
  padding: 6px 8px 2px;
}
.mailto-empty { padding: 10px; font-size: 12.5px; color: var(--text-soft, #7a7f96); }

.link-button {
  border: none;
  background: transparent;
  color: var(--accent, #5d5fef);
  font-size: 12px;
  cursor: pointer;
  padding: 0;
  text-align: left;
  width: fit-content;
}
.link-button:hover { text-decoration: underline; }

/* Send: filled accent icon, docked right beside the recipients picker */
.send-accent [data-icon] { color: var(--accent, #5d5fef); }

.step3-send {
  width: 36px;
  min-width: 36px;
  height: 36px;
  min-height: 36px;
  padding: 0;
  font-size: 0;
  gap: 0;
  justify-content: center;
  flex: 0 0 auto;
  align-self: flex-start;
}

.output-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  flex: 1 1 auto;
  flex-wrap: nowrap;
  /* Override .action-row's margin-top:auto so the icon row sits level with
     the Mail-to trigger (both are 36px tall). */
  margin-top: 0;
  align-self: flex-start;
}

.output-actions .command {
  width: 36px;
  min-width: 36px;
  height: 36px;
  min-height: 36px;
  padding: 0;
  font-size: 0;
  /* The hidden text span is still a flex item: without gap:0 it drags the
     icon off-center inside the circular button. */
  gap: 0;
  justify-content: center;
  flex: 0 0 auto;
}

.output-actions .command [data-icon] {
  width: 18px;
  height: 18px;
}

.archive-target {
  max-width: 260px;
}

.generate-theme-target {
  display: grid;
  grid-template-columns: auto minmax(190px, 1fr);
  align-items: center;
  gap: 10px;
  max-width: none;
  min-width: 0;
  white-space: nowrap;
}

.generate-theme-target select {
  min-width: 0;
}

.file-action-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.file-action-row .file-pill {
  min-width: 0;
}

.file-action-row .icon-button {
  flex: 0 0 auto;
}

.settings-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  min-height: 0;
  flex: 1;
  align-content: start;
}

.settings-nav {
  grid-row: 1 / span 2;
  align-content: start;
  padding: 10px;
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  border: 1px solid var(--border);
}

.settings-pages {
  min-height: 0;
  max-height: calc(100vh - 180px);
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 12px;
}

.settings-footer {
  grid-column: 1;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding: 0 6px 0 0;
}

.settings-footer .command {
  min-height: 38px;
  height: 38px;
  padding: 0 16px;
  border-radius: 999px;
}

.settings-page {
  display: none;
}

.settings-page.active {
  display: block;
}

.settings-card {
  padding: 22px;
  display: grid;
  gap: 18px;
  overflow: visible;
}

.info-view {
  width: 100%;
  max-width: none;
  overflow: auto;
  padding-right: clamp(10px, 2vw, 28px);
}

.info-stack {
  width: 100%;
  display: grid;
  gap: 16px;
}

.info-view > .topbar {
  width: 100%;
}

.info-card {
  align-content: start;
  line-height: 1.6;
}

.notice-card {
  display: grid;
  gap: 4px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  color: var(--text);
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 12%, var(--surface)), var(--surface-soft));
  border: 1px solid color-mix(in srgb, var(--accent) 26%, var(--border));
}

.notice-card span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.info-card > p {
  color: var(--text);
}

.info-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding-left: 22px;
}

.info-list li {
  padding-left: 4px;
}

/* Info & Legal: uniform 9pt (12px) explanatory text everywhere.
   Titles keep their own sizes; only body copy is normalized. */
.info-view .info-card > p,
.info-view .info-card .info-list li,
.info-view .notice-card span,
.info-view .card-title p,
.info-view .helper-note,
.info-view .about-card p,
.info-view .about-list dt,
.info-view .about-list dd {
  font-size: 12px;
  line-height: 1.55;
}

.about-card {
  display: grid;
  grid-template-columns: 86px 1fr;
  align-items: start;
}

.about-card img {
  width: 66px;
  height: 66px;
  object-fit: contain;
}

.about-list {
  display: grid;
  gap: 10px;
  margin: 18px 0 0;
}

.about-list div {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 12px;
}

.about-list dt {
  color: var(--muted);
}

.about-list dd {
  margin: 0;
}

.license-status-card {
  gap: 16px;
}

.license-status-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 14px;
  margin: 0;
}

.license-status-grid div {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
}

.license-status-grid dt {
  color: var(--muted);
  font-size: 12px;
}

.license-status-grid dd {
  margin: 4px 0 0;
  font-weight: 700;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 12px;
}

.status-pill.active {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--border));
  background: color-mix(in srgb, var(--accent) 15%, transparent);
}

.license-owner-status {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--accent) 28%, var(--border));
  color: var(--muted);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  font-size: 12px;
  white-space: nowrap;
}

.license-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.billing-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-soft);
}

.billing-toggle > span {
  padding: 0 8px;
  color: var(--muted);
  font-size: 12px;
}

.billing-option {
  min-height: 30px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 999px;
  color: var(--text);
  background: transparent;
  cursor: pointer;
  font: inherit;
}

.billing-option.active {
  border-color: color-mix(in srgb, var(--accent) 50%, var(--border));
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  box-shadow: var(--shadow-soft);
}

.pricing-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.pricing-card {
  display: grid;
  gap: 14px;
  align-content: start;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, var(--surface), var(--surface-soft));
}

.pricing-card.featured {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  box-shadow: var(--shadow-soft);
}

.plan-kicker {
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.pricing-card h3 {
  margin: 4px 0 6px;
  font-size: 18px;
}

.pricing-card p {
  margin: 0;
  color: var(--muted);
}

.plan-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 20px;
}

.tier-list {
  display: grid;
  gap: 8px;
}

.tier-list span {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-weight: 700;
}

.archives-layout {
  display: grid;
  grid-template-columns: minmax(300px, 0.8fr) minmax(520px, 1.6fr);
  gap: 18px;
  min-height: 0;
  flex: 1;
}

.archive-content-stack {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 14px;
  min-height: 0;
}

.archive-sidebar,
.archive-index,
.archive-subject-card,
.archive-reader {
  min-height: 0;
  overflow: hidden;
}

.archive-index {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  align-content: start;
  gap: 14px;
}

.archive-sidebar {
  align-content: start;
  padding: 14px 16px;
  gap: 10px;
}

.archive-subject-card {
  padding: 14px 18px;
  gap: 8px;
}

.archive-filter-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 12px;
  align-items: center;
}

/* BL-09: export controls, right end of the Filter panel */
.archive-export-zone {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-self: end;
}

.ax-radio {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  white-space: nowrap;
  cursor: pointer;
}

.ax-radio input[type="radio"] {
  appearance: auto;
  width: 14px;
  height: 14px;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: none;
  background: none;
  box-shadow: none;
  accent-color: var(--accent, #5d5fef);
}

#archiveExportBtn { min-width: 200px; justify-content: center; }

/* Archive flag markers (Index list + Subject meta) */
.af-lock { margin-left: 6px; }
.af-high { color: #e5484d; font-weight: 800; margin-left: 6px; }
.af-low { color: #3b82f6; font-weight: 800; margin-left: 6px; }
.asm-flags { display: inline-flex; align-items: center; gap: 4px; margin-left: auto; white-space: nowrap; }
#archiveSubjectMeta { display: flex; align-items: baseline; gap: 10px; }

/* Archived subject line: body default is 10pt everywhere */
/* Full content toolbar */
.archive-reader-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.archive-tools { display: flex; align-items: center; gap: 6px; flex-wrap: nowrap; }
.arch-mailto { width: 210px; flex: 0 0 210px; }
.arch-mailto .mailto-menu { bottom: auto; top: calc(100% + 6px); }
.arch-tool-btn {
  width: 34px;
  min-width: 34px;
  height: 34px;
  min-height: 34px;
  padding: 0;
  font-size: 0;
  gap: 0;
  justify-content: center;
  flex: 0 0 auto;
}

.archive-item-list {
  display: grid;
  gap: 8px;
  min-height: 0;
  align-self: start;
  align-content: start;
  grid-auto-rows: max-content;
  overflow: auto;
  padding-right: 4px;
}

.archive-item {
  width: 100%;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  background: var(--surface-soft);
  cursor: pointer;
  text-align: left;
}

.archive-item.active {
  border-color: color-mix(in srgb, var(--accent) 60%, var(--border));
  background: color-mix(in srgb, var(--accent) 10%, var(--surface-soft));
}

.archive-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  justify-content: stretch;
}

.archive-tree-group {
  display: grid;
  gap: 6px;
  align-content: start;
}

.archive-tree-heading {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 34px;
  height: 34px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  background: linear-gradient(180deg, var(--surface), var(--surface-soft));
  cursor: pointer;
  text-align: left;
}

.archive-tree-heading:hover {
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
}

.archive-tree-toggle {
  width: 20px;
  height: 20px;
  display: inline-grid;
  place-items: center;
  border-radius: 6px;
  color: var(--text);
  background: color-mix(in srgb, var(--accent) 10%, var(--surface-soft));
  border: 1px solid color-mix(in srgb, var(--accent) 24%, var(--border));
  font-weight: 700;
  line-height: 1;
}

.archive-tree-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.archive-tree-count {
  color: var(--muted);
  font-size: 12px;
}

.archive-tree-children {
  display: grid;
  gap: 6px;
  padding-left: 24px;
  border-left: 1px solid color-mix(in srgb, var(--border) 80%, transparent);
  margin-left: 10px;
}

.archive-tree-children.collapsed,
.archive-theme-children.collapsed {
  display: none;
}

.archive-theme-node {
  display: grid;
  gap: 6px;
}

.archive-theme-heading {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 32px;
  height: 32px;
  padding: 5px 10px;
  border: 1px solid color-mix(in srgb, var(--border) 82%, transparent);
  border-radius: 14px;
  color: var(--muted);
  background: color-mix(in srgb, var(--surface-soft) 72%, transparent);
  cursor: pointer;
  text-align: left;
}

.archive-theme-heading:hover {
  color: var(--text);
  border-color: color-mix(in srgb, var(--accent) 30%, var(--border));
}

.archive-theme-children {
  display: grid;
  gap: 6px;
  padding-left: 22px;
}

.archive-tree-empty {
  padding: 8px 10px;
  color: var(--muted);
  font-size: 12px;
}

.archive-item-main {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.archive-item-title-row {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  color: var(--text);
  font-size: 13px;
}

.archive-item-main strong {
  font-size: 13px;
  line-height: 1.35;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.archive-item-main span {
  color: var(--muted);
  font-size: 12px;
}

.archive-item-main .archive-item-title-row {
  color: var(--text);
  font-size: 13px;
}

.archive-favorite-marker {
  flex: 0 0 auto;
  color: #f6b73c;
  font-size: 13px;
  line-height: 1;
  filter: drop-shadow(0 2px 6px rgba(246, 183, 60, .22));
}

/* Delete standard: red "x", same as every other delete control. */
.archive-delete {
  width: 30px;
  height: 30px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  color: #b42318;
  font-size: 13px;
  font-weight: 600;
  background: transparent;
}

.archive-delete:hover {
  color: #b42318;
  background: color-mix(in srgb, #b42318 12%, var(--surface));
}

.archive-subject {
  padding: 2px 0 0;
  color: var(--text);
  /* Body default is 10pt everywhere — the subject line is body text. */
  font-size: 10pt;
  line-height: 1.5;
}

.archive-preview {
  min-height: 0;
  flex: 1;
  overflow: auto;
  padding: 4px 0 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  font-family: "Century Gothic", "Montserrat", "Segoe UI", sans-serif;
  font-size: 10pt;
  line-height: 1.45;
}

.archive-preview h1,
.archive-preview h2 {
  font-size: 14pt;
  line-height: 1.25;
  margin: 0 0 8px;
}

.archive-preview h3 {
  font-size: 12pt;
  line-height: 1.3;
  margin: 10px 0 6px;
}

.archive-preview p,
.archive-preview li,
.archive-preview td,
.archive-preview th {
  font-size: 10pt;
}

.archive-preview img {
  max-width: 100%;
  height: auto;
}

.archive-reader {
  display: flex;
  flex-direction: column;
}

.empty-state {
  padding: 18px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  color: var(--muted);
  text-align: center;
}

.provider-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 12px;
}

.provider-card {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
  cursor: pointer;
}

.provider-card.active {
  border-color: color-mix(in srgb, var(--accent) 65%, var(--border));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 12%, transparent);
}

.provider-card strong {
  display: block;
  margin-bottom: 4px;
}

.provider-card span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.form-grid,
.layout-row,
.style-toolbar {
  display: grid;
  grid-template-columns: 150px 1fr;
  align-items: center;
  gap: 12px;
}

.theme-profile-toolbar {
  display: grid;
  grid-template-columns: minmax(310px, 0.9fr) minmax(430px, 1.4fr) auto;
  align-items: start;
  gap: 12px;
}

.theme-profile-toolbar .command {
  height: 38px;
  min-height: 38px;
  padding: 0 14px;
  white-space: nowrap;
}

.toolbar-field {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-height: 40px;
}

.toolbar-field > span:first-child {
  white-space: nowrap;
}

.toolbar-field > select,
.theme-name-stack > input {
  min-width: 0;
}

.theme-name-stack {
  display: grid;
  grid-template-rows: 38px auto;
  gap: 5px;
  min-width: 0;
}

.theme-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.theme-toolbar-actions .icon-button {
  flex: 0 0 auto;
}

.theme-profile-toolbar .danger {
  width: 38px;
  min-width: 38px;
  padding: 0;
  font-size: 18px;
}

/* Subscription panel: breathing room between the data grid and the buttons */
#subscriptionPanel .license-actions {
  margin-top: 18px;
}

.sub-activate-note {
  display: block;
  margin-top: 6px;
  font-size: 11.5px;
  color: var(--muted);
  text-decoration: underline;
  cursor: pointer;
}

.sub-activate-note:hover {
  color: var(--accent);
}

/* Pressed/active state for command buttons that open a panel */
.command.active {
  background: color-mix(in srgb, var(--accent) 16%, var(--surface));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 45%, var(--border));
}

/* GLOBAL delete standard: every delete control in the tool is the same red
   "x" icon-button — no trash cans, no text buttons, anywhere. */
.icon-button.danger {
  color: #b42318;
  font-size: 16px;
  font-weight: 600;
}

.contact-actions .icon-button.danger {
  font-size: 13px;
}

.reset-theme-button {
  align-self: start;
  margin-top: 0;
}

.reset-action-button {
  width: 38px;
  min-width: 38px;
  height: 38px;
  min-height: 38px;
}

.custom-theme-field {
  min-width: 0;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
}

.custom-theme-field > span:first-child {
  padding-top: 10px;
}

.field-hint {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.2;
  padding-left: 2px;
}

.helper-note {
  margin: -2px 0 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.top-note {
  margin: 0 0 16px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
}

.settings-zone {
  display: grid;
  gap: 14px;
  padding: 18px 0;
  border-top: 1px solid color-mix(in srgb, var(--border) 78%, transparent);
}

.settings-zone:first-of-type {
  border-top: 0;
  padding-top: 0;
}

.top-note + .settings-zone {
  border-top: 0;
  padding-top: 0;
}

.zone-title {
  display: grid;
  gap: 3px;
}

.zone-title h3 {
  margin: 0;
  font-size: 15px;
}

.zone-title p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.inline-field {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.hidden {
  display: none !important;
}

/* Plain caption below the API key field — no box/contour (2026-07-09).
   margin-left = form-grid label column (150px) + gap (12px), so the text
   starts exactly where the input field starts. */
.model-note {
  padding: 0;
  margin-top: -6px;
  margin-left: 162px;
  border: 0;
  background: transparent;
  font-style: italic;
  font-size: 11.5px;
  color: var(--muted);
}

.three-col,
.two-col {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.two-col {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

label {
  display: grid;
  gap: 7px;
  color: var(--text);
  font-size: 13px;
}

.layout-row {
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
}

.layout-row > label {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  min-height: 38px;
}

.layout-row > label > select {
  min-width: 0;
}

.group-manager {
  display: grid;
  gap: 14px;
}

.chip-list {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.group-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-soft);
  font-size: 12px;
}

.group-chip button {
  width: 20px;
  height: 20px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border-radius: 999px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}

.group-chip button:hover {
  color: var(--text);
  background: color-mix(in srgb, var(--accent) 12%, var(--surface-soft));
}

/* Group-chip delete follows the global red "x" standard while keeping
   the compact chip footprint. */
.group-chip button.chip-delete {
  color: #b42318;
  font-size: 12px;
  font-weight: 600;
  border: 0;
}

.group-chip button.chip-delete:hover {
  color: #b42318;
  background: color-mix(in srgb, #b42318 12%, var(--surface-soft));
}

.group-chip [data-icon] {
  width: 13px;
  height: 13px;
}

/* One shared grid for the subject-length row, both tag rows AND the date
   row so the whole step reads as a single aligned table:
                [Subject length]
   [Use tag N]  [Tag set N]      [Add Custom Tag] [+ Add] [red x]
   [Use date]   [Date position]  [Date format]  */
.subject-builder-grid {
  display: grid;
  grid-template-columns: minmax(110px, 0.55fr) minmax(170px, 1fr) minmax(180px, 1.05fr) auto auto;
  gap: 14px 12px;
  align-items: end;
}

.subject-builder-grid > .subject-toggle {
  grid-column: 1;
  align-self: end;
  min-height: 38px;
}

/* Every label sits directly above its own field, left-aligned with it,
   consistently across all rows of the grid. */
.subject-builder-grid > label:not(.subject-toggle) {
  align-self: end;
  align-content: end;
  gap: 6px;
  min-width: 0;
}

.subject-builder-grid > label:not(.subject-toggle) > span:first-child {
  justify-self: start;
  line-height: 1.2;
}

.subject-builder-grid > label:not(.subject-toggle) > select {
  width: 100%;
  min-width: 0;
  height: 38px;
}

/* Subject length lives in the same select column, so its right edge lines
   up with the Tag set / Date position selects below it. */
.subject-builder-grid > .subject-length-field {
  grid-column: 2;
}

.subject-builder-grid > input {
  min-width: 0;
}

.subject-builder-grid .command {
  height: 38px;
  min-height: 38px;
  padding: 0 14px;
  white-space: nowrap;
  justify-self: start;
}

.subject-builder-grid .icon-button.danger {
  width: 38px;
  min-width: 38px;
  height: 38px;
  min-height: 38px;
  padding: 0;
  justify-self: start;
}

.subject-mode-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  gap: 12px;
}

.radio-card {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px 10px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
  cursor: pointer;
}

.radio-card input {
  width: 16px;
  min-height: 16px;
  accent-color: var(--accent);
}

.radio-card span {
  grid-column: 2;
  color: var(--muted);
  font-size: 12px;
}

.radio-card:has(input:checked) {
  border-color: color-mix(in srgb, var(--accent) 60%, var(--border));
  background: color-mix(in srgb, var(--accent) 9%, var(--surface-soft));
}

/* Compact single-line variant: "Structured | Use the syntax below" */
.radio-card-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
}

.radio-card-inline .rc-line {
  display: inline-flex;
  align-items: baseline;
  gap: 7px;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 12.5px;
  color: var(--muted);
}

.radio-card-inline .rc-line strong {
  color: var(--text);
  font-size: 13px;
}

.radio-card-inline .rc-sep {
  opacity: 0.45;
}

.subject-row-spacer {
  display: none;
}

.subject-toggle {
  align-self: center;
}

.disabled-section {
  opacity: 0.46;
}

.disabled-section,
.disabled-section * {
  cursor: not-allowed;
}

.subject-preview-display {
  /* Lives inside .subject-builder-grid: starts at the dropdown column. */
  grid-column: 2 / -1;
  padding: 0;
  color: var(--accent, #5d5fef);
  font-size: 10pt;
  font-weight: 600;
  line-height: 1.5;
}

.section-builder {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 18px;
}

.section-title-row {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 14px;
}

.inline-actions {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.section-order-panel {
  min-width: 0;
}

.order-control-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 38px;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
}

.order-move-actions {
  display: grid;
  gap: 8px;
  align-content: center;
}

/* Arrows, apply (✓) and reset (⟳) share the same round icon size. */
.order-move-actions .icon-button {
  width: 38px;
  min-width: 38px;
  height: 38px;
  min-height: 38px;
  padding: 0;
}

/* Read-only (default) layout presets: the order list ignores clicks while
   the surrounding panels are dimmed via .disabled-section. */
.order-list.locked {
  pointer-events: none;
}

.icon-button:disabled,
.text-action:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.icon-button:disabled:hover {
  transform: none;
  border-color: var(--border);
}

.text-action {
  padding: 0;
  color: var(--muted);
  background: transparent;
  border: 0;
  cursor: pointer;
  font-size: 12px;
}

.text-action:hover {
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.toast-host {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 40;
  display: grid;
  gap: 10px;
  pointer-events: none;
}

.toast {
  min-width: 240px;
  max-width: 360px;
  padding: 12px 14px;
  border-radius: 16px;
  color: var(--text);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.toast strong {
  display: block;
  margin-bottom: 3px;
  font-size: 13px;
}

.toast span {
  color: var(--muted);
  font-size: 12px;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(14, 16, 38, 0.32);
  backdrop-filter: blur(8px);
}

.modal-card {
  width: min(560px, 100%);
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 16px;
  padding: 22px;
  border-radius: 24px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 28px 80px rgba(14, 16, 38, 0.22);
}

.modal-icon {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  color: var(--text);
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 22%, var(--surface)), var(--surface-soft));
  border: 1px solid color-mix(in srgb, var(--accent) 28%, var(--border));
}

.modal-content {
  display: grid;
  gap: 12px;
}

.modal-content p {
  color: var(--muted);
  white-space: pre-line;
  line-height: 1.55;
}

.modal-check {
  display: flex;
  grid-template-columns: auto 1fr;
  align-items: flex-start;
  gap: 10px;
  color: var(--text);
}

.modal-check input {
  width: 16px;
  min-height: 16px;
  margin-top: 2px;
  accent-color: var(--accent);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 4px;
}

/* BL-24: cancellation exit survey (compact, two steps) */
.cs-card { display: block; width: min(500px, 100%); }
.cs-card h2 { font-size: 17px; line-height: 1.35; margin: 0 0 6px; }
.cs-hint { color: var(--text-soft, #7a7f96); font-size: 12.5px; margin: 0 0 12px; }
.cs-reasons { display: grid; gap: 8px; }
.cs-reason {
  text-align: left; font-size: 13.5px; padding: 10px 14px; border-radius: 10px;
  border: 1px solid var(--border, #d9dcea); background: var(--surface-soft, rgba(93,95,239,0.05));
  color: inherit; cursor: pointer; transition: border-color .12s, background .12s;
}
.cs-reason:hover { border-color: var(--accent, #5d5fef); background: rgba(93,95,239,0.10); }
.cs-reason:disabled { opacity: .55; cursor: default; }
.cs-reason.selected { border-color: var(--accent, #5d5fef); background: rgba(93,95,239,0.14); font-weight: 600; }
.cs-actions { justify-content: center; margin-top: 14px; }
#csStep2 { text-align: center; }
.cs-logo { width: 84px; height: 84px; object-fit: contain; margin: 6px auto 4px; display: block; }
.cs-ecosystem { font-style: italic; font-size: 11.5px; color: var(--text-soft, #7a7f96); margin: 0 0 12px; }

.check-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.check-row input {
  width: 16px;
  min-height: 16px;
  accent-color: var(--accent);
}

.order-list {
  margin: 0;
  padding: 8px;
  min-height: 220px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--field);
  list-style: none;
}

.order-list li {
  padding: 8px 10px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 13px;
}

.order-list li.active {
  background: color-mix(in srgb, var(--accent) 16%, var(--surface-soft));
}

.small-editor {
  min-height: 110px;
  resize: vertical;
  padding: 12px;
}

.style-toolbar:not(.theme-profile-toolbar) {
  grid-template-columns: 1fr auto auto;
}

.style-table {
  display: grid;
  grid-template-columns: minmax(96px, 140px) minmax(130px, 1fr) minmax(70px, 82px) minmax(72px, 86px) minmax(96px, 120px);
  gap: 10px;
  align-items: center;
}

/* Step 5: settings (left) + live preview panel (right) */
.step5-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(260px, 1fr);
  gap: 18px;
  align-items: start;
}

.style-settings-col {
  display: grid;
  /* Same rhythm as inside .style-table-groups: Table→Other→Images blocks
     sit as close to each other as the element blocks above them. */
  gap: 10px;
  min-width: 0;
}

.style-table-groups {
  display: grid;
  gap: 10px;
}

.style-row {
  display: grid;
  /* Font column is capped (220px) so it stops stretching; Align hosts a
     4-button icon group, Style a 3-button B/I/U group. The shared template
     keeps the head row and all four element rows aligned. */
  /* Fixed 110px element column: the extra rows below indent by exactly the
     same amount, so both control rows start on ONE vertical line. */
  grid-template-columns: 110px minmax(110px, 220px) minmax(52px, 64px) minmax(46px, 56px) minmax(112px, 124px) minmax(88px, 100px);
  gap: 8px;
  align-items: center;
}

.style-row select {
  min-width: 0;
  max-width: 220px;
}

.style-row-head {
  padding: 0 11px;
}

.style-element-block {
  display: grid;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
}

/* ONE compact line per extra row. Fields never SHRINK (shrinking caused
   labels to overlap the controls); tight gaps, no reserved dead space. */
.style-extra-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  align-items: center;
  margin-top: 2px;
  /* Start where the first-row controls start: 110px column + 8px gap.
     Applies to the Header/Section/Body blocks only (see override below). */
  padding-left: 118px;
}

/* Bullets Text (5th child after the head row) and Table (6th): their extra
   rows start at the LEFT edge — Val's spec, 2026-07-13. */
.style-table-groups > .style-element-block:nth-child(n+5) .style-extra-row {
  padding-left: 0;
}

/* Icon toggle groups (Align, Case, B/I/U). Radios for align/case, multi-
   choice for text style; the active buttons carry the accent highlight. */
.style-toggle-group {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
  width: fit-content;
  max-width: 100%;
}

.style-toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  padding: 0 4px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  line-height: 1;
}

.style-toggle-btn svg {
  width: 14px;
  height: 14px;
}

.style-toggle-glyph {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.style-toggle-btn:hover:not(:disabled) {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  color: inherit;
}

.style-toggle-btn.active {
  background: color-mix(in srgb, var(--accent) 22%, transparent);
  color: inherit;
  box-shadow: inset 0 0 0 1px var(--accent);
}

.style-toggle-btn:disabled {
  opacity: 0.55;
  cursor: default;
}

/* Bullet symbol + symbol color live inside the "Bullet points text" block. */
.style-bullet-symbol-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
}

/* Label and control side by side on ONE line (was label-above-control) */
.style-case-field,
.style-slider-field,
.style-inline-field {
  display: inline-flex;
  align-items: center;
  gap: 4px; /* label sits RIGHT next to its control — no dead air */
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  flex: 0 0 auto; /* never shrink: shrinking made labels overlap controls */
}

.style-slider-field input[type="range"] {
  width: 72px;
  margin: 0;
  accent-color: var(--accent);
}

/* Slimmer Case glyph buttons so the trio fits comfortably */
.style-case-group .style-toggle-btn {
  padding: 2px 6px;
  font-size: 10.5px;
}

/* "Banded: [x] rows [x] columns [color]" — one tight cluster */
.banded-field .check-inline {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.style-inline-field input[type="checkbox"],
.banded-field input[type="checkbox"] {
  appearance: auto;
  width: 14px;
  height: 14px;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: none;
  background: none;
  box-shadow: none;
  accent-color: var(--accent);
}


.table-block-title {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px 12px;
  align-items: center;
  min-width: 0;
}

/* Table/Other blocks: 110px title column like every block above, so the
   control run starts on the SAME vertical line as the first rows. */
.table-block-title > div:first-child {
  width: 110px;
  min-width: 110px;
  flex: 0 0 auto;
}

/* Uniform element titles across ALL Step 5 blocks: bold, 11pt. */
.style-element-block .style-row > div:first-child,
.table-block-title > div:first-child {
  font-weight: 600;
  font-size: 11pt;
}

/* Weight + color live directly on the title row: fixed compact sizes so
   the global input width:100% never stretches them into a full-width bar. */
.table-block-title > select.tbl-weight {
  width: 76px;
  min-width: 76px;
  flex: 0 0 auto;
}


/* Header/Footer image blocks: plain × in the top-right corner, shown only
   while an image is loaded (updateAssetPreview toggles it). */
.asset-block {
  position: relative;
}

/* Uniform 11pt block titles (matches the styled-element titles above). */
.asset-block h3,
.asset-upload-grid h3,
.signature-block h3 {
  font-size: 11pt;
  font-weight: 600;
}

.asset-clear-x {
  position: absolute;
  top: 4px;
  right: 6px;
  border: none;
  background: none;
  box-shadow: none;
  padding: 2px 6px;
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
}

.asset-clear-x:hover {
  color: #e5484d;
}

/* Hint hugs the row above and lines up under "Output container"
   (118px indent + Links color field ≈ 112px + 12px gap). */
.other-block {
  gap: 2px;
}

.other-block .field-note-italic {
  font-style: italic;
  margin-top: 0;
  padding-left: 242px;
}

#outputContainerWidth { width: 90px; }
#outputContainerWidth:disabled { opacity: 0.45; cursor: not-allowed; }

.style-preview-col {
  min-width: 0;
}

.style-preview-card {
  position: sticky;
  top: 12px;
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
}

.style-preview-card > h3 {
  margin: 0;
  font-size: 14px;
}

.style-preview-body {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  overflow: hidden;
}

.preview-strip {
  margin-bottom: 10px;
  border-radius: 6px;
  overflow: hidden;
  background: repeating-linear-gradient(45deg, #eef1f6 0 8px, #e2e7ef 8px 16px);
}

.preview-strip.preview-strip-footer {
  margin: 10px 0 0;
}

.preview-strip img {
  display: block;
  width: 100%;
  max-height: 54px;
  object-fit: cover;
}

.preview-container {
  margin: 0 auto;
  min-width: 0;
  transition: width 0.2s ease;
}

.preview-container-caption {
  margin: 8px auto 0;
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  border-top: 1px dashed var(--border);
  padding-top: 4px;
  transition: width 0.2s ease;
}

.preview-bullet-row {
  display: flex;
  gap: 6px;
  align-items: baseline;
}

.preview-table {
  border-collapse: collapse;
  width: 100%;
  margin: 10px 0;
}

.preview-signature {
  margin-top: 10px;
  border-top: 1px dashed var(--border);
  padding-top: 8px;
  font-size: 11px;
}

.preview-signature img {
  max-width: 100%;
  height: auto;
}

@media (max-width: 1100px) {
  .step5-layout {
    grid-template-columns: 1fr;
  }

  .style-preview-card {
    position: static;
  }
}

.table-style-row {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 12px;
  align-items: end;
}

.table-style-preview {
  height: 42px;
  border: 1px solid var(--border);
  border-radius: 12px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(2, 1fr);
  overflow: hidden;
  background: var(--surface-soft);
}

.table-style-preview span {
  border-right: 1px solid color-mix(in srgb, var(--border) 80%, transparent);
  border-bottom: 1px solid color-mix(in srgb, var(--border) 80%, transparent);
}

.table-style-preview.accent-1 span:nth-child(-n+3) {
  background: color-mix(in srgb, var(--table-accent-1, var(--accent)) 18%, #ffffff);
}

.table-style-preview.accent-2 span:nth-child(-n+3) {
  background: var(--table-accent-2, var(--accent));
}

.table-style-preview.medium-grid span {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
}

.field-note {
  align-self: center;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.asset-upload-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.asset-upload-grid > div {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
}

.asset-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}

/* Upload button + format hint on one line; compact block */
.asset-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.asset-hint {
  font-size: 11px;
  font-style: italic;
  color: var(--muted);
  white-space: nowrap;
}

.asset-upload-grid > div {
  gap: 6px;
}

.asset-preview img {
  max-width: 120px;
  max-height: 52px;
  border-radius: 8px;
  object-fit: contain;
  background: var(--surface);
  border: 1px solid var(--border);
}

.asset-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.style-head {
  color: var(--muted);
  font-size: 12px;
}

/* BL-36: the Lab's own tab strip is superseded by the Working Lab subnav. */
#distroTabs { display: none; }

/* BL-37: Theme Profiles steps 2-5 locked until a theme is selected. */
.step-gated {
  opacity: 0.5;
  pointer-events: none;
}

.stepper-gated [data-stepper]:not([data-stepper="1"]) {
  opacity: 0.5;
  pointer-events: none;
}

/* Scroll container — same mechanics the page had inside .settings-pages. */
#themesHost {
  display: grid;
  gap: 12px;
  min-height: 0;
  max-height: calc(100vh - 170px);
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 12px;
}

/* Bundled Montserrat (fallback font). The .ttf files live in
   app/assets/fonts/ — when absent, these rules are silently ignored and the
   CSS fallback chain (Segoe UI) takes over. */
/* Bundled font library (BL-35): Latin display/UI faces + non-Latin scripts.
   All ship with the app from app/assets/fonts. Compact one-liners. */
/* Non-Latin scripts */
/* Fonts not detected on this machine: greyed out in the pickers (still
   selectable — a document may target fonts the recipients do have). */
option.font-missing {
  color: #9aa0b8;
}

/* Uniform color pickers: the round capsule keeps the dropdown height
   (38px) everywhere; the color inside is a clean SQUARE swatch. */
input[type="color"] {
  width: 38px;
  min-width: 38px;
  height: 38px;
  min-height: 38px;
  padding: 8px;
  flex: 0 0 auto;
}

input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

input[type="color"]::-webkit-color-swatch {
  border: none;
  border-radius: 3px;
}

.signature-block {
  display: grid;
  gap: 10px;
}

.signature-editor {
  min-height: 120px;
  padding: 14px;
  overflow: auto;
}

.signature-editor table,
.signature-editor td,
.signature-editor th,
.briefly-output-signature table,
.briefly-output-signature td,
.briefly-output-signature th {
  border-color: transparent !important;
  outline: 0 !important;
}

@media (max-width: 1120px) {
  .app-shell {
    grid-template-columns: 220px 1fr;
  }

  .split-workspace,
  .section-builder,
  .archives-layout,
  .subject-builder-grid,
  .subject-mode-row,
  .asset-upload-grid {
    grid-template-columns: 1fr;
  }

  .subject-builder-grid > .subject-length-field {
    grid-column: 1;
  }

  .output-actions {
    grid-template-columns: minmax(150px, 1fr) repeat(5, 40px);
  }

  .theme-profile-toolbar {
    grid-template-columns: minmax(0, 1fr) auto 38px 38px;
  }

  .theme-profile-toolbar > label:first-child {
    grid-column: 1 / -1;
  }

  .custom-theme-field {
    grid-column: 1;
  }

  .layout-row {
    grid-template-columns: minmax(0, 1fr) auto auto;
  }

  .style-table {
    grid-template-columns: minmax(88px, 110px) minmax(120px, 1fr) minmax(64px, 74px) minmax(64px, 76px) minmax(84px, 100px);
  }
}

@keyframes edge-spark {
  0%,
  72%,
  100% {
    opacity: 0;
    transform: translateX(0);
  }

  76% {
    opacity: 0.34;
  }

  84% {
    opacity: 0;
    transform: translateX(calc(50vw - 160px));
  }
}

@media (prefers-reduced-motion: reduce) {
  .panel::after {
    animation: none;
  }
}

/* License gating: unlicensed = read-only Generate / Archives / Distribution / Settings */
.app-locked #generateView :is(button, input, textarea, select),
.app-locked #archivesView :is(button, input, textarea, select),
.app-locked #distributionView :is(button, input, textarea, select),
.app-locked #settingsView :is(button, input, textarea, select) {
  pointer-events: none;
  opacity: 0.55;
}

.app-locked #distributionView .step-header {
  pointer-events: none;
}

.app-locked #generateView #outputEditor {
  pointer-events: none;
  opacity: 0.75;
}

#lockBanner {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 16px;
  border-radius: 12px;
  background: rgba(20, 22, 46, 0.92);
  border: 1px solid rgba(93, 95, 239, 0.55);
  color: #f0f2fa;
  font-size: 13.5px;
  z-index: 900;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
}

#lockBanner button {
  white-space: nowrap;
}

/* License activation form (v0.3) */
.license-activate-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.license-activate-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  opacity: 0.92;
}

.license-activate-form input {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid rgba(128, 132, 168, 0.35);
  background: rgba(128, 132, 168, 0.08);
  color: inherit;
  font-size: 14px;
  font-family: inherit;
}

.license-activate-form input:focus {
  outline: 2px solid #5d5fef;
  border-color: transparent;
}

/* ===== Distribution Lab (v1) ===== */
.distro-empty {
  margin: 0;
  color: var(--muted);
  font-size: 12.5px;
}

.distro-group-pick {
  display: grid;
  gap: 6px;
}

.distro-actions-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.distro-chip {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
}

.distro-chip:hover {
  color: var(--text);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
}

.distro-chip.active {
  color: var(--text);
  background: color-mix(in srgb, var(--accent) 18%, var(--surface-soft));
  border-color: color-mix(in srgb, var(--accent) 55%, var(--border));
}

.distro-x {
  width: 22px;
  height: 22px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}

.distro-x:hover {
  color: var(--text);
  background: color-mix(in srgb, var(--accent) 12%, var(--surface-soft));
}

.contacts-list {
  /* Plain full-height list: scrolling is handled by the page, not the section */
  max-height: none;
  overflow: visible;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--field);
}

.contact-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.contact-row:last-child {
  border-bottom: none;
}

.contact-identity {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.contact-identity strong {
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.contact-identity em {
  color: var(--muted);
  font-style: normal;
  font-size: 11px;
}

.contact-row-groups {
  margin-top: 0;
  justify-content: flex-end;
  flex: 1;
}

.distro-dl-chip {
  cursor: pointer;
}

.distro-dl-chip.active {
  background: color-mix(in srgb, var(--accent) 18%, var(--surface-soft));
  border-color: color-mix(in srgb, var(--accent) 55%, var(--border));
}

.dl-members {
  display: grid;
  gap: 8px;
  max-height: 260px;
  overflow-y: auto;
}

.dl-members h3 {
  margin: 8px 0 0;
  font-size: 13px;
}

/* Recipient picker popup */
.distro-card {
  width: min(940px, 92vw);
  max-height: 86vh;
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 18px;
  overflow: hidden;
}

.distro-side {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
  border-right: 1px solid var(--border);
}

.distro-side h2 {
  margin: 0;
  font-size: 17px;
}

.distro-filter-block h3,
.distro-onetime h3 {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.distro-filter-block .check-list {
  margin-top: 0;
  max-height: 180px;
  overflow-y: auto;
}

.distro-main {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  min-width: 0;
}

.distro-recipients {
  flex: 1;
  min-height: 180px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--field);
}

.distro-recipient-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
}

.distro-recipient-row:last-child {
  border-bottom: none;
}

.distro-recipient-row.one-time {
  background: color-mix(in srgb, var(--accent) 6%, var(--field));
}

.distro-recipients .distro-empty {
  padding: 12px;
}

.distro-mini {
  padding: 4px 10px;
  font-size: 11.5px;
  white-space: nowrap;
}

.distro-onetime-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr) auto;
  gap: 10px;
}

.distro-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  border-top: 1px solid var(--border);
  padding-top: 14px;
}

.distro-footer-actions {
  display: flex;
  gap: 10px;
}

@media (max-width: 720px) {
  .distro-card {
    grid-template-columns: 1fr;
    max-height: 90vh;
    overflow-y: auto;
  }

  .distro-side {
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding-right: 0;
    padding-bottom: 12px;
  }

  .distro-onetime-form {
    grid-template-columns: 1fr;
  }
}

/* ===== Distribution Lab wizard (v2) ===== */
.step-theme-row {
  align-items: end;
}

.step-theme-action {
  display: flex;
  align-items: flex-end;
  padding-bottom: 2px;
}

/* Context badges in the step 3 header are purely informative — not clickable.
   They swallow their own clicks (JS stopPropagation) and look like plain
   muted labels, clearly separated from the title. */
.step-title-row {
  display: flex;
  align-items: center;
  width: 100%;
  gap: 10px;
}

.lab-context-badges {
  cursor: default;
  margin-left: auto;
  margin-right: 16px;
  display: inline-flex;
  gap: 8px;
}

/* Theme/group of a contact row: plain italic text, clearly not a control */
.contact-meta {
  font-style: italic;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

/* Compact single-line contact rows: name · email · role · meta · actions */
.contact-row {
  padding: 4px 10px !important;
  gap: 10px !important;
  justify-content: flex-start !important;
}

.contact-name {
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}

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

.contact-role {
  font-size: 12px;
  color: var(--text);
  white-space: nowrap;
}

.contact-row .contact-meta {
  margin-left: auto;
}

.contact-actions {
  display: inline-flex;
  gap: 4px;
  flex-shrink: 0;
}

.contact-actions .icon-button {
  width: 26px;
  height: 26px;
}

.contact-add-row {
  display: grid !important;
  grid-template-columns: 1.1fr 1.3fr 0.8fr auto auto !important;
  gap: 12px;
  align-items: end;
}

.contact-search-row {
  display: flex;
  gap: 12px;
  margin-top: 10px;
  align-items: center;
}

.contact-search-row input {
  flex: 1;
  min-width: 0;
}

/* Inline contact edit: everything on a single compact row, no repeated labels
   (the list header above already names the columns) */
.contact-row-editing {
  display: grid !important;
  grid-template-columns: 1.1fr 1.4fr 0.8fr 1fr 1fr auto;
  gap: 8px;
  align-items: center;
}

.contact-row-editing input,
.contact-row-editing select {
  min-width: 0;
}

@media (max-width: 900px) {
  .contact-row-editing {
    grid-template-columns: 1fr 1fr;
  }
}

/* Full-width Input explainer: edge-to-edge under the title/button row,
   justified, tighter leading (2026-07-10 UX request). */
.input-subtitle {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  text-align: justify;
  margin: 2px 0 10px;
}

/* Input processing progress bar (audio/video extraction) — brand-gradient,
   near the upload button so long transcriptions are visibly alive (BL-04). */
.input-progress {
  display: grid;
  gap: 5px;
  margin: 2px 0 10px;
}

.input-progress-caption {
  font-size: 11.5px;
  font-style: italic;
  color: var(--muted);
}

.input-progress-track {
  height: 6px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 12%, var(--surface-soft));
  overflow: hidden;
  position: relative;
}

.input-progress-fill {
  height: 100%;
  border-radius: 999px;
  width: 100%;
  background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 55%, #3ae2b8), var(--accent), color-mix(in srgb, var(--accent) 55%, #3ae2b8));
  background-size: 200% 100%;
  transition: width .4s ease;
}

/* Indeterminate: shimmering sweep while the part count is unknown. */
.input-progress-fill.indeterminate {
  width: 40%;
  position: absolute;
  animation: inputProgressSweep 1.4s ease-in-out infinite;
}

@keyframes inputProgressSweep {
  0%   { left: -40%; }
  100% { left: 100%; }
}

/* Determinate: gradient drifts so a slow chunk still reads as "working". */
.input-progress-fill:not(.indeterminate) {
  animation: inputProgressDrift 2.5s linear infinite;
}

@keyframes inputProgressDrift {
  0%   { background-position: 0% 0; }
  100% { background-position: 200% 0; }
}

/* Feedback & Support (BL-07/08) */
.fb-message {
  min-height: 130px;
}

.fb-stars {
  display: inline-flex;
  gap: 4px;
}

.fb-stars button {
  border: 0;
  background: transparent;
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
  padding: 2px;
  color: color-mix(in srgb, var(--muted) 45%, transparent);
  transition: color .15s ease, transform .1s ease;
}

.fb-stars button:hover { transform: scale(1.15); }
.fb-stars button.active { color: #f5b301; }

/* Compact rhythm for the feedback card: the global card grid gap (18px)
   creates dead air between every row — halved here (2026-07-11). */
#feedbackView .settings-card { gap: 10px; }
#feedbackView .card-title { margin-bottom: 4px; }

/* Consent + attribution: aligned with the Message input column
   (form-grid label 150px + 12px gap = 162px), plain and compact.
   border/background/box-shadow are zeroed because the global input
   styling was drawing an oversized box around the native checkbox. */
.fb-consent {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 0 162px;
  cursor: pointer;
}

.fb-consent input,
.fb-radio input {
  appearance: auto;
  width: 15px;
  height: 15px;
  min-width: 15px;
  padding: 0;
  margin: 0;
  border: none;
  background: transparent;
  box-shadow: none;
  outline: none;
  accent-color: var(--accent);
  cursor: pointer;
}

.fb-attribution {
  display: flex;
  gap: 18px;
  align-items: center;
  margin: -2px 0 0 162px; /* radios line up exactly under the checkbox */
  padding: 0;
  border: 0;
  background: transparent;
}

.fb-radio {
  display: inline-flex;
  gap: 7px;
  align-items: center;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}

.fb-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 0;
}

.fb-note {
  font-size: 11.5px;
  font-style: italic;
  color: #c00000;
  margin: 6px 0 0;
}

.fb-history {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}

.fb-history li a {
  color: var(--accent);
  font-size: 12.5px;
  cursor: pointer;
  text-decoration: none;
}

.fb-history li a:hover { text-decoration: underline; }

.fb-history .fb-history-empty {
  color: var(--muted);
  font-size: 12px;
  font-style: italic;
}

/* AI-generation progress: slim bar exactly as wide as the Generate control,
   shown while the provider is thinking (indeterminate sweep + drift). */
.generate-progress {
  height: 4px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 12%, var(--surface-soft));
  overflow: hidden;
  position: relative;
  margin-top: 6px;
  width: 100%;
}

.generate-progress-fill {
  height: 100%;
  border-radius: 999px;
  width: 40%;
  position: absolute;
  background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 55%, #3ae2b8), var(--accent));
  animation: inputProgressSweep 1.4s ease-in-out infinite;
}

/* Bulk selection (Step 3): checkbox column + Select all / delete-selected ✕ */
.contact-select {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  cursor: pointer;
  accent-color: var(--accent);
}

.contact-bulk {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.contact-bulk .contact-bulk-delete {
  width: 22px;
  height: 22px;
  font-size: 11px;
}

.contact-bulk-count {
  font-size: 11px;
  font-weight: 700;
  color: var(--danger, #d64545);
}

/* Contact list header: sorting lives on the Name column */
.contact-list-header {
  background: var(--surface-soft);
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.contact-list-header .contact-meta {
  font-style: normal;
}

.contact-sort-name {
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  color: var(--accent);
  font-weight: 700;
  font-size: 12px;
  text-align: left;
  max-width: 220px;
  min-width: 120px;
}

/* Empty contact list: plain message, no tight wrapping border */
.contacts-list:has(.distro-empty) {
  border: none;
  border-radius: 0;
  padding: 0;
}

@media (max-width: 760px) {
  .contact-add-row {
    grid-template-columns: 1fr !important;
  }
}

.lab-badge {
  display: inline-block;
  padding: 3px 12px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--accent) 42%, var(--border));
  background: color-mix(in srgb, var(--accent) 14%, var(--surface));
  color: var(--text);
  font-size: 11.5px;
  font-weight: 600;
  cursor: default;
  white-space: nowrap;
}

/* Step 3 visible-but-locked until a group is selected */
.distro-step.step-locked .step-header {
  opacity: 0.55;
}

.distro-step.step-locked .step-bubble {
  filter: grayscale(1);
}

.req::after {
  /* No-break space: the asterisk must never wrap away from its label. */
  content: "\00a0*";
  color: var(--accent);
  font-weight: 700;
}

/* Flow line / stepper */
.distro-stepper {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin: 0 0 16px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
}

/* Theme Profiles reuses the wizard chrome; unlike the Lab its stepper
   follows the intro card instead of the topbar, so give it a top gap. */
#themeStepper {
  margin-top: 16px;
}

.stepper-node {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 8px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 12.5px;
  cursor: pointer;
}

button.stepper-node:hover {
  color: var(--text);
  background: var(--surface-soft);
}

/* Stepper dots use the SAME style and size as the step-header bubbles below
   (single visual language across the whole flow). */
.stepper-dot {
  width: 28px;
  height: 28px;
  flex: none;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--border));
  background: color-mix(in srgb, var(--accent) 14%, var(--surface-soft));
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
}

.stepper-node:not(.done):not(.active) .stepper-dot {
  border-color: var(--border);
  background: var(--surface-soft);
  color: var(--muted);
}

.stepper-node.done {
  color: var(--text);
}

.stepper-node.active {
  color: var(--text);
  font-weight: 600;
}

.stepper-node.active .stepper-dot {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.stepper-ready {
  cursor: default;
  opacity: 0.6;
}

.stepper-ready.done {
  opacity: 1;
  color: var(--accent);
  font-weight: 700;
}

.stepper-ready.done .stepper-dot {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.stepper-line {
  flex: 1;
  min-width: 14px;
  height: 1px;
  background: var(--border);
}

/* Accordion step cards */
.step-header {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 2px 0;
  border: none;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.step-bubble {
  width: 28px;
  height: 28px;
  flex: none;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--border));
  background: color-mix(in srgb, var(--accent) 14%, var(--surface-soft));
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
}

.step-titles {
  display: grid;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.step-title {
  font-size: 15.5px;
  font-weight: 600;
}

.step-sub {
  color: var(--muted);
  font-size: 12.5px;
}

.step-chevron {
  color: var(--muted);
  transition: transform 160ms ease;
}

.step-chevron::before {
  content: "\25BE";
}

.distro-step.step-collapsed .step-chevron {
  transform: rotate(-90deg);
}

.step-body {
  display: grid;
  gap: 14px;
  overflow: hidden;
  max-height: 2000px;
  opacity: 1;
  margin-top: 14px;
  transition: max-height 220ms ease, opacity 160ms ease, margin-top 220ms ease;
}

.distro-step.step-collapsed .step-body {
  max-height: 0;
  opacity: 0;
  margin-top: 0;
  pointer-events: none;
}

.step-note {
  margin: 0;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.45;
}

.step-subhead {
  margin: 4px 0 0;
  font-size: 12.5px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.step-select-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

.step-select-row label {
  flex: 1;
  min-width: 0;
}

/* Step 2: single-column group manager (restyled renderArchiveControls chips) */
#archiveGroupList.group-rows {
  display: grid;
  gap: 8px;
  margin-top: 0;
}

.group-rows .group-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--radius-md);
  background: var(--field);
  font-size: 13px;
}

/* Step 4: two-panel distribution list builder */
/* Both panels end on the SAME bottom line: the left pool (15 fixed rows)
   drives the height; the shortlist stretches to fill the remainder. */
.dl-builder {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: stretch;
}

.dl-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  min-height: 0;
}

.dl-pool {
  min-height: 120px;
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--field);
}

.dl-pool .distro-empty {
  padding: 12px;
}

.dl-pool-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}

.dl-pool-row:last-child {
  border-bottom: none;
}

#dlAllContacts .dl-pool-row {
  cursor: pointer;
}

/* BL-38: compact one-line contact rows, fixed 15-row viewport, toolbar */
.dl-pool-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

/* Search capsule matches the dropdowns' height exactly */
.dl-pool-toolbar .dlp-search {
  flex: 1 1 auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0 10px;
  background: var(--surface);
  height: 36px;
  align-items: center;
}

.dl-pool-toolbar .dlp-search input {
  min-height: 0;
  height: 100%;
  padding: 0;
  border: none;
  box-shadow: none;
}

.dl-pool-toolbar select {
  max-width: 140px;
  height: 36px;
  min-height: 36px;
  flex: 0 0 auto;
}

.dlp-sort {
  width: 36px;
  height: 36px;
  min-height: 36px;
  padding: 0;
  flex: 0 0 auto;
}

/* Always-visible current-provider indicator on the AI connection page. */
.current-provider-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 12.5px;
  color: var(--muted);
  padding: 2px 2px 0;
}

.current-provider-row strong {
  color: var(--accent);
  font-size: 13px;
}

.current-provider-row strong.cp-none {
  color: var(--muted);
  font-weight: 600;
}

.current-provider-row .cp-model {
  font-size: 11px;
  font-style: italic;
}

/* Icon system coherence: every inline icon renders with soft rounded strokes,
   regardless of which generation of the icon set it comes from. */
[data-icon] svg {
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* The A↕Z glyphs need more canvas than the generic 16px icon size to stay legible. */
.dlp-sort [data-icon] svg {
  width: 20px;
  height: 20px;
}

/* Left pool: fixed 10 compact rows (~30px each) — the height driver. */
#dlAllContacts.dl-pool-fixed {
  height: 300px;
  max-height: 300px;
  overflow-y: auto;
  flex: 0 0 auto;
}

/* Right pool: fixed viewport — flex-basis 0 means its CONTENT never inflates
   the panel (and thus the grid row); the row height stays driven by the left
   column, the pool fills the remainder and scrolls internally past that. */
#dlShortlist.dl-pool-fixed {
  flex: 1 1 0;
  height: auto;
  max-height: none;
  min-height: 0;
  overflow-y: auto;
}

.dlp-compact {
  padding: 4px 8px;
}

.dlp-line {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
  flex: 1 1 auto;
  white-space: nowrap;
  overflow: hidden;
  font-size: 12.5px;
}

.dlp-line strong {
  flex: 0 0 auto;
}

/* Meta text (email, theme · group): 8pt in BOTH panels per Val's spec */
.dlp-mail {
  color: var(--muted);
  font-size: 8pt;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dlp-ctx {
  color: var(--muted);
  font-size: 8pt;
  flex: 0 0 auto;
  margin-left: auto;
  padding-left: 8px;
}

.dl-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

/* New DL name: title, then input + Create on ONE line, counter below */
.dl-name-row {
  display: grid;
  gap: 4px;
}

.dl-name-line {
  display: flex;
  align-items: center;
  gap: 10px;
}

.dl-name-line input {
  flex: 1 1 auto;
  min-width: 0;
}

.dl-name-line .command {
  flex: 0 0 auto;
}

#dlAllContacts .dl-pool-row:hover {
  background: color-mix(in srgb, var(--accent) 8%, var(--field));
}

#dlAllContacts .dl-pool-row.picked {
  opacity: 0.5;
  cursor: default;
}

#dlAllContacts .dl-pool-row.picked:hover {
  background: transparent;
}

.dl-pick-mark {
  width: 22px;
  height: 22px;
  flex: none;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 13px;
  line-height: 1;
}

.dl-pool-row.picked .dl-pick-mark {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 50%, var(--border));
}

.contact-identity .dl-meta {
  color: var(--muted);
  font-size: 11px;
}

.dl-rows {
  display: grid;
  gap: 8px;
}

.dl-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--field);
}

.dl-row .contact-identity {
  flex: 1;
}

/* DL card: name + member count + created date on ONE line, member names below. */
.dl-row-main {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 3px;
}

.dl-row-head {
  display: flex;
  align-items: baseline;
  gap: 14px;
  min-width: 0;
}

.dl-row-head strong {
  color: var(--accent);
}

.dl-members {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

.dl-members [data-icon] svg {
  width: 13px;
  height: 13px;
  display: block;
  position: relative;
  top: 1px;
}

.dl-created {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

.dl-row-names {
  font-size: 8pt;
  color: var(--muted);
  line-height: 1.45;
}

.dl-row.editing {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--border));
}

@media (max-width: 720px) {
  .dl-builder {
    grid-template-columns: 1fr;
  }

  .step-select-row {
    flex-wrap: wrap;
  }
}

/* ===== Distribution Lab tabs + database view (v3) ===== */
/* Scroll fix: mirror the .info-view overflow pattern so the Lab page scrolls. */
#distributionView {
  overflow-y: auto;
  padding-right: clamp(10px, 2vw, 28px);
}

/* Real tabs (2026-07-09): a tab strip resting on a baseline. The active tab
   is a filled, top-rounded tab standing ON the line; inactive tabs are plain
   labels. Colors derive from --accent so both themes and custom accents work. */
.distro-tabbar {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  align-items: flex-end;
  margin: 0 0 14px;
  border-bottom: 2px solid var(--border);
}

.distro-tab {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 9px 18px;
  border: 0;
  border-radius: 10px 10px 0 0;
  margin-bottom: -2px;                 /* sit exactly on the baseline */
  border-bottom: 2px solid transparent;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  text-align: left;
  font-size: 14px;
}

.distro-tab:hover {
  color: var(--text);
  background: var(--surface-soft);
  border-bottom-color: color-mix(in srgb, var(--accent) 40%, var(--border));
}

.distro-tab.active {
  color: color-mix(in srgb, #0b2a33 88%, var(--accent));
  background: linear-gradient(105deg, color-mix(in srgb, var(--accent) 55%, #3ae2b8), var(--accent));
  border-bottom-color: transparent;
  font-weight: 700;
}

.distro-tab-page {
  display: grid;
  gap: 16px;
  align-content: start;
}

/* Step 1/2 toolbars: select + inline icon action, Theme-profile toolbar style */
.select-with-action {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
}

.select-with-action .icon-button {
  width: 38px;
  min-width: 38px;
  height: 38px;
  min-height: 38px;
}

.theme-rename-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 10px;
  align-items: center;
}

.group-toolbar {
  display: grid;
  grid-template-columns: minmax(240px, 0.9fr) minmax(0, 1.4fr);
  align-items: end;
  gap: 12px;
}

.group-toolbar-field {
  display: grid;
  gap: 7px;
  min-width: 0;
  font-size: 13px;
}

/* Step 2: clickable group tiles, 3 columns */
.group-tile-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.group-tile {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--field);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  min-width: 0;
}

.group-tile:hover {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  background: color-mix(in srgb, var(--accent) 6%, var(--field));
}

.group-tile.active {
  background: color-mix(in srgb, var(--accent) 18%, var(--surface-soft));
  border-color: color-mix(in srgb, var(--accent) 55%, var(--border));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 35%, var(--border));
  font-weight: 600;
}

.group-tile.renaming {
  cursor: default;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
}

.group-tile-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.group-tile-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: none;
}

.group-tile-actions .icon-button {
  width: 26px;
  min-width: 26px;
  height: 26px;
  min-height: 26px;
  padding: 4px;
}

.group-tile-actions .icon-button.danger {
  font-size: 12px;
}

@media (max-width: 900px) {
  .group-tile-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 600px) {
  .group-tile-grid {
    grid-template-columns: 1fr;
  }

  .group-toolbar {
    grid-template-columns: 1fr;
  }
}

/* Step 3: live theme/group context badges in the header */
.step-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  min-width: 0;
}

.lab-context-badges {
  display: inline-flex;
  gap: 6px;
  flex-wrap: wrap;
}

.lab-context-badges .distro-chip {
  cursor: default;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: inline-block;
}

/* Step 3: name + email + add button on one row */
.contact-add-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr) auto;
  gap: 14px;
  align-items: end;
}

.contact-add-row > .command {
  height: 38px;
  min-height: 38px;
  white-space: nowrap;
}

@media (max-width: 720px) {
  .contact-add-row {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .theme-rename-row {
    grid-template-columns: 1fr;
  }
}

/* DL rows: inline rename */
.dl-row.renaming {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
}


/* ================= DEMO DRIVER PATCH (website demo only) ================= */
html,body{height:100%}
body{overflow:hidden}
.demo-caret{border-right:2px solid var(--accent);animation:demo-caret .7s step-end infinite}
@keyframes demo-caret{50%{border-color:transparent}}
.demo-click{position:absolute;width:44px;height:44px;border-radius:50%;pointer-events:none;z-index:9999;
  border:3px solid var(--accent-2);opacity:0;transform:scale(.35);box-shadow:0 0 0 2px rgba(0,240,200,.35)}
.demo-click.go{animation:demo-click .7s ease-out forwards}
.demo-click.go::after{content:"";position:absolute;inset:6px;border-radius:50%;border:2px solid var(--accent);
  animation:demo-click-inner .7s .08s ease-out forwards;opacity:0}
@keyframes demo-click{0%{opacity:.95;transform:scale(.35)}100%{opacity:0;transform:scale(1.8)}}
@keyframes demo-click-inner{0%{opacity:.9;transform:scale(.5)}100%{opacity:0;transform:scale(1.4)}}
.demo-cursor{position:absolute;z-index:9998;width:26px;height:26px;pointer-events:none;
  transition:left .55s cubic-bezier(.3,.7,.3,1),top .55s cubic-bezier(.3,.7,.3,1)}
.demo-cursor::before{content:"";position:absolute;left:-8px;top:-8px;width:40px;height:40px;border-radius:50%;
  background:radial-gradient(circle,rgba(0,240,200,.28) 0%,rgba(0,240,200,0) 68%);animation:demo-cur-halo 1.8s ease-in-out infinite}
@keyframes demo-cur-halo{0%,100%{transform:scale(1);opacity:.85}50%{transform:scale(1.25);opacity:.5}}
.demo-cursor svg{width:26px;height:26px;filter:drop-shadow(0 2px 5px rgba(14,16,38,.55)) drop-shadow(0 0 6px rgba(0,240,200,.35));position:relative}
