/* =========================================================================
   Breezy Design System
   Source of truth: .interface-design/styleguide.html · .interface-design/system.md
   Loaded standalone (not via Tailwind) so the system is decoupled from utility
   purging. All component classes are prefixed `.ds-`. Tokens use the canonical
   names from the styleguide.
   ========================================================================= */

/* ---------- Tokens · Light ---------- */
:root {
  --paper-page:   #F2EDE2;
  --paper-card:   #F8F4EA;
  --paper-pop:    #FDFBF3;
  --paper-inset:  #EAE3D2;
  --paper-well:   #DFD6C2;

  --ink-1: #1F1D1A;
  --ink-2: #463E33;
  --ink-3: #7C7065;
  --ink-4: #B5AC9F;

  --rule-soft:   rgba(31, 29, 26, 0.05);
  --rule:        rgba(31, 29, 26, 0.09);
  --rule-strong: rgba(31, 29, 26, 0.16);
  --rule-focus:  rgba(123, 90, 56, 0.45);

  --accent:        #7B5A38;
  --accent-on-ink: #C0945A;
  --accent-soft:   #E8DDC9;
  --accent-deep:   #4F3A24;

  --success:      #5F7448;
  --success-soft: #DCE3C9;
  --warning:      #8B6526;
  --warning-soft: #EBDFC0;
  --warning-ink:  #5A3F12;
  --danger:       #A23A24;
  --danger-hover: #862E1B;
  --danger-soft:  #EFC9B6;
  --info:         #3D5168;
  --info-soft:    #D6DCE5;

  --r-sm: 2px;
  --r-md: 4px;
  --r-lg: 6px;
  --r-xl: 10px;

  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  --sans:  "IBM Plex Sans", system-ui, -apple-system, sans-serif;
  --mono:  "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --ease-settle: cubic-bezier(0.2, 0.7, 0.2, 1);
  --dur-quick:   100ms;
  --dur-settle:  240ms;
  --dur-reveal:  180ms;
}

/* ---------- Tokens · Dark (OS-synced unless [data-theme="light"]) ---------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper-page:   #1A1815;
    --paper-card:   #232017;
    --paper-pop:    #2C2820;
    --paper-inset:  #14120F;
    --paper-well:   #0E0C09;

    --ink-1: #EDE6D5;
    --ink-2: #C9BFA8;
    --ink-3: #918674;
    --ink-4: #5A5347;

    --rule-soft:   rgba(237, 230, 213, 0.06);
    --rule:        rgba(237, 230, 213, 0.10);
    --rule-strong: rgba(237, 230, 213, 0.18);
    --rule-focus:  rgba(192, 148, 90, 0.60);

    --accent:        #C0945A;
    --accent-on-ink: #7B5A38;
    --accent-soft:   #3A2D18;
    --accent-deep:   #E8C896;

    --success:      #93AC76;
    --success-soft: #2A3520;
    --warning:      #D49E4F;
    --warning-soft: #3D2C0F;
    --warning-ink:  #F0CB85;
    --danger:       #DC7461;
    --danger-hover: #C25E48;
    --danger-soft:  #3D1F12;
    --info:         #8FA5C0;
    --info-soft:    #1F2734;
  }
}

:root[data-theme="dark"] {
  --paper-page:   #1A1815;
  --paper-card:   #232017;
  --paper-pop:    #2C2820;
  --paper-inset:  #14120F;
  --paper-well:   #0E0C09;

  --ink-1: #EDE6D5;
  --ink-2: #C9BFA8;
  --ink-3: #918674;
  --ink-4: #5A5347;

  --rule-soft:   rgba(237, 230, 213, 0.06);
  --rule:        rgba(237, 230, 213, 0.10);
  --rule-strong: rgba(237, 230, 213, 0.18);
  --rule-focus:  rgba(192, 148, 90, 0.60);

  --accent:        #C0945A;
  --accent-on-ink: #7B5A38;
  --accent-soft:   #3A2D18;
  --accent-deep:   #E8C896;

  --success:      #93AC76;
  --success-soft: #2A3520;
  --warning:      #D49E4F;
  --warning-soft: #3D2C0F;
  --warning-ink:  #F0CB85;
  --danger:       #D26B53;
  --danger-hover: #C45A40;
  --danger-soft:  #3D1F12;
  --info:         #8FA5C0;
  --info-soft:    #1F2734;
}

@media (prefers-reduced-motion: reduce) {
  .ds-page *, .ds-page *::before, .ds-page *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}


/* =========================================================================
   .ds-page · scope all component styles to a wrapper so we don't bleed into
   pre-redesign pages or the shared chrome (top nav, sidebar) until those
   migrate. Place `<div class="ds-page">…</div>` around any view content that
   should adopt the system.
   ========================================================================= */
