/* FuFlow360 component kit (slice D3). Served as /design-kit/kit.css, after /css/theme.css.
   Every colour, size and duration is a value from theme.css. Every class starts with fk-, so a page that
   does not use the kit is not changed. A page that does use it puts class="fk-body" on <body>.
   Usage and rules: docs/design/components.md. */

/* ---------- base ---------- */
html:has(> .fk-body) { color-scheme: var(--theme-color-scheme); }
.fk-body { margin: 0; background: var(--color-bg); color: var(--color-text); font: var(--weight-regular) var(--text-md)/var(--leading-body) var(--font-body); }
.fk-body, .fk-body *, .fk-body *::before, .fk-body *::after { box-sizing: border-box; }
.fk-body :focus-visible { outline: var(--focus-ring); outline-offset: var(--focus-ring-offset); }
.fk-body h1, .fk-body h2, .fk-body h3 { font-family: var(--font-display); font-weight: var(--weight-display); letter-spacing: var(--display-tracking); line-height: var(--leading-tight); margin: 0; }
.fk-body a { color: var(--color-link); text-underline-offset: var(--focus-ring-offset); }
.fk-body p { margin: 0; }
.fk-visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.fk-icon { width: 1.15em; height: 1.15em; flex: none; vertical-align: -0.2em; }
.fk-figure, .fk-num { font-variant-numeric: var(--figure-variant); white-space: nowrap; }
.fk-num { text-align: right; }

/* ---------- money figure: blue and red are for figures only, always with a sign ---------- */
.fk-money { font-variant-numeric: var(--figure-variant); white-space: nowrap; }
.fk-money--positive .fk-money__amount { color: var(--num-positive); }
.fk-money--negative .fk-money__amount { color: var(--num-negative); }
.fk-money--stacked { display: inline-flex; flex-direction: column; align-items: flex-end; line-height: var(--leading-tight); }
.fk-money--stacked .fk-money__amount { font-size: var(--text-lg); font-weight: var(--figure-weight); }
.fk-money--stacked .fk-money__asset { font-size: var(--text-xs); color: var(--color-text-subtle); }

/* ---------- buttons ---------- */
.fk-body a.fk-btn, .fk-btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2); min-height: var(--touch-target); padding: 0 var(--space-5); border: 1px solid transparent; border-radius: var(--radius-md); font: inherit; font-weight: var(--weight-bold); text-decoration: none; white-space: nowrap; cursor: pointer; transition: background-color var(--motion-fast) var(--ease-standard), box-shadow var(--motion-fast) var(--ease-standard); }
.fk-body a.fk-btn--secondary, .fk-btn--secondary { background: transparent; color: var(--color-primary-text); border-color: var(--color-border-control); }
.fk-btn--secondary:hover { background: var(--color-row-hover); }
.fk-body a.fk-btn--primary, .fk-btn--primary { background: var(--color-primary); color: var(--color-on-primary); }
.fk-btn--primary:hover { background: var(--color-primary-hover); }
.fk-body a.fk-btn--gold, .fk-btn--gold { background: var(--gradient-brand); color: var(--color-on-gradient); border-color: var(--color-brand-gold-edge); }
.fk-btn--gold:hover { box-shadow: var(--shadow-2); }
.fk-body a.fk-btn--danger, .fk-btn--danger { background: var(--color-danger); color: var(--color-on-danger); }
.fk-btn--danger:hover { background: var(--color-danger-hover); }
.fk-btn[disabled] { background: var(--color-fill-disabled); color: var(--color-text-disabled); border-color: transparent; box-shadow: none; cursor: not-allowed; }
.fk-body a.fk-btn--compact, .fk-btn--compact { min-height: var(--grid-header-height); padding: 0 var(--space-3); border-radius: var(--radius-sm); font-size: var(--text-sm); }
[data-surface="ink"] a.fk-btn--secondary, [data-surface="ink"] .fk-btn--secondary { color: var(--color-nav-text); border-color: var(--color-nav-text-subtle); }
[data-surface="ink"] .fk-btn--secondary:hover { background: var(--color-nav-hover-bg); }
@media (max-width: 899px) { .fk-body a.fk-btn--compact, .fk-btn--compact { min-height: var(--touch-target); } }

/* ---------- status: a family colour, its icon and its word ---------- */
.fk-status { display: inline-flex; align-items: center; gap: var(--space-1); min-height: var(--space-6); padding: 0 var(--space-3); border-radius: var(--radius-pill); font-size: var(--text-xs); font-weight: var(--weight-bold); white-space: nowrap; }
.fk-status--neutral { background: var(--status-neutral-bg); color: var(--status-neutral-fg); }
.fk-status--wait { background: var(--status-wait-bg); color: var(--status-wait-fg); }
.fk-status--progress { background: var(--status-progress-bg); color: var(--status-progress-fg); }
.fk-status--done { background: var(--status-done-bg); color: var(--status-done-fg); }
.fk-status--held { background: var(--status-held-bg); color: var(--status-held-fg); }
.fk-status--inline { display: inline; min-height: 0; padding: 0; border-radius: 0; background: none; font-size: inherit; font-weight: inherit; }
.fk-status--inline .fk-icon { margin-right: var(--space-1); }
.fk-status--inline.fk-status--neutral { color: var(--color-text-muted); }
.fk-status--inline.fk-status--held { font-weight: var(--weight-bold); }

