/* Kleto Pulse content planner: plan editor and site writing settings
   (planner-editor.js, specs/pulse-content-planner.md section 5).
   Anchors: the Linear issue side panel (label/value property rows, quiet
   autosave), the Pulse project sheet (projects.css) for chrome, and the
   Vercel settings save bar. Pulse grammar: hairlines, 4px corners on panels
   and fields, Space Grotesk titles in title case, Space Mono only for data
   (hosts, addresses, numbers, times). Two flourishes, both rare: the live
   "Writing" step pulses in the iridescent chrome, and the settings save bar
   gains an iridescent hairline while it holds unsaved changes. */

.pe-dialog, .pe-confirm, .pe-toast {
  --ui-ground: var(--bg); --ui-rail: var(--card); --ui-raised: var(--panel);
  --ui-hover: var(--accent-tint); --ui-pressed: var(--border);
  --ui-ink: var(--text); --ui-ink-muted: var(--dim); --ui-ink-faint: var(--faint);
  --ui-ink-inverse: var(--bg); --ui-line: var(--border); --ui-line-strong: var(--line-strong);
  --ui-accent: var(--accent); --ui-accent-ink: var(--bg); --ui-ring-color: var(--ring);
  --ui-radius: var(--radius); --ui-radius-card: var(--radius);
  --pe-pad: 22px;
  font-family: var(--body);
  color: var(--text);
}
/* platform.css reserves a stable scrollbar gutter; while the sheet is open
   the page cannot scroll, so give the gutter back to the drawer. */
html.pe-locked { overflow: hidden; scrollbar-gutter: auto; }
.pe-ico { width: 16px; height: 16px; flex: none; }
.pe-grow { flex: 1 1 auto; }
.pe-mono { font-family: var(--mono); font-variant-numeric: tabular-nums slashed-zero; }
.pe-dialog [hidden] { display: none !important; }

/* ── the drawer (desktop) ─────────────────────────────────────────────── */
/* Anchored by left from 100vw, so a page scrollbar gutter leaves no gap. */
.pe-dialog {
  --pe-w: min(520px, 100vw);
  position: fixed; inset: 0 auto 0 calc(100vw - var(--pe-w)); margin: 0;
  width: var(--pe-w); max-width: 100vw; height: 100dvh; max-height: 100dvh;
  padding: 0; gap: 0; display: block; overflow: hidden;
  background: var(--card); border: 0; border-left: 1px solid var(--line-strong); border-radius: 0;
  box-shadow: -30px 0 80px rgba(0, 0, 0, .55);
  transform: translateY(var(--pe-drag, 0px));
}
.pe-dialog[data-view="settings"] { --pe-w: min(600px, 100vw); }
/* display: block above beats the browser rule that hides a closed dialog,
   so restore it; otherwise the closed sheet stays painted and eats taps. */
dialog.pe-dialog:not([open]), dialog.pe-confirm:not([open]) { display: none; }
dialog.pe-dialog[open] { animation: pe-in-right 240ms var(--ease-settle) both; }
dialog.pe-dialog.is-closing { animation: pe-out-right 170ms var(--ease-out) both; }
.pe-dialog::backdrop { background: rgba(0, 0, 0, .52); }
@keyframes pe-in-right { from { transform: translateX(28px); opacity: 0; } }
@keyframes pe-out-right { to { transform: translateX(28px); opacity: 0; } }

.pe-shell { position: relative; display: flex; flex-direction: column; height: 100%; min-height: 0; }
.pe-handle { display: none; }

/* ── header ───────────────────────────────────────────────────────────── */
.pe-head { flex: none; padding: 14px var(--pe-pad) 12px; border-bottom: 1px solid var(--border); outline: none; }
.pe-head-top { display: flex; align-items: center; gap: 10px; min-height: 36px; margin-right: -8px; }
.pe-kicker { display: flex; align-items: baseline; gap: 8px; min-width: 0; margin: 0; font: 500 13px/1.4 var(--body); color: var(--dim); }
.pe-kicker-text { white-space: nowrap; }
.pe-dot { align-self: center; width: 8px; height: 8px; flex: none; border-radius: 50%; background: var(--pe-c, var(--faint)); box-shadow: 0 0 0 2px rgba(0, 0, 0, .6); }
.pe-host { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 400 11px/1.4 var(--mono); color: var(--faint); text-transform: lowercase; }
.pe-close { --ui-ib: 36px; color: var(--dim); }
.pe-close:hover { color: var(--text); }
.pe-close .pe-ico { width: 18px; height: 18px; }
.pe-heading-loading { margin: 14px 0 4px; font: 600 21px/1.3 var(--body); color: var(--dim); }

