/* ════════════════════════════════════════════════════════════════════
   PHYSEA COMPONENT LIBRARY  ·  physea-components.css
   The shared, reusable component kit. Link it AFTER the palette + skin:

     <link rel="stylesheet" href=".../physea-tokens.css">   (palette — required)
     <link rel="stylesheet" href=".../physea-skin.css">     (cursor/scrollbar/.skin-card — required)
     <link rel="stylesheet" href=".../physea-components.css"><!-- this file -->

   Everything here references design-system tokens (var(--paper), --ink,
   --primary, --rule, --font-*, --button-radius, --radius-*) so a palette edit
   in physea-tokens.css re-skins all of it — light AND dark — for free.
   Photoreal language (raised clay, layered shadows, surface gradients, glass).
   Cascade order matters: tokens → skin → components → any page-inline overrides.
   ════════════════════════════════════════════════════════════════════ */

/* ════════════════ BUTTONS ════════════════ */
.b {
  font-family: var(--font-ui); font-weight: 600; font-size: 14px; line-height: 1;
  padding: 11px 20px; border-radius: var(--button-radius); cursor: pointer;
  display: inline-flex; align-items: center; gap: 9px; white-space: nowrap;
  border: 1px solid var(--rule); color: var(--ink);
  background: linear-gradient(168deg, color-mix(in srgb, var(--paper-2) 38%, white 10%), var(--paper-2) 60%, color-mix(in srgb, var(--paper-2) 72%, black 6%));
  box-shadow: 0 1px 0 rgba(255,255,255,.55) inset, 0 2px 4px rgba(0,0,0,.06), 0 10px 22px rgba(0,0,0,.12);
  transition: transform .08s ease, box-shadow .15s ease, filter .15s ease;
}
.b:hover { filter: brightness(1.03); box-shadow: 0 1px 0 rgba(255,255,255,.6) inset, 0 3px 6px rgba(0,0,0,.08), 0 14px 30px rgba(0,0,0,.16); }
.b:active { transform: translateY(1px); box-shadow: 0 1px 0 rgba(255,255,255,.4) inset, 0 1px 2px rgba(0,0,0,.1); }
.b:focus-visible { outline: none; box-shadow: 0 1px 0 rgba(255,255,255,.55) inset, 0 2px 4px rgba(0,0,0,.06), 0 0 0 3px color-mix(in srgb, var(--primary) 45%, transparent); }
.b--primary {
  color: var(--paper); border-color: transparent;
  background: radial-gradient(120% 160% at 30% 0%, color-mix(in srgb, var(--primary) 86%, white 14%) 0%, var(--primary) 60%, color-mix(in srgb, var(--primary) 72%, black 16%) 100%);
  box-shadow: 0 1px 0 rgba(255,255,255,.3) inset, 0 2px 4px rgba(0,0,0,.1), 0 14px 30px color-mix(in srgb, var(--primary) 38%, transparent);
}
.b--accent {
  color: var(--paper); border-color: transparent;
  background: radial-gradient(120% 160% at 30% 0%, color-mix(in srgb, var(--accent) 88%, white 12%) 0%, var(--accent) 60%, color-mix(in srgb, var(--accent) 72%, black 14%) 100%);
  box-shadow: 0 1px 0 rgba(255,255,255,.3) inset, 0 2px 4px rgba(0,0,0,.1), 0 14px 30px color-mix(in srgb, var(--accent) 38%, transparent);
}
.b--ghost { background: transparent; color: var(--ink); border: 1px solid color-mix(in srgb, var(--ink) 50%, transparent); box-shadow: none; } /* rule-bold measured 1.97; border is the only affordance */
.b--ghost:hover { background: var(--rule-soft); box-shadow: none; }
.b:disabled, .b[disabled] { opacity: .45; cursor: not-allowed; filter: grayscale(.3); box-shadow: none; }
.b:disabled:active { transform: none; }
.b.is-loading { pointer-events: none; opacity: .75; }
.b.is-loading::before {
  content: ""; width: 1em; height: 1em; flex: none; border-radius: 50%;
  border: 2px solid color-mix(in srgb, currentColor 30%, transparent);
  border-top-color: currentColor; animation: spin .8s linear infinite;
}
@media (prefers-reduced-motion: reduce) {
  .b.is-loading::before { animation: none; border-top-color: color-mix(in srgb, currentColor 30%, transparent); border-style: dashed; }
}
.b--sm { padding: 7px 14px; font-size: 12.5px; border-radius: calc(var(--button-radius) - 4px); }
.b--lg { padding: 15px 28px; font-size: 16px; border-radius: calc(var(--button-radius) + 2px); }
.b--icon { padding: 11px; width: 42px; height: 42px; justify-content: center; }
.b .ico { font-size: 1.05em; line-height: 1; }
.b .lead-pip { width: 8px; height: 8px; border-radius: 50%; background: var(--status); box-shadow: 0 0 0 3px color-mix(in srgb, var(--status) 28%, transparent); }
.b--primary .lead-pip { background: var(--paper); box-shadow: 0 0 0 3px color-mix(in srgb, var(--paper) 30%, transparent); }