/* ---------- form field ---------- */
.fk-field { display: flex; flex-direction: column; gap: var(--space-1); }
.fk-field__label { font-size: var(--text-sm); font-weight: var(--weight-medium); }
.fk-field__input { width: 100%; height: var(--field-height); padding: 0 var(--space-3); border: 1px solid var(--color-border-control); border-radius: var(--radius-sm); background: var(--color-surface); color: inherit; font: inherit; font-size: var(--text-lg); font-variant-numeric: var(--figure-variant); }
.fk-field__input:disabled { background: var(--color-fill-disabled); color: var(--color-text-disabled); border-color: transparent; }
.fk-field__help { font-size: var(--text-sm); color: var(--color-text-subtle); }
.fk-field__error { display: flex; align-items: center; gap: var(--space-1); font-size: var(--text-sm); font-weight: var(--weight-medium); color: var(--status-held-fg); }
.fk-field--invalid .fk-field__input { border: var(--focus-ring-width) solid var(--status-held-fg); }
.fk-check { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; column-gap: var(--space-3); min-height: var(--touch-target); }
.fk-check__box { width: var(--space-5); height: var(--space-5); margin: 0; accent-color: var(--color-primary); }
.fk-check__label { display: flex; align-items: center; min-height: var(--touch-target); font-size: var(--text-md); cursor: pointer; }
.fk-check__help { grid-column: 2; padding-bottom: var(--space-2); font-size: var(--text-sm); color: var(--color-text-subtle); }

/* ---------- segmented control ---------- */
.fk-segments ul { display: flex; height: var(--segment-height); margin: 0; padding: 0; list-style: none; }
.fk-segments li { flex: 1; display: flex; }
.fk-body .fk-segments a, .fk-segments a { flex: 1; display: grid; place-items: center; padding: 0 var(--space-3); border: 1px solid var(--color-border-control); border-left-width: 0; background: var(--color-surface); color: var(--color-text); font-size: var(--text-sm); text-decoration: none; white-space: nowrap; }
.fk-segments li:first-child a { border-left-width: 1px; border-radius: var(--segment-radius) 0 0 var(--segment-radius); }
.fk-segments li:last-child a { border-radius: 0 var(--segment-radius) var(--segment-radius) 0; }
.fk-segments a:hover { background: var(--color-row-hover); }
.fk-body .fk-segments a[aria-current], .fk-segments a[aria-current] { background: var(--color-primary); border-color: var(--color-primary); color: var(--color-on-primary); font-weight: var(--weight-bold); }
.fk-segments a:focus-visible { position: relative; z-index: 1; }

/* ---------- period picker ---------- */
.fk-period { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.fk-period__control, .fk-period input { display: inline-flex; align-items: center; gap: var(--space-1); height: var(--segment-height); padding: 0 var(--space-2); border: 1px solid var(--color-border-control); border-radius: var(--segment-radius); background: var(--color-surface); color: inherit; font: inherit; font-size: var(--text-sm); }
.fk-period select { height: 100%; border: 0; background: transparent; color: inherit; font: inherit; }
.fk-period .fk-btn--compact { min-height: var(--segment-height); }
.fk-caption { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-2) var(--space-4); padding: var(--space-2) var(--space-3); background: var(--color-surface); border-bottom: var(--hairline); }
.fk-caption__title { font-size: var(--text-lg); }
.fk-caption > .fk-period { margin-left: auto; justify-content: flex-end; }
.fk-segments .fk-badge { margin-left: var(--space-1); }

/* ---------- summary block and totals ---------- */
.fk-summary { background: var(--color-surface-sunken); border-bottom: var(--hairline); padding: var(--space-1) var(--space-4); }
.fk-summary__title { padding: var(--space-2) 0 var(--space-1); font-size: var(--text-sm); }
.fk-summary dl, .fk-totals dl, .fk-row__detail dl { margin: 0; }
.fk-summary__line { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); min-height: var(--summary-row-height); border-bottom: var(--hairline); font-size: var(--text-sm); }
.fk-summary__line:last-child { border-bottom: 0; }
.fk-summary dt, .fk-totals dt, .fk-row__detail dt { color: var(--color-text-muted); }
.fk-summary dd, .fk-totals dd { margin: 0; font-weight: var(--weight-bold); }
.fk-totals { background: var(--color-surface-sunken); border-top: var(--hairline); border-bottom: var(--hairline); padding: 0 var(--space-3); font-size: var(--text-sm); }
.fk-totals dl { display: flex; flex-wrap: wrap; gap: 0 var(--space-6); }
.fk-totals dl > div { display: flex; align-items: center; gap: var(--space-2); min-height: var(--row-height-grid); }
@media (max-width: 899px) {
  .fk-totals { padding: var(--space-1) var(--space-4); }
  .fk-totals dl { display: block; }
  .fk-totals dl > div { justify-content: space-between; min-height: var(--summary-row-height); border-bottom: var(--hairline); }
  .fk-totals dl > div:last-child { border-bottom: 0; }
}

