/* PostWatch Unified v4 — Command Calm foundation
   Load after the legacy/route foundations and immediately before
   postwatch-conversations-v4.css. This file owns semantic tokens, shared
   controls, and the adaptive shell; route files own page composition. */

:root {
  color-scheme: light;

  /* Brand and semantic color roles. */
  --pw-navy-950: #0a1f37;
  --pw-navy-900: #0f2a4a;
  --pw-navy-800: #173a5d;
  --pw-steel-700: #3e566d;
  --pw-steel-600: #536a80;
  --pw-steel-500: #718397;
  --pw-gold-600: #a87920;
  --pw-gold-ink: #8a6112;

  --pw-bg: #f5f6f8;
  --pw-surface: #ffffff;
  --pw-surface-raised: #ffffff;
  --pw-surface-muted: #f1f3f6;
  --pw-surface-strong: #e8ebf0;
  --pw-text: #20242c;
  --pw-text-muted: #596171;
  --pw-text-subtle: #667080;
  --pw-border: #e3e6ec;
  --pw-border-strong: #bac2cf;

  --pw-primary: #315ee7;
  --pw-accent: #315ee7;
  --pw-accent-soft: #edf2ff;
  --pw-on-primary: #ffffff;
  --pw-primary-hover: #244bcc;
  --pw-navigation: #191c24;
  --pw-navigation-text: #e8ebf2;
  --pw-navigation-muted: #a5aec0;
  --pw-navigation-hover: #252b38;
  --pw-navigation-selected: #303d62;
  --pw-navigation-border: #303645;
  --pw-focus: #2e5bff;
  --pw-focus-halo: rgba(46, 91, 255, .22);

  --pw-success: #157347;
  --pw-success-soft: #e7f6ee;
  --pw-success-ink: #12633f;
  --pw-warning: #8a5100;
  --pw-warning-soft: #fff3da;
  --pw-warning-ink: #7a4700;
  --pw-danger: #b42318;
  --pw-danger-soft: #fff0ed;
  --pw-danger-ink: #a61b12;
  --pw-on-status: #ffffff;

  /* Readable operational metadata; decorative wordmarks may remain smaller. */
  --pw-font-meta: .875rem;

  /* Consistent elevation, shape, space, and motion. */
  --pw-shadow-1: 0 1px 2px rgba(20, 20, 15, .045), 0 12px 32px -28px rgba(20, 20, 15, .26);
  --pw-shadow-2: 0 2px 6px rgba(20, 20, 15, .065), 0 24px 54px -34px rgba(20, 20, 15, .34);
  --pw-shadow-overlay: 0 30px 90px rgba(5, 18, 32, .3);
  --pw-radius-control: 10px;
  --pw-radius-card: 14px;
  --pw-radius-sheet: 18px;
  --pw-control-height: 48px;
  --pw-ease-out: cubic-bezier(.2, .8, .2, 1);
  --pw-ease-in: cubic-bezier(.4, 0, 1, 1);
  --pw-motion-fast: 140ms;
  --pw-motion-base: 210ms;

  /* Adaptive shell. */
  --pw-shell-sidebar: 248px;
  --pw-shell-rail: 88px;
  --pw-shell-header: 64px;
  --pw-canvas-max: 1440px;
  --pw-gutter: clamp(20px, 2.6vw, 40px);
  --pw-safe-top: env(safe-area-inset-top, 0px);
  --pw-safe-right: env(safe-area-inset-right, 0px);
  --pw-safe-bottom: env(safe-area-inset-bottom, 0px);
  --pw-safe-left: env(safe-area-inset-left, 0px);

  /* Compatibility aliases. Existing pages inherit the same truth. */
  --bg: var(--pw-bg);
  --surface: var(--pw-surface);
  --surface-2: var(--pw-surface-muted);
  --border: var(--pw-border);
  --border-strong: var(--pw-border-strong);
  --text: var(--pw-text);
  --text-muted: var(--pw-text-muted);
  --text-subtle: var(--pw-text-subtle);
  --primary: var(--pw-primary);
  --primary-ink: var(--pw-on-primary);
  --primary-grad: var(--pw-primary);
  --accent: var(--pw-steel-600);
  --accent-soft: #e7f0f8;
  --focus-ring: var(--pw-focus);
  --ok: var(--pw-success);
  --ok-soft: var(--pw-success-soft);
  --ok-ink: var(--pw-success-ink);
  --warn: var(--pw-warning);
  --warn-soft: var(--pw-warning-soft);
  --warn-ink: var(--pw-warning-ink);
  --crit: var(--pw-danger);
  --crit-soft: var(--pw-danger-soft);
  --crit-ink: var(--pw-danger-ink);
  --on-status: var(--pw-on-status);
  --fs-meta: var(--pw-font-meta);
  --shadow-1: var(--pw-shadow-1);
  --shadow-2: var(--pw-shadow-2);
  --os-sidebar: var(--pw-shell-sidebar);
  --os-rail: var(--pw-shell-rail);
  --os-utility: var(--pw-shell-header);
  --os-content: var(--pw-canvas-max);
  --container-max: var(--pw-canvas-max);
  --gutter: var(--pw-gutter);
  --ease-out: var(--pw-ease-out);
  --ease-in: var(--pw-ease-in);
}