/* ════════════════ FORM FIELDS ════════════════ */
.field { display: flex; flex-direction: column; gap: 7px; }
.field > label { font-family: var(--font-mono); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-2); }
.inp {
  font-family: var(--font-ui); font-size: 14px; color: var(--ink);
  padding: 11px 14px; border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--paper-3) 30%, var(--paper));
  border: 1px solid color-mix(in srgb, var(--ink) 50%, transparent); /* 3:1 control boundary (AA 1.4.11) */
  box-shadow: inset 2px 2px 6px rgba(0,0,0,.10), inset -1px -1px 0 rgba(255,255,255,.4);
  outline: none; width: 100%; transition: border-color .15s, box-shadow .15s;
}
.inp::placeholder { color: var(--ink-3); opacity: 1; } /* ink-2@.55 measured 2.33; ink-3 is 4.71/6.33 */
.inp:focus { border-color: var(--primary); box-shadow: inset 2px 2px 6px rgba(0,0,0,.10), 0 0 0 3px color-mix(in srgb, var(--primary) 22%, transparent); }
textarea.inp { resize: vertical; min-height: 92px; line-height: 1.5; }
select.inp { appearance: none; -webkit-appearance: none; cursor: pointer; background-image: none; }
.select-wrap { position: relative; }
.select-wrap::after { content: "▾"; position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--primary); pointer-events: none; font-size: 12px; }
.search-wrap { position: relative; }
.search-wrap .ico { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--ink-2); opacity: .7; pointer-events: none; }
.search-wrap .inp { padding-left: 38px; }
.helper { font-family: var(--font-ui); font-size: 12px; color: var(--ink-2); }
.field.is-error .inp { border-color: var(--primary); box-shadow: inset 2px 2px 6px rgba(0,0,0,.08), 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent); }
.field.is-error .helper { color: var(--primary); opacity: 1; font-weight: 500; }

/* ════════════════ TOGGLES ════════════════ */
.switch { position: relative; display: inline-flex; align-items: center; gap: 12px; cursor: pointer; user-select: none; font-family: var(--font-ui); font-size: 14px; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track {
  width: 46px; height: 27px; border-radius: var(--radius-pill); position: relative; flex: none;
  background: color-mix(in srgb, var(--paper-3) 40%, var(--paper));
  border: 1px solid color-mix(in srgb, var(--ink) 50%, transparent); /* 3:1 control boundary (AA 1.4.11) */
  box-shadow: inset 2px 2px 5px rgba(0,0,0,.14), inset -1px -1px 0 rgba(255,255,255,.4);
  transition: background .2s;
}
.switch .knob {
  position: absolute; top: 2px; left: 2px; width: 21px; height: 21px; border-radius: 50%;
  background: linear-gradient(168deg, color-mix(in srgb, var(--paper) 60%, white 30%), var(--paper-2));
  box-shadow: 0 1px 0 rgba(255,255,255,.6) inset, 0 2px 5px rgba(0,0,0,.28);
  transition: transform .2s cubic-bezier(.4,1.3,.5,1);
}
.switch input:checked + .track { background: radial-gradient(120% 160% at 30% 0%, color-mix(in srgb, var(--primary) 86%, white 12%), var(--primary)); border-color: transparent; }
.switch input:checked + .track .knob { transform: translateX(19px); }
.switch input:focus-visible + .track { box-shadow: inset 2px 2px 5px rgba(0,0,0,.14), inset -1px -1px 0 rgba(255,255,255,.4), 0 0 0 3px color-mix(in srgb, var(--primary) 45%, transparent); }

.check, .radio { display: inline-flex; align-items: center; gap: 11px; cursor: pointer; user-select: none; font-family: var(--font-ui); font-size: 14px; }
.check input, .radio input { position: absolute; opacity: 0; width: 0; height: 0; }
.check .box {
  width: 22px; height: 22px; border-radius: var(--radius-xs); flex: none; position: relative;
  background: color-mix(in srgb, var(--paper-3) 30%, var(--paper));
  border: 1px solid color-mix(in srgb, var(--ink) 50%, transparent); /* 3:1 control boundary (AA 1.4.11) */
  box-shadow: inset 2px 2px 5px rgba(0,0,0,.12), inset -1px -1px 0 rgba(255,255,255,.4);
  transition: background .15s, border-color .15s;
}
.check .box::after { content: ""; position: absolute; left: 7px; top: 3px; width: 5px; height: 10px; border: solid var(--paper); border-width: 0 2.5px 2.5px 0; transform: rotate(45deg) scale(0); transition: transform .15s cubic-bezier(.4,1.4,.5,1); }
.check input:checked + .box { background: radial-gradient(120% 160% at 30% 0%, color-mix(in srgb, var(--primary) 86%, white 12%), var(--primary)); border-color: transparent; }
.check input:checked + .box::after { transform: rotate(45deg) scale(1); }
.radio .box { border-radius: 50%; width: 22px; height: 22px; }
.radio .box::after { content: ""; position: absolute; inset: 0; margin: auto; width: 9px; height: 9px; border-radius: 50%; background: var(--paper); transform: scale(0); transition: transform .15s cubic-bezier(.4,1.4,.5,1); }
.radio input:checked + .box { background: radial-gradient(120% 160% at 30% 0%, color-mix(in srgb, var(--primary) 86%, white 12%), var(--primary)); border-color: transparent; }
.radio input:checked + .box::after { transform: scale(1); }
.check input:focus-visible + .box, .radio input:focus-visible + .box { box-shadow: inset 2px 2px 5px rgba(0,0,0,.12), inset -1px -1px 0 rgba(255,255,255,.4), 0 0 0 3px color-mix(in srgb, var(--primary) 45%, transparent); }

/* segmented control / tabs */
.segmented {
  display: inline-flex; padding: 4px; border-radius: var(--radius-lg); gap: 2px;
  background: color-mix(in srgb, var(--paper-3) 30%, var(--paper));
  border: 1px solid var(--rule);
  box-shadow: inset 2px 2px 6px rgba(0,0,0,.12), inset -1px -1px 0 rgba(255,255,255,.4);
}
.segmented button {
  font-family: var(--font-ui); font-size: 13px; font-weight: 600; color: var(--ink-2);
  padding: 8px 18px; border: 0; background: transparent; border-radius: var(--radius-sm); cursor: pointer; transition: color .15s;
}
.segmented button:focus-visible { outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 45%, transparent); }
.segmented button.on {
  color: var(--paper);
  background: radial-gradient(120% 160% at 30% 0%, color-mix(in srgb, var(--primary) 86%, white 12%), var(--primary));
  box-shadow: 0 1px 0 rgba(255,255,255,.25) inset, 0 4px 12px color-mix(in srgb, var(--primary) 36%, transparent);
}
.tabpanel { font-family: var(--font-ui); font-size: 14px; color: var(--ink-2); margin-top: 16px; line-height: 1.5; }