.pe-title {
  display: block; width: 100%; margin: 8px 0 2px; padding: 4px 6px; margin-inline: -6px; width: calc(100% + 12px);
  border: 1px solid transparent; border-radius: var(--radius); background: transparent; resize: none; overflow: hidden;
  color: var(--text); font: 600 21px/1.32 var(--body); letter-spacing: -.012em;
  transition: border-color 150ms var(--ease-out), background 150ms var(--ease-out);
}
.pe-title::placeholder { color: var(--faint); }
.pe-title:hover { background: var(--accent-tint); }
.pe-title:focus { outline: none; border-color: var(--line-strong); background: var(--bg); }
.pe-title:focus-visible { box-shadow: 0 0 0 1px var(--ring); }
.pe-title[aria-invalid="true"] { border-color: var(--down); }
.pe-settings-title { margin: 8px 0 2px; font: 600 21px/1.32 var(--body); letter-spacing: -.012em; overflow-wrap: anywhere; }

/* Save state: quiet, beside the close button. */
.pe-save { display: inline-flex; align-items: center; gap: 5px; font: 400 11px/1 var(--mono); color: var(--faint); white-space: nowrap; transition: opacity 400ms var(--ease-out); }
.pe-save .pe-ico { width: 13px; height: 13px; }
.pe-save[data-save="idle"] { opacity: 0; }
.pe-save[data-save="saving"]::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--dim); animation: pe-breathe 900ms ease-in-out infinite alternate; }
.pe-save[data-save="saved"] { color: var(--faint); }
.pe-save[data-save="error"] { color: var(--down); }
@keyframes pe-breathe { from { opacity: .25; } to { opacity: 1; } }

/* ── scroll body ──────────────────────────────────────────────────────── */
.pe-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 18px var(--pe-pad) 32px; scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
.pe-scroll[aria-busy="true"] { display: grid; gap: 14px; align-content: start; }
.pe-scroll[aria-busy="true"] .block { height: 92px; }
.pe-failed { display: grid; gap: 14px; align-content: start; font-size: 14px; line-height: 1.6; }
.pe-failed div { display: flex; gap: 8px; }

/* ── pipeline stepper ─────────────────────────────────────────────────── */
.pe-pipe { margin: 0 0 22px; padding: 16px 16px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); }
.pe-steps { --pe-dot: 14px; list-style: none; margin: 0 0 4px; padding: 0 0 28px; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); }
.pe-step { position: relative; display: flex; justify-content: center; }
/* the rail: each step draws the segment from the previous centre */
.pe-step + .pe-step::before { content: ''; position: absolute; top: calc(var(--pe-dot) / 2); right: 50%; width: 100%; height: 1px; background: var(--line-strong); }
.pe-step.is-past::before, .pe-step.is-now::before { background: var(--text); }
.pe-step-dot { position: relative; z-index: 1; display: grid; place-items: center; width: var(--pe-dot); height: var(--pe-dot); border-radius: 50%; border: 1px solid var(--mark); background: var(--bg); color: var(--bg); }
.pe-step-dot .pe-ico { width: 10px; height: 10px; stroke-width: 2.4; }
.pe-step.is-past .pe-step-dot { background: var(--text); border-color: var(--text); }
.pe-step.is-now .pe-step-dot { --pe-ring: var(--text); border: 2px solid var(--pe-ring); box-shadow: 0 0 0 4px var(--bg), 0 0 0 5px color-mix(in srgb, var(--pe-ring) 35%, transparent); }
.pe-step.is-now .pe-step-dot::after { content: ''; width: 4px; height: 4px; border-radius: 50%; background: var(--pe-ring); }
.pe-step-name { position: absolute; top: calc(var(--pe-dot) + 7px); left: 50%; transform: translateX(-50%); white-space: nowrap; font: 400 11px/1.3 var(--body); color: var(--faint); }
.pe-step:first-child .pe-step-name { left: 0; transform: none; }
.pe-step:first-child { justify-content: flex-start; }
.pe-step:first-child + .pe-step::before { right: 50%; width: calc(100% + 50% - var(--pe-dot) / 2); }
.pe-step:last-child { justify-content: flex-end; }
.pe-step:last-child::before { right: 0; width: calc(100% + 50% - var(--pe-dot) / 2); }
.pe-step:last-child .pe-step-name { left: auto; right: 0; transform: none; }
.pe-step.is-past .pe-step-name { color: var(--dim); }
.pe-step.is-now .pe-step-name { color: var(--text); font-weight: 600; }