.ds-page {
  background: var(--paper-page);
  color: var(--ink-1);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
.ds-page :focus-visible {
  outline: 2px solid var(--rule-focus);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

/* The shell owns page rhythm. Components no longer carry margin-bottom; the
   shell decides how blocks breathe. Nest .ds-shell-tight on a wrapper to
   bring the next sibling into a tight (16px) pair instead of the base 32px. */
.ds-shell {
  max-width: 1080px;
  margin: 0 auto;
  padding: 32px 24px 80px;
}
.ds-shell > * + * { margin-top: 32px; }
.ds-shell > .ds-shell-tight + * { margin-top: 16px; }

/* ---------- Type voices ---------- */
.ds-serif { font-family: var(--serif); font-variation-settings: "opsz" 24; font-weight: 500; letter-spacing: -0.005em; }
.ds-serif-italic { font-family: var(--serif); font-style: italic; font-variation-settings: "opsz" 24; }
.ds-italic-ai { font-style: italic; color: var(--ink-2); }
.ds-mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* ---------- Page header · the label motif at full scale ---------- */
.ds-page-header {
  padding: 8px 0 32px;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 32px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 24px;
  align-items: end;
}
.ds-page-header__lead { min-width: 0; }
.ds-page-header__kicker {
  font-size: 11px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 500;
  margin: 0 0 12px 0;
  font-family: var(--sans);
}
.ds-page-header__title {
  font-family: var(--serif);
  font-variation-settings: "opsz" 60;
  font-weight: 500;
  font-size: 36px;
  letter-spacing: -0.018em;
  line-height: 1.1;
  color: var(--ink-1);
  margin: 0;
}
.ds-page-header__lede {
  font-family: var(--serif);
  font-variation-settings: "opsz" 16;
  font-style: italic;
  font-size: 16px;
  color: var(--ink-2);
  margin: 8px 0 0 0;
  line-height: 1.55;
  max-width: 60ch;
}
.ds-page-header__actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

/* ---------- Section header · smaller label motif inline with sections ---------- */
.ds-section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 24px;
  margin: 0 0 16px;
}
.ds-section-header__kicker {
  font-size: 11px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 500;
}
.ds-section-header__lede {
  font-family: var(--serif);
  font-style: italic;
  font-size: 14px;
  color: var(--ink-3);
}

/* ---------- Reassurance card · the calm anchor (page header role) ---------- */
.ds-reassurance {
  background: var(--paper-card);
  border: 1px solid var(--rule);
  border-radius: var(--r-lg);
  padding: 40px 36px 32px;
}
/* Quiet "you are here" line — outlet identity in the operator's writing,
   above the date kicker. Proper-case (never lowercased), serif italic so
   it reads as content rather than system chrome. */
.ds-reassurance__subtitle {
  font-family: var(--serif);
  font-variation-settings: "opsz" 16;
  font-style: italic;
  font-size: 14px;
  color: var(--ink-3);
  margin: 0 0 10px 0;
  line-height: 1.4;
}
.ds-reassurance__kicker {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 500;
  color: var(--ink-3);
  margin: 0 0 14px 0;
}
.ds-reassurance__dot {
  display: inline-block;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}
.ds-reassurance__title {
  font-family: var(--serif);
  font-variation-settings: "opsz" 60;
  font-weight: 500;
  font-size: 36px;
  letter-spacing: -0.018em;
  color: var(--ink-1);
  margin: 0 0 14px 0;
  line-height: 1.05;
}
.ds-reassurance__lede {
  font-family: var(--serif);
  font-variation-settings: "opsz" 18;
  font-style: italic;
  font-size: 17px;
  line-height: 1.55;
  color: var(--ink-2);
  margin: 0;
  max-width: 56ch;
}
.ds-reassurance__lede a {
  color: var(--accent-deep);
  text-decoration: none;
  border-bottom: 1px solid var(--accent);
  padding-bottom: 1px;
}
.ds-reassurance__lede a:hover { color: var(--ink-1); }
.ds-reassurance__actions {
  margin-top: 20px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
/* Hairline rule beneath the lede; draws in left-to-right on first paint
   (the system's pen-on-page gesture, scoped to the page's defining horizontal). */
.ds-reassurance__rule {
  display: block;
  height: 1px;
  background: var(--rule);
  margin: 28px 0 24px;
  transform-origin: left center;
}
html.initial-paint .ds-reassurance__rule {
  transform: scaleX(0);
  animation: ds-reveal var(--dur-settle) var(--ease-settle) 80ms forwards;
}

/* ---------- Instrument strip · vanity stats inside the reassurance card ---------- */
.ds-instruments {
  display: flex;
  align-items: baseline;
  gap: 48px;
  flex-wrap: wrap;
}
.ds-instrument {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.ds-instrument__label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.10em;
  color: var(--ink-3);
  font-weight: 500;
}
.ds-instrument__value-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.ds-instrument__value {
  font-family: var(--mono);
  font-size: 24px;
  font-weight: 500;
  color: var(--ink-1);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.018em;
  line-height: 1.1;
}
.ds-instrument__delta {
  font-size: 11px;
  color: var(--ink-3);
  font-style: italic;
}
.ds-instrument__delta--up    { color: var(--success); }
.ds-instrument__delta--down  { color: var(--danger); }
.ds-instrument__delta--first { color: var(--ink-3); }

/* ---------- Inline sparkline · 56×16, currentColor ---------- */
.ds-spark {
  display: inline-block;
  vertical-align: middle;
  width: 56px;
  height: 16px;
  color: var(--ink-3);
}
.ds-spark__line {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.25;
  stroke-linejoin: round;
  stroke-linecap: round;
}

/* ---------- Credits gauge · the fuel cell, separate from vanity stats ---------- */
.ds-gauge {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 14px 22px;
  background: var(--paper-card);
  border: 1px solid var(--rule);
  border-radius: var(--r-md);
}
.ds-gauge--low {
  background: var(--warning-soft);
  border-color: transparent;
}
.ds-gauge__label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.10em;
  color: var(--ink-3);
  font-weight: 500;
  flex-shrink: 0;
}
.ds-gauge--low .ds-gauge__label { color: var(--warning-ink); }
.ds-gauge__value {
  font-family: var(--mono);
  font-size: 18px;
  color: var(--ink-1);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.ds-gauge--low .ds-gauge__value { color: var(--warning-ink); }
.ds-gauge__state {
  font-size: 13px;
  color: var(--ink-2);
  font-style: italic;
  margin-left: auto;
}
.ds-gauge__state a {
  color: inherit;
  font-style: normal;
  text-decoration: none;
  border-bottom: 1px solid var(--accent);
  padding-bottom: 1px;
}
.ds-gauge--low .ds-gauge__state {
  color: var(--warning-ink);
  font-style: normal;
}
.ds-gauge--low .ds-gauge__state a { border-bottom-color: var(--warning-ink); }

/* ---------- Ledger · the spine ---------- */
.ds-ledger {
  background: var(--paper-card);
  border: 1px solid var(--rule);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.ds-ledger__head {
  display: grid;
  grid-template-columns: [time] 60px [body] 1fr [margin] auto;
  gap: 18px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--rule);
  background: var(--paper-page);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-3);
  font-weight: 500;
}
.ds-ledger__row {
  display: grid;
  grid-template-columns: [time] 60px [body] 1fr [margin] auto;
  gap: 18px;
  padding: 20px 28px;
  border-bottom: 1px solid var(--rule-soft);
  align-items: center;
  transition: background 120ms ease-out;
  position: relative;
  text-decoration: none;
  color: inherit;
}
.ds-ledger__row:last-child { border-bottom: 0; }
.ds-ledger__row::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 2px;
  background: var(--accent);
  transform: scaleY(0);
  transform-origin: top center;
  transition: transform var(--dur-reveal) var(--ease-settle);
}
.ds-ledger__row:hover { background: var(--paper-pop); }
.ds-ledger__row:hover::before { transform: scaleY(1); }
.ds-ledger__row--selected { background: var(--paper-pop); }
.ds-ledger__row--selected::before { transform: scaleY(1); }
.ds-ledger__row--selected .ds-ledger__primary { font-weight: 500; }
.ds-ledger__time {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}
.ds-ledger__body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.ds-ledger__primary {
  font-size: 14px;
  color: var(--ink-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ds-ledger__primary strong { font-weight: 500; }
.ds-ledger__secondary {
  font-size: 13px;
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ds-ledger__secondary--ai { font-style: italic; color: var(--ink-2); }
.ds-ledger__margin { display: flex; align-items: center; gap: 8px; }

/* ---------- Chips · paper-toned, restrained, lowercase ---------- */
.ds-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  padding: 3px 9px;
  border-radius: var(--r-sm);
  text-transform: lowercase;
  font-family: var(--sans);
}
.ds-chip--ai      { background: var(--success-soft); color: var(--success); }
.ds-chip--escal   { background: var(--warning-soft); color: var(--warning-ink); }
.ds-chip--operator{ background: var(--info-soft);    color: var(--info); }
.ds-chip--voice   { background: var(--accent-soft);  color: var(--accent-deep); }
.ds-chip--awaiting{ background: var(--paper-inset);  color: var(--ink-3); }
.ds-chip__dot {
  width: 4px; height: 4px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.85;
}
.ds-chip__duration {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  text-transform: none;
  letter-spacing: 0.02em;
}

/* ---------- Buttons · flat & considered ---------- */
.ds-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.005em;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  transition: background 100ms ease-out, border-color 100ms ease-out, color 100ms ease-out;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  background: transparent;
  color: var(--ink-1);
}
.ds-btn--primary { background: var(--ink-1); color: var(--paper-page); }
.ds-btn--primary:hover { background: var(--ink-2); }
.ds-btn--primary:active { background: var(--ink-2); filter: brightness(0.88); }

.ds-btn--secondary {
  background: var(--paper-card);
  color: var(--ink-1);
  border-color: var(--rule-strong);
}
.ds-btn--secondary:hover { background: var(--paper-pop); border-color: var(--ink-3); }

.ds-btn--ghost {
  background: transparent;
  color: var(--ink-2);
  position: relative;
  padding: 9px 4px;
  border-radius: 0;
}
.ds-btn--ghost::after {
  content: "";
  position: absolute;
  left: 4px; right: 4px; bottom: 6px;
  height: 1px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 160ms ease-out;
}
.ds-btn--ghost:hover { color: var(--ink-1); }
.ds-btn--ghost:hover::after { transform: scaleX(1); }

.ds-btn--danger { background: var(--danger); color: var(--paper-page); }
.ds-btn--danger:hover { background: var(--danger-hover); }

.ds-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.ds-btn--compact { padding: 6px 14px; font-size: 12px; }

/* Busy state · the in-flight pen mark. Driven by submit_controller, which
   adds .ds-btn--busy to the form's submit button on submit and removes it
   on turbo:submit-end. Three small things happen at once: the label shifts
   to the verb in motion (handled by submit_controller via data-busy-label),
   the ground mutes a notch, and a 1px umber pen-stroke draws and fades
   beneath the label, repeating until the request resolves. The pen lives
   inside so the layout below doesn't shift while the request runs. */
.ds-btn--busy {
  position: relative;
  cursor: progress;
  pointer-events: none;
  overflow: hidden;
}
.ds-btn--primary.ds-btn--busy { background: var(--ink-2); }
.ds-btn--secondary.ds-btn--busy { background: var(--paper-pop); }
.ds-btn--danger.ds-btn--busy { background: var(--danger-hover); }
.ds-btn--busy::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 1px;
  background: var(--accent-on-ink);
  transform: scaleX(0);
  transform-origin: left center;
  animation: ds-btn-busy-draw 1400ms var(--ease-settle) infinite;
}
.ds-btn--secondary.ds-btn--busy::after,
.ds-btn--ghost.ds-btn--busy::after { background: var(--accent); }
@keyframes ds-btn-busy-draw {
  0%   { transform: scaleX(0); opacity: 1; }
  60%  { transform: scaleX(1); opacity: 1; }
  85%  { transform: scaleX(1); opacity: 0; }
  100% { transform: scaleX(0); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .ds-btn--busy::after {
    animation: none;
    transform: scaleX(1);
    opacity: 0.6;
  }
}

/* ---------- Forms ---------- */
/* The pen-stroke focus indicator is the system's signature input gesture.
   A 1.5px umber stroke draws beneath the field on :focus-within via the
   Reveal primitive, replacing the SaaS box-shadow focus ring. The wrapper
   carries the pseudo-element; the input itself only changes background
   and border colour on focus. Pure CSS; no JS for the focus animation. */
.ds-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.ds-field__label {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-family: var(--sans);
}
.ds-field--required .ds-field__label::after {
  content: " *";
  color: var(--ink-3);
  font-weight: 400;
}
.ds-field__wrapper {
  position: relative;
  border-radius: var(--r-sm);
}
.ds-field__wrapper::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 1.5px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform var(--dur-settle) var(--ease-settle);
  pointer-events: none;
  border-bottom-left-radius: var(--r-sm);
  border-bottom-right-radius: var(--r-sm);
}
.ds-field__wrapper:focus-within::after { transform: scaleX(1); }
.ds-field__input,
.ds-field__textarea {
  width: 100%;
  display: block;
  background: var(--paper-inset);
  border: 1px solid var(--rule);
  border-radius: var(--r-sm);
  padding: 9px 12px;
  color: var(--ink-1);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  transition: border-color var(--dur-quick) ease-out, background var(--dur-quick) ease-out;
}
.ds-field__input::placeholder,
.ds-field__textarea::placeholder { color: var(--ink-4); }
.ds-field__input:hover,
.ds-field__textarea:hover { border-color: var(--rule-strong); }
.ds-field__input:focus,
.ds-field__textarea:focus {
  outline: none;
  border-color: var(--rule-strong);
  background: var(--paper-pop);
}
.ds-field__input:disabled,
.ds-field__textarea:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  background: var(--paper-card);
}
.ds-field__input[readonly],
.ds-field__textarea[readonly] {
  color: var(--ink-3);
  background: var(--paper-card);
}
.ds-field__textarea {
  min-height: 96px;
  resize: vertical;
}
.ds-field__help {
  font-family: var(--sans);
  font-style: italic;
  font-size: 12px;
  color: var(--ink-3);
  line-height: 1.5;
}
.ds-field__error {
  font-family: var(--sans);
  font-size: 12px;
  color: var(--danger);
  line-height: 1.5;
}
.ds-field--error .ds-field__wrapper::after {
  background: var(--danger);
  transform: scaleX(1);
}
.ds-field--error .ds-field__input,
.ds-field--error .ds-field__textarea {
  border-color: var(--danger);
}
.ds-field--error .ds-field__help { color: var(--danger); font-style: normal; }