/* ════════════════ FEEDBACK ════════════════ */
.chip {
  display: inline-flex; align-items: center; gap: 7px; font-family: var(--font-mono);
  font-size: 11px; letter-spacing: .04em; padding: 6px 12px; border-radius: var(--radius-pill);
  border: 1px solid var(--rule); color: var(--ink);
  background: color-mix(in srgb, var(--paper-2) 60%, var(--paper));
  box-shadow: 0 1px 0 rgba(255,255,255,.4) inset;
}
.chip--primary { color: var(--primary); border-color: color-mix(in srgb, var(--primary) 40%, transparent); background: color-mix(in srgb, var(--primary) 12%, transparent); }
.chip--live { color: var(--ink); }
.chip--live .skin-pip { width: 8px; height: 8px; }
.chip--partial { border-style: dashed; border-color: color-mix(in srgb, var(--amber) 55%, transparent); }
.chip--partial .skin-pip { width: 8px; height: 8px; background: var(--amber); box-shadow: 0 0 0 3px color-mix(in srgb, var(--amber) 25%, transparent); }

.tooltip { position: relative; display: inline-flex; }
.tooltip .tip {
  position: absolute; bottom: calc(100% + 10px); left: 50%; transform: translateX(-50%) translateY(4px);
  opacity: 0; pointer-events: none; transition: opacity .15s, transform .15s; white-space: nowrap;
  font-family: var(--font-ui); font-size: 12px; padding: 8px 12px; border-radius: var(--radius-sm);
  color: var(--paper); background: var(--ink);
  box-shadow: 0 10px 24px rgba(0,0,0,.28); z-index: 5;
}
.tooltip .tip::after { content: ""; position: absolute; top: 100%; left: 50%; transform: translateX(-50%); border: 5px solid transparent; border-top-color: var(--ink); }
.tooltip:hover .tip,
.tooltip:focus-within .tip { opacity: 1; transform: translateX(-50%) translateY(0); }

.alert {
  display: flex; gap: 13px; align-items: flex-start; padding: 14px 16px; border-radius: var(--radius-lg);
  font-family: var(--font-ui); font-size: 13.5px; line-height: 1.45;
  border: 1px solid var(--rule); background: color-mix(in srgb, var(--paper-2) 55%, var(--paper));
  box-shadow: 0 1px 0 rgba(255,255,255,.4) inset, 0 8px 20px rgba(0,0,0,.08);
}
.alert .bar { width: 3px; align-self: stretch; border-radius: var(--radius-pill); flex: none; }
.alert .a-title { font-weight: 700; display: block; margin-bottom: 2px; }
.alert .a-body { color: var(--ink-2); }
.alert--info  { border-color: color-mix(in srgb, var(--status) 40%, transparent); }
.alert--info  .bar { background: var(--status); }
.alert--ok    { border-color: color-mix(in srgb, var(--ok, var(--primary)) 38%, transparent); }
.alert--ok    .bar { background: var(--ok, var(--primary)); }
.alert--warn  { border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.alert--warn  .bar { background: var(--accent); }
.alert--error { border-color: color-mix(in srgb, var(--err, var(--primary)) 45%, transparent); }
.alert--error .bar { background: var(--err, var(--primary)); }
.alert .a-ico { font-size: 1.1em; line-height: 1.3; }
.alert--info .a-ico { color: var(--status); }
.alert--ok   .a-ico { color: var(--ok, var(--primary)); }
.alert--warn .a-ico { color: var(--accent); }
.alert--error .a-ico { color: var(--err, var(--primary)); }

.progress {
  height: 12px; border-radius: var(--radius-pill); overflow: hidden; width: 100%;
  background: color-mix(in srgb, var(--paper-3) 40%, var(--paper));
  border: 1px solid var(--rule);
  box-shadow: inset 2px 2px 5px rgba(0,0,0,.14);
}
.progress > i {
  display: block; height: 100%; border-radius: var(--radius-pill);
  background: radial-gradient(120% 160% at 30% 0%, color-mix(in srgb, var(--primary) 86%, white 14%), var(--primary));
  box-shadow: 0 0 12px color-mix(in srgb, var(--primary) 50%, transparent);
  transition: width .4s ease;
}

.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--rule); border-top-color: var(--primary); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; opacity: .6; border-top-color: var(--primary); } }