/* ---------- two-line touch rows: always 54px, each line cut with an ellipsis ---------- */
.fk-rows ul { margin: 0; padding: 0; list-style: none; }
.fk-group-title { display: flex; justify-content: space-between; padding: var(--space-2) var(--space-4); background: var(--color-bg); border-bottom: var(--hairline); color: var(--color-text-subtle); font-size: var(--text-xs); font-variant-numeric: var(--figure-variant); }
.fk-row { container-type: inline-size; background: var(--color-surface); border-bottom: var(--hairline); }
.fk-body a.fk-row__link, .fk-row__link { display: flex; flex-direction: column; justify-content: center; height: var(--row-height-2line); padding: 0 var(--space-4); color: inherit; text-decoration: none; }
.fk-row__link:hover { background: var(--color-row-hover); }
.fk-row__link:focus-visible { outline-offset: calc(var(--focus-ring-width) * -1); }
.fk-row__line { position: relative; display: flex; align-items: baseline; gap: var(--space-3); min-width: 0; white-space: nowrap; }
.fk-row__title { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; font-size: var(--text-md); font-variant-numeric: var(--figure-variant); }
.fk-row__line .fk-money { flex: none; margin-left: auto; }
.fk-row__line .fk-money__amount { font-size: var(--text-lg); font-weight: var(--figure-weight); }
.fk-row__line .fk-money__asset { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.fk-row__sub { gap: 0; overflow: hidden; font-size: var(--text-sm); color: var(--color-text-muted); }
.fk-row__kind, .fk-row__state, .fk-row__meta, .fk-row__asset { flex: none; }
.fk-row__kind .fk-icon { margin-right: var(--space-1); }
.fk-row__rest { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.fk-row__sub > * + *:not(.fk-row__asset)::before { content: "\00B7"; margin: 0 var(--space-1); color: var(--color-text-subtle); font-weight: var(--weight-regular); }
.fk-row__meta { font-variant-numeric: var(--figure-variant); }
.fk-row__asset { margin-left: auto; padding-left: var(--space-3); font-size: var(--text-xs); color: var(--color-text-subtle); }
@container (max-width: 359px) {
  .fk-row__kind-word { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .fk-row__kind .fk-icon { margin-right: 0; }
}
.fk-row--selected, .fk-row--selected .fk-row__link:hover { background: var(--color-row-selected); }
.fk-row__detail { padding: 0 var(--space-4) var(--space-3); font-size: var(--text-sm); }
.fk-row__detail dl { margin-bottom: var(--space-3); }
.fk-row__detail dl > div { display: flex; justify-content: space-between; gap: var(--space-2); }
.fk-row__detail dl > div:first-child { font-weight: var(--weight-bold); }
.fk-row__detail dd { margin: 0; font-variant-numeric: var(--figure-variant); }
.fk-row__detail .fk-btn { width: 100%; }

/* ---------- dense grid ---------- */
.fk-grid-wrap { overflow: auto; background: var(--color-surface); }
.fk-grid-wrap:focus-visible { outline-offset: calc(var(--focus-ring-width) * -1); }
.fk-grid { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.fk-grid th { position: sticky; top: 0; z-index: var(--z-sticky); height: var(--grid-header-height); padding: 0 var(--space-2); background: var(--color-surface-sunken); border-bottom: 1px solid var(--color-border-strong); border-right: var(--hairline); color: var(--color-text-muted); font-size: var(--text-xs); font-weight: var(--weight-bold); text-align: left; white-space: nowrap; }
.fk-grid th[aria-sort] { color: var(--color-text); }
.fk-body .fk-grid th a, .fk-grid th a { display: inline-flex; align-items: center; gap: var(--space-1); color: inherit; text-decoration: none; }
.fk-grid th a:hover { text-decoration: underline; }
.fk-grid td { height: var(--row-height-grid); padding: 0 var(--space-2); border-bottom: var(--hairline); font-variant-numeric: var(--figure-variant); white-space: nowrap; }
.fk-grid td > .fk-icon { margin-right: var(--space-1); }
.fk-grid th.fk-num, .fk-grid td.fk-num { text-align: right; }
.fk-grid tbody tr:nth-child(even) td { background: var(--color-row-zebra); }
.fk-grid tbody tr:hover td { background: var(--color-row-hover); }
.fk-grid tbody tr[aria-selected="true"] td { background: var(--color-row-selected); }
@media (max-width: 899px) { .fk-grid td { height: var(--touch-target); } }

/* ---------- phone shell ---------- */
.fk-phone { display: flex; flex-direction: column; height: 100dvh; background: var(--color-bg); }
.fk-topbar { flex: none; display: flex; align-items: center; gap: var(--space-3); min-height: var(--field-height); padding: 0 var(--space-2) 0 var(--space-4); background: var(--color-nav-bg); color: var(--color-nav-text-strong); }
.fk-logo { flex: none; width: var(--space-6); height: var(--space-6); }
.fk-topbar__title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: var(--weight-display) var(--text-lg)/var(--leading-tight) var(--font-display); }
.fk-body a.fk-topbar__action, .fk-topbar__action { display: grid; place-items: center; width: var(--touch-target); height: var(--touch-target); color: var(--color-nav-active-bg); font-size: var(--text-xl); }
.fk-phone__main { flex: 1; min-height: 0; overflow-y: auto; }
.fk-tabbar { flex: none; z-index: var(--z-tabbar); padding-bottom: env(safe-area-inset-bottom, 0px); background: var(--color-tabbar-bg); border-top: var(--hairline); }
.fk-tabbar ul { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); height: var(--tabbar-height); margin: 0; padding: 0; list-style: none; }
.fk-body a.fk-tabbar__tab, .fk-tabbar__tab { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--space-1); height: 100%; color: var(--color-text-muted); font-size: var(--tabbar-label-size); line-height: var(--leading-tight); text-decoration: none; }
.fk-tabbar__tab:focus-visible { outline-offset: calc(var(--focus-ring-width) * -1); }
.fk-tabbar__tab .fk-icon { width: var(--tabbar-icon-size); height: var(--tabbar-icon-size); }
.fk-body a.fk-tabbar__tab[aria-current], .fk-tabbar__tab[aria-current] { color: var(--color-primary-text); font-weight: var(--weight-bold); }
.fk-tabbar__tab[aria-current]::before { content: ""; position: absolute; top: 0; left: 28%; right: 28%; height: var(--space-1); border-radius: 0 0 var(--radius-sm) var(--radius-sm); background: var(--color-brand-gold-edge); }
.fk-badge { display: inline-block; min-width: var(--space-4); padding: 0 var(--space-1); border-radius: var(--radius-pill); background: var(--color-nav-active-bg); color: var(--color-nav-active-text); font-size: var(--tabbar-label-size); font-weight: var(--weight-bold); font-variant-numeric: var(--figure-variant); line-height: var(--space-4); text-align: center; }
.fk-tabbar .fk-badge { position: absolute; top: var(--space-1); left: 54%; }

/* ---------- desktop shell: toolbar, Navigator, main, Toolbox, status bar ---------- */
.fk-desk { position: relative; display: grid; height: 100dvh; grid-template: "bar bar" var(--touch-target) "nav main" minmax(0, 1fr) "nav tool" var(--toolbox-height) "status status" var(--statusbar-height) / var(--navigator-width) minmax(0, 1fr); font-size: var(--text-sm); }
.fk-desk__toolbar { grid-area: bar; display: flex; align-items: center; gap: var(--space-2); padding: 0 var(--space-4); background: var(--color-nav-bg); color: var(--color-nav-text-strong); }
.fk-desk__wordmark { margin-right: var(--space-2); font: var(--weight-bold) var(--text-md) var(--font-display); letter-spacing: var(--wordmark-tracking); }
.fk-desk__wordmark b { color: var(--color-nav-active-bg); }
.fk-desk__search { display: flex; align-items: center; gap: var(--space-2); flex: 0 1 calc(var(--navigator-width) + var(--space-7)); min-width: 0; height: var(--grid-header-height); margin-left: auto; padding: 0 var(--space-3); border-radius: var(--radius-sm); background: var(--color-nav-hover-bg); color: var(--color-nav-text); }
.fk-desk__search input { flex: 1; min-width: 0; border: 0; background: transparent; color: var(--color-nav-text-strong); font: inherit; }
.fk-desk__search input::placeholder { color: var(--color-nav-text-subtle); opacity: 1; }
.fk-desk__nav { grid-area: nav; overflow: hidden auto; background: var(--color-surface); border-right: 1px solid var(--color-border-strong); }
.fk-pane-title { flex: none; display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); min-height: var(--grid-header-height); padding: 0 var(--space-3); background: var(--color-surface-sunken); border-bottom: var(--hairline); font-size: var(--text-xs); font-weight: var(--weight-bold); }
.fk-pane-title__text { margin: 0; font: inherit; }
.fk-pane-title .fk-segments ul { height: var(--grid-header-height); }
.fk-pane-title .fk-segments a { font-size: var(--text-xs); border-top-width: 0; border-bottom-width: 0; border-radius: 0; }
.fk-desk__main { grid-area: main; display: flex; flex-direction: column; min-height: 0; overflow: hidden; background: var(--color-surface); }
.fk-desk__main > .fk-grid-wrap { flex: 1; min-height: 0; }
.fk-desk__toolbox { grid-area: tool; display: flex; flex-direction: column; min-height: 0; border-top: 1px solid var(--color-border-strong); background: var(--color-surface); }
.fk-statusbar { grid-area: status; display: flex; align-items: center; gap: var(--space-5); overflow: hidden; padding: 0 var(--space-3); background: var(--color-nav-bg); color: var(--color-nav-text); font-size: var(--text-xs); white-space: nowrap; }
.fk-statusbar > span { display: inline-flex; align-items: center; gap: var(--space-1); }
.fk-statusbar b { color: var(--color-nav-text-strong); }
.fk-statusbar__end { margin-left: auto; }