.pe-pipe.is-fail .pe-step.is-now .pe-step-dot { --pe-ring: var(--down); }
.pe-pipe.is-fail .pe-step.is-now .pe-step-name { color: var(--down); }
.pe-pipe.is-hold .pe-step.is-now .pe-step-dot { --pe-ring: var(--dim); border-style: dashed; }
.pe-pipe.is-hold .pe-step.is-now .pe-step-dot::after { display: none; }
.pe-pipe.is-done .pe-step.is-now .pe-step-dot { --pe-ring: var(--up); background: var(--up); border-color: var(--up); box-shadow: 0 0 0 4px var(--bg), 0 0 0 5px rgba(63, 232, 77, .3); }
.pe-pipe.is-done .pe-step.is-now .pe-step-dot::after { display: none; }
.pe-pipe.is-done .pe-step-dot .pe-ico { color: #000; }
.pe-pipe.is-archived .pe-steps { opacity: .4; }
/* Flourish one: the live writing step breathes in the chrome. */
.pe-pipe.is-live .pe-step.is-now .pe-step-dot { border-color: transparent; background: linear-gradient(var(--bg), var(--bg)) padding-box, var(--iri) border-box; box-shadow: 0 0 0 4px var(--bg); }
.pe-pipe.is-live .pe-step.is-now .pe-step-dot::after { width: 6px; height: 6px; background: var(--iri); animation: pe-breathe 1100ms ease-in-out infinite alternate; }

.pe-pipe-line { margin: 2px 0 0; font-size: 13.5px; line-height: 1.55; color: var(--dim); }
.pe-pipe.is-fail .pe-pipe-line { color: var(--text); }
.pe-fails { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 6px; }
.pe-fails li { display: flex; gap: 9px; align-items: flex-start; padding: 9px 11px; border: 1px solid rgba(255, 69, 58, .32); border-radius: var(--radius); background: rgba(255, 69, 58, .07); font-size: 13px; line-height: 1.5; color: var(--text); }
.pe-fails .pe-ico { width: 15px; height: 15px; margin-top: 2px; color: var(--down); }
.pe-fails li > span { min-width: 0; overflow-wrap: anywhere; }
.pe-pipe-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.pe-pipe-actions .ui-btn { gap: 6px; font-size: 12.5px; }
.pe-pipe-actions .pe-ico { width: 14px; height: 14px; }

/* ── property rows ────────────────────────────────────────────────────── */
.pe-props { display: grid; }
.pe-props-text { margin-top: 6px; padding-top: 8px; border-top: 1px solid var(--border); }
.pe-row { display: grid; grid-template-columns: 108px minmax(0, 1fr); gap: 4px 14px; align-items: start; padding: 7px 0; }
.pe-row.is-wide { grid-template-columns: minmax(0, 1fr); gap: 7px; padding: 12px 0 8px; }
.pe-label { padding-top: 10px; font-size: 13px; line-height: 1.4; color: var(--dim); }
.pe-row.is-wide .pe-label { padding-top: 0; }
.pe-row.is-invalid .pe-label { color: var(--down); }
.pe-ctl { min-width: 0; }
.pe-help { margin: 6px 0 0; font-size: 12px; line-height: 1.5; color: var(--faint); overflow-wrap: anywhere; }
.pe-err { margin: 6px 0 0; font-size: 12px; line-height: 1.45; color: var(--down) !important; }
.pe-title-err { margin: 2px 0 4px; }

.pe-dialog .ui-input { width: 100%; min-width: 0; background: var(--bg); border-color: var(--line-strong); color: var(--text); font-size: 14px; }
.pe-dialog .ui-input:hover:not(:focus):not([readonly]) { border-color: var(--mark); }
.pe-dialog .ui-input:focus-visible, .pe-dialog .ui-input:focus { outline: 2px solid var(--ring); outline-offset: 1px; border-color: var(--line-strong); }
.pe-dialog .ui-input[readonly] { color: var(--dim); background: var(--card); border-style: dashed; }
.pe-dialog .ui-input[aria-invalid="true"] { border-color: var(--down); }
.pe-dialog .ui-input::placeholder { color: var(--faint); opacity: 1; }
.pe-dialog input[type="date"].ui-input { color-scheme: dark; max-width: 200px; }
.pe-dialog .ui-unit { max-width: 200px; }
.pe-dialog .ui-unit > span { font: 400 11px var(--mono); color: var(--faint); }
.pe-dialog input[type="number"] { -moz-appearance: textfield; }
.pe-dialog input[type="number"]::-webkit-inner-spin-button, .pe-dialog input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.pe-dialog .ui-select > select { padding-right: 34px; }
.pe-dialog .ui-select > svg { width: 14px; height: 14px; }

.pe-seg { display: flex; width: 100%; --ui-seg-h: 40px; border-color: var(--line-strong); }
.pe-seg > button { flex: 1 1 0; min-width: 0; padding: 0 8px; font-size: 13px; }
.pe-seg > button[aria-pressed="true"] { font-weight: 600; }

.pe-intents { display: flex; flex-wrap: wrap; gap: 6px; }
.pe-intent { height: 32px; padding: 0 11px; font-size: 13px; border-color: var(--line-strong); background: transparent; }
.pe-intent[aria-checked="true"] { border-color: var(--text); color: var(--text); background: var(--accent-tint); font-weight: 600; }
.pe-intent:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }

