/* ============================================================================
   PRISM — shared components

   The pieces every area uses, written once against the --p-* tokens: a button,
   a segmented control, a field, a chip, an inset-grouped list, a section header,
   a table, an empty state, a tile, and the surfaces that float (toast, alert,
   sheet, menu, palette). Promoted from Cadence, whose own copies keep winning
   inside `.cad` (their selectors are heavier) until it swaps over.

   In @layer house, so a view's own CSS can no longer restyle
   them by accident. Nothing here is rooted at #view — the chrome uses them too.
   ========================================================================== */

@layer house {

/* ---- button ----
   One default per view, and it is the accent. A near-black filled button does
   not exist on the Mac. Labels are Title Case with no glyph prefix. */
.p-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap;
  min-height: var(--p-hit); padding: 0 var(--p-sp-3); border: 0; border-radius: var(--p-r);
  background: var(--p-fill); color: var(--p-label); font: var(--p-control); letter-spacing: 0;
  text-decoration: none; cursor: pointer;
  transition: background var(--p-dur-fast) var(--p-ease), filter var(--p-dur-fast) var(--p-ease);
}
.p-btn:hover { background: var(--p-fill-strong); text-decoration: none; }
.p-btn:active { filter: brightness(.92); }
.p-btn.primary { background: var(--p-tint); color: #fff; }
.p-btn.primary:hover { background: var(--p-tint); filter: brightness(1.08); }
.p-btn.plain { background: none; color: var(--p-link); padding: 0 var(--p-sp-2); }
.p-btn.plain:hover { background: var(--p-fill); }
.p-btn.danger { color: var(--p-red-text); }
.p-btn:disabled, .p-btn[aria-disabled="true"] { opacity: .4; cursor: default; filter: none; }
.p-btn svg { width: 16px; height: 16px; }

/* a toolbar glyph: 28 square on a Mac, 44 on a phone */
.p-icon {
  display: inline-grid; place-items: center; flex: none; padding: 0; border: 0; border-radius: var(--p-r);
  min-width: var(--p-hit); min-height: var(--p-hit); background: none; color: var(--p-label-2);
  cursor: pointer; line-height: 0; text-decoration: none;
  transition: background var(--p-dur-fast) var(--p-ease), color var(--p-dur-fast) var(--p-ease);
}
.p-icon:hover { background: var(--p-fill); color: var(--p-label); text-decoration: none; }
.p-icon svg { width: 18px; height: 18px; }

/* ---- segmented control: one widget for switching views ---- */
.p-seg { display: inline-flex; padding: 2px; gap: 2px; border-radius: var(--p-r); background: var(--p-fill); max-width: 100%; }
.p-seg > button, .p-seg > a {
  min-height: calc(var(--p-hit) - 4px); padding: 0 var(--p-sp-3); border: 0; border-radius: var(--p-r-sm);
  background: none; color: var(--p-label-2); font: var(--p-control); letter-spacing: 0; cursor: pointer;
  text-decoration: none; display: inline-flex; align-items: center; white-space: nowrap;
  transition: background var(--p-dur) var(--p-ease), color var(--p-dur) var(--p-ease);
}
.p-seg > button:hover, .p-seg > a:hover { color: var(--p-label); text-decoration: none; }
.p-seg > .on, .p-seg > [aria-pressed="true"], .p-seg > [aria-current="page"] {
  background: var(--p-bg-elevated); color: var(--p-label); box-shadow: var(--p-shadow-1);
}
/* a segmented control that fills its row and shrinks its labels: for four or five segments */
.p-seg.compact > button, .p-seg.compact > a { justify-content: center; padding: 0 var(--p-sp-2); font: var(--p-subhead); font-weight: 500; }
@media (max-width: 767px) {
  /* equal widths, filling the row: four or five short labels fit 358px */
  .p-seg.compact { display: flex; width: 100%; }
  .p-seg.compact > button, .p-seg.compact > a { flex: 1 1 0; min-width: 0; padding: 0 var(--p-sp-1); }
}
/* A phone: the TRACK is the 44pt hit, the selected pill sits 2px inside it (a
   transparent border that the background does not paint under). */
@media (max-width: 767px) {
  .p-seg { padding: 0 2px; }
  .p-seg > button, .p-seg > a { min-height: 44px; border-top: 2px solid transparent; border-bottom: 2px solid transparent; background-clip: padding-box; }
}

/* ---- fields: a fill, no border ---- */
.p-field, .p-search {
  width: 100%; min-height: 30px; padding: 0 var(--p-sp-3); border: 0; border-radius: var(--p-r);
  background: var(--p-fill); color: var(--p-label); font: var(--p-subhead); letter-spacing: 0;
}
textarea.p-field { padding: var(--p-sp-2) var(--p-sp-3); resize: vertical; }
.p-field::placeholder, .p-search::placeholder { color: var(--p-label-2); }

/* ---- chips: a filter or a tag. Selected is tinted, never black. ---- */
.p-chip {
  display: inline-flex; align-items: center; gap: 5px; min-height: var(--p-hit); padding: 0 10px; border: 0;
  border-radius: var(--p-r-pill); background: var(--p-fill); color: var(--p-label);
  font: var(--p-subhead); letter-spacing: 0; text-decoration: none; cursor: pointer; white-space: nowrap;
}
.p-chip:hover { background: var(--p-fill-strong); text-decoration: none; }
.p-chip.on, .p-chip[aria-pressed="true"] { background: color-mix(in srgb, var(--p-tint) 14%, transparent); color: var(--p-link); }
.p-chip em { font-style: normal; color: var(--p-label-2); font: var(--p-footnote); }

/* ---- a section: sentence case, no rule ---- */
.p-sec { display: flex; align-items: baseline; gap: var(--p-sp-2); margin: var(--p-sp-6) 0 var(--p-sp-2); padding: 0 var(--p-sp-1); }
.p-sec h2, .p-sec h3, .p-sec > .t { margin: 0; font: var(--p-headline); letter-spacing: 0; color: var(--p-label); }
.p-sec .n { font: var(--p-subhead); color: var(--p-label-2); font-variant-numeric: tabular-nums; }
.p-sec .p-btn { margin-left: auto; align-self: center; }
/* the first heading on a page (or in an inspector, or a pane marked .p-start) sits at the page's own padding */
.p-page > .p-sec:first-child, .p-page > section:first-child > .p-sec,
.p-start > .p-sec:first-child, .p-start > section:first-child > .p-sec, .p-start > :is(div, section):first-child > section:first-child > .p-sec,
.p-detail-body > section:first-child > .p-sec { margin-top: 0; }

/* ---- an inset-grouped list: the shape most of Prism is ----
   Rows sit on --p-bg-elevated inside a group that sits on --p-bg-2. A 0.5px
   separator starts at the text, not the edge. The row IS the control (a link or
   a button) and says so with a chevron; an action never hides until hover. */
.p-list { background: var(--p-bg-elevated); border-radius: var(--p-r-lg); overflow: hidden; }
.p-row {
  position: relative; display: flex; align-items: center; gap: var(--p-sp-3); width: 100%;
  min-height: 44px; padding: var(--p-sp-2) var(--p-sp-4); border: 0; background: none; text-align: left;
  color: var(--p-label); font: var(--p-body); letter-spacing: 0; text-decoration: none;
}
.p-row + .p-row::before {
  content: ""; position: absolute; top: 0; left: var(--p-sp-4); right: 0; border-top: var(--p-hairline) solid var(--p-separator);
}
.p-row-b { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.p-row-t { font: var(--p-body); color: var(--p-label); overflow-wrap: anywhere; }
.p-row-s { font: var(--p-subhead); color: var(--p-label-2); overflow-wrap: anywhere; }
.p-row-v { flex: none; font: var(--p-subhead); color: var(--p-label-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.p-row.bad .p-row-v, .p-row-v.bad { color: var(--p-red-text); }
a.p-row, button.p-row, .p-row[role="button"] { cursor: pointer; }
a.p-row::after, button.p-row::after, .p-row[role="button"]::after, .p-row.go::after {
  content: ""; flex: none; width: 7px; height: 7px; margin-left: 2px;
  border-top: 1.5px solid var(--p-label-3); border-right: 1.5px solid var(--p-label-3); transform: rotate(45deg);
}
a.p-row:hover, button.p-row:hover, .p-row[role="button"]:hover { background: var(--p-fill); text-decoration: none; }
a.p-row:focus-visible, button.p-row:focus-visible, .p-row[role="button"]:focus-visible { outline-offset: -3px; }
.p-row.nochev::after { display: none; }
/* the open row of a list beside its inspector (on a phone the detail is a page, so none is shown) */
@media (min-width: 768px) { .p-row[aria-current="true"], .p-row.on, .p-row.sel { background: var(--p-fill); } }
.p-row-t.danger { color: var(--p-red-text); }
.p-row-v.wrap { white-space: normal; text-align: right; }
.p-dot { flex: none; width: 20px; height: 20px; border-radius: 50%; border: 1.5px solid var(--p-label-3); }
.p-row.bad .p-dot { border-color: var(--p-red); }
@media (min-width: 768px) { .p-row { min-height: 36px; padding-block: 6px; font: var(--p-callout); } .p-row-t { font: var(--p-callout); } }

/* ---- a table: header in caption weight, sentence case, hairlines only ---- */
.p-table-wrap { overflow-x: auto; background: var(--p-bg-elevated); border-radius: var(--p-r-lg); }
.p-table { width: 100%; border-collapse: collapse; font: var(--p-subhead); font-variant-numeric: tabular-nums; }
.p-table th {
  position: sticky; top: 0; padding: 8px var(--p-sp-4); text-align: left; background: var(--p-bg-elevated);
  font: var(--p-caption); font-weight: 600; color: var(--p-label-2); border-bottom: var(--p-hairline) solid var(--p-separator);
  white-space: nowrap;
}
.p-table td { padding: 9px var(--p-sp-4); border-bottom: var(--p-hairline) solid var(--p-separator); color: var(--p-label); }
.p-table tr:last-child td { border-bottom: 0; }
.p-table .num { text-align: right; }
.p-table tr[data-go], .p-table tr[role="button"] { cursor: pointer; }
.p-table tr[data-go]:hover td { background: var(--p-fill); }
/* below a tablet a stacked table is a list: one small card per row, label over value */
@media (max-width: 767px) {
  .p-table.stack thead { display: none; }
  .p-table.stack, .p-table.stack tbody, .p-table.stack tr, .p-table.stack td { display: block; }
  .p-table.stack tr { position: relative; padding: var(--p-sp-2) var(--p-sp-4); border-bottom: var(--p-hairline) solid var(--p-separator); }
  .p-table.stack tr:last-child { border-bottom: 0; }
  .p-table.stack td { display: flex; gap: var(--p-sp-3); justify-content: space-between; padding: 3px 0; border: 0; text-align: right; }
  .p-table.stack td::before { content: attr(data-l); flex: none; color: var(--p-label-2); font: var(--p-footnote); text-align: left; }
  .p-table.stack td:first-child { font-weight: 600; text-align: left; justify-content: flex-start; }
  .p-table.stack td:first-child::before { display: none; }
}

/* ---- empty and failed: no card. A glyph, a title, one line, one button. ---- */
.p-empty { padding: var(--p-sp-12) var(--p-sp-4); text-align: center; color: var(--p-label-2); }
.p-empty .p-glyph { display: grid; place-items: center; margin: 0 auto var(--p-sp-3); color: var(--p-label-3); }
.p-empty .p-glyph svg { width: 40px; height: 40px; stroke-width: 1.2; }
.p-empty h2, .p-empty h3, .p-empty .t { margin: 0 0 4px; font: var(--p-section); letter-spacing: 0; color: var(--p-label); }
.p-empty p { margin: 0 auto var(--p-sp-4); max-width: 40ch; font: var(--p-callout); color: var(--p-label-2); }
.p-empty.bad .t, .p-empty.bad h2 { color: var(--p-red-text); }

/* ---- the page a view lives on: one column, one gutter, nothing else ----
   Desktop 24/32, phone 16. A view's root carries this class; it needs no other
   chrome of its own (the toolbar already says where you are). `.split` gives a
   list and an inspector the room they need. */
.p-page { max-width: 1080px; margin: 0 auto; padding: var(--p-sp-6) var(--p-sp-8) var(--p-sp-12); }
.p-page.narrow { max-width: 720px; }
.p-page.split { max-width: 1320px; }
@media (max-width: 767px) { .p-page, .p-page.narrow, .p-page.split { padding: var(--p-sp-4) var(--p-sp-4) var(--p-sp-12); } }

/* a quiet line under a list or at the top of a page: a footnote, never a paragraph */
.p-foot { margin: var(--p-sp-2) var(--p-sp-4) 0; font: var(--p-footnote); color: var(--p-label-2); max-width: none; }
.p-lede { margin: 0 var(--p-sp-1) var(--p-sp-4); font: var(--p-subhead); color: var(--p-label-2); max-width: none; }

/* a search field: a fill with a magnifier inside */
.p-searchbox { position: relative; display: block; }
.p-searchbox > svg { position: absolute; left: 9px; top: 50%; width: 15px; height: 15px; margin-top: -7.5px; color: var(--p-label-2); pointer-events: none; }
.p-searchbox > .p-search { padding-left: 29px; min-height: 32px; }
.p-search::-webkit-search-cancel-button { -webkit-appearance: none; }
/* the row above a list: search, then filter and the like */
.p-bar { display: flex; align-items: center; gap: var(--p-sp-2); margin-bottom: var(--p-sp-4); }
.p-bar .p-searchbox { flex: 1; min-width: 0; }

/* ---- a badge: a status word. Neutral; colour only for an exception ---- */
.p-badge { display: inline-flex; align-items: center; gap: 5px; min-height: 18px; padding: 0 7px; border-radius: var(--p-r-pill);
  background: var(--p-fill); color: var(--p-label-2); font: var(--p-caption); font-weight: 500; white-space: nowrap; }
.p-badge.good::before, .p-badge.warn::before, .p-badge.bad::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.p-badge.good { color: #248A3D; } .p-badge.warn { color: var(--p-label); } .p-badge.warn::before { background: var(--p-orange); }
.p-badge.bad { color: var(--p-red-text); }
:root[data-theme="dark"] .p-badge.good { color: #30D158; }

/* ---- a meter: 4px, the accent on a fill ---- */
.p-meter { height: 4px; border-radius: 2px; background: var(--p-fill); overflow: hidden; min-width: 40px; }
.p-meter.muted > i { background: var(--p-label-3); }
.p-meter.good > i { background: var(--p-green); }
.p-meter > i { display: block; height: 100%; border-radius: 2px; background: var(--p-tint); transition: width var(--p-dur-slow) var(--p-ease-out); }

/* ---- a banner: only when something is wrong. A glyph, words in label colour, an action ---- */
.p-banner { display: flex; align-items: center; gap: var(--p-sp-3); margin-bottom: var(--p-sp-4); padding: var(--p-sp-3) var(--p-sp-4);
  background: var(--p-bg-elevated); border-radius: var(--p-r-lg); font: var(--p-callout); color: var(--p-label); }
.p-banner .g { flex: none; display: grid; color: var(--p-orange); } .p-banner.bad .g { color: var(--p-red); }
.p-banner .g svg { width: 18px; height: 18px; }
.p-banner .t { flex: 1; min-width: 0; }
.p-banner .p-btn { flex: none; }

/* ---- a circle that completes (Reminders): 22px drawn, 44 to tap on a phone ---- */
.p-circle { position: relative; flex: none; width: 22px; height: 22px; padding: 0; border: 1.5px solid var(--p-label-3); border-radius: 50%;
  background: none; cursor: pointer; transition: border-color var(--p-dur-fast) var(--p-ease), background var(--p-dur-fast) var(--p-ease); }
.p-circle::after { content: ""; position: absolute; inset: -11px; }
.p-circle:hover { border-color: var(--p-tint); }
.p-circle.done { background: var(--p-tint); border-color: var(--p-tint); }
.p-circle.done::before { content: ""; position: absolute; left: 6.5px; top: 3px; width: 5px; height: 9px; border: solid #fff; border-width: 0 1.8px 1.8px 0; transform: rotate(45deg); }

/* ---- a disclosure: a section that starts folded ---- */
.p-disc { margin-top: var(--p-sp-6); }
.p-disc:first-child, .p-page > .p-disc:first-child { margin-top: 0; }
.p-disc > summary { display: flex; align-items: baseline; gap: var(--p-sp-2); padding: 0 var(--p-sp-1); margin-bottom: var(--p-sp-2); list-style: none; cursor: pointer; min-height: 28px; align-items: center; }
.p-disc > summary::-webkit-details-marker { display: none; }
.p-disc > summary::before { content: ""; flex: none; width: 6px; height: 6px; margin-right: 2px; border-top: 1.5px solid var(--p-label-2); border-right: 1.5px solid var(--p-label-2); transform: rotate(45deg); transition: transform var(--p-dur-fast) var(--p-ease); }
.p-disc[open] > summary::before { transform: rotate(135deg); }
.p-disc > summary .t { font: var(--p-headline); color: var(--p-label); }
.p-disc > summary .n { font: var(--p-subhead); color: var(--p-label-2); font-variant-numeric: tabular-nums; }

/* ---- a list and its inspector: Mail's two columns. On a phone one shows at a time. ---- */
.p-split { display: grid; grid-template-columns: minmax(280px, 380px) minmax(0, 1fr); gap: var(--p-sp-6); align-items: start; }
.p-master { min-width: 0; }
.p-detail { min-width: 0; position: sticky; top: var(--p-sp-4); max-height: calc(100dvh - 96px); overflow-y: auto;
  background: var(--p-bg-elevated); border-radius: var(--p-r-lg); }
.p-detail.is-none { background: none; }                    /* nothing selected: no card, just the quiet line */
.p-desk { }                                                 /* controls that only make sense beside a list: hidden on a phone, below */
.p-field.lg { font: var(--p-callout); line-height: 1.5; }   /* a body of text, not a one-line field */
.p-detail-hd { display: flex; align-items: center; gap: var(--p-sp-3); padding: var(--p-sp-4) var(--p-sp-4) var(--p-sp-3); border-bottom: var(--p-hairline) solid var(--p-separator); }
.p-detail-hd .b { flex: 1; min-width: 0; }
.p-detail-hd h2 { margin: 0; font: var(--p-title-3); overflow-wrap: anywhere; }
.p-detail-hd .s { font: var(--p-subhead); color: var(--p-label-2); overflow-wrap: anywhere; }
.p-detail-hd .acts { flex: none; display: flex; align-items: center; gap: var(--p-sp-1); }
.p-detail-body { padding: var(--p-sp-4); }
.p-detail-none { padding: var(--p-sp-12) var(--p-sp-4); text-align: center; font: var(--p-callout); color: var(--p-label-2); }
.p-back { display: none; }
/* a label and its value, one per line: the inspector's rows */
.p-kv { margin: 0; }
.p-kv > div { display: flex; gap: var(--p-sp-3); align-items: baseline; padding: 9px 0; border-bottom: var(--p-hairline) solid var(--p-separator); font: var(--p-callout); }
.p-kv > div:last-child { border-bottom: 0; }
.p-kv dt { flex: none; width: 112px; color: var(--p-label-2); font: var(--p-subhead); }
.p-kv dd { flex: 1; min-width: 0; margin: 0; overflow-wrap: anywhere; }
@media (max-width: 767px) {
  .p-split { display: block; }
  .p-split:not(.has-detail) > .p-detail { display: none; }
  .p-split.has-detail > .p-master { display: none; }
  .p-detail { position: static; max-height: none; overflow: visible; }
  .p-back { display: inline-flex; }
  .p-desk, .p-btn.p-desk, .p-icon.p-desk { display: none; }
  .p-kv dt { width: 96px; }
}

/* ---- a smart tile (Home): glyph, count, name ---- */
.p-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--p-sp-3); }
.p-tile {
  display: flex; flex-direction: column; justify-content: space-between; gap: var(--p-sp-2); min-height: 76px;
  padding: var(--p-sp-3) var(--p-sp-4); border: 0; border-radius: var(--p-r-lg); background: var(--p-bg-elevated);
  color: var(--p-label); text-align: left; cursor: pointer; text-decoration: none; letter-spacing: 0;
  transition: filter var(--p-dur-fast) var(--p-ease);
}
.p-tile:hover { filter: brightness(.97); text-decoration: none; }
.p-tile:active { filter: brightness(.92); }
.p-tile .top { display: flex; align-items: center; justify-content: space-between; }
.p-tile .ico { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--p-tint); color: #fff; }
.p-tile .ico svg { width: 16px; height: 16px; }
.p-tile.warn .ico { background: var(--p-red); }
.p-tile .n { font: var(--p-title-2); font-variant-numeric: tabular-nums; }
.p-tile .l { font: var(--p-subhead); color: var(--p-label-2); }

/* ---- skeleton: shaped like the thing ---- */
.p-skel { display: grid; gap: 1px; }
.p-skel-row { height: 44px; background: linear-gradient(90deg, var(--p-fill) 0%, var(--p-fill-strong) 50%, var(--p-fill) 100%);
  background-size: 200% 100%; animation: p-shimmer 1.4s linear infinite; }
@keyframes p-shimmer { 0% { background-position: 100% 0 } 100% { background-position: 0 0 } }

/* ---- a figure that earns its place: a label, a value, a sub-line ---- */
.p-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--p-sp-3); }
.p-stat { padding: var(--p-sp-3) var(--p-sp-4); border-radius: var(--p-r-lg); background: var(--p-bg-elevated); text-align: left; border: 0; color: var(--p-label); }
.p-stat.is-link { cursor: pointer; }
.p-stat-l { font: var(--p-subhead); color: var(--p-label-2); }
.p-stat-v { font: var(--p-title-2); font-variant-numeric: tabular-nums; }
.p-stat-v.warn { color: var(--p-red-text); }
.p-stat-s { font: var(--p-footnote); color: var(--p-label-2); }

/* ================================================================ FLOATING
   Toasts, alerts, sheets, menus and the palette share one material. */

#toasts {
  position: fixed; inset: auto; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 200;
  display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none;
  margin: 0; padding: 0; border: 0; background: none; overflow: visible; width: auto; height: auto;
}
#toasts:empty { display: none; }
/* menus and scrims are popovers (top layer): drop the UA's centred box */
:where(.p-pop[popover]) { inset: auto; margin: 0; }   /* zero specificity: the phone sheet below sets its own edges */
.p-pop-scrim[popover] { inset: 0; border: 0; padding: 0; background: var(--p-scrim); width: auto; height: auto; max-width: none; max-height: none; }
.p-toast {
  display: flex; align-items: center; gap: var(--p-sp-4); padding: 9px 14px; border-radius: var(--p-r-md);
  background: var(--p-bg-elevated); color: var(--p-label); box-shadow: var(--p-shadow-2);
  font: var(--p-subhead); max-width: min(360px, 90vw); pointer-events: auto;
}
.p-toast.bad { color: var(--p-red-text); }
.p-toast-act { border: 0; background: none; padding: 0; min-height: 20px; color: var(--p-link); font: var(--p-control); font-weight: 600; cursor: pointer; }

/* ---- dialogs: alert (centred, stacked), input (a sheet), content sheet ---- */
.p-dlg { border: 0; padding: 0; background: transparent; color: var(--p-label); max-width: 100vw; max-height: 100dvh; }
.p-dlg::backdrop { background: var(--p-scrim); }
.p-dlg:not(.p-sheet) form {
  width: min(480px, 92vw); padding: var(--p-sp-5); background: var(--p-bg-elevated); color: var(--p-label);
  border: var(--p-hairline) solid var(--p-separator); border-radius: var(--p-r-lg); box-shadow: var(--p-shadow-3);
}
.p-dlg h3 { margin: 0 0 4px; font: var(--p-headline); color: var(--p-label); }
.p-dlg .hint { margin: 0 0 var(--p-sp-4); font: var(--p-subhead); color: var(--p-label-2); max-width: none; }
.p-dlg .fld { display: block; margin-bottom: var(--p-sp-3); }
.p-dlg .fld span { display: block; margin-bottom: 4px; font: var(--p-subhead); color: var(--p-label-2); }
.p-dlg input, .p-dlg textarea, .p-dlg select {
  width: 100%; min-height: 32px; padding: 6px 10px; border: 0; border-radius: var(--p-r);
  background: var(--p-fill); color: var(--p-label); font: var(--p-callout);
}
.p-dlg textarea { resize: vertical; }
/* the first submit is what Enter presses, so the confirm is written first and painted last */
.p-dlg .row { display: flex; flex-direction: row-reverse; justify-content: flex-start; gap: 8px; margin-top: var(--p-sp-4); }
.p-dlg.alert form { width: min(280px, 92vw); padding: var(--p-sp-5) var(--p-sp-4) var(--p-sp-3); text-align: center; }
.p-dlg.alert h3 { text-align: center; }
.p-dlg.alert .hint { font: var(--p-footnote); text-align: center; }
.p-dlg.alert .row { flex-direction: column-reverse; gap: 0; margin-top: 0; }
.p-dlg.alert .p-btn { width: 100%; min-height: 36px; background: none; border-radius: 0; border-top: var(--p-hairline) solid var(--p-separator); }
.p-dlg.alert .p-btn.cancel { font-weight: 600; color: var(--p-link); }
.p-dlg.alert .p-btn.danger { color: var(--p-red-text); }

.p-sheet-in {
  width: min(560px, 94vw); max-height: min(82vh, 720px); display: flex; flex-direction: column;
  background: var(--p-bg-2); color: var(--p-label); border: var(--p-hairline) solid var(--p-separator);
  border-radius: var(--p-r-xl); box-shadow: var(--p-shadow-3); overflow: hidden;
  opacity: 0; transform: scale(.98); transition: opacity var(--p-dur-fast) var(--p-ease), transform var(--p-dur-fast) var(--p-ease);
}
.p-sheet.in .p-sheet-in { opacity: 1; transform: none; }
.p-sheet-hd { flex: none; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: var(--p-sp-2) var(--p-sp-3); background: var(--p-bg-2); border-bottom: var(--p-hairline) solid var(--p-separator); }
.p-sheet-hd h2 { margin: 0; font: var(--p-headline); text-align: center; }
.p-sheet-hd .p-btn { justify-self: end; font-weight: 600; }
.p-sheet-in:focus { outline: none; }
.p-sheet-body { flex: 1; overflow-y: auto; padding: var(--p-sp-4); }

/* ---- popover and menu ---- */
.p-pop-scrim { display: none; }
.p-pop {
  position: fixed; z-index: 150; min-width: var(--pop-w, 220px); max-width: min(360px, calc(100vw - 16px));
  max-height: min(70vh, 520px); overflow-y: auto; padding: 5px; border-radius: var(--p-r-lg);
  background: var(--glass-2); -webkit-backdrop-filter: var(--blur-lg); backdrop-filter: var(--blur-lg);
  color: var(--p-label); box-shadow: var(--p-shadow-3); border: var(--p-hairline) solid var(--p-separator); outline: 0;
  opacity: 0; transform: scale(.98); transform-origin: top;
  transition: opacity var(--p-dur-fast) var(--p-ease), transform var(--p-dur-fast) var(--p-ease);
}
.p-pop.in { opacity: 1; transform: none; }
.p-pop hr { border: 0; border-top: var(--p-hairline) solid var(--p-separator); margin: 5px 2px; }
.p-pop-h { padding: 6px 10px 2px; font: var(--p-footnote); color: var(--p-label-2); }
.p-pop-i {
  display: flex; align-items: center; gap: 8px; width: 100%; min-height: 28px; padding: 3px 10px; border: 0;
  border-radius: var(--p-r-sm); background: none; color: var(--p-label); font: var(--p-subhead); letter-spacing: 0;
  text-align: left; text-decoration: none; cursor: pointer;
}
/* a menu selects the way a menu does: the tint, with white on it */
.p-pop-i:hover:not(:disabled), .p-pop-i:focus-visible { background: var(--p-tint); color: #fff; outline: 0; text-decoration: none; }
.p-pop-i:disabled { opacity: .4; cursor: default; }
.p-pop-i.danger { color: var(--p-red-text); }
.p-pop-i.danger:hover, .p-pop-i.danger:focus-visible { color: #fff; }
.p-pop-i .lbl { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.p-pop-i small { font: var(--p-footnote); color: var(--p-label-2); }
.p-pop-i:hover small, .p-pop-i:focus-visible small, .p-pop-i:hover .trl, .p-pop-i:focus-visible .trl { color: rgba(255,255,255,.85); }
.p-pop-i .trl { font-variant-numeric: tabular-nums; color: var(--p-label-2); }
.p-pop-i .ico, .p-pop-i .chk { display: inline-grid; color: inherit; }
.p-pop-i svg { width: 15px; height: 15px; }
.p-pop-cancel { display: none; }
.p-pop-text { margin: 0; padding: 8px 10px; font: var(--p-subhead); color: var(--p-label-2); }

/* ---- the record control: a red disc with a white dot; while it records, a ring
   around a red square. 28 on a desktop, 44 on a phone. `.fab` is the phone's
   centred bottom button. (Cadence keeps its own `.rec-btn`, drawn inside `.cad`;
   this one is named apart so neither can restyle the other.) ---- */
.p-rec { position: relative; flex: none; display: inline-grid; place-items: center; width: var(--p-hit);
  height: var(--p-hit); padding: 0; border: 0; border-radius: 50%; background: var(--p-red); cursor: pointer;
  transition: filter var(--p-dur-fast) var(--p-ease); }
.p-rec::before { content: ""; width: 36%; height: 36%; border-radius: 50%; background: #fff;
  transition: border-radius var(--p-dur-fast) var(--p-ease); }
.p-rec:hover { filter: brightness(1.06); }
.p-rec[data-state="recording"] { background: transparent; box-shadow: inset 0 0 0 2px var(--p-red); }
.p-rec[data-state="recording"]::before { width: 38%; height: 38%; border-radius: 3px; background: var(--p-red); }
.p-rec:disabled { opacity: .35; cursor: default; filter: none; }
.p-rec:focus-visible { outline: 3px solid color-mix(in srgb, var(--p-red) 45%, transparent); outline-offset: 2px; }
.p-rec.fab { display: none; }
@media (max-width: 767px) {
  .p-rec.fab { display: inline-grid; position: fixed; z-index: 30; left: 50%; transform: translateX(-50%);
    bottom: calc(16px + env(safe-area-inset-bottom)); box-shadow: 0 0 0 4px var(--p-bg-2), var(--p-shadow-2); }
  .p-rec.fab[data-state="recording"] { background: var(--p-bg-2);
    box-shadow: inset 0 0 0 2px var(--p-red), 0 0 0 4px var(--p-bg-2), var(--p-shadow-2); }
}

/* the [hidden] attribute wins over a component's own display, wherever it is set */
:is(.p-btn, .p-seg, .p-icon, .p-chip, .p-row, .p-banner, .p-disc, .p-list, .p-sec, .p-rec, .p-field, .p-badge)[hidden] { display: none; }

/* ---- the palette (⌘K) ---- */
.p-pal { border: 0; padding: 0; background: transparent; color: var(--p-label); margin: 12vh auto auto; max-width: 100vw; }
.p-pal::backdrop { background: var(--p-scrim); }
.p-pal .pal {
  width: min(560px, 94vw); padding: var(--p-sp-4); background: var(--p-bg-elevated); border-radius: var(--p-r-lg);
  border: var(--p-hairline) solid var(--p-separator); box-shadow: var(--p-shadow-3);
}
.p-pal input {
  width: 100%; padding: 6px 2px 12px; border: 0; border-bottom: var(--p-hairline) solid var(--p-separator);
  background: none; color: var(--p-label); font: var(--p-title-3); outline: none;
}
.p-pal input::-webkit-search-cancel-button { display: none; }
.p-pal .pal-rows { max-height: 52vh; overflow-y: auto; margin-top: var(--p-sp-2); }
.p-pal .pal-h { padding: 10px 10px 4px; font: var(--p-caption); font-weight: 600; color: var(--p-label-2); }
.p-pal .pal-row {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 8px 10px; border: 0;
  border-radius: var(--p-r); background: none; color: var(--p-label); cursor: pointer;
}
.p-pal .pal-row.on { background: var(--p-fill); }
.p-pal .pal-row .ico { flex: none; display: grid; place-items: center; width: 22px; color: var(--p-label-2); }
.p-pal .pal-row .ico svg { width: 16px; height: 16px; }
.p-pal .pal-row .t { flex: 1; min-width: 0; font: var(--p-callout); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.p-pal .pal-row .s { display: block; font: var(--p-footnote); color: var(--p-label-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.p-pal .pal-row .k { font: var(--p-footnote); color: var(--p-label-2); }
.p-pal .pal-none { padding: var(--p-sp-6) var(--p-sp-4); text-align: center; font: var(--p-callout); color: var(--p-label-2); }

/* ---- a phone: a menu is an action sheet, an alert keeps its size, a sheet is the screen ---- */
@media (max-width: 767px) {
  .p-pop-scrim { display: block; position: fixed; inset: 0; z-index: 149; background: var(--p-scrim); opacity: 0; transition: opacity var(--p-dur-slow) var(--p-ease-out); }
  .p-pop-scrim.in { opacity: 1; }
  .p-pop { left: 8px !important; right: 8px; top: auto !important; bottom: calc(8px + env(safe-area-inset-bottom)); min-width: 0; max-width: none; width: auto;
    border-radius: var(--p-r-xl); padding: 6px; transform: translateY(16px); transform-origin: bottom;
    transition: opacity var(--p-dur-slow) var(--p-ease-out), transform var(--p-dur-slow) var(--p-ease-out); }
  .p-pop.in { transform: none; }
  .p-pop-i { min-height: 44px; font: var(--p-body); padding: 0 var(--p-sp-4); }
  .p-pop-cancel { display: block; width: 100%; min-height: 44px; margin-top: 6px; border: 0; border-radius: var(--p-r-md);
    background: var(--p-fill); color: var(--p-link); font: var(--p-body); font-weight: 600; cursor: pointer; }

  .p-dlg:not(.alert):not(.p-sheet) { margin: auto 0 0; }
  .p-dlg:not(.alert):not(.p-sheet) form { width: 100vw; border-radius: var(--p-r-xl) var(--p-r-xl) 0 0; border-bottom: 0; padding-bottom: calc(var(--p-sp-5) + env(safe-area-inset-bottom)); }
  .p-dlg input, .p-dlg textarea, .p-dlg select { min-height: 44px; font: var(--p-body); }

  .p-sheet { margin: 0; width: 100vw; height: 100dvh; max-height: 100dvh; }
  .p-sheet-in { width: 100vw; height: 100dvh; max-height: 100dvh; border-radius: 0; border: 0; transform: translateY(24px); transition: opacity var(--p-dur-slow) var(--p-ease-out), transform var(--p-dur-slow) var(--p-ease-out); }
  .p-sheet-hd { padding-top: calc(var(--p-sp-3) + env(safe-area-inset-top)); }
  .p-sheet-hd .p-btn { min-height: 44px; }
  .p-pal { margin: 0; width: 100vw; height: 100dvh; }
  .p-pal .pal { width: 100vw; height: 100dvh; border-radius: 0; border: 0; padding-top: calc(var(--p-sp-4) + env(safe-area-inset-top)); }
  .p-pal .pal-rows { max-height: none; }
  .p-pal .pal-row { min-height: 44px; }
  #toasts { bottom: calc(20px + env(safe-area-inset-bottom)); }
  .p-toast-act { min-height: 44px; padding: 0 var(--p-sp-2); }
}

} /* @layer house */
