/* R192 customer/workspace surfaces. Keep editor canvases and financial
   markup semantically unchanged; only shell, cards and controls are themed. */
body.pf-portal-r192[data-portal-family="tools"],
body.pf-portal-r192[data-portal-family="editor"],
body.pf-portal-r192[data-portal-family="account"],
body.pf-portal-r192[data-portal-family="commerce"],
body.pf-portal-r192[data-portal-family="chat"] {
  --ws192-bg: #f4f5f7;
  --ws192-surface: #fff;
  --ws192-text: #171b2d;
  --ws192-muted: #596174;
  --ws192-line: #dfe2ea;
  --ws192-accent: #6158ef;
  --ws192-soft: #efefff;
  background: var(--ws192-bg);
  color: var(--ws192-text);
  color-scheme: light;
}
body.pf-portal-r192[data-portal-family="tools"] [hidden],
body.pf-portal-r192[data-portal-family="editor"] [hidden],
body.pf-portal-r192[data-portal-family="account"] [hidden],
body.pf-portal-r192[data-portal-family="commerce"] [hidden],
body.pf-portal-r192[data-portal-family="chat"] [hidden] { display: none !important; }

/* Standalone tools. */
body.pf-portal-r192[data-portal-family="tools"] .tools-topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  width: min(1240px, calc(100% - 32px));
  max-width: 1240px;
  margin-inline: auto;
  padding: 8px 0;
  border-bottom-color: var(--ws192-line);
  background: var(--ws192-surface);
}
body.pf-portal-r192[data-portal-family="tools"] .tools-brand,
body.pf-portal-r192[data-portal-family="tools"] .tools-breadcrumb { color: var(--ws192-text); }
body.pf-portal-r192[data-portal-family="tools"] .tools-primary-nav { min-width: 0; margin-left: auto; }
body.pf-portal-r192[data-portal-family="tools"] .tools-nav-link {
  min-height: 44px;
  border-radius: 8px;
  color: var(--ws192-muted);
  font-size: 14px;
}
body.pf-portal-r192[data-portal-family="tools"] .tools-nav-link:hover,
body.pf-portal-r192[data-portal-family="tools"] .tools-nav-link.is-active {
  background: var(--ws192-soft);
  color: var(--ws192-accent);
}
body.pf-portal-r192[data-portal-family="tools"] main {
  width: min(1240px, calc(100% - 32px));
  max-width: 1240px;
  margin-inline: auto;
  padding: 30px 0 52px;
}
body.pf-portal-r192[data-portal-family="tools"] :is(.toolbar, .search-row, .summary, .layout > aside, .health, .secondary-monitor, section, .entry, .source-row, .service, .empty) {
  border-color: var(--ws192-line);
  background: var(--ws192-surface);
  color: var(--ws192-text);
}
body.pf-portal-r192[data-portal-family="tools"] :is(h1, h2, h3, h4) { color: var(--ws192-text); }
body.pf-portal-r192[data-portal-family="tools"] :is(p, label, small, .muted, .note, .range, .meta, .source, .source-row small, .entry small, .service small) { color: var(--ws192-muted); }
body.pf-portal-r192[data-portal-family="tools"] :is(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]), select) {
  min-height: 44px;
  border: 1px solid #c9ceda;
  border-radius: 8px;
  background: var(--ws192-surface);
  color: var(--ws192-text);
  font-size: 16px;
}
body.pf-portal-r192[data-portal-family="tools"] :is(button, .button, .outline) { min-height: 44px; border-radius: 8px; }
body.pf-portal-r192[data-portal-family="tools"] :is(button[aria-pressed="true"], .button.primary) { background: var(--ws192-accent); border-color: var(--ws192-accent); color: #fff; }
body.pf-portal-r192[data-portal-family="tools"] .fw-reset { --rs-bg: var(--ws192-surface); --rs-line: var(--ws192-line); --rs-text: var(--ws192-text); --rs-muted: var(--ws192-muted); --rs-accent: var(--ws192-accent); }

/* The standalone tool pages use .periods, .filters and .warn/.warning in
   their shipped DOM. Keep the selected label and source-health notices
   readable on the light portal surface. */
body.pf-portal-r192[data-portal-family="tools"] :is(.periods a[aria-current="page"], .filters button[aria-pressed="true"]) {
  border-color: var(--ws192-accent);
  background: var(--ws192-accent);
  color: #fff;
}
body.pf-portal-r192[data-portal-family="tools"] .periods a[aria-current="page"] :is(strong, span) { color: #fff; }
body.pf-portal-r192[data-portal-family="tools"] :is(.warning, .warn, .note.warn, .source-row .warning, .source-line .warn) {
  border-color: #e0bd56;
  background: #fff4c2;
  color: #684a00;
}
body.pf-portal-r192[data-portal-family="tools"] #status:not(:empty) {
  border-color: #e0bd56;
  background: #fff4c2;
  color: #684a00;
}
body.pf-portal-r192[data-portal-family="tools"] :is(.intro, .heading) {
  gap: 12px;
  margin-bottom: 14px;
}
body.pf-portal-r192[data-portal-family="tools"] :is(.intro h1, .heading h1) { margin-block: 4px 8px; }
body.pf-portal-r192[data-portal-family="tools"] :is(.intro p, .heading p) { margin-block: 4px 8px; }
body.pf-portal-r192[data-portal-family="tools"] .periods { margin: 12px 0; }
body.pf-portal-r192[data-portal-family="tools"] :is(.toolbar, .filters, .search-row, .summary) {
  gap: 10px;
  margin-top: 10px;
}
body.pf-portal-r192[data-portal-family="tools"] :is(.toolbar, .search-row, .summary) { padding: 10px 12px; }
body.pf-portal-r192[data-portal-family="tools"] .layout { margin-top: 14px; gap: 18px; }

/* AI News has a period navigation that distinguishes it from the monitor.
   Keep the monitor's dense layout intact while making each news entry a
   readable card on the light portal, including when the OS is in dark mode. */
body.pf-portal-r192[data-portal-family="tools"] main:has(.periods) .intro {
  gap: 8px;
  margin-bottom: 8px;
}
body.pf-portal-r192[data-portal-family="tools"] main:has(.periods) .intro h1 {
  margin-block: 2px 6px;
}
body.pf-portal-r192[data-portal-family="tools"] main:has(.periods) .intro p {
  margin-block: 4px 0;
}
body.pf-portal-r192[data-portal-family="tools"] main:has(.periods) .periods {
  margin: 8px 0;
}
body.pf-portal-r192[data-portal-family="tools"] main:has(.periods) .layout {
  margin-top: 10px;
}
body.pf-portal-r192[data-portal-family="tools"] main:has(.periods) .layout > section .entry {
  margin-bottom: 12px;
  padding: 18px 20px;
  border: 1px solid var(--ws192-line);
  border-radius: 10px;
  background: var(--ws192-surface);
  color: var(--ws192-text);
}
body.pf-portal-r192[data-portal-family="tools"] main:has(.periods) .layout > section .entry h2,
body.pf-portal-r192[data-portal-family="tools"] main:has(.periods) .layout > section .entry h2 a {
  color: var(--ws192-text);
}
body.pf-portal-r192[data-portal-family="tools"] main:has(.periods) .layout > section .entry h2 a:hover {
  color: var(--ws192-accent);
}
body.pf-portal-r192[data-portal-family="tools"] main:has(.periods) :is(.toolbar button, .summary button) {
  color: #fff;
}
body.pf-portal-r192[data-portal-family="tools"] .tools-topbar {
  box-shadow: none;
}
body.pf-portal-r192[data-portal-family="tools"] main:has(.periods) :is(.toolbar, .layout > aside) {
  box-shadow: 0 4px 14px rgb(23 27 45 / 5%);
}

@media (max-width: 640px) {
  /* AI News has three real filters plus refresh. Keep search prominent while
     giving source and sort their own half-width controls. */
  body.pf-portal-r192[data-portal-family="tools"] main:has(.periods) .toolbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 8px;
    padding: 8px 10px;
  }
  body.pf-portal-r192[data-portal-family="tools"] main:has(.periods) .toolbar > label:first-of-type {
    grid-column: 1 / -1;
  }
  body.pf-portal-r192[data-portal-family="tools"] main:has(.periods) .toolbar > label {
    min-width: 0;
  }
  body.pf-portal-r192[data-portal-family="tools"] main:has(.periods) .toolbar #refresh {
    grid-column: 1 / -1;
    width: 100%;
    background: var(--ws192-accent);
    border-color: var(--ws192-accent);
    color: #fff;
  }
  body.pf-portal-r192[data-portal-family="tools"] main:has(.periods) .periods {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }
  body.pf-portal-r192[data-portal-family="tools"] main:has(.periods) .periods a {
    display: grid;
    min-width: 0;
    min-height: 44px;
    place-items: center;
    gap: 2px;
    padding: 8px 4px;
    text-align: center;
  }
  body.pf-portal-r192[data-portal-family="tools"] main:has(.periods) .periods a :is(strong, span) {
    display: block;
    max-width: 100%;
    white-space: nowrap;
    line-height: 1.2;
  }
  body.pf-portal-r192[data-portal-family="tools"] main:has(.periods) .summary .summary-actions button:not(:disabled) {
    background: var(--ws192-accent);
    border-color: var(--ws192-accent);
    color: #fff;
  }
  body.pf-portal-r192[data-portal-family="tools"] main:has(.periods) .intro .outline {
    background: var(--ws192-surface);
    border-color: var(--ws192-line);
    color: var(--ws192-text);
  }
}

