/* SKILLMERC product kit v1: components. Needs tokens.css first.
   is-hover and is-focus show those states in screenshots and the sample board only; never set them in a product.
   Every class starts with sk- so nothing collides with a host page or a product's old CSS.
   Rules held by every component: works at 320 px wide, in dark mode, by keyboard, and at 200 percent zoom.
   Status is never shown by colour alone: every badge and notice has words, and most have a mark. */

/* ---------- base ---------- */
/* The focus ring is built here, not in tokens.css, so it picks up the product accent of the element it is on. */
.sk-root, .sk-root * { --sk-focus-ring: 0 0 0 2px var(--sk-surface), 0 0 0 4px var(--sk-accent); }
.sk-root {
  font-family: var(--sk-font); font-size: var(--sk-text-sm); line-height: var(--sk-leading); font-weight: var(--sk-weight);
  color: var(--sk-text); background: var(--sk-bg); -webkit-font-smoothing: antialiased; text-size-adjust: 100%;
}
.sk-root *, .sk-root *::before, .sk-root *::after { box-sizing: border-box; }
.sk-root :where(h1, h2, h3, h4, p, ul, ol, figure) { margin: 0; }
.sk-root :where(h1, h2, h3) { font-weight: var(--sk-weight-title); letter-spacing: var(--sk-tracking-title); line-height: var(--sk-leading-tight); }
.sk-root :where(a) { color: var(--sk-accent); text-underline-offset: 2px; }
.sk-root :where(a):hover { color: var(--sk-accent-hover); }
.sk-root :where(code, kbd, pre) { font-family: var(--sk-mono); font-size: 0.92em; }
.sk-root [hidden] { display: none !important; }
.sk-root :focus { outline: none; }
.sk-root :focus-visible, .sk-root .is-focus { outline: none; box-shadow: var(--sk-focus-ring); }
/* Windows high contrast: box-shadow is dropped there, so keep a real outline. */
@media (forced-colors: active) { .sk-root :focus-visible { outline: 2px solid CanvasText; outline-offset: 2px; } }
.sk-muted { color: var(--sk-text-muted); }
.sk-small { font-size: var(--sk-text-xs); }
.sk-title { font-size: var(--sk-text-md); font-weight: var(--sk-weight-title); }
.sk-h1 { font-size: var(--sk-text-lg); }
.sk-stack { display: flex; flex-direction: column; gap: var(--sk-space-2); }
.sk-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sk-space-2); }
.sk-grow { flex: 1 1 auto; min-width: 0; }
.sk-sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- buttons ----------
   .sk-btn alone = secondary. Add --primary (one per view), --quiet (low weight), --danger (deletes).
   Loading: set aria-busy="true" and disabled; the label stays so the width does not jump. */
.sk-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sk-space-2);
  min-height: 32px; padding: 6px 12px; border-radius: var(--sk-radius); border: 1px solid var(--sk-line-strong);
  background: var(--sk-surface); color: var(--sk-text); font: inherit; font-weight: var(--sk-weight-strong);
  line-height: 1.2; text-align: center; text-decoration: none; cursor: pointer; white-space: normal; overflow-wrap: break-word;
  transition: background-color var(--sk-fast) var(--sk-ease), border-color var(--sk-fast) var(--sk-ease), color var(--sk-fast) var(--sk-ease);
}
.sk-btn:hover:not(:disabled):not([aria-disabled="true"]), .sk-btn.is-hover { border-color: var(--sk-accent); color: var(--sk-text); background: var(--sk-accent-soft); }
.sk-btn:active:not(:disabled) { transform: translateY(1px); }
.sk-btn--primary { background: var(--sk-accent); border-color: var(--sk-accent); color: var(--sk-on-accent); }
.sk-btn--primary:hover:not(:disabled):not([aria-disabled="true"]), .sk-btn--primary.is-hover { background: var(--sk-accent-hover); border-color: var(--sk-accent-hover); color: var(--sk-on-accent); }
.sk-btn--quiet { border-color: transparent; background: transparent; color: var(--sk-accent); }
.sk-btn--quiet:hover:not(:disabled):not([aria-disabled="true"]), .sk-btn--quiet.is-hover { background: var(--sk-accent-soft); border-color: transparent; color: var(--sk-accent); }
.sk-btn--danger { color: var(--sk-danger); border-color: var(--sk-danger); }
.sk-btn--danger:hover:not(:disabled):not([aria-disabled="true"]), .sk-btn--danger.is-hover { background: var(--sk-danger-soft); border-color: var(--sk-danger); color: var(--sk-danger); }
.sk-btn--danger-solid { background: var(--sk-danger); border-color: var(--sk-danger); color: var(--sk-on-accent); }
.sk-btn--sm { min-height: 28px; padding: 4px 10px; font-size: var(--sk-text-xs); }
.sk-btn--block { display: flex; width: 100%; }
/* A grid of equal buttons (export formats): as many columns as fit, never a word broken inside a button. */
.sk-btn-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: var(--sk-space-2); }
.sk-btn--icon { min-width: 32px; padding: 6px; border-color: transparent; background: transparent; color: var(--sk-text-muted); }
.sk-btn:disabled, .sk-btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }
.sk-btn[aria-busy="true"] { cursor: progress; opacity: 0.85; }
.sk-btn[aria-busy="true"]::before {
  content: ""; width: 12px; height: 12px; flex: none; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent; animation: sk-spin 0.8s linear infinite;
}
@keyframes sk-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .sk-btn[aria-busy="true"]::before { animation: none; border-right-color: currentColor; opacity: 0.6; } .sk-btn:active:not(:disabled) { transform: none; } }

