/* =====================================================================================================================
   macOS look. Window chrome, sidebar and glass toolbar groups come from Puppertino (vendor/puppertino, MIT);
   this layer maps the Sutra tokens onto them and gives every other surface the same quiet, material feel.
   Colours stay tokens (multitype-skills.md section 2): one accent, brand gradient only on the hero and the logo.
   ===================================================================================================================== */
:root {
  --mac-hair: color-mix(in srgb, var(--label) 11%, transparent);
  --mac-lift: 0 0 0 .5px var(--mac-hair), 0 1px 2px rgba(15, 23, 42, .05), 0 6px 18px rgba(15, 23, 42, .04);
  --mac-ring: 0 0 0 3.5px color-mix(in srgb, var(--accent) 32%, transparent);
  --p-vibrant-blue: var(--accent);
  --p-sidebar-material: #E8ECF4;
  --p-sidebar-material-inactive: #EEF1F7;
  --p-sidebar-text: var(--label);
  --p-sidebar-text-dim: var(--label3);
  --p-sidebar-selected: color-mix(in srgb, var(--accent) 14%, transparent);
  --p-sidebar-hover: color-mix(in srgb, var(--label) 5%, transparent);
  --p-sidebar-icon: var(--accent);
  --p-sidebar-detail: var(--label3);
  --p-window-band: color-mix(in srgb, var(--surface) 78%, transparent);
  --p-window-separator: var(--mac-hair);
  --p-window-title: var(--label);
}
:root[data-theme="dark"] {
  --mac-hair: color-mix(in srgb, #fff 12%, transparent);
  --mac-lift: 0 0 0 .5px var(--mac-hair), 0 1px 2px rgba(0, 0, 0, .4), 0 6px 18px rgba(0, 0, 0, .28);
  --p-sidebar-material: #0E1424;
  --p-sidebar-material-inactive: #0F1526;
  --p-window-band: color-mix(in srgb, var(--surface) 70%, transparent);
}
html, body { background: var(--bg); }
.win.mac { background: var(--bg); }

/* ---- unified title bar + toolbar ---- */
.mac-tb { background: var(--surface); }
.mac-tb .p-window-titlebar-row { height: 52px; padding: 0 12px; gap: 10px; }
.mac-logo { width: 22px; height: 22px; border-radius: 6px; flex: none; }
.mac-tb .p-window-titles { min-width: 130px; flex: none; }
.mac-tb .p-window-title { font: 700 13px var(--ui); letter-spacing: -.1px; color: var(--label); }
.mac-tb .p-window-subtitle { font: 500 11px var(--ui); color: var(--label3); }
.mac-tb .p-window-spacer { flex: 1; min-width: 6px; }
.mac-tb .p-traffic-lights { gap: 8px; margin-right: 4px; }
.mac-tb .p-traffic-light { width: 12px; height: 12px; }
.mac-tb:hover .p-traffic-light-close::after, .mac-tb:hover .p-traffic-light-min::after, .mac-tb:hover .p-traffic-light-zoom::after { opacity: .55; }
.mac-glass { background: var(--surface); box-shadow: var(--mac-lift); border-radius: 10px; height: 32px; padding: 0 2px; gap: 1px; }
.mac-glass .p-toolbar-btn { height: 26px; border-radius: 8px; color: var(--label); font: 500 13px var(--deva); gap: 6px; padding: 0 9px; min-width: 28px; }
.mac-glass .p-toolbar-btn:hover { background: color-mix(in srgb, var(--label) 7%, transparent); }
.mac-glass .p-toolbar-btn:active { background: color-mix(in srgb, var(--accent) 16%, transparent); }
.mac-glass .ico { width: 16px; height: 16px; }
.mac-glass .kbd { margin-left: 2px; }
.mac-date { font-weight: 700 !important; min-width: 210px; }
.mac-date .faint { font-weight: 500; }
.mac-sel { appearance: none; -webkit-appearance: none; border: 0; background: transparent; color: var(--label); font: 500 13px var(--deva); height: 26px; padding: 0 10px; border-radius: 8px; cursor: pointer; outline: none; }
.mac-sel:hover { background: color-mix(in srgb, var(--label) 7%, transparent); }
.mac-sel option { color: #0F172A; background: #fff; }

/* ---- sidebar (source list) ---- */
.wbody { grid-template-columns: 224px 1fr; }
.mac-side { width: auto; padding: 12px 10px; display: flex; flex-direction: column; gap: 1px; overflow-y: auto; border-right: .5px solid var(--mac-hair); background: var(--p-sidebar-material); }
.mac-side .p-sidebar-header { font: 700 11px var(--ui); letter-spacing: .6px; text-transform: uppercase; color: var(--label3); min-height: 26px; margin-top: 12px; padding: 0 10px; }
.mac-side .p-sidebar-header:first-child { margin-top: 2px; }
.mac-row { height: 42px; border-radius: 9px; padding: 0 10px; gap: 0; text-align: left; width: 100%; background: none; border: 0; cursor: pointer; transition: background .16s ease, transform .22s var(--spring); }
.mac-row:active { transform: scale(.985); }
.mac-row .p-sidebar-icon { width: 22px; height: 22px; margin-right: 11px; color: var(--accent); display: grid; place-items: center; }
.mac-row .p-sidebar-icon .ico { width: 20px; height: 20px; }
.mac-lbl { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.15; text-align: left; }
.mac-lbl .lbl { font: 600 15px var(--deva); color: var(--label); }
.mac-lbl .sub { font: 500 10.5px var(--ui); color: var(--label3); }
.mac-row.p-selected { background: color-mix(in srgb, var(--accent) 16%, transparent); }
.mac-row.p-selected .lbl { color: var(--accent); }
.mac-row .p-sidebar-detail { font: 600 10px var(--ui); color: var(--label3); border: .5px solid var(--mac-hair); border-radius: 5px; padding: 1px 5px; background: color-mix(in srgb, var(--surface) 65%, transparent); }
.mac-grow { flex: 1; }
.mac-foot { font: 500 11px/1.5 var(--ui); color: var(--label3); padding: 10px; }

/* ---- surfaces: grouped, hairline-lit, soft ---- */
.card, .tbl-wrap, .panel, .chart, .fact, .sun2, .hero { border: 0 !important; box-shadow: var(--mac-lift) !important; }
.card, .tbl-wrap, .panel, .chart { border-radius: 12px; }
.fact { border-radius: 10px; }
.hero { border-radius: 16px; box-shadow: 0 0 0 .5px rgba(255, 255, 255, .18) inset, 0 10px 30px rgba(30, 60, 114, .22) !important; }
.sheet { border-radius: 14px; box-shadow: 0 0 0 .5px var(--mac-hair), 0 24px 70px rgba(0, 0, 0, .38); }
.scrim { backdrop-filter: blur(6px) saturate(120%); }

/* tables: quiet header, hairline rows */
th { background: color-mix(in srgb, var(--surface) 86%, var(--surface-alt)); color: var(--label2); font: 600 11.5px var(--deva); text-transform: none; letter-spacing: .1px; border-bottom: .5px solid var(--mac-hair); }
thead { position: sticky; top: 0; z-index: 1; }
td { border-top: .5px solid var(--mac-hair); }
tbody tr:nth-child(even) { background: color-mix(in srgb, var(--label) 2.6%, transparent); }
tbody tr:hover { background: color-mix(in srgb, var(--accent) 9%, transparent); }
tbody tr.today { background: color-mix(in srgb, var(--accent) 16%, transparent); box-shadow: none; }
tbody tr.today td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.panel > h3 { background: color-mix(in srgb, var(--surface) 86%, var(--surface-alt)); color: var(--label); text-align: left; font: 700 13.5px var(--deva); padding: 9px 14px; border-bottom: .5px solid var(--mac-hair); }
.panel > h4 { background: transparent; text-align: left; padding: 7px 14px 2px; font: 600 11.5px var(--ui); color: var(--label3); text-transform: uppercase; letter-spacing: .5px; }
.mrow { border-top: .5px solid var(--mac-hair); }
.mrow.hot { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.row { border-top: .5px solid var(--mac-hair); }
.event, saved, .saved { border-top-color: var(--mac-hair); }

/* controls */
.btn { border-radius: 7px; min-height: 30px; padding: 5px 15px; font: 600 13px var(--ui); background: linear-gradient(color-mix(in srgb, var(--accent) 92%, #fff), var(--accent)); box-shadow: 0 .5px 1px rgba(0, 0, 0, .25), inset 0 .5px 0 rgba(255, 255, 255, .28); }
.btn:hover { filter: brightness(1.06); }
.btn:active { filter: brightness(.94); transform: none; }
.btn.alt, .btn.ghost { background: var(--surface); color: var(--label); box-shadow: var(--mac-lift); }
.btn.alt:hover, .btn.ghost:hover { background: color-mix(in srgb, var(--label) 4%, var(--surface)); filter: none; }
.btn.ghost { color: var(--label2); }
.seg { background: color-mix(in srgb, var(--label) 7%, transparent); border-radius: 9px; padding: 2px; gap: 0; }
.seg button { min-height: 26px; padding: 3px 14px; border-radius: 7px; font: 500 13px var(--deva); }
.seg button.on { background: var(--surface); color: var(--label); font-weight: 600; box-shadow: 0 .5px 2px rgba(0, 0, 0, .22), 0 0 0 .5px var(--mac-hair); }
.in { border-radius: 7px; background: var(--surface); border: 0; box-shadow: 0 0 0 .5px var(--mac-hair), inset 0 1px 1px rgba(15, 23, 42, .05); min-height: 30px; padding: 4px 10px; font: 500 14px var(--ui); }
.in:focus { box-shadow: var(--mac-ring), 0 0 0 .5px var(--accent); border-color: transparent; }
select.in { appearance: none; -webkit-appearance: none; padding-right: 26px; background-image: linear-gradient(45deg, transparent 50%, var(--label3) 50%), linear-gradient(135deg, var(--label3) 50%, transparent 50%); background-position: calc(100% - 15px) 50%, calc(100% - 10px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.chip { background: var(--surface); box-shadow: var(--mac-lift); min-height: 30px; border-radius: 8px; font-size: 13.5px; }
.chip:hover { background: color-mix(in srgb, var(--accent) 8%, var(--surface)); }
.tabs { background: color-mix(in srgb, var(--label) 7%, transparent); border-radius: 10px; padding: 2px; gap: 0; }
.tabs button { min-height: 28px; padding: 2px 14px; border-radius: 8px; font: 500 14px var(--deva); }
.tabs button.on { background: var(--surface); color: var(--label); box-shadow: 0 .5px 2px rgba(0, 0, 0, .22), 0 0 0 .5px var(--mac-hair); }
.doctabs { border-bottom: .5px solid var(--mac-hair); }
.doctabs button.on { background: var(--surface); border: 0; box-shadow: 0 -1px 0 0 var(--accent) inset, 0 0 0 .5px var(--mac-hair); }
.round { background: rgba(255, 255, 255, .2); backdrop-filter: blur(8px); }
.pal .li button.sel { background: var(--accent); color: #fff; }
.pal .li button.sel .kbd { color: #fff; border-color: rgba(255, 255, 255, .5); background: transparent; }
.sb { background: color-mix(in srgb, var(--surface) 80%, transparent); border-top: .5px solid var(--mac-hair); backdrop-filter: blur(16px); }
.page { padding: 18px 26px 32px; }
.top h1 { font: 700 26px var(--deva); letter-spacing: -.4px; }

/* scrollbars: thin overlay thumbs */
.main, .mac-side, .tbl-wrap, .lib, .plist, .sheet { scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--label) 28%, transparent) transparent; }

@media (max-width: 1320px) { .mac-tb .p-window-titles, .mac-logo { display: none; } .mac-date { min-width: 160px; } .mac-glass .kbd, #cpal span:not(.kbd) { display: none; } }
@media (max-width: 900px) {
  .wbody { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .mac-side { flex-direction: row; order: 2; border-right: 0; border-top: .5px solid var(--mac-hair); overflow-x: auto; padding: 4px; }
  .mac-side .p-sidebar-header, .mac-grow, .mac-foot, .mac-row .p-sidebar-detail, .mac-lbl .sub { display: none; }
  .mac-row { flex-direction: column; justify-content: center; height: 48px; min-width: 64px; }
  .mac-row .p-sidebar-icon { margin: 0; } .mac-lbl .lbl { font-size: 11px; }
}

/* ---- Windows caption row: minimise, maximise / restore, close (standard 46 x 32 buttons) ---- */
.win-tb { display: flex; flex-direction: column; }
.win-caption { display: flex; align-items: center; height: 32px; padding-left: 10px; gap: 8px; }
.win-caption .mac-logo { width: 16px; height: 16px; border-radius: 4px; }
.win-title { flex: 1; min-width: 0; font: 500 12px var(--ui); color: var(--label2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: 0; }
.win-sub { color: var(--label3); }
.win-sub:not(:empty)::before { content: "  ·  "; white-space: pre; }
.win-ctl { display: flex; height: 100%; margin-left: auto; }
.win-btn { width: 46px; height: 32px; display: grid; place-items: center; border-radius: 0; color: var(--label); background: transparent; transition: background .12s ease; }
.win-btn svg { width: 10px; height: 10px; fill: none; stroke: currentColor; stroke-width: 1; stroke-linecap: square; shape-rendering: crispEdges; }
.win-btn:hover { background: color-mix(in srgb, var(--label) 9%, transparent); }
.win-btn:active { background: color-mix(in srgb, var(--label) 15%, transparent); }
.win-close:hover { background: #E81123; color: #fff; }
.win-close:active { background: #F1707A; color: #fff; }
.mac-toolbar.p-window-titlebar-row { height: 44px; padding: 0 12px 6px; }
.mac-tb .p-window-titlebar-row.mac-toolbar { align-items: center; }