.fk-tree ul { margin: 0; padding: 0; list-style: none; }
.fk-body a.fk-tree__node, .fk-tree__node { display: flex; align-items: center; gap: var(--space-2); height: var(--row-height-grid); padding: 0 var(--space-3); color: var(--color-text); text-decoration: none; white-space: nowrap; }
.fk-tree ul ul .fk-tree__node { padding-left: var(--space-7); }
.fk-tree ul ul ul .fk-tree__node { padding-left: var(--space-8); }
a.fk-tree__node:hover { background: var(--color-row-hover); }
.fk-tree__node:focus-visible { outline-offset: calc(var(--focus-ring-width) * -1); }
.fk-tree__node[aria-current] { background: var(--color-row-selected); font-weight: var(--weight-bold); }
.fk-tree__label { min-width: 0; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: var(--figure-variant); }
.fk-tree__count { margin-left: auto; color: var(--color-text-subtle); font-variant-numeric: var(--figure-variant); }

.fk-toolbox { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.fk-toolbox__panel { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: auto; }
.fk-toolbox__panel > .fk-totals { margin-top: auto; border-bottom: 0; }
.fk-toolbox__tabs { flex: none; background: var(--color-surface-sunken); border-top: var(--hairline); }
.fk-toolbox__tabs ul { display: flex; height: var(--toolbox-tab-height); margin: 0; padding: 0 0 0 var(--space-2); list-style: none; }
.fk-body .fk-toolbox__tabs a, .fk-toolbox__tabs a { display: flex; align-items: center; gap: var(--space-2); height: 100%; padding: 0 var(--space-4); border-right: var(--hairline); color: var(--color-text-muted); text-decoration: none; white-space: nowrap; }
.fk-toolbox__tabs a:focus-visible { outline-offset: calc(var(--focus-ring-width) * -1); }
.fk-body .fk-toolbox__tabs a[aria-current], .fk-toolbox__tabs a[aria-current] { background: var(--color-surface); color: var(--color-text); font-weight: var(--weight-bold); box-shadow: inset 0 calc(var(--space-1) * -1) 0 var(--color-brand-gold-edge); }

/* 900 to 1150px: the Navigator becomes an icon rail (mt5-parity.md, W7). Every node stays, including the
   trading accounts. A label is hidden from sight only, so the link keeps its name; it shows beside the rail
   on keyboard focus or hover. It is placed against .fk-desk, so the Navigator's own scrolling does not clip it. */
@media (max-width: 1150px) {
  .fk-desk { grid-template-columns: var(--navigator-rail-width) minmax(0, 1fr); }
  .fk-desk__nav .fk-pane-title, .fk-tree__count { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; min-height: 0; padding: 0; border: 0; }
  .fk-tree__label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .fk-tree .fk-tree__node, .fk-tree ul ul .fk-tree__node, .fk-tree ul ul ul .fk-tree__node { justify-content: center; height: var(--touch-target); padding: 0; font-size: var(--text-lg); }
  .fk-tree__node:focus-visible .fk-tree__label, a.fk-tree__node:hover .fk-tree__label { left: var(--navigator-rail-width); z-index: var(--z-dropdown); width: auto; height: auto; overflow: visible; clip-path: none; margin-left: var(--space-1); padding: var(--space-1) var(--space-3); border: 1px solid var(--color-border-strong); border-radius: var(--radius-sm); background: var(--color-surface); color: var(--color-text); box-shadow: var(--shadow-2); font-size: var(--text-sm); font-weight: var(--weight-regular); }
  .fk-desk__wordmark { display: none; }
}

/* One page, two shells: the desktop workspace is for 900px and wider, the phone shell for narrower. */
@media (max-width: 899px) { .fk-desk:not(.fk-desk--embedded) { display: none; } }
@media (min-width: 900px) { .fk-phone--narrow-only:not(.fk-phone--embedded) { display: none; } }

/* ---------- Toolbox tab strip alone, and a tab that has no page yet ---------- */
.fk-toolbox__tab { display: flex; align-items: center; height: 100%; padding: 0 var(--space-4); border-right: var(--hairline); color: var(--color-text-subtle); white-space: nowrap; cursor: default; }

/* ---------- Navigator rail: the button that opens the full tree over the main area (mt5-parity.md, W7) ---------- */
.fk-desk__nav { position: relative; }
.fk-rail-open { display: none; }
.fk-rail-open > summary { display: grid; place-items: center; height: var(--touch-target); border-bottom: var(--hairline); color: var(--color-text); font-size: var(--text-lg); cursor: pointer; list-style: none; }
.fk-rail-open > summary::-webkit-details-marker { display: none; }
.fk-rail-open > summary:hover { background: var(--color-row-hover); }
.fk-rail-open > summary:focus-visible { outline-offset: calc(var(--focus-ring-width) * -1); }
.fk-rail-open[open] .fk-rail-open__closed, .fk-rail-open:not([open]) .fk-rail-open__opened { display: none; }
@media (min-width: 900px) and (max-width: 1150px) {
  .fk-rail-open { display: block; }
  .fk-desk__nav:has(> .fk-rail-open[open]) { z-index: var(--z-dropdown); width: var(--navigator-width); box-shadow: var(--shadow-3); }
  .fk-desk__nav:has(> .fk-rail-open[open]) > .fk-pane-title { position: static; width: auto; height: auto; overflow: visible; clip-path: none; min-height: var(--grid-header-height); padding: 0 var(--space-3); border-bottom: var(--hairline); }
  .fk-desk__nav:has(> .fk-rail-open[open]) .fk-tree .fk-tree__node { justify-content: flex-start; height: var(--row-height-grid); padding: 0 var(--space-3); font-size: inherit; }
  .fk-desk__nav:has(> .fk-rail-open[open]) .fk-tree ul ul .fk-tree__node { padding-left: var(--space-7); }
  .fk-desk__nav:has(> .fk-rail-open[open]) .fk-tree ul ul ul .fk-tree__node { padding-left: var(--space-8); }
  .fk-desk__nav:has(> .fk-rail-open[open]) .fk-tree .fk-tree__node .fk-tree__label { position: static; width: auto; height: auto; overflow: hidden; clip-path: none; margin: 0; padding: 0; border: 0; border-radius: 0; background: none; box-shadow: none; color: inherit; font-size: inherit; font-weight: inherit; }
  .fk-desk__nav:has(> .fk-rail-open[open]) .fk-tree__count { position: static; width: auto; height: auto; overflow: visible; clip-path: none; }
}

/* ---------- menu button: a native disclosure with a small panel under it ---------- */
.fk-menu { position: relative; flex: none; }
.fk-menu__button { display: grid; grid-auto-flow: column; place-items: center; gap: var(--space-1); min-width: var(--touch-target); height: var(--touch-target); padding: 0 var(--space-2); border-radius: var(--radius-sm); color: var(--color-nav-active-bg); font-size: var(--text-xl); cursor: pointer; list-style: none; }
.fk-menu__button::-webkit-details-marker { display: none; }
.fk-menu__button span { font-size: var(--text-sm); font-weight: var(--weight-bold); }
.fk-menu__button:focus-visible { outline: var(--focus-ring); outline-offset: calc(var(--focus-ring-width) * -1); }
.fk-menu[open] > .fk-menu__button { background: var(--color-nav-hover-bg); }
.fk-menu__panel { --color-focus: var(--color-link); --focus-ring: var(--focus-ring-width) solid var(--color-focus); position: absolute; top: calc(100% + var(--space-1)); right: 0; z-index: var(--z-dropdown); min-width: calc(var(--space-8) * 4); max-width: calc(100vw - var(--space-4)); max-height: calc(100dvh - var(--space-8) * 2); overflow: auto; padding: var(--space-1) 0; border: 1px solid var(--color-border-strong); border-radius: var(--radius-md); background: var(--color-surface); color: var(--color-text); box-shadow: var(--shadow-2); font: var(--weight-regular) var(--text-md)/var(--leading-body) var(--font-body); }
.fk-menu__panel form { display: block; width: auto; margin: 0; }
.fk-body a.fk-menu__item, .fk-menu__item { display: flex; align-items: center; gap: var(--space-2); width: 100%; min-width: 0; min-height: var(--touch-target); margin: 0; padding: 0 var(--space-4); border: 0; border-radius: 0; background: transparent; color: var(--color-text); font: inherit; text-align: left; text-decoration: none; white-space: nowrap; cursor: pointer; }
a.fk-menu__item:hover, button.fk-menu__item:hover { background: var(--color-row-hover); }
.fk-menu__item:focus-visible { outline: var(--focus-ring); outline-offset: calc(var(--focus-ring-width) * -1); }
.fk-menu__item[aria-current], .fk-menu__item[aria-pressed="true"] { font-weight: var(--weight-bold); }
.fk-menu__text { margin: 0; padding: var(--space-2) var(--space-4); color: var(--color-text-muted); font-size: var(--text-sm); overflow-wrap: anywhere; }
.fk-menu__text b { display: block; color: var(--color-text); font-size: var(--text-md); }
.fk-menu__rule { height: 0; margin: var(--space-1) 0; border: 0; border-top: var(--hairline); }

/* ---------- status bar controls: a language button or a link inside the 26px line ---------- */
.fk-statusbar form { display: inline-flex; width: auto; margin: 0; }
.fk-body a.fk-statusbar__control, .fk-statusbar__control { display: inline-flex; align-items: center; gap: var(--space-1); min-width: 0; min-height: var(--statusbar-height); margin: 0; padding: 0 var(--space-1); border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--color-nav-text); font: inherit; text-decoration: none; cursor: pointer; }
.fk-statusbar__control:hover { background: var(--color-nav-hover-bg); color: var(--color-nav-text-strong); }
.fk-statusbar__control[aria-current], .fk-statusbar__control[aria-pressed="true"] { color: var(--color-nav-text-strong); font-weight: var(--weight-bold); }
.fk-statusbar__control:focus-visible { outline: var(--focus-ring); outline-offset: calc(var(--focus-ring-width) * -1); }
.fk-statusbar__group { display: inline-flex; align-items: center; gap: var(--space-1); }