.pe-brief { min-height: 104px; resize: none; overflow: hidden; line-height: 1.55; }

/* Pillar combobox (local; ui/MANIFEST.md lists it) */
.pe-combo { position: relative; }
.pe-combo-list { position: absolute; z-index: 5; top: calc(100% + 4px); left: 0; right: 0; max-height: 232px; overflow-y: auto; margin: 0; padding: 4px; list-style: none; background: var(--panel); border: 1px solid var(--line-strong); border-radius: var(--radius); box-shadow: 0 18px 50px rgba(0, 0, 0, .7); }
.pe-combo-list [role="option"] { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 38px; padding: 0 10px; border-radius: 3px; font-size: 13.5px; cursor: pointer; }
.pe-combo-list [role="option"]:hover, .pe-combo-list [aria-selected="true"] { background: var(--accent-tint); }
.pe-combo-list [aria-selected="true"] { box-shadow: inset 2px 0 0 var(--text); }
.pe-combo-count { font: 400 10.5px var(--mono); color: var(--faint); white-space: nowrap; }

/* Chip input (keywords, avoid lists) */
.pe-chipbox { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-height: 40px; padding: 5px 6px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--bg); cursor: text; }
.pe-chipbox:hover { border-color: var(--mark); }
.pe-chipbox:focus-within { outline: 2px solid var(--ring); outline-offset: 1px; }
.pe-chipbox:has([aria-invalid="true"]) { border-color: var(--down); }
.pe-chip { display: inline-flex; align-items: center; gap: 2px; max-width: 100%; height: 28px; padding: 0 2px 0 10px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--panel); font-size: 13px; color: var(--text); }
.pe-chip > :first-child { overflow: hidden; text-overflow: ellipsis; }
.pe-chip button { display: grid; place-items: center; width: 24px; height: 24px; padding: 0; border: 0; border-radius: 3px; background: transparent; color: var(--faint); cursor: pointer; }
.pe-chip button:hover { color: var(--text); background: var(--accent-tint); }
.pe-chip button:focus-visible { outline: 2px solid var(--ring); outline-offset: 0; }
.pe-chip .pe-ico { width: 12px; height: 12px; }
.pe-chip-input { flex: 1 1 120px; min-width: 100px; height: 28px; padding: 0 4px; border: 0; outline: none; background: transparent; color: var(--text); font: 14px var(--body); }
.pe-chip-input::placeholder { color: var(--faint); }

/* Address and its live URL */
.pe-url { display: block; font: 400 12px/1.6 var(--mono); color: var(--faint); overflow-wrap: anywhere; }
.pe-url strong { font-weight: 400; color: var(--text); }
.pe-url-note:not(:empty) { display: block; margin-top: 2px; }

.pe-more { margin-top: 8px; border-top: 1px solid var(--border); }
.pe-more summary { display: flex; align-items: center; gap: 8px; min-height: 44px; font-size: 13px; color: var(--dim); cursor: pointer; list-style: none; width: fit-content; }
.pe-more summary::-webkit-details-marker { display: none; }
.pe-more summary::before { content: ''; width: 6px; height: 6px; border-right: 1px solid currentColor; border-bottom: 1px solid currentColor; transform: rotate(-45deg); transition: transform 160ms var(--ease-out); }
.pe-more[open] summary::before { transform: rotate(45deg); }
.pe-more summary:hover { color: var(--text); }
.pe-more summary:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.pe-more .pe-row { padding-top: 0; }
.pe-meta { margin: 18px 0 0; font: 400 11px/1.6 var(--mono); color: var(--faint); }