/* ════════════════ SURFACES ════════════════ */
/* Card body: pair with .skin-card (physea-skin.css) for the clay shell. */
.card-demo { padding: 22px; border-radius: var(--radius-xl); }
.card-demo .ch { font-family: var(--font-head); font-weight: 700; font-size: 1.05rem; margin: 0 0 6px; letter-spacing: -.02em; }
.card-demo .cb { font-family: var(--font-ui); font-size: 13.5px; color: var(--ink-2); line-height: 1.5; margin: 0; }
.skin-glass.card-demo { padding: 22px; }

.stat { padding: 20px 22px; border-radius: var(--radius-xl); }
.stat .s-label { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-2); opacity: .75; }
.stat .s-num { font-family: var(--font-head); font-weight: 700; font-size: 2.1rem; letter-spacing: -.04em; margin: 6px 0 2px; }
.stat .s-delta { font-family: var(--font-mono); font-size: 12px; color: var(--primary); display: inline-flex; align-items: center; gap: 5px; }

.listrow {
  display: flex; align-items: center; gap: 14px; padding: 13px 16px; border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--paper-2) 45%, var(--paper));
  border: 1px solid var(--rule-soft); transition: background .15s, transform .1s;
}
.listrow + .listrow { margin-top: 8px; }
.listrow:hover { background: color-mix(in srgb, var(--paper-2) 75%, var(--paper)); transform: translateX(2px); }
.listrow:focus-visible,
.listrow:focus-within {
  background: color-mix(in srgb, var(--paper-2) 75%, var(--paper));
  outline: 2px solid color-mix(in srgb, var(--primary) 60%, transparent); outline-offset: 2px;
}
.listrow .avatar { width: 38px; height: 38px; border-radius: var(--radius-sm); flex: none; display: grid; place-items: center; font-family: var(--font-head); font-weight: 700; color: var(--paper); background: radial-gradient(120% 160% at 30% 0%, var(--accent), var(--primary)); box-shadow: 0 4px 10px rgba(0,0,0,.16); }
.listrow .lr-main { flex: 1; min-width: 0; }
.listrow .lr-title { font-family: var(--font-ui); font-weight: 600; font-size: 14px; }
.listrow .lr-sub { font-family: var(--font-mono); font-size: 11px; color: var(--ink-2); }

table.data { width: 100%; border-collapse: collapse; font-family: var(--font-ui); font-size: 13.5px; }
table.data thead th {
  text-align: left; font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--ink-2); opacity: .8; font-weight: 500; padding: 10px 14px; border-bottom: 1px solid var(--rule);
}
table.data tbody td { padding: 12px 14px; border-bottom: 1px solid var(--rule-soft); color: var(--ink); }
table.data tbody tr { transition: background .12s; }
table.data tbody tr:hover { background: color-mix(in srgb, var(--paper-2) 60%, var(--paper)); }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data .num { font-family: var(--font-mono); text-align: right; }

/* ════════════════ NAVIGATION ════════════════ */
.appbar {
  display: flex; align-items: center; gap: 16px; padding: 12px 18px; border-radius: var(--radius-lg);
  background: linear-gradient(168deg, color-mix(in srgb, var(--paper-2) 40%, white 8%), var(--paper-2) 60%, color-mix(in srgb, var(--paper-2) 70%, black 6%));
  border: 1px solid var(--rule);
  box-shadow: 0 1px 0 rgba(255,255,255,.5) inset, 0 10px 26px rgba(0,0,0,.12);
}
.appbar .ab-brand { font-family: var(--font-head); font-weight: 700; letter-spacing: -.02em; font-size: 1.05rem; }
.appbar .ab-brand span { color: var(--primary); }
.appbar .ab-links { display: flex; gap: 4px; margin-left: 10px; }
.appbar .ab-links a { font-family: var(--font-ui); font-size: 13px; font-weight: 500; text-decoration: none; color: var(--ink-2); padding: 7px 12px; border-radius: var(--radius-sm); transition: background .15s, color .15s; }
.appbar .ab-links a:hover, .appbar .ab-links a.on { color: var(--ink); background: var(--rule-soft); }
.appbar .ab-spacer { flex: 1; }