/* ---------- Fieldset · groups related fields under a shared legend ---------- */
.ds-fieldset {
  border: 0;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}
.ds-fieldset__legend {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-family: var(--sans);
  padding: 0;
  margin: 0 0 4px 0;
}
.ds-fieldset__helper {
  font-family: var(--sans);
  font-style: italic;
  font-size: 12px;
  color: var(--ink-3);
  margin: -4px 0 4px 0;
  line-height: 1.5;
}
.ds-fieldset__items {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.ds-fieldset--row .ds-fieldset__items {
  flex-direction: row;
  flex-wrap: wrap;
  gap: 18px;
}

/* ---------- Custom select · trigger button + popover panel ----------
   Native <select> can't carry the system's input vocabulary (background,
   border, padding, the pen-stroke focus). The trigger looks and behaves
   like an input; the panel lifts via lightness (paper-pop on paper-page),
   no shadow, the same flat-depth strategy as the outlet switcher popover. */
.ds-select { position: relative; }
.ds-select__trigger {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--paper-inset);
  border: 1px solid var(--rule);
  border-radius: var(--r-sm);
  padding: 9px 12px;
  color: var(--ink-1);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  text-align: left;
  cursor: pointer;
  transition: border-color var(--dur-quick) ease-out, background var(--dur-quick) ease-out;
}
.ds-select__trigger:hover { border-color: var(--rule-strong); }
.ds-select__trigger:focus {
  outline: none;
  border-color: var(--rule-strong);
  background: var(--paper-pop);
}
.ds-select__trigger[aria-expanded="true"] {
  border-color: var(--rule-strong);
  background: var(--paper-pop);
}
.ds-select__trigger:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  background: var(--paper-card);
}
.ds-select__label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ds-select__label--placeholder { color: var(--ink-4); }
.ds-select__chevron {
  width: 12px;
  height: 12px;
  color: var(--ink-3);
  flex-shrink: 0;
  transition: transform var(--dur-quick) ease-out, color var(--dur-quick) ease-out;
}
.ds-select__trigger[aria-expanded="true"] .ds-select__chevron {
  transform: rotate(180deg);
  color: var(--ink-2);
}
.ds-select__panel {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 30;
  background: var(--paper-pop);
  border: 1px solid var(--rule);
  border-radius: var(--r-md);
  padding: 4px;
  display: none;
  max-height: 280px;
  overflow-y: auto;
}
.ds-select__panel.is-open { display: block; }
.ds-select__option {
  display: block;
  padding: 8px 10px;
  font-size: 13px;
  color: var(--ink-2);
  border-radius: var(--r-sm);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: transparent;
  border: 0;
  width: 100%;
  text-align: left;
  font-family: var(--sans);
}
.ds-select__option:hover,
.ds-select__option--active {
  background: var(--paper-card);
  color: var(--ink-1);
}
.ds-select__option[aria-selected="true"] {
  background: var(--paper-card);
  color: var(--ink-1);
  font-weight: 500;
}
.ds-field--error .ds-select__trigger { border-color: var(--danger); }