/* ---------- a plain list of destinations (Settings: mt5-parity.md, P9) ---------- */
.fk-links { background: var(--color-surface); }
.fk-links ul { margin: 0; padding: 0; list-style: none; }
.fk-body a.fk-links__link, .fk-links__link { display: flex; align-items: center; gap: var(--space-3); min-height: var(--row-height-1line); padding: 0 var(--space-4); border-bottom: var(--hairline); color: var(--color-text); text-decoration: none; }
.fk-links__link:hover { background: var(--color-row-hover); }
.fk-links__link:focus-visible { outline: var(--focus-ring); outline-offset: calc(var(--focus-ring-width) * -1); }
.fk-links__link[aria-current] { background: var(--color-row-selected); font-weight: var(--weight-bold); }
.fk-links__link .fk-icon { color: var(--color-text-muted); }

/* ---------- the shell as a host layout (D4): one page body, the document scrolls, the bars stick ----------
   The page is not a kit page (no fk-body), so each bar carries its own type. A staff layout nests the
   DesktopShell inside the PhoneShell; under 900px only the desktop shell's main area shows, and at 900px and
   wider only the phone shell's two bars hide. */
.fk-phone--layout { display: block; height: auto; min-height: 100dvh; }
.fk-phone--layout > .fk-topbar, .fk-phone--layout > .fk-tabbar, .fk-desk--layout > .fk-desk__toolbar, .fk-desk--layout > .fk-desk__nav, .fk-desk--layout > .fk-desk__toolbox, .fk-desk--layout > .fk-statusbar { font-family: var(--font-body); font-weight: var(--weight-regular); line-height: var(--leading-body); }
.fk-phone--layout > .fk-topbar { position: sticky; top: 0; z-index: var(--z-tabbar); padding-top: env(safe-area-inset-top, 0px); }
.fk-phone--layout > .fk-phone__main { overflow: visible; }
.fk-phone--layout > .fk-tabbar { position: fixed; left: 0; right: 0; bottom: 0; }
.fk-phone--layout:has(> .fk-tabbar) > .fk-phone__main { padding-bottom: calc(var(--tabbar-height) + env(safe-area-inset-bottom, 0px) + var(--space-4)); }
.fk-desk--layout { font-size: inherit; }
.fk-desk--layout > .fk-desk__main { display: block; min-width: 0; overflow: visible; background: transparent; }
.fk-desk--layout > .fk-desk__toolbar, .fk-desk--layout > .fk-desk__nav, .fk-desk--layout > .fk-desk__toolbox { font-size: var(--text-sm); }
.fk-desk--layout > .fk-desk__toolbar > .fk-desk__end { display: flex; align-items: center; gap: var(--space-2); margin-left: auto; }
.fk-desk--layout > .fk-desk__toolbar form { display: inline-flex; width: auto; margin: 0; }
@media (max-width: 899px) {
  .fk-desk--layout:not(.fk-desk--embedded) { display: block; height: auto; }
  .fk-desk--layout > .fk-desk__toolbar, .fk-desk--layout > .fk-desk__nav, .fk-desk--layout > .fk-desk__toolbox, .fk-desk--layout > .fk-statusbar { display: none; }
}
@media (min-width: 900px) {
  .fk-phone--layout.fk-phone--narrow-only:not(.fk-phone--embedded) { display: block; }
  .fk-phone--layout.fk-phone--narrow-only > .fk-topbar, .fk-phone--layout.fk-phone--narrow-only > .fk-tabbar { display: none; }
  .fk-phone--layout.fk-phone--narrow-only:has(> .fk-tabbar) > .fk-phone__main { padding-bottom: 0; }
  .fk-desk--layout { height: auto; min-height: 100dvh; grid-template-rows: var(--touch-target) minmax(0, 1fr) auto var(--statusbar-height); }
  .fk-desk--layout:not(:has(> .fk-desk__nav)) { grid-template-columns: minmax(0, 1fr); grid-template-areas: "bar" "main" "tool" "status"; }
  .fk-desk--layout > .fk-desk__toolbar { position: sticky; top: 0; z-index: var(--z-tabbar); }
  .fk-desk--layout > .fk-desk__nav { position: sticky; top: var(--touch-target); align-self: start; height: calc(100dvh - var(--touch-target) - var(--statusbar-height)); z-index: var(--z-sticky); }
  .fk-desk--layout > .fk-desk__toolbox { position: sticky; bottom: var(--statusbar-height); z-index: var(--z-sticky); }
  .fk-desk--layout > .fk-statusbar { position: sticky; bottom: 0; z-index: var(--z-tabbar); }
}
/* In a layout the Navigator is the scrolling box, so a rail label is placed against the window instead. */
@media (min-width: 900px) and (max-width: 1150px) {
  .fk-desk--layout .fk-tree__node:focus-visible .fk-tree__label, .fk-desk--layout a.fk-tree__node:hover .fk-tree__label { position: fixed; }
}