/* ── footer ───────────────────────────────────────────────────────────── */
.pe-foot { flex: none; display: flex; align-items: center; gap: 6px; padding: 12px var(--pe-pad) calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--border); background: rgba(10, 10, 10, .96); }
.pe-foot .ui-btn { height: 40px; gap: 7px; font-size: 13.5px; }
.pe-foot .ui-btn .pe-ico { width: 15px; height: 15px; }
.pe-primary { padding: 0 20px; font-weight: 600; }
.pe-del { color: var(--dim); }
.pe-del:hover { color: var(--down) !important; background: rgba(255, 69, 58, .08) !important; }
.ui-btn.pe-danger { border-radius: 999px; background: var(--down); border-color: var(--down); color: #000; font-weight: 600; }
.ui-btn.pe-danger:hover { background: #ff6a61; }

/* ── toast ────────────────────────────────────────────────────────────── */
.pe-toast {
  display: flex; align-items: center; gap: 6px; max-width: min(440px, calc(100vw - 32px));
  margin: 0; padding: 6px 6px 6px 14px; min-height: 44px;
  border: 1px solid var(--line-strong); border-radius: 6px; background: #161616; color: var(--text);
  font-size: 13.5px; box-shadow: 0 16px 48px rgba(0, 0, 0, .7);
}
.pe-toast[hidden] { display: none; }
.pe-toast[popover] { position: fixed; inset: auto auto calc(24px + env(safe-area-inset-bottom)) 50%; transform: translateX(-50%); overflow: visible; }
.pe-toast.is-docked { position: absolute; z-index: 6; left: 50%; bottom: calc(76px + env(safe-area-inset-bottom)); transform: translateX(-50%); width: max-content; }
.pe-toast.is-in { animation: pe-toast-in 220ms var(--ease-settle) both; }
.pe-toast-msg { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pe-toast .ui-btn { height: 32px; color: var(--text); font-weight: 600; flex: none; }
@keyframes pe-toast-in { from { opacity: 0; translate: 0 6px; } }

/* ── confirm ──────────────────────────────────────────────────────────── */
.pe-confirm { width: min(420px, calc(100vw - 32px)); padding: 0; gap: 0; background: var(--card); border: 1px solid var(--line-strong); border-radius: 8px; box-shadow: 0 30px 90px rgba(0, 0, 0, .8); }
.pe-confirm::backdrop { background: rgba(0, 0, 0, .6); }
.pe-confirm-inner { padding: 24px; }
.pe-confirm-mark { display: grid; place-items: center; width: 36px; height: 36px; margin-bottom: 16px; border: 1px solid var(--line-strong); border-radius: var(--radius); color: var(--dim); }
.pe-confirm-mark.is-danger { color: var(--down); border-color: rgba(255, 69, 58, .4); background: rgba(255, 69, 58, .07); }
.pe-confirm-mark .pe-ico { width: 18px; height: 18px; }
.pe-confirm h2 { margin: 0 0 8px; font: 600 17px/1.35 var(--body); }
.pe-confirm p { margin: 0; font-size: 13.5px; line-height: 1.6; color: var(--dim); overflow-wrap: anywhere; }
.pe-confirm-status:not(:empty) { margin-top: 10px !important; color: var(--down) !important; }
.pe-confirm-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 22px; }
.pe-confirm-actions .ui-btn { height: 40px; font-size: 13.5px; }

/* ════════════════════════ settings ════════════════════════ */
.pe-state { border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); overflow: hidden; }
.pe-state-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 13px 14px; }
.pe-state-row + .pe-state-row { border-top: 1px solid var(--border); }
.pe-state-row > div { display: grid; gap: 3px; min-width: 0; }
.pe-state-row.is-disabled .pe-state-name { color: var(--dim); }
.pe-state-name { font-size: 14px; font-weight: 500; }
.pe-state-sub { font-size: 12px; line-height: 1.45; color: var(--faint); }
.pe-state-line { display: flex; align-items: baseline; gap: 9px; margin: 0; padding: 11px 14px; border-top: 1px solid var(--border); background: var(--card); font-size: 13px; line-height: 1.5; color: var(--text); }
.pe-state-dot { width: 7px; height: 7px; flex: none; border-radius: 50%; background: var(--faint); transform: translateY(-1px); }
.pe-state.is-on .pe-state-dot { background: var(--up); box-shadow: 0 0 0 3px rgba(63, 232, 77, .15); }
.pe-state.is-paused .pe-state-dot { background: var(--warn); }
.pe-dialog .ui-switch { flex: none; border-radius: 999px; --ui-radius-mark: 50%; }
.pe-dialog .ui-switch::after { border-radius: 50%; }

.pe-sec { margin-top: 30px; }
.pe-sec-head { margin-bottom: 12px; }
.pe-sec-head h3 { margin: 0; font: 600 15px/1.35 var(--body); letter-spacing: -.005em; }
.pe-sec-head p { margin: 3px 0 0; font-size: 12.5px; line-height: 1.5; color: var(--faint); }

