/* Apple UI Kit — macOS 27 app structure: window, sidebar, toolbar, split view, list column, detail pane, Finder table, overlay scroll bars.
   Separate from mac.css so an app can adopt the components first and the structure later. */

/* ---------- window shell: sidebar | content ---------- */
html.mac body { overflow: hidden; }
.mac-window { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); height: 100vh; height: 100dvh; }
.mac-window.sb-hidden { grid-template-columns: 0 minmax(0, 1fr); }
.mac-window.sb-hidden .sidebar { visibility: hidden; }

/* ---------- sidebar (source list) — M-Mail, M-Notes ---------- */
.sidebar { position: relative; display: flex; flex-direction: column; min-height: 0; background: var(--sidebar); box-shadow: inset -.5px 0 0 var(--sidebar-edge); }
.sb-top { position: relative; z-index: 2; display: flex; align-items: center; justify-content: flex-end; gap: 8px; height: var(--toolbar-h); padding: 0 8px 0 10px; flex: none; }
.sb-top .tb-search { flex: 1 1 0; width: auto; min-width: 0; margin: 0; }
.sb-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 4px 10px 16px; scrollbar-width: none; }
.sb-scroll::-webkit-scrollbar { display: none; }
.sb-sec + .sb-sec { margin-top: 10px; }
.sb-h { display: flex; align-items: center; justify-content: space-between; height: 26px; padding: 0 10px; font-size: var(--fs-head); font-weight: 600; color: var(--text2); border: 0; background: none; width: 100%; text-align: left; }
.sb-h .sb-fold { width: 10px; height: 10px; opacity: 0; transition: transform .2s, opacity .15s; }
.sb-h:hover .sb-fold { opacity: .8; }
.sb-sec.folded .sb-fold { transform: rotate(-90deg); }
.sb-sec.folded .sb-link { display: none; }
.sb-link { display: flex; align-items: center; gap: 8px; height: var(--sb-row); padding: 0 10px; border-radius: 10px; color: var(--text); font-size: var(--fs-body); text-decoration: none; }
.sb-link svg { width: 17px; height: 17px; color: var(--accent); stroke-width: 1.8; flex: none; }
.sb-link span { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-link .count { flex: none; color: var(--text2); font-size: var(--fs-body); }
.sb-link.on { background: var(--select); font-weight: 600; }
.sidebar.focus .sb-link.on { background: var(--accent); color: #fff; }
.sidebar.focus .sb-link.on svg, .sidebar.focus .sb-link.on .count { color: #fff; }

/* ---------- toolbar (unified, no bar or line; glass controls) — M-SR, M-Mail, M-Notes ---------- */
.content { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); }
.toolbar { position: absolute; top: 0; left: 0; right: 0; z-index: 20; display: flex; align-items: center; gap: 8px; height: var(--toolbar-h); padding: 0 8px 0 16px; pointer-events: none; }
.toolbar > * { pointer-events: auto; }
.toolbar::before { /* scroll edge: content passing under the toolbar is frosted and fades out (GHL #ggGlass) */
  content: ""; position: absolute; inset: 0 0 -32px; z-index: -1; opacity: 0; pointer-events: none; transition: opacity .2s;
  background: color-mix(in srgb, var(--bg) var(--edge-tint), transparent); -webkit-backdrop-filter: var(--edge-blur); backdrop-filter: var(--edge-blur);
  -webkit-mask-image: linear-gradient(#000 62%, transparent); mask-image: linear-gradient(#000 62%, transparent); }
.toolbar.scrolled::before { opacity: 1; }
@media (prefers-reduced-transparency: reduce) { .toolbar::before { background: var(--bg); -webkit-backdrop-filter: none; backdrop-filter: none; } }
.toolbar .spacer { flex: 1; pointer-events: none; }
.tb-titles { display: flex; flex-direction: column; justify-content: center; min-width: 0; padding: 0 4px; }
.tb-title { font-size: var(--fs-title); font-weight: 700; line-height: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-sub { font-size: var(--fs-sub); line-height: 14px; color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.scroller { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding-top: var(--toolbar-h); }

/* glass toolbar buttons: round 36 pt; text capsule; a capsule of several related buttons (Mail: reply / reply all / forward) */
.tb-btn, .tb-group, .tb-search, .tb-pop { background: var(--gbtn); box-shadow: var(--gbtn-shadow); -webkit-backdrop-filter: var(--gblur); backdrop-filter: var(--gblur); }
.tb-btn { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 5px; width: var(--tbtn); height: var(--tbtn); padding: 0; border: 0; border-radius: 999px; color: var(--text); font-size: var(--fs-body); font-weight: 500; flex: none; }
.tb-btn svg { width: 18px; height: 18px; stroke-width: 1.7; }
.tb-btn:hover { background: var(--gbtn-hover); }
.tb-btn:disabled { color: var(--text3); }
.tb-btn.text { width: auto; padding: 0 14px; }
.tb-btn.prominent { background: var(--accent); color: #fff; }
.tb-group { display: inline-flex; align-items: center; height: var(--tbtn); padding: 0 4px; border-radius: 999px; flex: none; }
.tb-group .tb-btn { background: none; box-shadow: none; -webkit-backdrop-filter: none; backdrop-filter: none; width: 34px; }
.tb-group .tb-btn:hover { background: var(--fill); }
.tb-group .tb-btn + .tb-btn::before { content: ""; position: absolute; left: -1px; top: 10px; bottom: 10px; border-left: 1px solid var(--fill); }
.tb-pop { height: var(--tbtn); padding: 0 12px 0 14px; border-radius: 999px; }
.tb-pop select { height: var(--tbtn); font-size: var(--fs-body); font-weight: 500; padding-right: 18px; }
.tb-pop .pop-ic { right: 10px; width: 12px; height: 12px; }
.tb-search { display: flex; align-items: center; gap: 6px; width: 220px; height: var(--tbtn); padding: 0 12px; border-radius: 999px; color: var(--text2); flex: none; }
.tb-search svg { width: 15px; height: 15px; flex: none; }
.tb-search input { flex: 1; min-width: 0; border: 0; background: none; outline: none; font-size: var(--fs-body); color: var(--text); }
.tb-search:focus-within { box-shadow: var(--gbtn-shadow), 0 0 0 3px color-mix(in srgb, var(--accent) 50%, transparent); }
.tb-badge { position: absolute; top: -3px; right: -3px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--red); color: #fff; font-size: 10px; font-weight: 700; line-height: 16px; text-align: center; }

/* ---------- split view: list column | detail (Mail, Notes, Contacts) ---------- */
.split { flex: 1; display: grid; grid-template-columns: var(--list-w) minmax(0, 1fr); min-height: 0; height: 100%; }
.split > .list-col { position: relative; display: flex; flex-direction: column; min-height: 0; box-shadow: inset -.5px 0 0 var(--divider); }
.split > .detail { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.split-handle { position: absolute; top: 0; bottom: 0; right: -3px; width: 6px; cursor: col-resize; z-index: 25; }
.list-col .scroller { padding-left: 10px; padding-right: 10px; }

/* list rows: rounded selection inset 10 pt, 0.5 pt separators inset to the text — M-Notes, M-Mail, M-Contacts */
.lc-sec { position: sticky; top: 0; z-index: 3; padding: 14px 10px 6px; font-size: var(--fs-section); font-weight: 700; background: var(--bg); }
.lc-row { position: relative; display: flex; gap: 10px; align-items: center; width: 100%; padding: 9px 10px; border: 0; border-radius: 10px; background: none; color: var(--text); text-align: left; cursor: default; outline: none; }
.lc-row + .lc-row::before { content: ""; position: absolute; top: 0; left: 10px; right: 10px; border-top: .5px solid var(--sep); }
.lc-row.with-avatar + .lc-row.with-avatar::before { left: 56px; }
.lc-row.sel::before, .lc-row.sel + .lc-row::before { display: none; }
.lc-row.sel { background: var(--select); }
.list-col.focus .lc-row.sel { background: var(--list-sel); color: #fff; }
.list-col.focus .lc-row.sel :is(.lc-sub, .lc-date, .lc-prev, .lc-end) { color: rgba(255,255,255,.82); }
.lc-main { flex: 1; min-width: 0; }
.lc-top { display: flex; align-items: baseline; gap: 8px; }
.lc-title { flex: 1; min-width: 0; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lc-date, .lc-end { flex: none; color: var(--text2); font-variant-numeric: tabular-nums; }
.lc-end { font-weight: 600; color: var(--text); }
.lc-line { margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lc-sub { margin-top: 2px; color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lc-prev { margin-top: 2px; color: var(--text2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 17px; }
.lc-row .avatar { width: 32px; height: 32px; font-size: 13px; }
.lc-row .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.lc-row.mail { align-items: flex-start; padding: 10px 10px 11px; }
.lc-empty { padding: 60px 20px; text-align: center; color: var(--text2); }

/* ---------- detail pane ---------- */
.detail .scroller { padding-left: 24px; padding-right: 24px; }
.detail-empty { flex: 1; display: grid; place-items: center; color: var(--text2); font-size: 17px; font-weight: 600; }
.readable { max-width: 680px; margin: 0 auto; }   /* System Settings / Contacts keep a readable column, centred */

/* ---------- Finder table (list view) — M-SR Table ---------- */
.table-page .scroller { padding: var(--toolbar-h) 0 0; }
.tbl-wrap { position: relative; }
.tbl { width: 100%; border-collapse: separate; border-spacing: 0; table-layout: fixed; font-size: var(--fs-body); }
.tbl th { position: sticky; top: 0; z-index: 2; height: 28px; padding: 0 8px; text-align: left; font-size: var(--fs-head); font-weight: 500; color: var(--text2); white-space: nowrap; cursor: default; user-select: none;
  background: color-mix(in srgb, var(--band) 55%, transparent); -webkit-backdrop-filter: var(--edge-blur); backdrop-filter: var(--edge-blur); border-bottom: 1px solid var(--tbl-line); }
.tbl th:first-child { padding-left: 18px; } .tbl td:first-child { padding-left: 18px; }
.tbl th + th::before { content: ""; position: absolute; left: 0; top: 7px; bottom: 7px; border-left: 1px solid var(--tbl-line); }
.tbl th.sorted { color: var(--text); font-weight: 700; }
.tbl th.r, .tbl td.r { text-align: right; }
.tbl .sort-ic { display: inline-block; width: 10px; height: 10px; margin-left: 3px; vertical-align: middle; stroke-width: 2.6; }
.tbl td { height: 24px; padding: 0 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tbl tbody tr { cursor: default; outline: none; }
.tbl tbody tr:nth-child(even) td { background: var(--alt); }
.tbl tbody tr td:first-child { border-radius: 6px 0 0 6px; } .tbl tbody tr td:last-child { border-radius: 0 6px 6px 0; }   /* inset rounded stripes */
.tbl tbody tr.sel td { background: var(--select); }
.tbl:focus-within tbody tr.sel td { background: var(--list-sel); color: #fff; }
.tbl:focus-within tbody tr.sel td * { color: #fff !important; }
/* neighbouring selected rows join into one rounded block (Finder) */
.tbl tbody tr.sel-up td:first-child { border-top-left-radius: 0; } .tbl tbody tr.sel-up td:last-child { border-top-right-radius: 0; }
.tbl tbody tr.sel-down td:first-child { border-bottom-left-radius: 0; } .tbl tbody tr.sel-down td:last-child { border-bottom-right-radius: 0; }
.tbl tfoot td { font-weight: 600; border-top: 1px solid var(--tbl-line); }
.tbl-inset { margin: 0 10px; }

/* ---------- overlay scroll bars (macOS draws thin thumbs only while scrolling) ---------- */
html.mac .scroller, html.mac .inspector { scrollbar-width: thin; scrollbar-color: transparent transparent; }
html.mac .scroller:hover, html.mac .inspector:hover { scrollbar-color: var(--text3) transparent; }
.detail > .with-inspector, .detail > .scroller { flex: 1; min-height: 0; }
.with-inspector > .doc-canvas { overflow-y: auto; min-height: 0; }

/* list column extras (added 24 Nov for TieBond): a search field pinned at the top of the list (Contacts), dimmed rows (void),
   coloured trailing amounts, a small lead symbol */
.lc-search { position: relative; display: flex; align-items: center; gap: 6px; height: 30px; margin: 2px 0 8px; padding: 0 10px; border-radius: 999px;
  background: var(--fill2, rgba(127,127,127,.1)); color: var(--text2); }
.lc-search:focus-within { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 50%, transparent); }
.lc-search svg { width: 14px; height: 14px; flex: none; }
.lc-search input { flex: 1; min-width: 0; border: 0; background: none; outline: none; font-size: var(--fs-body); color: var(--text); }
.lc-search input::-webkit-search-cancel-button { -webkit-appearance: none; }
.lc-search .lc-clear { display: grid; place-items: center; width: 16px; height: 16px; padding: 0; border: 0; border-radius: 50%; background: var(--text3); color: var(--bg); }
.lc-search .lc-clear svg { width: 8px; height: 8px; stroke-width: 3; }
.lc-search .lc-clear[hidden] { display: none; }
.lc-row.dim :is(.lc-title, .lc-line, .lc-end) { color: var(--text2); }
.lc-row.dim .lc-end { text-decoration: line-through; }
.lc-end.neg { color: var(--red); }
.lc-end.warn { color: var(--orange-text); }
.list-col.focus .lc-row.sel .lc-end { color: #fff; }
.lc-row > .lead { flex: none; }
.lc-row .state { font-size: 11px; }
.list-col .empty-state { padding: 60px 12px; }