/* ---------- Checkbox & radio ----------
   Native input is visually hidden but focusable; the visible visual is a
   sibling span. Sibling-selector CSS draws the tick / dot. Native click
   and keyboard handling stay intact, so the controls are accessible and
   forms submit normally. */
.ds-checkbox,
.ds-radio {
  display: inline-flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  position: relative;
  font-family: var(--sans);
  font-size: 14px;
  color: var(--ink-2);
  line-height: 1.4;
}
.ds-checkbox__input,
.ds-radio__input {
  position: absolute;
  opacity: 0;
  width: 16px;
  height: 16px;
  margin: 0;
  cursor: pointer;
}
.ds-checkbox__visual,
.ds-radio__visual {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  background: var(--paper-inset);
  border: 1px solid var(--rule-strong);
  position: relative;
  margin-top: 2px;
  transition: background var(--dur-quick) ease-out, border-color var(--dur-quick) ease-out;
}
.ds-checkbox__visual { border-radius: var(--r-sm); }
.ds-radio__visual { border-radius: 50%; }

.ds-checkbox:hover .ds-checkbox__visual,
.ds-radio:hover .ds-radio__visual { border-color: var(--ink-3); }

.ds-checkbox__input:checked + .ds-checkbox__visual {
  background: var(--ink-1);
  border-color: var(--ink-1);
}
.ds-checkbox__input:checked + .ds-checkbox__visual::after {
  content: "";
  position: absolute;
  left: 4px;
  top: 1px;
  width: 5px;
  height: 9px;
  border: solid var(--paper-page);
  border-width: 0 1.5px 1.5px 0;
  transform: rotate(45deg);
}
.ds-radio__input:checked + .ds-radio__visual {
  border-color: var(--ink-1);
}
.ds-radio__input:checked + .ds-radio__visual::after {
  content: "";
  position: absolute;
  left: 3px;
  top: 3px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ink-1);
}
.ds-checkbox__input:focus-visible + .ds-checkbox__visual,
.ds-radio__input:focus-visible + .ds-radio__visual {
  outline: 2px solid var(--rule-focus);
  outline-offset: 2px;
}
.ds-checkbox__input:disabled ~ .ds-checkbox__visual,
.ds-radio__input:disabled ~ .ds-radio__visual { opacity: 0.55; }
.ds-checkbox__input:disabled ~ .ds-checkbox__label,
.ds-radio__input:disabled ~ .ds-radio__label,
.ds-checkbox--disabled,
.ds-radio--disabled { cursor: not-allowed; opacity: 0.7; }