html.dark {
  color-scheme: dark;
  --pw-navy-950: #edf0f4;
  --pw-navy-900: #c9d9e8;
  --pw-navy-800: #9cc2e8;
  --pw-steel-700: #bdc9d6;
  --pw-steel-600: #c4ccd6;
  --pw-steel-500: #95a0ae;
  --pw-gold-600: #e2b95f;
  --pw-gold-ink: #f2cb78;

  --pw-bg: #121419;
  --pw-surface: #1b1e25;
  --pw-surface-raised: #242832;
  --pw-surface-muted: #232730;
  --pw-surface-strong: #2d3340;
  --pw-text: #eef0f5;
  --pw-text-muted: #b5bdcc;
  --pw-text-subtle: #a0aaba;
  --pw-border: #303641;
  --pw-border-strong: #566174;

  --pw-primary: #315ee7;
  --pw-accent: #9db6ff;
  --pw-accent-soft: #263456;
  --pw-on-primary: #ffffff;
  --pw-primary-hover: #244bcc;
  --pw-navigation: #171920;
  --pw-focus: #6e93ff;
  --pw-focus-halo: rgba(110, 147, 255, .3);

  --pw-success: #5fd39b;
  --pw-success-soft: #0e2a20;
  --pw-success-ink: #72dda9;
  --pw-warning: #f0bc5f;
  --pw-warning-soft: #2a2110;
  --pw-warning-ink: #ffd690;
  --pw-danger: #ff9b91;
  --pw-danger-soft: #2c1411;
  --pw-danger-ink: #ffaca4;
  --pw-on-status: #08111c;

  --pw-shadow-1: 0 1px 2px rgba(0, 0, 0, .28), 0 16px 34px -28px rgba(0, 0, 0, .9);
  --pw-shadow-2: 0 3px 10px rgba(0, 0, 0, .28), 0 26px 60px -36px rgba(0, 0, 0, .95);
  --pw-shadow-overlay: 0 34px 100px rgba(0, 0, 0, .72);
  --accent-soft: #19324a;
}

/* Base readability and content resilience. */
html {
  min-width: 320px;
  background: var(--pw-bg);
  scroll-padding-top: calc(var(--pw-shell-header) + 16px);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  background: var(--pw-bg);
  color: var(--pw-text);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  letter-spacing: -.005em;
}

:where(h1, h2, h3, h4) {
  color: var(--pw-text);
  text-wrap: balance;
}

/* `anywhere` is not a safer `break-word`: it also lets a box report a
   one-character min-content width, so a grid track collapses far below the
   text it holds and the word then breaks mid-syllable. That produced
   "Not acti / ve", "83 / %" and "PostWatc / h" in shipped views.
   `break-word` gives the same overflow protection for long emails, refs and
   URLs without distorting intrinsic sizing. Short interactive labels
   (button, a) wrap between words like any other label. */
:where(p, li, dd, td, th, input, textarea, select) {
  overflow-wrap: break-word;
}

/* Display type, metrics, brand and navigation labels never break mid-word.
   If one of these cannot fit, the layout is wrong, not the word. */
:where(h1, h2, h3, h4, h5, h6),
:where(.pw4-rail__brand, .pw4-brand, .pw4-metric strong, .pw4-bottom-item, .pw4-rail-item, .pw4-nav-item),
:where([data-pw-display], .pw-display, .pw-numeral) {
  overflow-wrap: normal;
  word-break: normal;
  hyphens: none;
}

/* Opt-in for the genuinely unbreakable tokens: object refs, emails, URLs. */
:where(.pw-breakable, [data-pw-breakable]) {
  overflow-wrap: anywhere;
  word-break: break-word;
}

:where(.metric, .kpi, .stat, output, time, td[data-number], th[data-number]) {
  font-variant-numeric: tabular-nums;
}

:where(a, button, input, select, textarea, summary) {
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(18, 58, 98, .16);
}

:where(a, button, input, select, textarea, summary):focus-visible {
  outline: 3px solid var(--pw-focus);
  outline-offset: 3px;
  box-shadow: 0 0 0 5px var(--pw-focus-halo);
}

.pw4-visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
  padding: 0 !important;
  margin: -1px !important;
  border: 0 !important;
  clip: rect(0 0 0 0) !important;
  clip-path: inset(50%) !important;
  white-space: nowrap !important;
}

body.pw4-modal-open { overflow: hidden; }

@media (forced-colors: active) {
  :where(a, button, input, select, textarea, summary):focus-visible {
    outline: 3px solid Highlight;
    box-shadow: none;
  }
}

/* Shared controls. Explicit states prevent white-on-white and dark bleed. */
:where(.btn, .pwc-button, .pwauth-primary, .pwauth-secondary, .pw4-button) {
  min-height: var(--pw-control-height);
  min-width: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 10px 16px;
  border: 1px solid var(--pw-border-strong);
  border-radius: var(--pw-radius-control);
  background: var(--pw-surface);
  color: var(--pw-text);
  box-shadow: none;
  font: inherit;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition: background-color var(--pw-motion-fast) var(--pw-ease-out), border-color var(--pw-motion-fast) var(--pw-ease-out), color var(--pw-motion-fast) var(--pw-ease-out), box-shadow var(--pw-motion-fast) var(--pw-ease-out), opacity var(--pw-motion-fast) var(--pw-ease-out);
}

:where(.btn, .pwc-button, .pwauth-primary, .pwauth-secondary, .pw4-button):hover:not(:disabled):not([aria-disabled="true"]) {
  border-color: var(--pw-steel-600);
  background: var(--pw-surface-muted);
  color: var(--pw-text);
}

:where(.btn, .pwc-button, .pwauth-primary, .pwauth-secondary, .pw4-button):active:not(:disabled):not([aria-disabled="true"]) {
  transform: none !important;
  box-shadow: inset 0 0 0 999px color-mix(in srgb, var(--pw-primary) 10%, transparent);
}