/* ---------- confirm dialog and bottom sheet ---------- */
.fk-dialog-layer { position: fixed; inset: 0; z-index: var(--z-scrim); display: grid; place-items: center; padding: var(--space-4); background: var(--color-scrim); }
.fk-dialog { position: relative; z-index: var(--z-sheet); width: 100%; max-width: calc(var(--space-8) * 9); padding: var(--space-5); border-radius: var(--radius-xl); background: var(--color-surface); color: var(--color-text); box-shadow: var(--shadow-3); }
.fk-dialog__title { font-size: var(--text-lg); }
.fk-dialog__body { margin: var(--space-2) 0 var(--space-5); color: var(--color-text-muted); }
.fk-dialog__actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--space-3); }
.fk-dialog-layer--sheet { place-items: end stretch; padding: 0; }
.fk-dialog-layer--sheet .fk-dialog { max-width: none; padding-bottom: calc(var(--space-5) + env(safe-area-inset-bottom, 0px)); border-radius: var(--radius-xl) var(--radius-xl) 0 0; }
.fk-dialog-layer--sheet .fk-dialog__actions { flex-direction: column-reverse; }
@media (max-width: 599px) {
  .fk-dialog-layer { place-items: end stretch; padding: 0; }
  .fk-dialog { max-width: none; padding-bottom: calc(var(--space-5) + env(safe-area-inset-bottom, 0px)); border-radius: var(--radius-xl) var(--radius-xl) 0 0; }
  .fk-dialog__actions { flex-direction: column-reverse; }
}