.ds-checkbox__label,
.ds-radio__label { min-width: 0; }
.ds-checkbox__label-text,
.ds-radio__label-text { display: block; }
.ds-checkbox__help,
.ds-radio__help {
  display: block;
  font-style: italic;
  font-size: 12px;
  color: var(--ink-3);
  margin-top: 2px;
}

.ds-field--error .ds-checkbox__visual,
.ds-field--error .ds-radio__visual { border-color: var(--danger); }

/* ---------- Empty state ---------- */
.ds-empty {
  background: var(--paper-card);
  border: 1px solid var(--rule);
  border-radius: var(--r-lg);
  padding: 80px 32px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.ds-empty__title {
  font-family: var(--serif);
  font-variation-settings: "opsz" 32;
  font-weight: 500;
  font-size: 24px;
  letter-spacing: -0.01em;
  color: var(--ink-1);
  margin: 0;
  line-height: 1.2;
}
.ds-empty__title em { font-style: italic; color: var(--ink-2); }
.ds-empty__body {
  font-family: var(--serif);
  font-variation-settings: "opsz" 16;
  font-style: italic;
  font-size: 15px;
  color: var(--ink-2);
  margin: 0;
  max-width: 44ch;
  line-height: 1.5;
}
.ds-empty__action { margin-top: 18px; }

/* ---------- Footnote · peripheral signals at page bottom ---------- */
.ds-footnote {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid var(--rule-soft);
  font-size: 13px;
  color: var(--ink-3);
}
.ds-footnote__cell { display: flex; align-items: baseline; gap: 8px; }
.ds-footnote__label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-3);
  font-weight: 500;
}
.ds-footnote a {
  color: var(--accent-deep);
  text-decoration: none;
  border-bottom: 1px solid var(--accent);
  padding-bottom: 1px;
}
.ds-footnote a:hover { color: var(--ink-1); }
@media (max-width: 720px) {
  .ds-footnote { grid-template-columns: 1fr; }
}