:where(.btn--primary, .pwc-button--primary, .pwauth-primary, .pw4-button--primary) {
  border-color: var(--pw-primary);
  background: var(--pw-primary);
  color: var(--pw-on-primary);
}

:where(.btn--primary, .pwc-button--primary, .pwauth-primary, .pw4-button--primary):hover:not(:disabled):not([aria-disabled="true"]) {
  border-color: var(--pw-primary-hover);
  background: var(--pw-primary-hover);
  color: var(--pw-on-primary);
  filter: none;
  transform: none;
}

:where(.btn--ghost, .btn--quiet, .pwc-button--secondary, .pwauth-secondary, .pw4-button--quiet) {
  border-color: var(--pw-border);
  background: transparent;
  color: var(--pw-text);
}

:where(.btn--danger, .pw4-button--danger) {
  border-color: var(--pw-danger);
  background: var(--pw-danger);
  color: var(--pw-on-status);
}

.btn--light {
  border-color: #ffffff;
  background: #ffffff;
  color: #0b2037;
}

:where(.icon-btn, .pw4-icon-button) {
  width: 48px;
  height: 48px;
  min-width: 48px;
  min-height: 48px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--pw-border);
  border-radius: var(--pw-radius-control);
  background: var(--pw-surface);
  color: var(--pw-text);
  cursor: pointer;
  transition: background-color var(--pw-motion-fast) var(--pw-ease-out), border-color var(--pw-motion-fast) var(--pw-ease-out), color var(--pw-motion-fast) var(--pw-ease-out), box-shadow var(--pw-motion-fast) var(--pw-ease-out);
}

:where(.icon-btn, .pw4-icon-button):hover:not(:disabled) {
  border-color: var(--pw-steel-600);
  background: var(--pw-surface-muted);
  color: var(--pw-text);
}

:where(.icon-btn, .pw4-icon-button):active:not(:disabled) {
  transform: none !important;
  box-shadow: inset 0 0 0 999px color-mix(in srgb, var(--pw-primary) 10%, transparent);
}

:where(.icon-btn, .pw4-icon-button) :where(svg, i) {
  width: 21px;
  height: 21px;
}

:where(button, .btn, .pwc-button, .pwauth-primary, .pwauth-secondary):disabled,
:where(button, .btn, .pwc-button, .pwauth-primary, .pwauth-secondary)[aria-disabled="true"] {
  opacity: .48;
  cursor: not-allowed;
  pointer-events: none;
  filter: saturate(.55);
}

/* Stable-width busy feedback. Consumers set aria-busy or data-loading. */
:where(button, .btn, .pwc-button)[aria-busy="true"],
:where(button, .btn, .pwc-button)[data-loading="true"],
:where(button, .btn, .pwc-button).is-loading {
  position: relative;
  cursor: wait;
}

:where(button, .btn, .pwc-button)[aria-busy="true"]::after,
:where(button, .btn, .pwc-button)[data-loading="true"]::after,
:where(button, .btn, .pwc-button).is-loading::after {
  content: "";
  width: 17px;
  height: 17px;
  flex: 0 0 17px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: pw4-spin .75s linear infinite;
}

@keyframes pw4-spin { to { transform: rotate(360deg); } }

/* Forms keep a visible label, large target, and explicit dark appearance. */
:where(.form-field, .pw4-field) > label,
:where(label.pw4-label) {
  display: block;
  margin-bottom: 6px;
  color: var(--pw-text);
  font-size: 15px;
  font-weight: 700;
  line-height: 1.35;
}

:where(input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), select, textarea) {
  min-height: var(--pw-control-height);
  max-width: 100%;
  border: 1px solid var(--pw-border-strong);
  border-radius: var(--pw-radius-control);
  background-color: var(--pw-surface);
  color: var(--pw-text);
  font: inherit;
  font-size: 16px;
  line-height: 1.4;
  transition: background-color var(--pw-motion-fast) var(--pw-ease-out), border-color var(--pw-motion-fast) var(--pw-ease-out), box-shadow var(--pw-motion-fast) var(--pw-ease-out);
}

:where(input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), select) {
  padding: 10px 13px;
}

textarea {
  min-height: 112px;
  padding: 12px 13px;
  resize: vertical;
}

:where(input, textarea)::placeholder {
  color: var(--pw-text-subtle);
  opacity: 1;
}

:where(input, select, textarea):hover:not(:disabled):not([readonly]) {
  border-color: var(--pw-steel-600);
}

:where(input, select, textarea):focus-visible {
  border-color: var(--pw-focus);
}

:where(input, select, textarea):disabled {
  background: var(--pw-surface-muted);
  color: var(--pw-text-muted);
  opacity: .64;
  cursor: not-allowed;
}

:where(input, textarea)[readonly] {
  border-style: dashed;
  background: var(--pw-surface-muted);
  color: var(--pw-text);
}

:where(input[type="checkbox"], input[type="radio"]) {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  accent-color: var(--pw-primary);
}

/* Shared surfaces and tables. */
:where(.card, .pwc-surface, .pwauth-card, .policy-panel, .admin-os-card, .pw4-card) {
  border-color: var(--pw-border);
  border-radius: var(--pw-radius-card);
  background: var(--pw-surface);
  color: var(--pw-text);
  box-shadow: var(--pw-shadow-1);
}

:where(.card, .admin-os-card, .pw4-card):hover {
  transform: none;
}

.pw4-card[data-priority] {
  position: relative;
  overflow: clip;
}