/* ---------- empty, loading, error ---------- */
.fk-state { display: flex; flex-direction: column; align-items: center; gap: var(--space-2); padding: var(--space-7) var(--space-4); background: var(--color-surface); color: var(--color-text-muted); text-align: center; }
.fk-state > .fk-icon { width: var(--space-7); height: var(--space-7); color: var(--color-text-subtle); }
.fk-state__title { color: var(--color-text); font-size: var(--text-md); }
.fk-state .fk-btn { margin-top: var(--space-2); }
.fk-state--error > .fk-icon { color: var(--status-held-fg); }
.fk-state--loading { display: block; padding: 0; }
.fk-skeleton { margin: 0; padding: 0; list-style: none; }
.fk-skeleton li { display: grid; align-content: center; gap: var(--space-2); height: var(--row-height-2line); padding: 0 var(--space-4); border-bottom: var(--hairline); }
.fk-skeleton li::before, .fk-skeleton li::after { content: ""; height: var(--space-3); border-radius: var(--radius-sm); background: var(--color-surface-sunken); animation: fk-pulse calc(var(--motion-slow) * 3) var(--ease-standard) infinite alternate; }
.fk-skeleton li::before { width: 55%; }
.fk-skeleton li::after { width: 35%; }
@keyframes fk-pulse { to { opacity: .4; } }
@media (prefers-reduced-motion: reduce) { .fk-skeleton li::before, .fk-skeleton li::after { animation: none; } }

/* ---------- alert banner and toast ---------- */
.fk-alert { display: flex; align-items: flex-start; gap: var(--space-3); padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); background: var(--status-neutral-bg); color: var(--status-neutral-fg); font-size: var(--text-sm); }
.fk-alert[hidden] { display: none; }
.fk-alert--wait { background: var(--status-wait-bg); color: var(--status-wait-fg); }
.fk-alert--progress { background: var(--status-progress-bg); color: var(--status-progress-fg); }
.fk-alert--done { background: var(--status-done-bg); color: var(--status-done-fg); }
.fk-alert--held { background: var(--status-held-bg); color: var(--status-held-fg); }
.fk-alert > .fk-icon { margin-top: var(--space-1); }
.fk-alert__text { flex: 1; min-width: 0; }
.fk-alert__text strong { display: block; }
.fk-body a.fk-alert__close, .fk-alert__close { display: grid; place-items: center; width: var(--touch-target); height: var(--touch-target); margin: calc(var(--space-3) * -1) calc(var(--space-3) * -1) calc(var(--space-3) * -1) 0; color: inherit; }
.fk-alert--toast { position: fixed; z-index: var(--z-toast); left: var(--space-4); right: var(--space-4); bottom: calc(var(--tabbar-height) + var(--space-4) + env(safe-area-inset-bottom, 0px)); max-width: calc(var(--space-8) * 9); margin: 0 auto; box-shadow: var(--shadow-2); }

/* ---------- gallery page only ---------- */
.fk-gallery { max-width: calc(var(--space-8) * 30); margin: 0 auto; padding: var(--space-5) var(--space-4) var(--space-8); }
.fk-gallery__head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3) var(--space-4); }
.fk-gallery__head > div { flex: 1 1 calc(var(--space-8) * 6); }
.fk-gallery__head h1 { font-size: var(--text-xl); }
.fk-gallery__head p { color: var(--color-text-muted); }
.fk-gallery > section > h2 { margin: var(--space-7) 0 var(--space-3); font-size: var(--text-lg); }
.fk-gallery__stage { margin-bottom: var(--space-3); border: var(--hairline); border-radius: var(--radius-lg); background: var(--color-surface); overflow: hidden; }
.fk-gallery__stage--row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-4); padding: var(--space-4); }
.fk-gallery__stage--stack { display: grid; gap: var(--space-3); padding: var(--space-4); }
.fk-gallery__stage--fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(calc(var(--space-8) * 5), 1fr)); gap: var(--space-4); padding: var(--space-4); }
.fk-gallery__stage--split { display: grid; grid-template-columns: repeat(auto-fit, minmax(calc(var(--space-8) * 5), 1fr)); }
.fk-gallery__stage--split > * { border-right: var(--hairline); }
.fk-gallery__ink { padding: var(--space-2) var(--space-3); border-radius: var(--radius-sm); background: var(--color-nav-bg); color: var(--color-nav-text-strong); }
.fk-gallery__frame { width: 375px; max-width: 100%; height: calc(var(--space-8) * 15); border: 1px solid var(--color-border-strong); border-radius: var(--radius-xl); overflow: hidden; }
.fk-gallery__frame .fk-phone { height: 100%; }
@media (max-width: 439px) {
  .fk-gallery__stage:has(> .fk-gallery__frame) { margin-inline: calc(var(--space-4) * -1); padding: var(--space-4) 0; border-inline: 0; border-radius: 0; }
  .fk-gallery__frame { border-inline: 0; border-radius: 0; }
}
.fk-gallery__desk { overflow-x: auto; }
.fk-gallery__desk .fk-desk { min-width: 900px; height: calc(var(--space-8) * 13); }
.fk-gallery__note { padding: var(--space-3) var(--space-4); color: var(--color-text-muted); font-size: var(--text-sm); }
.fk-gallery__stage .fk-dialog-layer { position: relative; z-index: auto; min-height: calc(var(--space-8) * 6); }
.fk-gallery__stage .fk-alert--toast { position: static; margin: 0; }