/* ---------- fields ---------- */
.sk-field { display: flex; flex-direction: column; gap: var(--sk-space-1); min-width: 0; }
.sk-label { font-weight: var(--sk-weight-strong); color: var(--sk-text); }
.sk-hint { font-size: var(--sk-text-xs); color: var(--sk-text-muted); }
.sk-error-text { font-size: var(--sk-text-xs); color: var(--sk-danger); font-weight: var(--sk-weight-strong); }
.sk-input, .sk-select {
  width: 100%; min-width: 0; min-height: 32px; padding: 6px 10px; border-radius: var(--sk-radius);
  border: 1px solid var(--sk-line-strong); background: var(--sk-surface); color: var(--sk-text); font: inherit;
}
.sk-input::placeholder { color: var(--sk-text-faint); opacity: 1; }
.sk-input:focus-visible, .sk-select:focus-visible, .sk-input.is-focus { border-color: var(--sk-accent); border-radius: var(--sk-radius); }
.sk-input[aria-invalid="true"] { border-color: var(--sk-danger); }
.sk-input:disabled, .sk-select:disabled { opacity: 0.55; cursor: not-allowed; }
.sk-input--num { width: 72px; }
.sk-select { appearance: none; padding-right: 28px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 14px) 50%, calc(100% - 9px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.sk-check { display: inline-flex; align-items: flex-start; gap: var(--sk-space-2); cursor: pointer; }
.sk-check input { width: 16px; height: 16px; margin: 1px 0 0; flex: none; accent-color: var(--sk-accent); cursor: pointer; }
.sk-check input:focus-visible { box-shadow: var(--sk-focus-ring); border-radius: 3px; }
/* Switch: <button class="sk-switch" role="switch" aria-checked="true"><span class="sk-switch__track"></span>Label</button> */
.sk-switch { display: inline-flex; align-items: center; gap: var(--sk-space-2); padding: 2px 0; border: 0; background: none; color: var(--sk-text); font: inherit; cursor: pointer; text-align: left; }
.sk-switch__track { position: relative; width: 34px; height: 20px; flex: none; border-radius: var(--sk-radius-pill); background: var(--sk-n-400); transition: background-color var(--sk-base) var(--sk-ease); }
.sk-switch__track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--sk-n-0); box-shadow: var(--sk-shadow-1); transition: transform var(--sk-base) var(--sk-ease); }
.sk-switch[aria-checked="true"] .sk-switch__track { background: var(--sk-accent); }
.sk-switch[aria-checked="true"] .sk-switch__track::after { transform: translateX(14px); }
.sk-switch:focus-visible, .sk-switch.is-focus { box-shadow: none; }
.sk-switch:focus-visible .sk-switch__track, .sk-switch.is-focus .sk-switch__track { box-shadow: var(--sk-focus-ring); }
.sk-switch[aria-checked="true"] .sk-switch__state::before { content: "On"; }
.sk-switch[aria-checked="false"] .sk-switch__state::before { content: "Off"; }
.sk-switch__state { font-size: var(--sk-text-xs); color: var(--sk-text-muted); }

/* ---------- badge and pill ----------
   Pill = plan (Free, Pro). Badge = status, always with a mark and a word. */