.pw4-card[data-priority]::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--pw-steel-600);
}

.pw4-card[data-priority="urgent"]::before { background: var(--pw-danger); }
.pw4-card[data-priority="attention"]::before { background: var(--pw-warning); }
.pw4-card[data-priority="complete"]::before { background: var(--pw-success); }

.pw4-completeness[data-state="partial"] {
  background-color: var(--pw-surface-muted);
  background-image: repeating-linear-gradient(135deg, transparent 0 7px, color-mix(in srgb, var(--pw-warning) 13%, transparent) 7px 10px);
}

:where(.table-wrap, .pw4-table-wrap) {
  max-width: 100%;
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--pw-border);
  border-radius: var(--pw-radius-card);
  background: var(--pw-surface);
}

:where(.table, table) {
  color: var(--pw-text);
  font-variant-numeric: tabular-nums;
}

:where(.table, table) :where(th, td) {
  border-color: var(--pw-border);
  color: var(--pw-text);
}

:where(.table, table) th {
  background: var(--pw-surface-muted);
  color: var(--pw-text-muted);
}

:where(.table, table) tbody tr:hover {
  background: color-mix(in srgb, var(--pw-steel-600) 7%, var(--pw-surface));
}

/* Skeleton and receipt hooks. */
:where(.pw-skeleton, .pw4-skeleton, [data-pw-skeleton="true"]) {
  overflow: hidden;
  color: transparent !important;
  background: linear-gradient(90deg, var(--pw-surface-muted) 20%, color-mix(in srgb, var(--pw-surface-muted) 50%, var(--pw-surface)) 44%, var(--pw-surface-muted) 68%);
  background-size: 230% 100%;
  border-radius: 10px;
  animation: pw4-skeleton 1.25s ease-in-out infinite;
}

@keyframes pw4-skeleton { to { background-position: -180% 0; } }

.pw4-receipt {
  padding: 14px 16px;
  border: 1px solid color-mix(in srgb, var(--pw-success) 42%, var(--pw-border));
  border-left: 4px solid var(--pw-success);
  border-radius: 14px;
  background: var(--pw-success-soft);
  color: var(--pw-text);
}

/* Skip link is created by v4 JS and remains above every overlay. */
.os-skip-link {
  position: fixed;
  z-index: 30000;
  top: max(12px, var(--pw-safe-top));
  left: max(12px, var(--pw-safe-left));
  min-height: 48px;
  padding: 11px 16px;
  border: 2px solid var(--pw-focus);
  border-radius: var(--pw-radius-control);
  background: var(--pw-surface);
  color: var(--pw-text);
  font-weight: 800;
  transform: translateY(-180%);
  transition: transform var(--pw-motion-fast) var(--pw-ease-out);
}

.os-skip-link:focus { transform: translateY(0); }