/* Account portal: preserve tab buttons and the hidden panels consumed by
   portal.js, but give the shell a compact sidebar/content reading hierarchy. */
body.pf-portal-r192[data-portal-family="account"] .portal-topbar {
  min-height: 64px;
  border-bottom-color: var(--ws192-line);
  background: var(--ws192-surface);
}
body.pf-portal-r192[data-portal-family="account"] :is(.portal-brand, .portal-brand strong, .portal-user-menu summary) { color: var(--ws192-text); }
body.pf-portal-r192[data-portal-family="account"] :is(.portal-brand small, .portal-top-actions, .portal-panel p, .portal-subheading p, .portal-sync-state, .portal-settings-block small) { color: var(--ws192-muted); }
body.pf-portal-r192[data-portal-family="account"] .portal-shell { grid-template-columns: minmax(220px, 270px) minmax(0, 1fr); }
body.pf-portal-r192[data-portal-family="account"] .portal-sidebar {
  border-right-color: var(--ws192-line);
  background: var(--ws192-surface);
}
body.pf-portal-r192[data-portal-family="account"] .portal-nav-item {
  min-height: 44px;
  border-radius: 8px;
  color: var(--ws192-muted);
}
body.pf-portal-r192[data-portal-family="account"] .portal-nav-item:hover,
body.pf-portal-r192[data-portal-family="account"] .portal-nav-item.is-active { background: var(--ws192-soft); color: var(--ws192-accent); }
body.pf-portal-r192[data-portal-family="account"] .portal-workspace { background: var(--ws192-bg); }
body.pf-portal-r192[data-portal-family="account"] :is(.portal-panel, .portal-primary-block, .portal-settings-block, .portal-consultation-card, .portal-empty, .portal-action-group, .portal-resource-group, .portal-decision, .portal-data-list article) {
  border-color: var(--ws192-line);
  border-radius: 12px;
  background: var(--ws192-surface);
  color: var(--ws192-text);
}
body.pf-portal-r192[data-portal-family="account"] .portal-button { min-height: 44px; border-radius: 8px; background: var(--ws192-accent); border-color: var(--ws192-accent); color: #fff; }
body.pf-portal-r192[data-portal-family="account"] .portal-button.is-secondary,
body.pf-portal-r192[data-portal-family="account"] .portal-button.is-quiet { background: var(--ws192-surface); color: var(--ws192-text); border-color: var(--ws192-line); }
body.pf-portal-r192[data-portal-family="account"] :is(.portal-alert.is-error, .portal-auth-recovery) {
  border-color: #e7b6c0;
  background: #fff1f4;
  color: #8a2035;
}
body.pf-portal-r192[data-portal-family="account"] :is(.portal-alert.is-error, .portal-auth-recovery) :is(h3, p, small, strong) {
  color: #8a2035;
}
body.pf-portal-r192[data-portal-family="account"] .portal-settings-block.is-danger {
  border-color: #e7b6c0;
  background: #fff7f8;
  color: #7d1f32;
}
body.pf-portal-r192[data-portal-family="account"] .portal-settings-block.is-danger :is(h3, p, small, span) { color: #7d1f32; }

/* Customer-facing quote pages. Amounts/dates remain the renderer's exact
   values; this only makes their document and action regions readable. */
body.pf-portal-r192[data-portal-family="commerce"] .commerce-main {
  width: min(1120px, calc(100% - 32px));
  margin-inline: auto;
  padding-block: 30px 52px;
  color: var(--ws192-text);
}
body.pf-portal-r192[data-portal-family="commerce"] .commerce-card,
body.pf-portal-r192[data-portal-family="commerce"] .commerce-document,
body.pf-portal-r192[data-portal-family="commerce"] .commerce-message {
  border-color: var(--ws192-line);
  border-radius: 12px;
  background: var(--ws192-surface);
  color: var(--ws192-text);
}
body.pf-portal-r192[data-portal-family="commerce"] :is(.commerce-prose, .commerce-document p, .commerce-document small, .commerce-document-meta) { color: var(--ws192-muted); }
body.pf-portal-r192[data-portal-family="commerce"] :is(.commerce-button, button) { min-height: 44px; border-radius: 8px; }
body.pf-portal-r192[data-portal-family="commerce"] .commerce-button:not(.is-quiet):not(.is-danger) { background: var(--ws192-accent); border-color: var(--ws192-accent); color: #fff; }
body.pf-portal-r192[data-portal-family="commerce"] :is(input:not([type="checkbox"]), select, textarea) { min-height: 44px; border-color: var(--ws192-line); background: var(--ws192-surface); color: var(--ws192-text); font-size: 16px; }

/* Community chat. Bubble and composer themes remain separate from the public
   community-feed stylesheet. */
body.pf-portal-r192[data-portal-family="chat"] .ch-shell {
  width: min(1120px, calc(100% - 32px));
  margin-inline: auto;
  color: var(--ws192-text);
}
body.pf-portal-r192[data-portal-family="chat"] .ch-top :is(a, h1),
body.pf-portal-r192[data-portal-family="chat"] .ch-sidebar :is(summary, h2),
body.pf-portal-r192[data-portal-family="chat"] .ch-sidebar summary span,
body.pf-portal-r192[data-portal-family="chat"] .co-chat-context :is(p, summary, blockquote),
body.pf-portal-r192[data-portal-family="chat"] .ch-composer label,
body.pf-portal-r192[data-portal-family="chat"] .ch-message > p,
body.pf-portal-r192[data-portal-family="chat"] .ch-message > p strong {
  color: var(--ws192-text);
}
body.pf-portal-r192[data-portal-family="chat"] .co-chat-context {
  border-color: var(--ws192-line);
  background: var(--ws192-surface);
  color: var(--ws192-text);
}
body.pf-portal-r192[data-portal-family="chat"] .co-chat-context a,
body.pf-portal-r192[data-portal-family="chat"] .ch-message :is(button, summary) {
  color: var(--ws192-accent);
}
body.pf-portal-r192[data-portal-family="chat"] .ch-message > p time,
body.pf-portal-r192[data-portal-family="chat"] .ch-composer small,
body.pf-portal-r192[data-portal-family="chat"] .ch-status,
body.pf-portal-r192[data-portal-family="chat"] .ch-sidebar small {
  color: var(--ws192-muted);
}
body.pf-portal-r192[data-portal-family="chat"] :is(.ch-layout, .ch-sidebar, .ch-members, .ch-conversation, .ch-join-choices article) {
  border-color: var(--ws192-line);
  background: var(--ws192-surface);
  color: var(--ws192-text);
}
body.pf-portal-r192[data-portal-family="chat"] :is(.ch-top a, .ch-shell small, .ch-status, .ch-message > p, .ch-members p) { color: var(--ws192-muted); }
body.pf-portal-r192[data-portal-family="chat"] .ch-bubble { border-color: var(--ws192-line); background: #f6f6ff; color: var(--ws192-text); }
body.pf-portal-r192[data-portal-family="chat"] .ch-message.is-mine .ch-bubble { border-color: #bdb9ff; background: var(--ws192-soft); color: var(--ws192-text); }
body.pf-portal-r192[data-portal-family="chat"] :is(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]), select, textarea) { min-height: 44px; border-color: var(--ws192-line); background: var(--ws192-surface); color: var(--ws192-text); font-size: 16px; }
body.pf-portal-r192[data-portal-family="chat"] .ch-composer button { min-height: 44px; border-color: var(--ws192-accent); background: var(--ws192-accent); color: #fff; }

@media (max-width: 760px) {
  body.pf-portal-r192[data-portal-family="tools"] .tools-topbar,
  body.pf-portal-r192[data-portal-family="tools"] main,
  body.pf-portal-r192[data-portal-family="chat"] .ch-shell { width: calc(100% - 24px); }
  body.pf-portal-r192[data-portal-family="tools"] main { padding-block: 24px 40px; }
  body.pf-portal-r192[data-portal-family="tools"] .tools-topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    grid-template-areas:
      "brand language menu"
      "breadcrumb breadcrumb breadcrumb";
    gap: 2px 8px;
    align-items: center;
    padding: 6px 12px;
  }
  body.pf-portal-r192[data-portal-family="tools"] .tools-brand { grid-area: brand; min-height: 44px; }
  body.pf-portal-r192[data-portal-family="tools"] .tools-language { grid-area: language; display: inline-flex; min-height: 44px; align-items: center; }
  body.pf-portal-r192[data-portal-family="tools"] .tools-mobile-menu { grid-area: menu; display: block; margin-left: 0; }
  body.pf-portal-r192[data-portal-family="tools"] .tools-breadcrumb { grid-area: breadcrumb; width: 100%; min-height: 32px; }
  body.pf-portal-r192[data-portal-family="tools"] .tools-primary-nav { display: none; }
  body.pf-portal-r192[data-portal-family="account"] .portal-shell { display: block; }
  body.pf-portal-r192[data-portal-family="account"] .portal-sidebar { border-right: 0; border-bottom-color: var(--ws192-line); }
  body.pf-portal-r192[data-portal-family="account"] .portal-workspace { padding: 20px 14px 40px; }
  body.pf-portal-r192[data-portal-family="commerce"] .commerce-main { width: calc(100% - 24px); padding-block: 22px 40px; }
  body.pf-portal-r192[data-portal-family="chat"] .ch-layout { grid-template-columns: minmax(0, 1fr); }
  body.pf-portal-r192[data-portal-family="chat"] .ch-members { grid-column: 1; }
}
@media (prefers-color-scheme: dark) {
  body.pf-portal-r192[data-portal-family="tools"],
  body.pf-portal-r192[data-portal-family="editor"],
  body.pf-portal-r192[data-portal-family="account"],
  body.pf-portal-r192[data-portal-family="commerce"],
  body.pf-portal-r192[data-portal-family="chat"] { color-scheme: light; }
}

/* R195 managed-tool chrome: standalone pages use the same FORMWEFT
   wordmark/nav rhythm as the portal while retaining the app's own handlers. */
body.pf-portal-r192.pf-tools-suite[data-portal-family="tools"] .tools-topbar {
  width: 100%;
  max-width: none;
  min-height: 64px;
  margin-inline: auto;
  padding: 8px max(16px, calc((100% - 1240px) / 2));
  box-sizing: border-box;
  gap: 10px;
  border-bottom-color: var(--ws192-line);
  background: var(--ws192-surface);
  box-shadow: none;
}
body.pf-portal-r192.pf-tools-suite[data-portal-family="tools"] .tools-brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  color: var(--ws192-text);
  font-size: 16px;
  font-weight: 750;
  letter-spacing: .04em;
}
body.pf-portal-r192.pf-tools-suite[data-portal-family="tools"] .tools-brand .brand-mark {
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
}
body.pf-portal-r192.pf-tools-suite[data-portal-family="tools"] .tools-breadcrumb {
  order: 0;
  color: var(--ws192-muted);
  font-size: 13px;
}
body.pf-portal-r192.pf-tools-suite[data-portal-family="tools"] main > .tools-breadcrumb {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  margin: 0 0 8px;
  color: var(--ws192-muted);
  font-size: 13px;
}
body.pf-portal-r192.pf-tools-suite[data-portal-family="tools"] .tools-primary-nav {
  order: 2;
  min-width: 0;
  margin-left: auto;
}
body.pf-portal-r192.pf-tools-suite[data-portal-family="tools"] #language,
body.pf-portal-r192.pf-tools-suite[data-portal-family="tools"] .tools-language {
  order: 3;
  min-height: 44px;
  color: var(--ws192-accent);
}
body.pf-portal-r192.pf-tools-suite[data-portal-family="tools"] .tools-mobile-menu { order: 4; }
body.pf-portal-r192.pf-tools-suite[data-portal-family="tools"] main {
  width: min(1240px, calc(100% - 32px));
  max-width: 1240px;
  margin-inline: auto;
  padding: 24px 0 44px;
}
body.pf-portal-r192.pf-tools-suite[data-portal-family="tools"] :is(h1, h2, h3) {
  font-weight: 650;
  line-height: 1.3;
}
body.pf-portal-r192.pf-tools-suite[data-portal-family="tools"] :is(.intro h1, .heading h1) {
  margin-block: 0 6px;
  font-size: clamp(24px, 3vw, 32px);
}
body.pf-portal-r192.pf-tools-suite[data-portal-family="tools"] :is(.intro p, .heading p) {
  max-width: 70ch;
  margin-block: 4px 8px;
  line-height: 1.55;
}
body.pf-portal-r192.pf-tools-suite[data-portal-family="tools"] :is(.toolbar, .filters, .search-row, .summary) {
  gap: 8px;
  margin-block: 8px;
  font-size: 14px;
}
body.pf-portal-r192.pf-tools-suite[data-portal-family="tools"] :is(.toolbar, .search-row, .summary) { padding: 8px 10px; }
body.pf-portal-r192.pf-tools-suite[data-portal-family="tools"] :is(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]), select) { font-size: 16px; }

@media (max-width: 760px) {
  body.pf-portal-r192.pf-tools-suite[data-portal-family="tools"] .tools-topbar,
  body.pf-portal-r192.pf-tools-suite[data-portal-family="tools"] main { width: calc(100% - 24px); }
  body.pf-portal-r192.pf-tools-suite[data-portal-family="tools"] .tools-topbar { width: 100%; min-height: 64px; padding: 6px 12px; }
  body.pf-portal-r192.pf-tools-suite[data-portal-family="tools"] .tools-brand { font-size: 14px; }
  body.pf-portal-r192.pf-tools-suite[data-portal-family="tools"] main { padding-block: 18px 36px; }
}