.pe-presets { display: grid; gap: 6px; }
.pe-preset {
  display: grid; grid-template-columns: 36px minmax(0, 1fr) 16px; align-items: center; gap: 12px;
  width: 100%; min-height: 60px; padding: 10px 14px 10px 10px; text-align: left; font: inherit; color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); cursor: pointer;
  transition: border-color 150ms var(--ease-out), background 150ms var(--ease-out);
}
.pe-preset::after { content: ''; width: 14px; height: 14px; border-radius: 50%; border: 1px solid var(--mark); box-sizing: border-box; }
.pe-preset:hover { border-color: var(--mark); }
.pe-preset:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.pe-preset.is-on { border-color: var(--text); background: var(--accent-tint); }
.pe-preset.is-on::after { border: 4px solid var(--text); }
.pe-preset-ico { display: grid; place-items: center; width: 36px; height: 36px; border: 1px solid var(--line-strong); border-radius: var(--radius); color: var(--dim); }
.pe-preset.is-on .pe-preset-ico { color: var(--text); border-color: var(--mark); }
.pe-preset-ico .pe-ico { width: 18px; height: 18px; }
.pe-preset-text { display: grid; gap: 2px; min-width: 0; }
.pe-preset-name { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; }
.pe-preset-line { font-size: 12.5px; line-height: 1.45; color: var(--dim); }
.pe-current { height: 18px; padding: 0 6px; font: 400 10px/1 var(--mono); color: var(--dim); border-color: var(--line-strong); }

.pe-diff { margin-top: 10px; padding: 12px 14px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--panel); animation: ui-reveal 200ms var(--ease-out) both; }
.pe-diff p { margin: 0; font-size: 13px; line-height: 1.5; color: var(--dim); }
.pe-diff strong { color: var(--text); font-weight: 600; }
.pe-diff ul { list-style: none; margin: 8px 0 0; padding: 0; }
.pe-diff li { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 6px 0; border-top: 1px solid var(--border); font-size: 12.5px; color: var(--dim); }
.pe-diff-v { display: inline-flex; align-items: center; flex-wrap: wrap; justify-content: flex-end; gap: 6px; font: 400 11.5px/1.4 var(--mono); text-align: right; }
.pe-diff-v s { color: var(--faint); }
.pe-diff-v b { font-weight: 400; color: var(--text); }
.pe-diff-arrow { width: 11px; height: 11px; color: var(--faint); transform: rotate(45deg); }
.pe-diff-kept { margin-top: 8px !important; font-size: 12px !important; color: var(--faint) !important; }

.pe-set { padding: 14px 0 12px; border-top: 1px solid var(--border); }
.pe-set-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 26px; }
.pe-set-label { font-size: 13.5px; font-weight: 500; }
.pe-set.is-invalid .pe-set-label { color: var(--down); }
.pe-set-src { display: inline-flex; align-items: center; gap: 4px; flex: none; }
.pe-set-help { margin: 2px 0 0; font-size: 12px; line-height: 1.5; color: var(--faint); }
.pe-set-ctl { margin-top: 9px; }
.pe-src { display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border: 1px solid var(--border); border-radius: 3px; font: 400 10px/1 var(--mono); color: var(--faint); cursor: default; }
.pe-src.is-custom { color: var(--text); border-color: var(--mark); background: var(--accent-tint); }
.pe-reset { display: inline-flex; align-items: center; gap: 4px; height: 28px; padding: 0 7px; border: 0; border-radius: 3px; background: transparent; color: var(--dim); font: 12px var(--body); cursor: pointer; }
.pe-reset .pe-ico { width: 12px; height: 12px; }
.pe-reset:hover { color: var(--text); background: var(--accent-tint); }
.pe-reset:focus-visible { outline: 2px solid var(--ring); outline-offset: 1px; }