/* Unified shell primitives. */
.pw4-sidebar,
.pw4-rail {
  background: linear-gradient(180deg, #0b2037 0%, #102d4d 100%);
  color: #f5f9fd;
}

.pw4-sidebar {
  position: fixed;
  inset: 12px auto 12px 12px;
  z-index: 360;
  width: calc(var(--pw-shell-sidebar) - 24px);
  display: none;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 24px;
  box-shadow: 0 22px 60px -32px rgba(5, 18, 32, .72);
}

.pw4-brand {
  min-height: 76px;
  display: flex;
  align-items: center;
  padding: 17px 20px;
  border-bottom: 0;
  color: #ffffff;
  text-decoration: none;
}

.pw4-brand__copy { min-width: 0; }
.pw4-brand__copy strong,
.pw4-brand__copy small { display: block; }
.pw4-brand__copy strong { font-size: 19px; font-weight: 760; letter-spacing: -.025em; line-height: 1.15; }
.pw4-brand__copy small { margin-top: 5px; color: #b9c9d9; font-size: 12px; font-weight: 800; letter-spacing: .14em; line-height: 1.3; text-transform: uppercase; }

.pw4-sidebar__nav {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px 12px 24px;
  scrollbar-width: thin;
}

.pw4-nav-group + .pw4-nav-group { margin-top: 18px; }

.pw4-nav-group__title {
  padding: 0 12px 7px;
  color: #a8bbcf;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: .075em;
  line-height: 1.3;
  text-transform: uppercase;
}

.pw4-nav-link {
  position: relative;
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: 12px;
  color: #dce7f2;
  font-size: 16px;
  font-weight: 650;
  line-height: 1.25;
  text-decoration: none;
  transition: background-color var(--pw-motion-fast) var(--pw-ease-out), color var(--pw-motion-fast) var(--pw-ease-out);
}

.pw4-nav-link svg { width: 20px; height: 20px; flex: 0 0 auto; color: #b5c8da; }
.pw4-nav-link:hover { background: rgba(255, 255, 255, .1); color: #ffffff; }
.pw4-nav-link.is-active {
  border: 1px solid rgba(255, 255, 255, .16);
  background: rgba(255, 255, 255, .12);
  color: #ffffff;
  font-weight: 780;
  box-shadow: inset 3px 0 0 #e2b95f, 0 8px 24px -20px rgba(0, 0, 0, .8);
}
.pw4-nav-link.is-active svg { color: #d9e9f7; }
.pw4-nav-link--primary:not(.is-active)::after {
  content: "";
  width: 6px;
  height: 6px;
  margin-left: auto;
  border-radius: 50%;
  background: #e2b95f;
}

.pw4-profile-avatar {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  overflow: hidden;
  display: grid;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--pw-border-strong) 78%, transparent);
  border-radius: 50%;
  background: var(--pw-surface-strong);
  color: var(--pw-text);
  font-size: 13px;
  font-weight: 850;
  letter-spacing: .01em;
}

.pw4-profile-avatar.is-large { width: 52px; height: 52px; font-size: 15px; }
.pw4-profile-avatar img { width: 100%; height: 100%; display: block; object-fit: cover; }

.pw4-utility {
  position: fixed;
  inset: 0 0 auto var(--pw-shell-sidebar);
  z-index: 340;
  min-height: var(--pw-shell-header);
  display: none;
  align-items: center;
  justify-content: flex-end;
  gap: 18px;
  padding: 16px var(--pw-gutter) 8px;
  border: 0;
  background: linear-gradient(180deg, var(--pw-bg) 0%, color-mix(in srgb, var(--pw-bg) 90%, transparent) 72%, transparent 100%);
  color: var(--pw-text);
  pointer-events: none;
}

.pw4-utility__cluster { pointer-events: auto; }
.pw4-utility__cluster { min-width: 0; display: flex; align-items: center; justify-content: flex-end; gap: 12px; }
.pw4-utility__actions { display: flex; align-items: center; gap: 8px; }

.pw4-command-entry {
  min-width: 220px;
  max-width: min(360px, 34vw);
  min-height: 52px;
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) 18px;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  border: 1px solid color-mix(in srgb, var(--pw-border) 78%, transparent);
  border-radius: 16px;
  background: color-mix(in srgb, var(--pw-surface) 76%, transparent);
  color: var(--pw-text);
  box-shadow: var(--pw-shadow-1);
  text-decoration: none;
  backdrop-filter: blur(14px) saturate(125%);
  -webkit-backdrop-filter: blur(14px) saturate(125%);
}
.pw4-command-entry:hover { border-color: var(--pw-steel-600); background: var(--pw-surface); }
.pw4-command-entry > svg { width: 20px; height: 20px; color: var(--pw-steel-600); }
.pw4-command-entry > svg:last-child { width: 16px; height: 16px; color: var(--pw-text-muted); }
.pw4-command-entry__copy { min-width: 0; }
.pw4-command-entry__copy strong,
.pw4-command-entry__copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pw4-command-entry__copy strong { font-size: 15px; line-height: 1.2; }
.pw4-command-entry__copy small { margin-top: 2px; color: var(--pw-text-muted); font-size: 14px; line-height: 1.2; }

.pw4-profile-trigger {
  width: 48px;
  height: 48px;
  min-width: 48px;
  display: grid;
  place-items: center;
  padding: 2px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--pw-text);
  cursor: pointer;
}
.pw4-profile-trigger:hover { background: var(--pw-surface-muted); }
.pw4-profile-trigger .pw4-profile-avatar { width: 42px; height: 42px; }

.pw4-bell-wrap { position: relative; }
.pw4-notification-badge,
#notif-badge.pw4-notification-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  padding: 0 6px;
  border: 2px solid var(--pw-surface);
  border-radius: 999px;
  background: var(--pw-danger);
  color: var(--pw-on-status);
  font-size: var(--pw-font-meta);
  font-weight: 850;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.pw4-notification-badge[hidden] { display: none !important; }

.pw4-mobile-topbar {
  position: fixed;
  inset: 0 0 auto;
  z-index: 350;
  min-height: calc(60px + var(--pw-safe-top));
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  padding: calc(var(--pw-safe-top) + 7px) max(10px, var(--pw-safe-right)) 7px max(10px, var(--pw-safe-left));
  border: 0;
  background: linear-gradient(180deg, var(--pw-bg) 0%, color-mix(in srgb, var(--pw-bg) 92%, transparent) 82%, transparent 100%);
  color: var(--pw-text);
}

.pw4-mobile-brand { display: inline-flex; min-width: 0; min-height: 44px; max-width: 130px; align-items: center; color: var(--pw-text); text-decoration: none; }
.pw4-mobile-brand__copy strong,
.pw4-mobile-brand__copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pw4-mobile-brand__copy strong { font-size: 14px; font-weight: 780; letter-spacing: -.025em; line-height: 1.1; }
.pw4-mobile-brand__copy small { margin-top: 2px; color: var(--pw-text-muted); font-size: 12px; font-weight: 820; letter-spacing: .1em; line-height: 1.2; text-transform: uppercase; }
.pw4-mobile-actions { display: flex; align-items: center; gap: 5px; }

.pw4-page-heading--injected {
  width: min(100%, var(--pw-canvas-max));
  margin: 0 auto 20px;
  color: var(--pw-text);
  font-size: clamp(30px, 3.2vw, 44px);
  font-weight: 780;
  line-height: 1.1;
  letter-spacing: -.04em;
}

.pw4-rail {
  position: fixed;
  inset: 10px auto 10px 10px;
  z-index: 360;
  width: calc(var(--pw-shell-rail) - 20px);
  display: none;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 22px;
  box-shadow: 0 20px 50px -32px rgba(5, 18, 32, .72);
}

.pw4-rail__brand {
  width: 62px;
  min-height: 58px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 12px auto 9px;
  padding: 7px 4px;
  border-radius: 14px;
  background: rgba(255, 255, 255, .08);
  color: #ffffff;
  text-decoration: none;
}
.pw4-rail__brand strong { font-size: 17px; font-weight: 820; letter-spacing: -.035em; line-height: 1.05; }
.pw4-rail__brand small { margin-top: 5px; color: #c5d3e1; font-size: 10px; font-weight: 820; letter-spacing: .04em; line-height: 1; }
.pw4-rail__nav { flex: 1; display: flex; flex-direction: column; gap: 5px; padding: 8px; }

.pw4-rail-item {
  position: relative;
  min-height: 68px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 7px 3px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: #bed0e1;
  font: inherit;
  font-size: 14px;
  font-weight: 720;
  line-height: 1.08;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}

.pw4-rail-item svg { width: 22px; height: 22px; }
.pw4-rail-item:hover { background: rgba(255, 255, 255, .1); color: #ffffff; }
.pw4-rail-item.is-active { border: 1px solid rgba(255, 255, 255, .16); background: rgba(255, 255, 255, .13); color: #ffffff; box-shadow: inset 3px 0 0 #e2b95f; }
.pw4-rail-item.is-unavailable { opacity: .48; cursor: not-allowed; }
.pw4-rail-item .pw4-notification-badge { top: 5px; right: 8px; border-color: #0b2037; }

.pw4-bottom-nav {
  position: fixed;
  inset: auto 0 0;
  z-index: 345;
  min-height: calc(82px + var(--pw-safe-bottom));
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  padding: 4px max(4px, var(--pw-safe-right)) var(--pw-safe-bottom) max(4px, var(--pw-safe-left));
  border-top: 1px solid var(--pw-border);
  background: color-mix(in srgb, var(--pw-surface) 96%, transparent);
  box-shadow: 0 -14px 36px -28px rgba(11, 32, 55, .75);
  backdrop-filter: blur(20px) saturate(145%);
  -webkit-backdrop-filter: blur(20px) saturate(145%);
}

.pw4-bottom-item {
  position: relative;
  min-width: 0;
  min-height: 74px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 6px 2px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--pw-text-muted);
  font: inherit;
  font-size: 14px;
  font-weight: 730;
  line-height: 1.05;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}

.pw4-bottom-item > span:last-child {
  min-height: 29px;
  display: grid;
  place-items: center;
  text-wrap: balance;
}

.pw4-bottom-item svg { width: 22px; height: 22px; }
.pw4-bottom-item:hover { background: var(--pw-surface-muted); color: var(--pw-text); }
.pw4-bottom-item.is-active { color: var(--pw-accent); }
.pw4-bottom-item.is-active::after { content: ""; position: absolute; top: 3px; left: 50%; width: 22px; height: 3px; border-radius: 999px; background: var(--pw-gold-600); transform: translateX(-50%); }
.pw4-bottom-item.is-unavailable { opacity: .48; cursor: not-allowed; }
.pw4-bottom-item .pw4-notification-badge { top: 4px; right: max(6px, calc(50% - 27px)); }

/* More directory: searchable, grouped, and role-filtered. */
.pw4-directory {
  position: fixed;
  inset: 0;
  z-index: 13000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 12px 12px 0;
  background: rgba(5, 18, 32, .62);
  overscroll-behavior: contain;
}

.pw4-directory__panel {
  width: min(680px, 100%);
  max-height: min(88vh, 820px);
  max-height: min(88dvh, 820px);
  overflow: auto;
  overscroll-behavior: contain;
  padding: 12px 16px calc(22px + var(--pw-safe-bottom));
  border: 1px solid var(--pw-border);
  border-bottom: 0;
  border-radius: var(--pw-radius-sheet) var(--pw-radius-sheet) 0 0;
  background: var(--pw-surface);
  color: var(--pw-text);
  box-shadow: var(--pw-shadow-overlay);
}

.pw4-directory__handle { width: 48px; height: 5px; margin: 2px auto 14px; border-radius: 999px; background: var(--pw-border-strong); }
.pw4-directory__header { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 14px; }
.pw4-directory__header h2 { margin: 0; font-size: 24px; line-height: 1.2; }
.pw4-directory__header p { margin: 3px 0 0; color: var(--pw-text-muted); font-size: 14px; }
.pw4-directory__search { position: relative; display: flex; align-items: center; margin-bottom: 16px; }
.pw4-directory__search > svg { position: absolute; left: 15px; width: 20px; height: 20px; color: var(--pw-text-muted); pointer-events: none; }
.pw4-directory__search input { width: 100%; padding-left: 45px; }
.pw4-directory__groups { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.pw4-directory__group { min-width: 0; padding: 10px; border: 1px solid var(--pw-border); border-radius: 16px; background: var(--pw-surface-muted); }
.pw4-directory__group[hidden] { display: none; }
.pw4-directory__group h3 { margin: 3px 8px 6px; color: var(--pw-text-muted); font-size: 14px; font-weight: 800; letter-spacing: .065em; text-transform: uppercase; }
.pw4-directory__link {
  min-height: 50px;
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 12px;
  color: var(--pw-text);
  font-size: 16px;
  font-weight: 680;
  text-decoration: none;
}
.pw4-directory__link:hover { background: var(--pw-surface); }
.pw4-directory__link.is-active { background: var(--pw-surface); box-shadow: inset 3px 0 0 var(--pw-gold-600); }
.pw4-directory__link svg { width: 20px; height: 20px; color: var(--pw-steel-700); }
.pw4-directory__link svg:last-child { width: 16px; height: 16px; color: var(--pw-text-muted); }
.pw4-directory__link[hidden] { display: none; }
.pw4-directory__status { min-height: 24px; margin: 12px 2px 0; color: var(--pw-text-muted); font-size: 14px; }
.pw4-directory__footer { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--pw-border); }
.pw4-directory__footer > * { flex: 1 1 180px; }

/* Native account surface: anchored on desktop, a calm bottom sheet on touch. */
.pw4-account-layer {
  --pw4-account-top: 84px;
  --pw4-account-right: 20px;
  position: fixed;
  inset: 0;
  z-index: 15000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 18px;
  background: rgba(5, 18, 32, .48);
  overscroll-behavior: contain;
}

.pw4-account-menu {
  width: min(440px, 100%);
  max-height: calc(100vh - 36px - var(--pw-safe-top) - var(--pw-safe-bottom));
  max-height: calc(100dvh - 36px - var(--pw-safe-top) - var(--pw-safe-bottom));
  overflow: auto;
  padding: 16px 16px calc(16px + var(--pw-safe-bottom));
  border: 1px solid var(--pw-border);
  border-radius: var(--pw-radius-sheet);
  background: var(--pw-surface);
  color: var(--pw-text);
  box-shadow: var(--pw-shadow-overlay);
}

.pw4-account-menu__header { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 2px 2px 15px; border-bottom: 1px solid var(--pw-border); }
.pw4-account-identity { min-width: 0; display: flex; align-items: center; gap: 12px; }
.pw4-account-identity__copy { min-width: 0; }
.pw4-account-identity__copy strong,
.pw4-account-identity__copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pw4-account-identity__copy strong { color: var(--pw-text); font-size: 17px; line-height: 1.2; }
.pw4-account-identity__copy small { margin-top: 3px; color: var(--pw-text-muted); font-size: 14px; line-height: 1.25; }
.pw4-account-menu__actions { display: grid; gap: 4px; padding-top: 10px; }

.pw4-account-row {
  min-height: 52px;
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) 18px;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border: 0;
  border-radius: 13px;
  background: transparent;
  color: var(--pw-text);
  font: inherit;
  font-size: 16px;
  font-weight: 680;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.pw4-account-row:hover { background: var(--pw-surface-muted); }
.pw4-account-row > svg { width: 20px; height: 20px; color: var(--pw-steel-700); }
.pw4-account-row > svg:last-child { width: 16px; height: 16px; color: var(--pw-text-muted); }
.pw4-account-row.is-danger { margin-top: 5px; border-top: 1px solid var(--pw-border); border-radius: 0 0 13px 13px; color: var(--pw-danger); }
.pw4-account-row.is-danger > svg { color: currentColor; }

/* Action Center occupies its own pane and never collides with navigation. */
.notif-panel,
.action-center {
  z-index: 12900 !important;
  border-color: var(--pw-border) !important;
  background: var(--pw-surface) !important;
  color: var(--pw-text) !important;
  box-shadow: var(--pw-shadow-overlay) !important;
  overscroll-behavior: contain;
}

/* Help lives in the account sheet; the duplicate command-card guide is retired. */
#os-guide-my-day,
[data-guide-my-day] { display: none !important; }

body.pw4-authenticated .os-assistant-fab { display: none !important; }

/* Splash is explicit: the JS API shows it only around a real boot operation. */
.pw4-splash {
  position: fixed;
  inset: 0;
  z-index: 25000;
  display: grid;
  place-items: center;
  padding: max(24px, var(--pw-safe-top)) max(24px, var(--pw-safe-right)) max(24px, var(--pw-safe-bottom)) max(24px, var(--pw-safe-left));
  background: var(--pw-bg);
  color: var(--pw-text);
  opacity: 1;
  transition: opacity 180ms var(--pw-ease-in);
}

.pw4-splash.is-leaving { opacity: 0; pointer-events: none; }
.pw4-splash__content { width: min(420px, 100%); text-align: center; }
.pw4-splash__mark { width: 92px; height: 92px; margin: 0 auto 20px; display: grid; place-content: center; border: 1px solid var(--pw-border); border-radius: 25px; background: var(--pw-surface); box-shadow: var(--pw-shadow-2); }
.pw4-splash__mark strong,
.pw4-splash__mark small { display: block; }
.pw4-splash__mark strong { font-size: 25px; letter-spacing: -.04em; line-height: 1; }
.pw4-splash__mark small { margin-top: 7px; color: var(--pw-text-muted); font-size: 9px; font-weight: 850; letter-spacing: .11em; line-height: 1; text-transform: uppercase; }
.pw4-splash h1 { margin: 0; font-size: clamp(32px, 7vw, 46px); line-height: 1.1; }
.pw4-splash p { margin: 10px 0 18px; color: var(--pw-text-muted); font-size: 17px; }
.pw4-splash__track { height: 4px; overflow: hidden; border-radius: 999px; background: var(--pw-surface-strong); }
.pw4-splash__track::after { content: ""; width: 42%; height: 100%; display: block; border-radius: inherit; background: var(--pw-primary); animation: pw4-splash-progress 1.15s var(--pw-ease-out) infinite; }
@keyframes pw4-splash-progress { from { transform: translateX(-110%); } to { transform: translateX(340%); } }

/* Compact: phone and narrow split view. */
@media (max-width: 767px) {
  :root { --pw-shell-header: 60px; }
  .pw4-sidebar,
  .pw4-rail,
  .pw4-utility { display: none !important; }
  .pw4-mobile-topbar { display: grid !important; }
  body.pw-authenticated #bottom-nav-root,
  body.pw4-authenticated #bottom-nav-root { display: block !important; }
  body.pw-authenticated #app-root,
  body.pw4-authenticated #app-root {
    width: 100%;
    max-width: none;
    margin-left: 0;
    padding: calc(var(--pw-shell-header) + var(--pw-safe-top) + 12px) max(16px, var(--pw-safe-right)) calc(94px + var(--pw-safe-bottom)) max(16px, var(--pw-safe-left));
  }
  body.pw-authenticated #app-root > *,
  body.pw4-authenticated #app-root > * { max-width: 100%; }
  .notif-panel,
  .action-center {
    position: fixed !important;
    inset: calc(var(--pw-shell-header) + var(--pw-safe-top) + 6px) 8px calc(84px + var(--pw-safe-bottom) + 8px) !important;
    width: auto !important;
    max-width: none !important;
    max-height: none !important;
    border-radius: 18px !important;
  }
  .pw4-directory__groups { grid-template-columns: 1fr; }
}

/* Medium: real iPad/tablet rail, not a stretched phone. */
@media (min-width: 768px) and (max-width: 1023px) {
  :root { --pw-shell-header: 64px; }
  .pw4-sidebar,
  .pw4-mobile-topbar { display: none !important; }
  .pw4-rail { display: flex !important; }
  .pw4-utility { left: var(--pw-shell-rail); display: flex !important; }
  .pw4-utility { padding-inline: 24px; }
  .pw4-command-entry { min-width: 190px; max-width: 270px; }
  .pw4-command-entry__copy small { display: none; }
  .pw4-bell-wrap.is-compact-owned { display: none !important; }
  body.pw-authenticated #bottom-nav-root,
  body.pw4-authenticated #bottom-nav-root { display: none !important; }
  body.pw-authenticated #app-root,
  body.pw4-authenticated #app-root {
    width: auto;
    max-width: none;
    margin-left: var(--pw-shell-rail);
    padding: calc(var(--pw-shell-header) + 20px) 28px 64px;
  }
  body.pw-authenticated #app-root > *,
  body.pw4-authenticated #app-root > * { max-width: var(--pw-canvas-max); margin-inline: auto; }
  body.pw4-authenticated[data-pw-route="/chat"] #app-root,
  body.pw4-authenticated[data-pw-route="/ai"] #app-root { padding-bottom: 0; }
  .pw4-directory { justify-content: flex-start; padding: 0 0 0 var(--pw-shell-rail); }
  .pw4-directory__panel { width: min(520px, calc(100vw - var(--pw-shell-rail))); height: 100%; max-height: none; padding: max(18px, var(--pw-safe-top)) 18px max(18px, var(--pw-safe-bottom)); border: 0; border-right: 1px solid var(--pw-border); border-radius: 0 var(--pw-radius-sheet) var(--pw-radius-sheet) 0; }
  .pw4-directory__handle { display: none; }
  .pw4-directory__groups { grid-template-columns: 1fr; }
  .notif-panel,
  .action-center { max-height: calc(100vh - var(--pw-shell-header) - 16px) !important; max-height: calc(100dvh - var(--pw-shell-header) - 16px) !important; }
}

/* Expanded and wide: grouped sidebar and a full operational canvas. */
@media (min-width: 1024px) {
  .pw4-mobile-topbar,
  .pw4-rail { display: none !important; }
  .pw4-sidebar,
  .pw4-utility { display: flex !important; }
  body.pw-authenticated #bottom-nav-root,
  body.pw4-authenticated #bottom-nav-root { display: none !important; }
  body.pw-authenticated #app-root,
  body.pw4-authenticated #app-root {
    width: auto;
    max-width: none;
    margin-left: var(--pw-shell-sidebar);
    padding: calc(var(--pw-shell-header) + 20px) var(--pw-gutter) 72px;
  }
  body.pw-authenticated #app-root > *,
  body.pw4-authenticated #app-root > * { max-width: var(--pw-canvas-max); margin-inline: auto; }
  body.pw4-authenticated[data-pw-route="/chat"] #app-root,
  body.pw4-authenticated[data-pw-route="/ai"] #app-root { padding-bottom: 0; }
  .pw4-directory { align-items: stretch; justify-content: flex-end; padding: 0; }
  .pw4-directory__panel { width: min(540px, calc(100vw - var(--pw-shell-sidebar))); height: 100%; max-height: none; padding: max(20px, var(--pw-safe-top)) 20px max(20px, var(--pw-safe-bottom)); border: 0; border-left: 1px solid var(--pw-border); border-radius: var(--pw-radius-sheet) 0 0 var(--pw-radius-sheet); }
  .pw4-directory__handle { display: none; }
  .pw4-account-layer { display: block; padding: 0; background: transparent; }
  .pw4-account-menu { position: fixed; top: var(--pw4-account-top); right: var(--pw4-account-right); width: 340px; max-height: calc(100vh - var(--pw4-account-top) - 18px); max-height: calc(100dvh - var(--pw4-account-top) - 18px); padding: 14px; border-radius: 20px; }
  .notif-panel,
  .action-center { max-height: calc(100vh - var(--pw-shell-header) - 16px) !important; max-height: calc(100dvh - var(--pw-shell-header) - 16px) !important; }
}

@media (min-width: 1440px) {
  :root { --pw-canvas-max: 1440px; }
}

@media (max-width: 390px) {
  .pw4-bottom-item { font-size: 14px; }
  .pw4-mobile-actions { gap: 4px; }
  .pw4-directory { padding-inline: 8px; }
  .pw4-directory__panel { padding-inline: 13px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}

@media print {
  .pw4-sidebar,
  .pw4-rail,
  .pw4-utility,
  .pw4-mobile-topbar,
  .pw4-bottom-nav,
  .pw4-directory,
  .pw4-account-layer,
  .pw4-splash,
  .os-assistant-fab { display: none !important; }
  body.pw-authenticated #app-root,
  body.pw4-authenticated #app-root { margin: 0 !important; padding: 0 !important; }
}