.sk-pill { display: inline-flex; align-items: center; padding: 1px 8px; border-radius: var(--sk-radius-pill); font-size: var(--sk-text-xs); font-weight: var(--sk-weight-title); line-height: 1.5; letter-spacing: 0.02em; white-space: nowrap; border: 1px solid transparent; }
.sk-pill--free { background: var(--sk-bg-sunken); color: var(--sk-text-muted); border-color: var(--sk-line); }
.sk-pill--pro { background: var(--sk-accent-soft); color: var(--sk-accent); border-color: var(--sk-accent); }
.sk-badge { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: var(--sk-radius-pill); font-size: var(--sk-text-xs); font-weight: var(--sk-weight-strong); line-height: 1.5; border: 1px solid var(--sk-line-strong); color: var(--sk-text); background: var(--sk-surface); white-space: nowrap; }
.sk-badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.sk-badge--ok { color: var(--sk-success); border-color: currentColor; background: var(--sk-success-soft); }
.sk-badge--changed { color: var(--sk-accent); border-color: currentColor; background: var(--sk-accent-soft); }
.sk-badge--warn { color: var(--sk-warning); border-color: currentColor; background: var(--sk-warning-soft); }
.sk-badge--error { color: var(--sk-danger); border-color: currentColor; background: var(--sk-danger-soft); }
.sk-badge--off { color: var(--sk-text-muted); border-style: dashed; }
.sk-badge--off::before { background: transparent; border: 1.5px solid currentColor; width: 6px; height: 6px; }
/* Each status has its own mark shape, so status never rests on colour (Reviewer 1148): Changed = dot, No change = tick,
   Needs attention = triangle, Problem = diamond, Paused = ring. */
.sk-badge--ok::before { width: 4px; height: 8px; margin: 0 2px 2px 1px; border-radius: 0; background: transparent; border: solid currentColor; border-width: 0 2px 2px 0; transform: rotate(45deg); }
.sk-badge--warn::before { width: 9px; height: 8px; border-radius: 0; clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.sk-badge--error::before { width: 7px; height: 7px; border-radius: 0; transform: rotate(45deg); }

/* ---------- notice ----------
   Shape: title = what happened (one short sentence). Body = what to do next. Optional actions row. */
.sk-notice { --sk-notice-c: var(--sk-text-muted); display: grid; grid-template-columns: 18px minmax(0, 1fr); gap: 2px var(--sk-space-2); padding: 10px 12px; border-radius: var(--sk-radius); border: 1px solid var(--sk-line); border-left-width: 4px; background: var(--sk-bg-sunken); color: var(--sk-text); }
.sk-notice__icon { width: 18px; height: 18px; margin-top: 1px; color: var(--sk-notice-c); }
.sk-notice__title { font-weight: var(--sk-weight-strong); grid-column: 2; }
.sk-notice__body { grid-column: 2; color: var(--sk-text); }
.sk-notice__actions { grid-column: 2; display: flex; flex-wrap: wrap; gap: var(--sk-space-2); margin-top: var(--sk-space-2); }
.sk-notice--info { --sk-notice-c: var(--sk-info); background: var(--sk-info-soft); border-color: var(--sk-info); }
.sk-notice--success { --sk-notice-c: var(--sk-success); background: var(--sk-success-soft); border-color: var(--sk-success); }
.sk-notice--warning { --sk-notice-c: var(--sk-warning); background: var(--sk-warning-soft); border-color: var(--sk-warning); }
.sk-notice--error { --sk-notice-c: var(--sk-danger); background: var(--sk-danger-soft); border-color: var(--sk-danger); }
.sk-notice--info, .sk-notice--success, .sk-notice--warning, .sk-notice--error { border-top-color: transparent; border-right-color: transparent; border-bottom-color: transparent; }

/* ---------- card ---------- */
.sk-card { background: var(--sk-surface); border: 1px solid var(--sk-line); border-radius: var(--sk-radius-lg); padding: var(--sk-space-3) var(--sk-space-4); }
.sk-card--sunken { background: var(--sk-bg-sunken); }
.sk-card__head { display: flex; align-items: center; gap: var(--sk-space-2); margin-bottom: var(--sk-space-2); }
.sk-card__label { color: var(--sk-text-muted); font-size: var(--sk-text-xs); font-weight: var(--sk-weight-strong); text-transform: uppercase; letter-spacing: 0.06em; }

/* ---------- table ---------- */
.sk-table-wrap { overflow: auto; max-width: 100%; border: 1px solid var(--sk-line); border-radius: var(--sk-radius); background: var(--sk-surface); }
.sk-table-wrap:focus-visible { box-shadow: var(--sk-focus-ring); }
.sk-table { border-collapse: collapse; width: 100%; font-size: var(--sk-text-xs); font-variant-numeric: tabular-nums; }
.sk-table th { position: sticky; top: 0; z-index: 1; text-align: left; font-weight: var(--sk-weight-strong); color: var(--sk-text-muted); background: var(--sk-bg-sunken); border-bottom: 1px solid var(--sk-line); padding: 6px 8px; white-space: nowrap; }
.sk-table td { padding: 5px 8px; border-bottom: 1px solid var(--sk-line); max-width: 220px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; vertical-align: top; }
.sk-table tr:last-child td { border-bottom: 0; }
/* .sk-fill on the one long column: it takes the spare width and ends in "..." instead of pushing the table wider. */
.sk-table .sk-fill { max-width: 0; width: 100%; }
.sk-table td.sk-num, .sk-table th.sk-num { text-align: right; color: var(--sk-text-muted); width: 1%; }

/* ---------- empty state ----------
   Shape: what this place is for, one sentence on how to fill it, one primary action, optional sample. */
.sk-empty { display: flex; flex-direction: column; align-items: flex-start; gap: var(--sk-space-2); padding: var(--sk-space-5); border: 1px dashed var(--sk-line-strong); border-radius: var(--sk-radius-lg); background: var(--sk-bg-sunken); }
.sk-empty__icon { width: 28px; height: 28px; color: var(--sk-accent); }
.sk-empty__title { font-size: var(--sk-text-md); font-weight: var(--sk-weight-title); }

/* ---------- modal confirm ----------
   Use <dialog class="sk-modal"> with showModal(): it traps focus and Escape closes it.
   The safe choice (Cancel) gets first focus; the risky one is on the right. */
.sk-modal { width: min(420px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow: auto; padding: var(--sk-space-5); border: 1px solid var(--sk-line); border-radius: var(--sk-radius-lg); background: var(--sk-surface-raised); color: var(--sk-text); box-shadow: var(--sk-shadow-panel); }
.sk-modal::backdrop { background: var(--sk-backdrop); }
.sk-modal__title { font-size: var(--sk-text-md); font-weight: var(--sk-weight-title); margin-bottom: var(--sk-space-2); }
.sk-modal__actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--sk-space-2); margin-top: var(--sk-space-4); }