/* ---------- Motion · Settle, Reveal ----------
   Entry animations are gated to html.initial-paint, which is set once on
   DOMContentLoaded and removed before any Turbo render. Pages animate
   in on first app load (and on hard refresh) but never on Turbo navs,
   so cached-preview + fresh-swap doesn't fire animations twice. */
html.initial-paint .ds-settle {
  animation: ds-settle var(--dur-settle) var(--ease-settle) backwards;
}
@keyframes ds-settle {
  from { transform: translateY(4px); opacity: 0; }
  to   { transform: translateY(0);   opacity: 1; }
}

/* Reveal keyframe is consumed by component-scoped rules
   (e.g. .ds-reassurance__rule); no standalone class. */
@keyframes ds-reveal {
  from { transform: scaleX(0); }
  to   { transform: scaleX(1); }
}

/* =========================================================================
   Chrome · the page shell
   Lives outside .ds-page because the chrome wraps both DS pages and the
   pre-redesign content pages until each migrates. Sets the paper canvas,
   draws the sidebar, owns the mobile drawer + outlet switcher popover.
   ========================================================================= */

/* SR-only utility used inside the brand wordmark so the literal "Breezy"
   string is in the DOM for find-in-page, SEO, RSS, archival tools. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Brand wordmark · integrated ---------- */
/* Custom hand-drawn 'B' (SVG) + "reezy" in Newsreader italic + 1px umber
   pen-stroke beneath. The wordmark is the brand presence; no separate logo. */
.brand {
  font-family: var(--serif);
  font-style: italic;
  font-variation-settings: "opsz" 96, "wght" 500;
  font-size: 28px;
  letter-spacing: -0.02em;
  color: var(--ink-1);
  display: inline-flex;
  align-items: baseline;
  position: relative;
  padding-bottom: 0.55em;
  line-height: 1;
}
.brand__b {
  display: inline-block;
  width: 0.82em;
  height: 1em;
  position: relative;
  top: 0.32em;
  margin-right: 0.04em;
  flex-shrink: 0;
}
.brand__b svg {
  width: 100%;
  height: 100%;
  display: block;
  fill: currentColor;
  overflow: visible;
}
.brand__rest { display: inline-block; }
.brand::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 1px;
  background: var(--accent);
  transform-origin: left center;
}
/* Reveal class is added by brand-wordmark Stimulus controller on the
   first connect of an instance and removed on animationend, so the
   stroke draws once per app load — not on every Turbo navigation. */