.tabbar { display: flex; gap: 2px; border-bottom: 1px solid var(--rule); }
.tabbar button {
  font-family: var(--font-ui); font-size: 13.5px; font-weight: 600; color: var(--ink-2);
  background: transparent; border: 0; padding: 11px 16px; cursor: pointer; position: relative; transition: color .15s;
}
.tabbar button:focus-visible { outline: none; color: var(--ink); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 45%, transparent); border-radius: var(--radius-xs); }
.tabbar button.on { color: var(--ink); }
.tabbar button.on::after { content: ""; position: absolute; left: 12px; right: 12px; bottom: -1px; height: 2.5px; border-radius: var(--radius-pill); background: var(--primary); }

.breadcrumb { display: flex; align-items: center; gap: 8px; font-family: var(--font-mono); font-size: 12px; }
.breadcrumb a { color: var(--ink-2); text-decoration: none; opacity: .8; transition: opacity .15s; }
.breadcrumb a:hover { opacity: 1; color: var(--primary); }
.breadcrumb .sep { color: var(--ink-2); opacity: .4; }
.breadcrumb .here { color: var(--ink); }

.sidebar-nav { display: flex; flex-direction: column; gap: 3px; max-width: 230px; }
.sidebar-nav a {
  display: flex; align-items: center; gap: 11px; font-family: var(--font-ui); font-size: 13.5px; font-weight: 500;
  text-decoration: none; color: var(--ink-2); padding: 9px 13px; border-radius: var(--radius-sm); transition: background .15s, color .15s;
}
.sidebar-nav a .si { width: 17px; text-align: center; opacity: .8; }
.sidebar-nav a:hover { color: var(--ink); background: var(--rule-soft); }
.sidebar-nav a.on {
  color: var(--ink); background: color-mix(in srgb, var(--primary) 11%, transparent);
  box-shadow: inset 2px 0 0 var(--primary);
}

/* ════════════════ MENUS & NAVIGATION ════════════════ */
/* --menu-radius / --menu-gap are layout knobs. Each use site carries a fallback
   (14px / 6px) so the menus work standalone; library.html scopes overrides to
   #menus (its Randomizer knob) and the inherited value still wins over these. */

/* shared panel surface — the raised clay slab a menu floats on */
.m-panel, .m-flyout, .ctxmenu {
  background:
    radial-gradient(120% 90% at 18% 0%, color-mix(in srgb, var(--paper-2) 55%, var(--paper)) 0%, var(--paper) 62%),
    var(--paper);
  border: 1px solid var(--rule);
  box-shadow: 0 1px 0 rgba(255,255,255,.5) inset, 0 2px 4px rgba(0,0,0,.05), 0 22px 50px rgba(0,0,0,.18);
}

/* ── header row: wordmark left, nav center, CTA right ── */
.navhead {
  display: flex; align-items: center; gap: 18px; padding: 12px 16px; border-radius: var(--radius-xl);
  background: linear-gradient(168deg, color-mix(in srgb, var(--paper-2) 40%, white 8%), var(--paper-2) 60%, color-mix(in srgb, var(--paper-2) 70%, black 6%));
  border: 1px solid var(--rule);
  box-shadow: 0 1px 0 rgba(255,255,255,.5) inset, 0 10px 26px rgba(0,0,0,.12);
  position: relative; z-index: 5;
}
.navhead .nh-brand { font-family: var(--font-head); font-weight: 700; letter-spacing: -.02em; font-size: 1.05rem; }
.navhead .nh-brand span { color: var(--primary); }
.navhead .nh-spacer { flex: 1; }

.menubar { display: flex; align-items: center; gap: 2px; margin: 0; padding: 0; list-style: none; }
.menubar > li { position: relative; list-style: none; }

/* top-level trigger */
.m-trigger {
  font-family: var(--font-ui); font-size: 13px; font-weight: 500; color: var(--ink-2);
  padding: 8px 13px; border-radius: var(--radius-sm); border: 0; background: transparent; cursor: pointer;
  display: inline-flex; align-items: center; gap: 7px; text-decoration: none; transition: background .15s, color .15s;
}
.m-trigger .caret { font-size: 8px; opacity: .6; transition: transform .2s; }
.menubar > li:hover > .m-trigger,
.menubar > li:focus-within > .m-trigger,
.m-trigger:hover, .m-trigger.on { color: var(--ink); background: var(--rule-soft); }
.menubar > li:hover > .m-trigger .caret,
.menubar > li:focus-within > .m-trigger .caret,
.has-panel.open > .m-trigger .caret { transform: rotate(180deg); }

/* ── dropdown panel (css-only open on hover/focus, .open for pin/demo) ── */
.m-panel {
  position: absolute; top: calc(100% + 10px); left: 0; min-width: 236px; padding: 8px;
  border-radius: var(--menu-radius, 14px);
  opacity: 0; transform: translateY(-6px); pointer-events: none; transition: opacity .16s ease, transform .16s ease; z-index: 20;
}
.m-panel::before { content: ""; position: absolute; left: 0; right: 0; top: -10px; height: 10px; }
.has-panel:hover > .m-panel,
.has-panel:focus-within > .m-panel,
.has-panel.open > .m-panel { opacity: 1; transform: translateY(0); pointer-events: auto; }