.pe-num { display: grid; gap: 5px; }
.pe-num-label { font-size: 12px; color: var(--faint); }
.pe-num-box { display: inline-flex; align-items: center; width: fit-content; height: 40px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--bg); }
.pe-num-box:focus-within { outline: 2px solid var(--ring); outline-offset: 1px; }
.pe-num-box .ui-iconbtn { --ui-ib: 38px; color: var(--dim); border-radius: 3px; }
.pe-num-box .ui-iconbtn:hover { color: var(--text); background: var(--accent-tint); }
.pe-num-box .ui-iconbtn .pe-ico { width: 15px; height: 15px; }
.pe-num-box input { width: 52px; height: 100%; padding: 0; border: 0; border-inline: 1px solid var(--border); background: transparent; color: var(--text); text-align: center; font-size: 15px; outline: none; }
.pe-pair { display: flex; flex-wrap: wrap; gap: 12px 20px; }
.pe-cadence { margin: 0 0 4px; padding: 11px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); font-size: 14px; line-height: 1.5; }
.pe-hours { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.pe-hours .ui-select { width: 108px; }
.pe-hours-to { font-size: 13px; color: var(--dim); }
.pe-hours-tz { font: 400 11px var(--mono); color: var(--faint); }
.pe-toggles { display: flex; flex-wrap: wrap; gap: 6px; }
.pe-toggles .ui-chip { height: 34px; gap: 6px; padding: 0 12px; font-size: 13px; border-color: var(--line-strong); background: transparent; }
.pe-toggles .ui-chip[aria-pressed="true"] { border-color: var(--text); color: var(--text); background: var(--accent-tint); }
.pe-toggles .pe-ico { width: 13px; height: 13px; }

/* Length: one track, three thumbs (shortest, aim for, longest). */
.pe-len { --thumb: 20px; }
.pe-len-track { position: relative; height: 32px; }
.pe-len-track::before { content: ''; position: absolute; left: calc(var(--thumb) / 2); right: calc(var(--thumb) / 2); top: 50%; height: 2px; margin-top: -1px; background: var(--line-strong); border-radius: 2px; }
.pe-len-band { position: absolute; top: 50%; height: 4px; margin-top: -2px; border-radius: 2px; background: color-mix(in srgb, var(--text) 45%, transparent);
  left: calc(var(--thumb) / 2 + (100% - var(--thumb)) * var(--a)); right: calc(var(--thumb) / 2 + (100% - var(--thumb)) * (1 - var(--b))); }
.pe-len-mark { display: none; }
.pe-len-thumb { position: absolute; left: 0; top: 0; width: 100%; height: 32px; min-height: 0; margin: 0; padding: 0; border: 0; outline: 0; background: transparent; pointer-events: none; -webkit-appearance: none; appearance: none; }
.pe-len-thumb::-webkit-slider-runnable-track { background: transparent; height: 32px; border: 0; }
.pe-len-thumb::-moz-range-track { background: transparent; }
.pe-len-thumb::-webkit-slider-thumb { -webkit-appearance: none; pointer-events: auto; box-sizing: border-box; width: var(--thumb); height: var(--thumb); margin-top: calc((32px - var(--thumb)) / 2); border-radius: 50%; background: var(--card); border: 2px solid var(--text); cursor: grab; }
.pe-len-thumb::-moz-range-thumb { pointer-events: auto; width: 16px; height: 16px; border-radius: 50%; background: var(--card); border: 2px solid var(--text); cursor: grab; }
.pe-len-thumb.is-target::-webkit-slider-thumb { background: var(--text); border-color: var(--bg); box-shadow: 0 0 0 1px var(--text); }
.pe-len-thumb.is-target::-moz-range-thumb { background: var(--text); }
.pe-len-thumb:focus { outline: none; }
.pe-len-thumb:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 3px var(--ring); }
.pe-len-thumb:focus-visible::-moz-range-thumb { box-shadow: 0 0 0 3px var(--ring); }
.pe-len-scale { display: flex; justify-content: space-between; margin-top: 2px; font: 400 10px var(--mono); color: var(--faint); }
.pe-len-nums { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 12px; }
.pe-len-num { display: grid; gap: 5px; min-width: 0; }
.pe-len-num > span:first-child { font-size: 12px; color: var(--faint); }
.pe-len-num .ui-unit { max-width: none; }
.pe-len-num .ui-input { padding-left: 10px; padding-right: 46px; font-size: 14px; }

/* Save bar: sticky by construction (the footer). Flourish two: an
   iridescent hairline while it holds unsaved changes. */
.pe-savebar { position: relative; }
.pe-savebar.is-dirty::before { content: ''; position: absolute; left: 0; right: 0; top: -1px; height: 1px; background: var(--iri); }
.pe-count { display: inline-flex; align-items: center; gap: 8px; min-width: 0; margin: 0; font-size: 13px; line-height: 1.3; color: var(--faint); }
.pe-savebar .pe-primary { min-width: 0; }
.pe-count .pe-ico { width: 14px; height: 14px; }
.pe-savebar.is-dirty .pe-count { color: var(--text); font-weight: 500; }
.pe-count-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text); }

