/* Apple UI Kit — macOS 27 (Golden Gate) components. Only under html.mac.
   Patterns copied from Apple's Mac apps (see PLAN.md §2): Mail / Notes / Contacts split view, Finder table, System Settings form,
   Contacts card (macOS 27 poster style), Pages document page + inspector, sheets, alerts, menus. */

html.mac { --menu-blur-now: var(--menu-blur); }
@media (prefers-color-scheme: dark) { html.mac:not([data-theme="light"]) { --menu-blur-now: var(--menu-blur-dark); } }
html.mac[data-theme="dark"] { --menu-blur-now: var(--menu-blur-dark); }

/* ---------- document page (Pages / Preview: the paper itself on a canvas) + inspector ---------- */
.doc-canvas { min-height: 100%; padding: calc(var(--toolbar-h) + 16px) 24px 40px; background: light-dark(#ececec, #1e1e1e); }
.doc-paper { width: 595px; min-height: 842px; margin: 0 auto; padding: 44px 48px; /* A4 in points; scaled to fit like Preview's Zoom to Fit */ background: #fff; color: #1d1d1f; color-scheme: light;
  box-shadow: 0 1px 3px rgba(0,0,0,.18), 0 0 0 .5px rgba(0,0,0,.08), 0 8px 26px rgba(0,0,0,.08); font-size: 12px; line-height: 1.45; }
.doc-below { max-width: 595px; margin: 20px auto 0; }
.with-inspector { display: grid; grid-template-columns: minmax(0, 1fr) 260px; height: 100%; min-height: 0; }
.inspector { position: relative; overflow-y: auto; padding: calc(var(--toolbar-h) + 4px) 16px 24px; background: var(--bg); box-shadow: inset .5px 0 0 var(--divider); }
.insp-sec { padding: 12px 0; }
.insp-sec + .insp-sec { border-top: .5px solid var(--sep); }
.insp-h { font-size: var(--fs-head); font-weight: 700; color: var(--text); margin-bottom: 8px; }
.insp-row { display: flex; justify-content: space-between; gap: 10px; padding: 3px 0; }
.insp-row > :first-child { color: var(--text2); }
.insp-row > :last-child { text-align: right; font-variant-numeric: tabular-nums; }
.insp-big { font-size: 22px; font-weight: 700; line-height: 28px; font-variant-numeric: tabular-nums; }
.status { display: inline-flex; align-items: center; gap: 5px; font-weight: 600; }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }

/* ---------- grouped form (System Settings) — M-SR ---------- */
html.mac .section-h { margin: 22px 2px 7px; font-size: var(--fs-body); font-weight: 700; color: var(--text); }
html.mac .section-h a { font-weight: 400; }
html.mac .section-f { margin: 6px 2px 0; font-size: var(--fs-sub); line-height: 14px; color: var(--text2); }
html.mac .group { border-radius: var(--radius); box-shadow: inset 0 0 0 1px var(--card-edge); }
html.mac .group > * + *::before { left: 10px; right: 10px; border-top: 1px solid var(--form-sep); }
html.mac .group > * + .row:has(> .icon-dot)::before { left: 42px; }
html.mac .row { min-height: var(--row-h); padding: 7px 10px; gap: 10px; background: transparent; }
html.mac .row .sub { font-size: var(--fs-sub); line-height: 14px; }
html.mac a.row:hover, html.mac button.row:hover { background: var(--fill2); }
html.mac .row .chev { width: 6px; height: 10px; }
html.mac .icon-dot { width: 22px; height: 22px; border-radius: 6px; font-size: 11px; }
html.mac .icon-dot svg { width: 14px; height: 14px; }
html.mac .field { min-height: var(--row-h); padding: 0 10px; background: transparent; }
html.mac .field > input, html.mac .field > textarea, html.mac .field .f-pop select { font-size: var(--fs-body); padding: 10px 0; }
html.mac .field .f-pop select { padding-right: 20px; }
html.mac .field .f-pop .pop-ic { width: 12px; height: 12px; }
html.mac .field:focus-within { background: color-mix(in srgb, var(--accent) 6%, transparent); }
html.mac .field.stack textarea { min-height: 52px; }
html.mac .switch { width: 36px; height: 20px; }   /* form switch 36 × 18–20 — M-SR controls */
html.mac .switch i::after { width: 18px; height: 16px; top: 2px; left: 2px; box-shadow: 0 1px 2px rgba(0,0,0,.25); }
html.mac .switch input:checked + i { background: var(--accent); }
html.mac .switch input:checked + i::after { transform: translateX(14px); }
html.mac .seg { max-width: 360px; padding: 2px; }
html.mac .seg button { height: 24px; font-size: var(--fs-body); font-weight: 500; }
html.mac .seg button.on { background: var(--accent); color: #fff; font-weight: 500; box-shadow: none; }   /* selected segment = accent — M-SR */
html.mac .dp .dp-step { width: 11px; height: 11px; margin-left: 2px; opacity: .65; stroke-width: 2.2; }
html.mac .dp { height: 24px; padding: 0 5px 0 8px; border-radius: 6px; font-size: var(--fs-body); background: var(--card); box-shadow: inset 0 0 0 1px var(--card-edge), 0 .5px 1px rgba(0,0,0,.1); }
html.mac .empty-state { padding: 80px 24px; }
html.mac .empty-state > svg { width: 44px; height: 44px; }
html.mac .es-title { font-size: 17px; line-height: 22px; }
html.mac .es-msg { font-size: var(--fs-body); }
html.mac .btn-tinted { height: 28px; font-size: var(--fs-body); padding: 0 14px; }
html.mac .btn-prominent { height: 28px; padding: 0 16px; font-size: var(--fs-body); font-weight: 500; }
/* push buttons 24 pt, radius 8 — M-SR controls */
.mbtn { height: 24px; min-width: 72px; padding: 0 12px; border-radius: 8px; border: 0; font-size: var(--fs-body); font-weight: 500;
  background: light-dark(#fff, #5a5a5a); color: var(--text); box-shadow: 0 .5px 1.5px rgba(0,0,0,.25), inset 0 0 0 .5px var(--card-edge); }
.mbtn.default { background: var(--accent); color: #fff; }
.mbtn.destructive { background: var(--red); color: #fff; }
.mbtn:disabled { opacity: .5; }

/* ---------- sheet: comes down from the toolbar, centred on the window, window dimmed 20 % — M-SR sheet ---------- */
html.mac .sheet-scrim { display: flex; justify-content: center; align-items: flex-start; padding: 44px 20px 20px; }
html.mac .sheet { width: 100%; max-width: 520px; max-height: calc(100vh - 70px); display: flex; flex-direction: column; border-radius: 20px; background: var(--sheet);
  box-shadow: 0 22px 70px rgba(0,0,0,.35), 0 0 0 .5px rgba(0,0,0,.25); opacity: 0; transform: translateY(-14px) scale(.98); transition: opacity .2s, transform .22s var(--ease); }
html.mac .scrim.in .sheet { opacity: 1; transform: none; }
html.mac .sheet .group { background: var(--sheet-card); }
html.mac .sheet-head { padding: 16px 20px 2px; }
html.mac .sheet-title { font-size: var(--fs-body); font-weight: 700; }
html.mac .sheet-body { overflow-y: auto; padding: 4px 20px 16px; }
html.mac .sheet-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px 16px; }

/* ---------- alert — NSAlert on macOS 27.3 (references/mac/alert*.png): no app icon, title + text left-aligned 13 pt,
   capsule buttons 28 pt side by side; Cancel grey, a destructive button light red with red text, only a preferred action blue ---------- */
html.mac .scrim.center { background: transparent; }
html.mac .scrim.center.in { background: light-dark(rgba(0,0,0,.2), rgba(0,0,0,.25)); }
html.mac .alert { width: 260px; max-width: 100%; padding: 18px 16px 16px; border-radius: 16px; text-align: left; opacity: 0; transform: scale(1.06); transition: opacity .18s, transform .25s var(--ease);
  background: light-dark(#e6e6e6, #323233); -webkit-backdrop-filter: none; backdrop-filter: none; box-shadow: 0 12px 40px rgba(0,0,0,.28), 0 0 0 .5px light-dark(rgba(0,0,0,.15), rgba(255,255,255,.12)); }
html.mac .scrim.in .alert { opacity: 1; transform: none; }
html.mac .a-title { font-size: 13px; font-weight: 700; line-height: 16px; }
html.mac .a-msg { font-size: 13px; line-height: 17px; margin-top: 6px; }
html.mac .a-btns { display: flex; gap: 8px; margin-top: 16px; }
html.mac .a-btns.stack { flex-direction: column; }
html.mac .a-btns.stack .ab { flex: none; }
html.mac .ab { flex: 1 1 0; min-width: 0; padding: 0 12px; white-space: nowrap; height: 28px; border: 0; border-radius: 999px; background: light-dark(#d6d6d6, rgba(255,255,255,.12)); color: var(--text); font-size: 13px; font-weight: 400; }
html.mac .ab.destructive { background: light-dark(#e9c1bf, #603a3a); color: var(--red); }
html.mac .ab.is-default { background: var(--accent); color: #fff; }

/* ---------- menus, popovers (glass, attached to the window) ---------- */
html.mac .cmenu, html.mac .popover { position: fixed; z-index: 300; background: var(--menu-glass); -webkit-backdrop-filter: var(--menu-blur-now); backdrop-filter: var(--menu-blur-now); box-shadow: var(--menu-edge); }
html.mac .cmenu { min-width: 200px; padding: 5px; border-radius: 12px; }
html.mac .popover { border-radius: 14px; padding: 10px; }
html.mac .cm-item { display: flex; align-items: center; gap: 6px; width: 100%; height: 24px; padding: 0 10px; border: 0; border-radius: 6px; background: none; color: var(--text); text-align: left; font-size: var(--fs-body); }
html.mac .cm-item:hover, html.mac .cm-item:focus-visible { background: var(--menu-hover); outline: none; }
html.mac .cm-item.destructive { color: var(--red); }
html.mac .cm-item:disabled { color: var(--text3); }
html.mac .cm-label { flex: 1; white-space: nowrap; }
html.mac .cm-ic { width: 15px; height: 15px; flex: none; }
html.mac .cm-check { width: 13px; flex: none; display: grid; }
html.mac .cm-check svg { width: 12px; height: 12px; stroke-width: 2.4; }
html.mac .cm-more { width: 10px; height: 10px; flex: none; opacity: .7; }
html.mac .cm-key { color: var(--text2); margin-left: 16px; }
html.mac .cm-sep { height: 1px; margin: 5px 12px; background: var(--menu-sep); }
html.mac .cm-head { padding: 4px 10px 2px; font-size: var(--fs-sub); font-weight: 600; color: var(--text2); }


/* document page in a narrow pane (added 24 Nov for TieBond): no room beside the page, so the inspector goes under it and both scroll together */
.detail, .pane { container-type: inline-size; }
.pane { container-name: pane; }
@container (max-width: 720px) {
  .with-inspector { display: block; overflow-y: auto; height: 100%; }
  .with-inspector > .doc-canvas { overflow: visible; min-height: 0; padding-bottom: 16px; }
  .with-inspector > .inspector { overflow: visible; padding: 4px 24px 24px; box-shadow: none; }
}

/* ---------- Record header (Mac detail pane): Music artist header + Stocks key figures ---------- */
.rec-head { padding: 6px 0 18px; border-bottom: .5px solid var(--sep); margin-bottom: 18px; }
.rh-top { display: flex; align-items: center; gap: 16px; }
.rh-avatar { width: 80px; height: 80px; font-size: 30px; align-self: flex-start; }
.rh-titles { flex: 1; min-width: 0; }
.rh-name { margin: 0; font-size: 22px; line-height: 28px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rh-sub { margin-top: 2px; font-size: var(--fs-body); color: var(--text2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rh-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }   /* under the name, as Music's artist header: the name never truncates for buttons */
.rh-btn { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 14px; border: 0; border-radius: 999px;   /* SwiftUI .bordered, large — measured on 27.3 */
  background: var(--btn); color: var(--text); font: inherit; font-size: var(--fs-body); text-decoration: none; white-space: nowrap; cursor: default; }
.rh-btn svg { width: 15px; height: 15px; }
.rh-btn .rh-chev { width: 10px; height: 10px; margin-left: 2px; transform: rotate(90deg); }
.rh-btn.prominent { background: var(--accent); color: #fff; }
.rh-btn:hover { background: color-mix(in srgb, var(--btn), var(--text) 9%); }
.rh-btn:active, .rh-btn[aria-expanded=true] { background: color-mix(in srgb, var(--btn), var(--text) 18%); }
.rh-btn.prominent:hover { background: color-mix(in srgb, var(--accent), #fff 10%); }
.rh-btn.prominent:active { background: color-mix(in srgb, var(--accent), #000 14%); }
.rh-btn:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent), transparent 50%); outline-offset: 1px; }
.rh-btn:disabled { background: var(--fill); color: var(--text3); }
.rh-stats { display: flex; flex-wrap: wrap; row-gap: 10px; margin: 16px 0 0 -20px; clip-path: inset(0 0 0 20px); }   /* the line before the first figure of every row is clipped */
.rh-stat { min-width: 120px; padding: 0 20px; border-left: .5px solid var(--sep); }
.rh-stat dt { font-size: 11px; line-height: 14px; color: var(--text2); }
.rh-stat dd { margin: 2px 0 0; font-size: 17px; line-height: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }
.rh-stat dd.neg { color: var(--red); }
.rh-stat dd.pos { color: var(--green-text); }

/* tile instead of the round avatar: a thing (product, account, loan), as album artwork in Music */
.rh-tile { display: grid; place-items: center; border-radius: 16px; color: #fff; font-weight: 600; background: var(--gray); }
.rh-tile svg { width: 40px; height: 40px; }
.rh-tile.tone-blue { background: var(--blue); } .rh-tile.tone-green { background: var(--green); } .rh-tile.tone-red { background: var(--red); }
.rh-tile.tone-orange { background: var(--orange); } .rh-tile.tone-purple { background: var(--purple); } .rh-tile.tone-teal { background: #0093a0; } .rh-tile.tone-gray { background: #8e8e93; }
/* App Store ▸ Information */
.info-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px 20px; margin: 0; }
.info-grid dt { font-size: 11px; line-height: 14px; color: var(--text2); }
.info-grid dd { margin: 2px 0 0; overflow-wrap: anywhere; }
.info-grid a { color: var(--accent); text-decoration: none; }
/* inspector: entries, notes, push buttons */
.insp-entry { padding: 4px 0; }
.ie-t { overflow-wrap: anywhere; }
.ie-s, .insp-foot { font-size: 11px; line-height: 14px; color: var(--text2); overflow-wrap: anywhere; }
.insp-foot { margin-top: 6px; }
.insp-btns { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.insp-push { display: inline-flex; align-items: center; height: 24px; padding: 0 10px; border: 0; border-radius: 999px; background: var(--fill); color: var(--text) !important; font: inherit; text-decoration: none; }
.insp-push:hover { filter: brightness(.96); }
.insp-push.destructive { color: var(--red) !important; }
.tbl .col-off { display: none; }
.tbl-wrap.scroll-x { overflow-x: auto; }
.table-page .tbl-wrap.scroll-x { overflow-x: visible; }
.with-inspector > .scroller { overflow-y: auto; min-height: 0; }
@container (max-width: 720px) { .with-inspector > .scroller { overflow: visible; } }

/* inspector = SwiftUI .inspector with a grouped Form (27.3): grey heading, rounded cards, label left, value right */
.inspector { background: light-dark(#f7f7f7, #252525); padding-left: 10px; padding-right: 10px; }
.insp-sec { padding: 6px 0; }
.insp-sec + .insp-sec { border-top: 0; }
.insp-h { font-size: var(--fs-body); font-weight: 600; color: var(--text2); margin: 4px 10px 6px; }
.insp-big { margin: 0 10px 8px; }
.insp-card { border-radius: 10px; background: light-dark(#efefef, #2b2b2b); padding: 0 10px; }
.insp-card > * { padding: 9px 0; line-height: 18px; }
.insp-card > * + * { border-top: 1px solid light-dark(rgba(0,0,0,.07), rgba(255,255,255,.09)); }
.insp-card .insp-row > :first-child { color: var(--text); flex: none; }
.insp-card .insp-row > :last-child { color: var(--text2); min-width: 0; overflow-wrap: anywhere; }
.insp-foot { margin: 6px 10px 0; }
.insp-note { padding: 9px 10px; border-radius: 10px; background: light-dark(#efefef, #2b2b2b); white-space: pre-wrap; }
.insp-btns { margin-left: 0; }
.insp-push { border-radius: 8px; background: var(--btn); cursor: default; }
.insp-push:active { filter: brightness(1.2); }
/* view tabs inside a window (NSTabView, 27.3): neutral glass selection; the accent one (.seg in forms) is a Picker */
html.mac .seg-wrap .seg { height: 26px; max-width: none; padding: 2px; border-radius: 8px; background: var(--btn); }
html.mac .seg-wrap .seg button { flex: none; height: 22px; padding: 0 12px; border-radius: 6px; font-size: 13px; font-weight: 400; color: var(--text); background: none; }
html.mac .seg-wrap .seg button:hover { background: light-dark(rgba(0,0,0,.04), rgba(255,255,255,.05)); }
html.mac .seg-wrap .seg button.on { background: light-dark(#fff, #4a4a4a); color: var(--text); box-shadow: 0 .5px 1.5px light-dark(rgba(0,0,0,.25), transparent), inset 0 .5px 0 light-dark(transparent, rgba(255,255,255,.35)); }
/* Pointer (HIG ▸ Pointing devices): the arrow everywhere; the pointing hand only over text links; I-beam in text */
html.mac button, html.mac select, html.mac label, html.mac summary, html.mac [role=button], html.mac input[type=checkbox], html.mac a.row, html.mac a.rh-btn, html.mac a.btn-tinted, html.mac a.tb-btn, html.mac a.sb-link, html.mac a.insp-push, html.mac a.kpi, html.mac a.pin, html.mac a.stand-card, html.mac a.lc-row, html.mac a.cc-act { cursor: default; }
/* Finder Group By heading */
.tbl tr.grp td { height: 32px; padding: 8px 8px 2px; vertical-align: bottom; background: none !important; }
.grp-in { display: flex; justify-content: space-between; font-weight: 700; }
.mb-item, .kpi { -webkit-user-select: none; user-select: none; }