.brand--reveal::after {
  animation: ds-reveal var(--dur-settle) var(--ease-settle) 80ms backwards;
}
.brand--small { font-size: 19px; }

/* ---------- App shell · sidebar + main ---------- */
/* The chrome wraps every outlet page. Body class .ds-app paints the canvas;
   the layout is a CSS grid with a fixed-width sidebar on the left and a
   flexible main column on the right. */
.ds-app {
  background: var(--paper-page);
  color: var(--ink-1);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
.ds-app__shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}
.ds-app__main {
  min-width: 0;
  padding: 24px 32px 80px;
}

/* Mobile toggle · only visible below the sidebar breakpoint. */
.ds-mobile-toggle {
  display: none;
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 60;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  background: var(--paper-card);
  border: 1px solid var(--rule);
  border-radius: var(--r-md);
  color: var(--ink-2);
  cursor: pointer;
}
.ds-mobile-toggle:hover { color: var(--ink-1); }
.ds-mobile-toggle svg { width: 18px; height: 18px; }

/* ---------- Sidebar ----------
   Cream-on-cream: same canvas as the page, separated from content by a
   single rule on the right edge. Internal hierarchy is carried by space
   alone — no horizontal dividers between brand, outlet, nav, footer.
   The wordmark's umber pen-stroke is part of the brand, not a divider. */
.ds-sidebar {
  background: var(--paper-page);
  border-right: 1px solid var(--rule-strong);
  padding: 20px 12px 16px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.ds-sidebar__brand {
  padding: 0 4px;
  margin-bottom: 4px;
}
.ds-sidebar__brand-link {
  text-decoration: none;
  color: inherit;
}

/* Outlet identity · sits beneath the brand. With multiple outlets it's a
   click target that opens the switcher popover (full padding lives on the
   trigger so the entire row reacts to hover); with one, it's a quiet row. */
.ds-sidebar__outlet {
  position: relative;
  margin-bottom: 12px;
}
.ds-sidebar__outlet-trigger,
.ds-sidebar__outlet-static {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  font: 500 13px var(--sans);
  color: var(--ink-2);
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
}
.ds-sidebar__outlet-trigger {
  background: transparent;
  border: 0;
  cursor: pointer;
  transition: background var(--dur-quick) ease-out, color var(--dur-quick) ease-out;
}
.ds-sidebar__outlet-trigger:hover {
  color: var(--ink-1);
  background: var(--paper-card);
}
.ds-sidebar__outlet-trigger[aria-expanded="true"] {
  color: var(--ink-1);
  background: var(--paper-card);
}
.ds-sidebar__outlet-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ds-sidebar__outlet-chevron {
  width: 11px;
  height: 11px;
  color: var(--ink-3);
  flex-shrink: 0;
  transition: transform var(--dur-quick) ease-out;
}
.ds-sidebar__outlet-trigger[aria-expanded="true"] .ds-sidebar__outlet-chevron {
  transform: rotate(180deg);
  color: var(--ink-2);
}

/* Nav groups · today / configure / account */
.ds-sidebar__nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.ds-sidebar__group-items {
  list-style: none;
  margin: 0;
  padding: 0;
}
.ds-sidebar__group-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-weight: 500;
  color: var(--ink-3);
  padding: 0 10px 6px;
  margin: 0;
}

.ds-sidebar__item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px 8px 14px;
  border-radius: var(--r-sm);
  color: var(--ink-2);
  font-size: 13px;
  text-decoration: none;
  position: relative;
  transition: background var(--dur-quick) ease-out, color var(--dur-quick) ease-out;
}
.ds-sidebar__item:hover {
  color: var(--ink-1);
  background: var(--paper-card);
}
.ds-sidebar__item.active,
.ds-sidebar__item[aria-current="page"] {
  background: var(--paper-card);
  color: var(--ink-1);
  font-weight: 500;
}
/* The bar exists on every item but is collapsed (scaleY 0) by default;
   activating an item transitions it to scaleY 1. Using a transition rather
   than a keyframe means it fires only when the active state actually
   changes — Turbo's element-move on each render touches no property values
   and stays silent. The .initial-paint variant still uses a keyframe so
   the very first paint gets the satisfying draw-in. */
.ds-sidebar__item::before {
  content: "";
  position: absolute;
  left: 0; top: 8px; bottom: 8px;
  width: 2px;
  background: var(--accent);
  transform: scaleY(0);
  transform-origin: center;
  transition: transform var(--dur-reveal) var(--ease-settle);
}
.ds-sidebar__item.active::before,
.ds-sidebar__item[aria-current="page"]::before {
  transform: scaleY(1);
}
html.initial-paint .ds-sidebar__item.active::before,
html.initial-paint .ds-sidebar__item[aria-current="page"]::before {
  animation: ds-reveal-y var(--dur-reveal) var(--ease-settle) backwards;
}
.ds-sidebar__count {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}
.ds-sidebar__item[aria-current="page"] .ds-sidebar__count,
.ds-sidebar__item.active .ds-sidebar__count {
  color: var(--ink-2);
}