.m-list { display: flex; flex-direction: column; gap: var(--menu-gap, 6px); }
.m-item {
  display: flex; align-items: flex-start; gap: 11px; padding: 9px 11px; border-radius: calc(var(--menu-radius, 14px) - 6px);
  text-decoration: none; color: var(--ink); cursor: pointer; font-family: var(--font-ui); font-size: 13.5px; transition: background .13s;
}
.m-item:hover, .m-item:focus-visible, .m-item.on { background: color-mix(in srgb, var(--primary) 10%, transparent); }
.m-item .mi-ico { width: 18px; text-align: center; color: var(--primary); flex: none; margin-top: 1px; }
.m-item .mi-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.m-item .mi-title { font-weight: 600; }
.m-item .mi-desc { font-size: 11.5px; color: var(--ink-2); line-height: 1.35; }

/* ── mega panel: two columns, mono eyebrow labels ── */
.m-panel.mega { min-width: 520px; padding: 14px; left: 50%; transform: translateX(-50%) translateY(-6px); }
.has-panel:hover > .m-panel.mega,
.has-panel:focus-within > .m-panel.mega,
.has-panel.open > .m-panel.mega { transform: translateX(-50%) translateY(0); }
.mega-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 20px; }
.mega-col { display: flex; flex-direction: column; gap: var(--menu-gap, 6px); }
.mega-label { font-family: var(--font-mono); font-size: 10px; letter-spacing: .16em; text-transform: uppercase; color: var(--ink-3); padding: 6px 11px 3px; }
.mega-label .pip { color: var(--primary); opacity: 1; margin-right: .45em; }

/* ── nested flyout: second-level submenu flying to the side ── */
.m-sub { position: relative; }
.m-sub > .m-item .mi-arrow { margin-left: auto; padding-left: 12px; opacity: .55; font-size: 11px; align-self: center; }
.m-sub:hover > .m-item, .m-sub:focus-within > .m-item, .m-sub.open > .m-item { background: color-mix(in srgb, var(--primary) 10%, transparent); }
.m-flyout {
  position: absolute; top: -8px; left: calc(100% + 7px); min-width: 208px; padding: 8px;
  border-radius: var(--menu-radius, 14px);
  opacity: 0; transform: translateX(-6px); pointer-events: none; transition: opacity .16s ease, transform .16s ease; z-index: 30;
}
.m-flyout::before { content: ""; position: absolute; left: -8px; top: 0; bottom: 0; width: 8px; }
.m-sub:hover > .m-flyout, .m-sub:focus-within > .m-flyout, .m-sub.open > .m-flyout { opacity: 1; transform: translateX(0); pointer-events: auto; }

/* ── mobile / accordion menu (native details/summary) ── */
.acc-menu {
  max-width: 340px; border: 1px solid var(--rule); border-radius: var(--menu-radius, 14px); overflow: hidden;
  background: color-mix(in srgb, var(--paper-2) 45%, var(--paper));
  box-shadow: 0 1px 0 rgba(255,255,255,.4) inset, 0 10px 26px rgba(0,0,0,.10);
}
.acc-menu details { border-bottom: 1px solid var(--rule-soft); }
.acc-menu details:last-child { border-bottom: 0; }
.acc-menu summary {
  list-style: none; cursor: pointer; padding: 14px 16px; display: flex; align-items: center; gap: 11px;
  font-family: var(--font-ui); font-size: 14px; font-weight: 600; color: var(--ink);
}
.acc-menu summary::-webkit-details-marker { display: none; }
.acc-menu summary .acc-ico { color: var(--primary); width: 17px; text-align: center; }
.acc-menu summary .acc-caret { margin-left: auto; font-size: 10px; color: var(--primary); opacity: .8; transition: transform .2s; }
.acc-menu details[open] summary .acc-caret { transform: rotate(90deg); }
.acc-body { padding: 0 12px 12px; display: flex; flex-direction: column; gap: 2px; }
.acc-body a {
  display: block; padding: 9px 12px; border-radius: var(--radius-sm); text-decoration: none; color: var(--ink-2);
  font-family: var(--font-ui); font-size: 13.5px; transition: background .13s, color .13s;
}
.acc-body a:hover, .acc-body a:focus-visible { color: var(--ink); background: var(--rule-soft); }