/* ---------- directory list: one markup, two-line rows on a phone and a dense grid at 900px and wider ---------- */
.fk-dir { background: var(--color-surface); font-size: var(--text-sm); }
.fk-dir__rows { margin: 0; padding: 0; list-style: none; }
.fk-dir__row { position: relative; border-bottom: var(--hairline); }
.fk-dir__row:hover { background: var(--color-row-hover); }
.fk-dir dl, .fk-dir dd { margin: 0; }
.fk-dir dd { font-variant-numeric: var(--figure-variant); }
.fk-body a.fk-dir__title, .fk-dir__title { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--color-text); font-weight: var(--weight-bold); font-variant-numeric: var(--figure-variant); text-decoration: none; }
.fk-dir__title:focus-visible { outline-offset: calc(var(--focus-ring-width) * -1); }
.fk-dir__cell { min-width: 0; }
@media (max-width: 899px) {
  .fk-dir__head { display: none; }
  .fk-body a.fk-dir__title, .fk-dir__title { min-height: var(--row-height-2line); padding: var(--space-2) var(--space-4) calc(var(--row-height-2line) / 2); font-size: var(--text-md); line-height: var(--leading-tight); }
  .fk-dir .fk-dir__line { display: flex; align-items: center; height: calc(var(--row-height-2line) / 2); margin: calc(var(--row-height-2line) / -2) var(--space-4) 0; overflow: hidden; color: var(--color-text-muted); white-space: nowrap; pointer-events: none; }
  .fk-dir__line .fk-dir__cell { flex: 0 1 auto; display: flex; }
  .fk-dir__line .fk-dir__cell:has(.fk-status) { flex: none; }
  .fk-dir__line dt { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .fk-dir__line dd { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  .fk-dir__line .fk-dir__cell + .fk-dir__cell::before { content: "\00B7"; margin: 0 var(--space-1); color: var(--color-text-subtle); }
  .fk-dir__detail { padding: 0 var(--space-4) var(--space-2); }
  .fk-dir__detail .fk-dir__cell { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-3); min-height: var(--space-6); text-align: left; }
  .fk-dir__detail dt { flex: none; color: var(--color-text-muted); }
  .fk-dir__detail dd { min-width: 0; text-align: right; overflow-wrap: anywhere; }
  .fk-dir__detail .fk-dir__hint { display: none; }
}
@media (min-width: 900px) {
  .fk-dir { display: grid; grid-template-columns: var(--fk-dir-columns, repeat(var(--fk-dir-count), minmax(0, 1fr))); }
  .fk-dir--n2 { --fk-dir-count: 2; } .fk-dir--n3 { --fk-dir-count: 3; } .fk-dir--n4 { --fk-dir-count: 4; } .fk-dir--n5 { --fk-dir-count: 5; }
  .fk-dir--n6 { --fk-dir-count: 6; } .fk-dir--n7 { --fk-dir-count: 7; } .fk-dir--n8 { --fk-dir-count: 8; } .fk-dir--n9 { --fk-dir-count: 9; }
  .fk-dir--n10 { --fk-dir-count: 10; } .fk-dir--n11 { --fk-dir-count: 11; } .fk-dir--n12 { --fk-dir-count: 12; }
  .fk-dir__head, .fk-dir__rows, .fk-dir__row, .fk-dir__group { display: grid; grid-template-columns: subgrid; grid-column: 1 / -1; }
  .fk-dir__head > span { display: flex; align-items: center; min-width: 0; height: var(--grid-header-height); padding: 0 var(--space-2); overflow: hidden; background: var(--color-surface-sunken); border-bottom: 1px solid var(--color-border-strong); border-right: var(--hairline); color: var(--color-text-muted); font-size: var(--text-xs); font-weight: var(--weight-bold); white-space: nowrap; }
  .fk-dir__head > span.fk-num { justify-content: flex-end; }
  .fk-dir__row { align-items: center; min-height: var(--row-height-grid); }
  .fk-dir__row:nth-child(even) { background: var(--color-row-zebra); }
  .fk-dir__row:nth-child(even):hover { background: var(--color-row-hover); }
  .fk-body a.fk-dir__title, .fk-dir__title { height: var(--row-height-grid); padding: 0 var(--space-2); line-height: var(--row-height-grid); }
  .fk-dir__line, .fk-dir__detail { display: contents; }
  .fk-dir__group { grid-column: auto; }
  .fk-dir__span2 { grid-column: span 2; } .fk-dir__span3 { grid-column: span 3; } .fk-dir__span4 { grid-column: span 4; }
  .fk-dir__cell { position: relative; padding: 0 var(--space-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .fk-dir__cell dt { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .fk-dir__cell dd { display: inline; }
  .fk-dir__hint { display: none; }
}