/* Footer · theme toggle + auxiliary actions. Separated from the nav by
   margin-top: auto and the breathing room of the empty space — no rule.
   The system spec reserves rules for moments of commitment; the footer
   sits below the nav as quiet background. */
.ds-sidebar__footer {
  margin-top: auto;
  padding-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.ds-sidebar__footer-link {
  display: block;
  width: 100%;
  padding: 8px 10px;
  font: 400 13px var(--sans);
  color: var(--ink-3);
  text-align: left;
  text-decoration: none;
  background: transparent;
  border: 0;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: color var(--dur-quick) ease-out, background var(--dur-quick) ease-out;
}
.ds-sidebar__footer-link:hover {
  color: var(--ink-1);
  background: var(--paper-card);
}
.ds-sidebar__footer form { margin: 0; }

/* Theme toggle · auto / light / dark pill in the sidebar footer.
   Visually distinct from the footer-link rows: it conveys state, the
   links convey actions. Mono / pill / dot is a chip's vocabulary. */
.ds-theme-toggle {
  align-self: flex-start;
  margin: 0 4px 8px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px 4px 8px;
  background: var(--paper-card);
  color: var(--ink-2);
  border: 1px solid var(--rule);
  border-radius: 9999px;
  font: 500 11px var(--mono);
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: background var(--dur-quick) ease-out, border-color var(--dur-quick) ease-out, color var(--dur-quick) ease-out;
}
.ds-theme-toggle:hover {
  background: var(--paper-pop);
  border-color: var(--rule-strong);
  color: var(--ink-1);
}
.ds-theme-toggle__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  display: block;
  flex-shrink: 0;
}

/* ---------- Popover · outlet switcher ----------
   Lifts via lightness (paper-pop on paper-page) and a quiet 1px rule —
   no shadow, in line with the system's flat depth strategy. */
.ds-popover {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 4px;
  z-index: 30;
  background: var(--paper-pop);
  border: 1px solid var(--rule);
  border-radius: var(--r-md);
  padding: 4px;
  display: none;
}
.ds-popover.is-open { display: block; }
.ds-popover__item {
  display: block;
  padding: 8px 10px;
  font-size: 13px;
  color: var(--ink-2);
  text-decoration: none;
  border-radius: var(--r-sm);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ds-popover__item:hover {
  background: var(--paper-card);
  color: var(--ink-1);
}
.ds-popover__divider {
  display: block;
  height: 1px;
  background: var(--rule-soft);
  margin: 4px 8px;
}
.ds-popover__company {
  display: block;
  padding: 8px 10px;
  font-family: var(--serif);
  font-style: italic;
  font-size: 13px;
  color: var(--ink-3);
  text-decoration: none;
}
.ds-popover__company:hover { color: var(--ink-1); }

/* ---------- Flash ----------
   Paper-toned semantic ground, lowercase tone (§17), one quiet × dismiss.
   Sits inside the page's content well, not the chrome — but defined here
   alongside the chrome since FlashComponent is part of the layout shell. */
.ds-flash {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--r-md);
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 16px;
}
.ds-flash--success { background: var(--success-soft); color: var(--success); }
.ds-flash--info    { background: var(--info-soft);    color: var(--info); }
.ds-flash--danger  { background: var(--danger-soft);  color: var(--danger); }
.ds-flash--warning { background: var(--warning-soft); color: var(--warning-ink); }
.ds-flash__body { flex: 1; min-width: 0; }
.ds-flash__dismiss {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  margin: -2px -4px -2px 0;
  background: transparent;
  border: 0;
  border-radius: var(--r-sm);
  color: currentColor;
  opacity: 0.55;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  transition: opacity var(--dur-quick) ease-out;
}
.ds-flash__dismiss:hover { opacity: 1; }

/* ---------- Mobile drawer ---------- */
@media (max-width: 767px) {
  .ds-mobile-toggle { display: inline-flex; }
  .ds-app__shell { grid-template-columns: 1fr; }
  .ds-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 260px;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform var(--dur-settle) var(--ease-settle);
    box-shadow: 0 0 24px rgba(31, 29, 26, 0);
  }
  .ds-sidebar.is-open {
    transform: translateX(0);
    box-shadow: 0 0 24px rgba(31, 29, 26, 0.12);
  }
  /* Right-align the wordmark so it doesn't sit under the fixed toggle
     button (which lives in the top-left of the viewport on mobile). */
  .ds-sidebar__brand { text-align: right; }
  .ds-app__main { padding: 56px 18px 60px; }
}

/* Vertical reveal (used by the active nav bar). */
@keyframes ds-reveal-y {
  from { transform: scaleY(0); }
  to   { transform: scaleY(1); }
}