/* ── context / right-click menu ── */
.ctx-surface {
  display: grid; place-items: center; min-height: 150px; border-radius: var(--radius-lg); padding: 20px; text-align: center;
  background: color-mix(in srgb, var(--paper-3) 20%, var(--paper));
  border: 1px dashed var(--rule-bold); color: var(--ink-2);
  font-family: var(--font-ui); font-size: 13px; user-select: none;
}
.ctxmenu {
  width: 220px; padding: 6px; border-radius: var(--menu-radius, 14px);
  box-shadow: 0 1px 0 rgba(255,255,255,.5) inset, 0 22px 50px rgba(0,0,0,.22);
}
.ctxmenu.floating { position: fixed; z-index: 9998; }
.ctxmenu .cx-item {
  display: flex; align-items: center; gap: 11px; padding: 8px 10px; border-radius: var(--radius-sm);
  font-family: var(--font-ui); font-size: 13.5px; color: var(--ink); cursor: pointer; transition: background .12s; border: 0; background: transparent; width: 100%; text-align: left;
}
.ctxmenu .cx-item:hover, .ctxmenu .cx-item:focus-visible { background: color-mix(in srgb, var(--primary) 10%, transparent); }
.ctxmenu .cx-item .cx-ico { width: 16px; text-align: center; color: var(--ink-2); flex: none; }
.ctxmenu .cx-item .kbd { margin-left: auto; }
.ctxmenu .cx-item.danger { color: var(--primary); }
.ctxmenu .cx-item.danger .cx-ico { color: var(--primary); }
.ctxmenu .cx-item.danger:hover, .ctxmenu .cx-item.danger:focus-visible { background: color-mix(in srgb, var(--primary) 15%, transparent); }
.ctxmenu .cx-sep { height: 1px; margin: 5px 6px; background: var(--rule-soft); }
.kbd {
  font-family: var(--font-mono); font-size: 10.5px; color: var(--ink-2); padding: 2px 6px; border-radius: var(--radius-xs);
  background: color-mix(in srgb, var(--paper-3) 30%, var(--paper)); border: 1px solid var(--rule); box-shadow: 0 1px 0 rgba(0,0,0,.05);
}

/* ════════════════ SCROLLBAR CONTAINER ════════════════ */
/* The custom brick thumb lives in physea-skin.css; this is the scroll container. */
.scrollbox {
  height: 230px; overflow-y: auto; padding: 18px 20px; border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--paper-3) 22%, var(--paper));
  border: 1px solid var(--rule);
  box-shadow: inset 2px 2px 8px rgba(0,0,0,.10);
}
.scrollbox p { font-family: var(--font-ui); font-size: 13.5px; color: var(--ink-2); line-height: 1.6; margin: 0 0 12px; }
.scrollbox p b { color: var(--ink); }

/* ════════════════ TOAST ════════════════ */
/* ONE canonical toast (replaces the apps' ctoast / notify / toast trio).
   .toast-stack is the fixed corner container; .toast is a single message. */
.toast-stack {
  position: fixed; z-index: 9990; bottom: 22px; right: 22px;
  display: flex; flex-direction: column; gap: 10px; max-width: min(92vw, 380px); pointer-events: none;
}
.toast-stack > .toast { pointer-events: auto; }
.toast {
  display: flex; align-items: flex-start; gap: 12px; padding: 13px 15px; border-radius: var(--radius-lg);
  font-family: var(--font-ui); font-size: 13.5px; line-height: 1.45; color: var(--ink);
  background: linear-gradient(168deg, color-mix(in srgb, var(--paper-2) 42%, white 9%), var(--paper-2) 62%, color-mix(in srgb, var(--paper-2) 74%, black 6%));
  border: 1px solid var(--rule);
  box-shadow: 0 1px 0 rgba(255,255,255,.5) inset, 0 12px 30px rgba(0,0,0,.20);
}
.toast .t-ico { font-size: 1.1em; line-height: 1.2; color: var(--primary); flex: none; margin-top: 1px; }
.toast .t-main { flex: 1; min-width: 0; }
.toast .t-title { font-weight: 700; display: block; margin-bottom: 1px; }
.toast .t-body { color: var(--ink-2); }
.toast .t-close {
  flex: none; border: 0; background: transparent; cursor: pointer; color: var(--ink-2);
  font-size: 15px; line-height: 1; padding: 2px 4px; border-radius: var(--radius-xs); transition: color .13s, background .13s;
}
.toast .t-close:hover { color: var(--ink); background: var(--rule-soft); }
.toast .t-close:focus-visible { outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 45%, transparent); }
.toast--ok   { border-color: color-mix(in srgb, var(--primary) 40%, transparent); }
.toast--ok   .t-ico { color: var(--primary); }
.toast--warn { border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.toast--warn .t-ico { color: var(--accent); }
.toast--info { border-color: color-mix(in srgb, var(--status) 42%, transparent); }
.toast--info .t-ico { color: var(--status); }

/* ════════════════ MODAL / DIALOG ════════════════ */
.modal-scrim {
  position: fixed; inset: 0; z-index: 9980; display: grid; place-items: center; padding: 24px;
  background: color-mix(in srgb, var(--ink) 42%, transparent); backdrop-filter: blur(2px);
}
.modal {
  width: 100%; max-width: 440px; border-radius: var(--radius-xl); overflow: hidden;
  background:
    radial-gradient(120% 90% at 18% 0%, color-mix(in srgb, var(--paper-2) 50%, var(--paper)) 0%, var(--paper) 60%),
    var(--paper);
  border: 1px solid var(--rule);
  box-shadow: 0 1px 0 rgba(255,255,255,.5) inset, 0 30px 70px rgba(0,0,0,.4);
}
.modal .m-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; padding: 20px 22px 6px; }
.modal .m-head h3 { font-family: var(--font-head); font-weight: 700; font-size: 1.2rem; letter-spacing: -.02em; margin: 0; }
.modal .m-x {
  flex: none; border: 0; background: transparent; cursor: pointer; color: var(--ink-2);
  font-size: 18px; line-height: 1; padding: 3px 6px; border-radius: var(--radius-xs); transition: color .13s, background .13s;
}
.modal .m-x:hover { color: var(--ink); background: var(--rule-soft); }
.modal .m-x:focus-visible { outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 45%, transparent); }
.modal .m-body { padding: 6px 22px 18px; font-family: var(--font-ui); font-size: 14px; color: var(--ink-2); line-height: 1.55; }
.modal .m-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 22px 20px; }