/* ---------- toast ----------
   role="status" (polite). Stays at least 5 seconds, longer than that when it has an Undo. Never the only place an error is shown. */
.sk-toast { display: flex; align-items: center; gap: var(--sk-space-3); max-width: min(380px, calc(100vw - 24px)); padding: 10px 12px 10px 14px; border-radius: var(--sk-radius); background: var(--sk-n-900); color: var(--sk-n-50); box-shadow: var(--sk-shadow-2); font-size: var(--sk-text-sm); animation: sk-rise var(--sk-base) var(--sk-ease); }
[data-theme="dark"] .sk-toast { background: var(--sk-n-0); color: var(--sk-n-900); }
@media (prefers-color-scheme: dark) { .sk-root:not([data-theme="light"]) .sk-toast { background: var(--sk-n-0); color: var(--sk-n-900); } }
.sk-toast .sk-btn--quiet { color: inherit; text-decoration: underline; padding: 4px 6px; min-height: 28px; }
@keyframes sk-rise { from { transform: translateY(6px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- panel shell (injected into someone else's page) ----------
   Isolation, all three, every time:
   1. Mount in a closed shadow root on a host element the product creates: host.attachShadow({ mode: "closed" }).
      Page CSS cannot select inside it; our CSS cannot leak out.
   2. :host { all: initial } resets every inherited property the page sets on the host (font, color, line-height,
      letter-spacing, text-transform, direction...). Custom properties are NOT reset by all, so the panel's root
      element carries class sk-root, which redefines every --sk-* token itself.
   3. direction: ltr and unicode-bidi: isolate on :host and the panel, so a right-to-left page (Arabic, Hebrew)
      does not flip our panel (Threadkeep screen review F1, Nov 2026).
   Fonts: @font-face inside a shadow root is ignored by Chrome, and loading our font into a stranger's page
   would expose a web-accessible file. So panels use --sk-font-system. Pages the product owns use --sk-font.
   Sizes are px so a page's html { font-size } cannot shrink the panel. */
/* !important on :host: a page's own rule on the host element (a plain "div { letter-spacing: 4px }" or "* { all: unset }")
   beats a normal :host rule, but an important :host rule beats every page rule (Reviewer 1148 hostile-page test). */
:host { all: initial !important; display: block !important; direction: ltr !important; unicode-bidi: isolate !important; }
.sk-panel {
  direction: ltr; unicode-bidi: isolate; font-family: var(--sk-font-system);
  /* second lock: reset what a page could still pass down if a product mounts without a shadow root */
  text-align: left; text-indent: 0; text-transform: none; text-shadow: none; letter-spacing: normal; word-spacing: normal;
  white-space: normal; font-style: normal; cursor: auto; visibility: visible;
  position: fixed; top: 12px; right: 12px; z-index: 2147483647;
  width: 380px; max-width: calc(100vw - 24px); max-height: calc(100vh - 24px);
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--sk-surface); color: var(--sk-text); border: 1px solid var(--sk-line); border-radius: var(--sk-radius-lg); box-shadow: var(--sk-shadow-panel);
}
.sk-panel--static { position: static; max-height: none; }
.sk-panel--wide { width: 560px; }
.sk-panel__head { min-height: 52px; display: flex; align-items: center; gap: var(--sk-space-2); padding: 6px 10px 6px 14px; border-bottom: 1px solid var(--sk-line); }
.sk-panel__icon { width: 22px; height: 22px; flex: none; border-radius: var(--sk-radius-sm); background: var(--sk-accent); color: var(--sk-on-accent); display: grid; place-items: center; }
.sk-panel__icon svg { width: 14px; height: 14px; }
.sk-panel__name { font-size: var(--sk-text-md); font-weight: var(--sk-weight-title); letter-spacing: var(--sk-tracking-title); }
.sk-panel__body { display: flex; flex-direction: column; gap: var(--sk-space-3); padding: var(--sk-space-3) 14px; overflow: auto; min-height: 0; }
.sk-panel__foot { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sk-space-2) var(--sk-space-3); padding: 8px 14px; border-top: 1px solid var(--sk-line); background: var(--sk-bg-sunken); font-size: var(--sk-text-xs); color: var(--sk-text-muted); }
/* Launcher button a product may float on the page (Threadkeep's Export button). */
.sk-fab { position: fixed; right: 18px; bottom: 96px; z-index: 2147483646; display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 8px 14px; border-radius: var(--sk-radius-pill); border: 1px solid var(--sk-accent-hover); background: var(--sk-accent); color: var(--sk-on-accent); font-family: var(--sk-font-system); font-size: var(--sk-text-sm); font-weight: var(--sk-weight-strong); line-height: 1; box-shadow: var(--sk-shadow-2); cursor: pointer; direction: ltr; unicode-bidi: isolate; }
.sk-fab:hover { background: var(--sk-accent-hover); }

/* ---------- footer: the mark and "Made by SKILLMERC" ----------
   Same place in every product: the last line of the injected panel and of the settings or about page.
   Markup: <footer class="sk-made"><svg class="sk-mark">...the mark...</svg><span>Made by SKILLMERC</span></footer> */
.sk-made { display: inline-flex; align-items: center; gap: 6px; font-size: var(--sk-text-xs); color: var(--sk-text-muted); white-space: nowrap; }
.sk-made a { color: inherit; text-decoration: none; }
.sk-made a:hover { color: var(--sk-text); text-decoration: underline; }
.sk-mark { width: 16px; height: 16px; flex: none; display: block; }
.sk-foot-links { display: flex; flex-wrap: wrap; gap: var(--sk-space-3); margin-left: auto; }
.sk-foot-links a { color: var(--sk-text-muted); }

/* ---------- page shell (options, library, watch list: pages the product owns) ---------- */
.sk-page { max-width: 760px; margin: 0 auto; padding: var(--sk-space-6) var(--sk-space-4) var(--sk-space-8); font-size: var(--sk-text-md); }
.sk-page__head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sk-space-3); margin-bottom: var(--sk-space-5); }
.sk-page__foot { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sk-space-3); margin-top: var(--sk-space-8); padding-top: var(--sk-space-4); border-top: 1px solid var(--sk-line); }

/* ---------- small screens ---------- */
@media (max-width: 420px) {
  .sk-panel, .sk-panel--wide { top: 8px; right: 8px; left: 8px; width: auto; max-width: none; }
  .sk-panel--static { width: 100%; }
  .sk-modal__actions { flex-direction: column-reverse; }
  .sk-modal__actions .sk-btn { width: 100%; }
}