/* ── phone: the bottom sheet ──────────────────────────────────────────── */
@media (max-width: 767px) {
  .pe-dialog, .pe-dialog[data-view="settings"] {
    --pe-pad: 16px;
    --pe-w: 100vw; inset: auto 0 0 0; width: 100vw; height: 92dvh; max-height: 92dvh;
    border-left: 0; border-top: 1px solid var(--line-strong); border-radius: 14px 14px 0 0;
    box-shadow: 0 -20px 60px rgba(0, 0, 0, .6);
    transition: transform 220ms var(--ease-settle);
  }
  .pe-dialog.is-dragging { transition: none; }
  dialog.pe-dialog[open] { animation: pe-in-up 280ms var(--ease-settle) both; }
  dialog.pe-dialog.is-closing { animation: pe-out-down 170ms var(--ease-out) both; }
  .pe-handle { display: block !important; flex: none; width: 36px; height: 4px; margin: 8px auto 0; border-radius: 2px; background: #4a4a48; touch-action: none; }
  .pe-head { padding-top: 6px; touch-action: none; }
  .pe-head .pe-title, .pe-head .pe-close { touch-action: manipulation; }
  .pe-close { --ui-ib: 44px; }
  .pe-title, .pe-settings-title { font-size: 19px; }
  .pe-row, .pe-row.is-wide { grid-template-columns: minmax(0, 1fr); gap: 6px; padding: 9px 0; }
  .pe-label { padding-top: 0; }
  .pe-seg { --ui-seg-h: 44px; }
  .pe-intent { height: 38px; }
  .pe-dialog .ui-input, .pe-chip-input { font-size: 16px; }
  .pe-dialog input[type="date"].ui-input, .pe-dialog .ui-unit { max-width: none; }
  .pe-foot .ui-btn { height: 44px; }
  .pe-foot:not(.pe-savebar) .pe-primary { min-width: 112px; }
  .pe-toast.is-docked { bottom: calc(80px + env(safe-area-inset-bottom)); }
  .pe-confirm { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: 14px 14px 0 0; border-bottom: 0; }
  .pe-confirm-inner { padding: 22px 16px calc(18px + env(safe-area-inset-bottom)); }
  .pe-confirm-actions .ui-btn { flex: 1 1 auto; height: 44px; }
  .pe-len-nums { gap: 8px; }
  .pe-len-num .ui-input { padding-right: 40px; }
  .pe-len-num .ui-unit > span { font-size: 10px; }
  .pe-num-box { height: 44px; }
  .pe-num-box .ui-iconbtn { --ui-ib: 42px; }
}
@media (max-width: 420px) {
  .pe-steps .pe-step:not(.is-now) .pe-step-name { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .pe-step.is-now:nth-child(2) .pe-step-name { left: 0; transform: none; }
  .pe-step.is-now:nth-child(5) .pe-step-name { left: auto; right: 0; transform: none; }
  .pe-foot { gap: 2px; }
  .pe-foot .ui-btn.line, .pe-foot .ui-btn.text { padding: 0 10px; }
  .pe-preset { grid-template-columns: 32px minmax(0, 1fr) 16px; gap: 10px; padding-right: 12px; }
  .pe-preset-ico { width: 32px; height: 32px; }
  .pe-len-num .ui-unit > span { display: none; }
  .pe-len-num .ui-input { padding-right: 8px; }
}
/* ── read only, notes, approval, steppers with units ─────────────────── */
.pe-static { display: flex; align-items: center; gap: 8px; min-height: 40px; margin: 0; font-size: 14px; color: var(--text); }
.pe-readonly, .pe-note { margin: 0 0 14px; padding: 10px 12px; border: 1px dashed var(--line-strong); border-radius: var(--radius); font-size: 12.5px; line-height: 1.5; color: var(--dim); }
.pe-note { margin: 12px 0 0; border-style: solid; border-color: var(--border); background: var(--bg); }
.pe-num-row { display: flex; align-items: center; gap: 10px; }
.pe-num-unit { font: 400 11px var(--mono); color: var(--faint); }
.pe-set.is-toggle .pe-set-top { gap: 10px; }
.pe-set.is-toggle .pe-set-label { flex: 1 1 auto; }
.pe-src.is-pending { color: var(--dim); border-style: dashed; border-color: var(--mark); }
.pe-rhythm { max-width: 340px; margin-bottom: 12px; }
.pe-opt-help { margin-top: 8px; }
.pe-sec .pe-seg { max-width: 420px; }

@keyframes pe-in-up { from { transform: translateY(100%); } }
@keyframes pe-out-down { to { transform: translateY(100%); } }

@media (prefers-reduced-motion: reduce) {
  .pe-dialog, .pe-dialog *, .pe-toast, .pe-confirm { animation: none !important; transition: none !important; }
}