/* ════════════════ DRAWER / SLIDE-OVER ════════════════ */
.drawer-scrim { position: fixed; inset: 0; z-index: 9970; background: color-mix(in srgb, var(--ink) 38%, transparent); backdrop-filter: blur(1px); }
.drawer {
  position: fixed; top: 0; right: 0; z-index: 9971; height: 100%; width: min(92vw, 380px);
  display: flex; flex-direction: column;
  background:
    radial-gradient(120% 60% at 100% 0%, color-mix(in srgb, var(--paper-2) 55%, var(--paper)) 0%, var(--paper) 60%),
    var(--paper);
  border-left: 1px solid var(--rule);
  box-shadow: -24px 0 60px rgba(0,0,0,.30);
}
.drawer.left { right: auto; left: 0; border-left: 0; border-right: 1px solid var(--rule); box-shadow: 24px 0 60px rgba(0,0,0,.30); }
.drawer .d-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--rule-soft); }
.drawer .d-title { font-family: var(--font-head); font-weight: 700; font-size: 1.1rem; letter-spacing: -.02em; }
.drawer .d-x {
  border: 0; background: transparent; cursor: pointer; color: var(--ink-2);
  font-size: 18px; line-height: 1; padding: 3px 6px; border-radius: var(--radius-xs); transition: color .13s, background .13s;
}
.drawer .d-x:hover { color: var(--ink); background: var(--rule-soft); }
.drawer .d-x:focus-visible { outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 45%, transparent); }
.drawer .d-body { padding: 18px 20px; overflow-y: auto; font-family: var(--font-ui); font-size: 14px; color: var(--ink-2); line-height: 1.55; }

/* ════════════════ EMPTY STATE ════════════════ */
.empty {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px;
  padding: 40px 28px; border-radius: var(--radius-xl);
  border: 1px dashed var(--rule-bold);
  background: color-mix(in srgb, var(--paper-3) 16%, var(--paper));
}
.empty .e-ico {
  width: 54px; height: 54px; border-radius: var(--radius-lg); display: grid; place-items: center; margin-bottom: 6px;
  font-size: 1.5rem; color: var(--primary);
  background: color-mix(in srgb, var(--primary) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--primary) 26%, transparent);
}
.empty .e-title { font-family: var(--font-head); font-weight: 700; font-size: 1.15rem; letter-spacing: -.02em; color: var(--ink); }
.empty .e-body { font-family: var(--font-ui); font-size: 13.5px; color: var(--ink-2); line-height: 1.5; max-width: 46ch; margin: 0; }
.empty .e-actions { display: flex; gap: 10px; margin-top: 12px; }

/* ════════════════ CODE BLOCK ════════════════ */
.codeblock { border-radius: var(--radius-lg); overflow: hidden; border: 1px solid var(--rule); background: color-mix(in srgb, var(--paper-3) 26%, var(--paper)); }
.codeblock .cb-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 12px;
  border-bottom: 1px solid var(--rule-soft); background: color-mix(in srgb, var(--paper-2) 55%, var(--paper));
}
.codeblock .cb-name { font-family: var(--font-mono); font-size: 11px; letter-spacing: .04em; color: var(--ink-2); }
.codeblock .cb-copy {
  border: 1px solid var(--rule); background: transparent; cursor: pointer; color: var(--ink-2);
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .04em; padding: 4px 9px; border-radius: var(--radius-xs);
  transition: color .13s, background .13s, border-color .13s;
}
.codeblock .cb-copy:hover { color: var(--ink); border-color: var(--rule-bold); }
.codeblock .cb-copy:focus-visible { outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 45%, transparent); }
.codeblock pre {
  margin: 0; padding: 14px 16px; overflow-x: auto;
  font-family: var(--font-mono); font-size: 12.5px; line-height: 1.6; color: var(--ink); tab-size: 2;
}
.codeblock pre .tok-key { color: var(--primary); }
.codeblock pre .tok-mut { color: var(--ink-2); }

/* ════════════════ SKELETON / LOADING ════════════════ */
.skel {
  position: relative; overflow: hidden; border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--paper-3) 42%, var(--paper));
}
.skel::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--ink) 7%, transparent), transparent);
  transform: translateX(-100%); animation: skel-sweep 1.5s ease-in-out infinite;
}
@keyframes skel-sweep { to { transform: translateX(100%); } }
@media (prefers-reduced-motion: reduce) { .skel::after { animation: none; opacity: .6; } }
.skel-line { height: .8rem; border-radius: var(--radius-xs); }
.skel-line.short { width: 55%; }
.skel-block { height: 5rem; border-radius: var(--radius-md); }
.skel-circle { width: 44px; height: 44px; border-radius: 50%; }
