/** Shared app UI. Opt-in markers are emitted by view templates, never by routing.
 * Keep app-specific status colors, media/canvas geometry and technical monospace.
 * Screen-only rules leave printable agreements and certificate artifacts alone.
 */
@media screen {
  body[data-medallion-app] {
    --mds-app-focus: var(--mx-focus-ring-color, #f2cc76);
    --smile-heading: var(--mds-display);
    --smile-body: var(--mds-body);
    --ce-font-heading: var(--mds-display);
    --ce-font-body: var(--mds-body);
    --is-font: var(--mds-body);
    --is-display: var(--mds-display);
    --font-display: var(--mds-display);
    --font-sans: var(--mds-body);
    font-family: var(--mds-body);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
  }
  /* Actual UI roles override each app's legacy display faces. Font declarations
     with explicit mono intent and editable documents retain their own font. */
  body[data-medallion-app] :is(h1, h2, h3, h4, h5, h6, button, input, select, textarea, label, nav)
    :is(code, pre, kbd, samp) { font-family: var(--mx-font-mono, ui-monospace, monospace); }
  body[data-medallion-app] :is(h1, h2, h3, h4, h5, h6, button, input, select, textarea, label, nav):not([style*="mono"]):not(.mono):not([data-font="mono"]) {
    font-family: var(--mds-body) !important;
  }
  /* Inline React typography is localized to these known legacy font names. */
  body[data-medallion-app] :is([style*="DM Sans"], [style*="Space Grotesk"], [style*="Playfair Display"], [style*="Instrument Serif"], [style*="Chakra Petch"]) {
    font-family: var(--mds-body) !important;
  }
  body[data-medallion-app] :is(.lux-brand, .lux-logo, .m-logo, .m-nav__brand, .smile-brand) { font-family: var(--mds-display); }
  body[data-medallion-app="luxkey"] :is(.lux-top-nav-brand, .lux-popup-price, .lux-card-price, .lux-detail-price, .lux-dr-stat b, .feed-title, .mandate-title) {
    font-family: var(--mds-display);
  }
  body[data-medallion-app="chat-exchange"] :is(.cr-root, .room-mode-slot) { --cr-font: var(--mds-body); }
  body[data-medallion-app] :is(code, pre, kbd, samp) { font-family: var(--mx-font-mono, ui-monospace, monospace); }
  body[data-medallion-app] :focus-visible { outline: 2px solid var(--mds-app-focus) !important; outline-offset: 3px; }

  /* A consistent resting elevation across app cards. App-specific colors,
     density and media geometry remain authoritative. */
  body[data-medallion-app] :is(.ls-panel, .is-card, .lux-card, .m-card, .smile-stream-card, .ce-exchange-card),
  body[data-medallion-app="approval"] .card,
  body[data-medallion-app="aoe"] .aoe-shell .grid > article {
    border-color: color-mix(in srgb, currentColor 12%, transparent);
    box-shadow: var(--mds-shadow-soft);
  }
  body[data-medallion-app] :is(.ls-panel, .is-card, .lux-card, .m-card, .smile-stream-card, .ce-exchange-card):hover,
  body[data-medallion-app="approval"] .card:hover {
    box-shadow: var(--mds-shadow-lifted);
  }

  /* Mail Cannon's dark dashboard labels are rendered with inline legacy
     tertiary colors. Raise only the affected dashboard labels/secondary
     controls to the existing readable dark-surface role. */
  body[data-medallion-app="mail-cannon"] .mail-main :is(
    .mc-dashboard-stats > div > div > div > div:first-child,
    .mc-dashboard-performance > div > div > div > div:first-child,
    .mc-dashboard-sidebar > div > div:nth-child(2),
    .mc-dashboard-sidebar > div > div:nth-child(2) > div:nth-child(2),
    .mc-dashboard-sidebar > div > div:nth-child(3) > div:nth-child(2)
  ) { color: #aebbd0 !important; }
  body[data-medallion-app="mail-cannon"] .mail-main .mc-dashboard-sidebar button[type="button"] {
    color: #aebbd0 !important;
  }
  body[data-medallion-app="mail-cannon"] .mail-main > nav button[type="button"] {
    color: #aebbd0 !important;
  }
  body[data-medallion-app="mail-cannon"] .mail-main button[aria-current] {
    color: #aebbd0 !important;
  }
  body[data-medallion-app="mail-cannon"] .mail-main .mc-topnav button { color: #aebbd0 !important; }
  body[data-medallion-app="mail-cannon"] .xsh-icon-btn { color: #aebbd0 !important; }
  body[data-medallion-app="mail-cannon"] .xsh-tab { color: #aebbd0 !important; }
  body[data-medallion-app="mail-cannon"] button[style*="139, 159, 191"],
  body[data-medallion-app="mail-cannon"] button[style*="8B9FBF"] { color: #aebbd0 !important; }
  body[data-medallion-app="mail-cannon"] button:not([aria-current])[style*="26, 111, 255"] {
    background-color: #155fc4 !important;
  }
  body[data-medallion-app="mail-cannon"] .mail-main .mc-dashboard-sidebar > div:first-child > div:nth-child(2),
  body[data-medallion-app="mail-cannon"] .mail-main .mc-dashboard-sidebar > div:nth-child(2) > div:nth-child(2) > div > div:nth-child(2) {
    color: #aebbd0 !important;
  }

  /* Existing light work surfaces need a dark focus outline independent of the
     dark platform sidebar. Their theme policies are unchanged. */
  body[data-medallion-app="approval"], body[data-medallion-app="luxkey"],
  body[data-medallion-app="moolah"], body[data-medallion-app="crop-shoot"]:not(.studio) {
    --mds-app-focus: #845500;
  }

  /* Shared component geometry. Rows remain rows; media tools keep their rails. */
  body[data-medallion-app] :is(.ls-btn, .is-btn, .lux-btn-primary, .lux-btn-secondary, .m-btn, .smile-btn, .ce-btn),
  body[data-medallion-app="approval"] .btn,
  body[data-medallion-app="aoe"] .aoe-shell button {
    min-height: 44px;
    border-radius: var(--mds-control);
    transition: background-color var(--mds-motion), border-color var(--mds-motion), color var(--mds-motion);
  }
  body[data-medallion-app] :is(.ls-panel, .is-card, .lux-card, .m-card, .smile-stream-card, .ce-exchange-card),
  body[data-medallion-app="approval"] .card,
  body[data-medallion-app="aoe"] .aoe-shell .grid > article {
    border-radius: var(--mds-radius);
  }
  body[data-medallion-app]:not(.studio):not([data-medallion-app="zeknova"])
    :is(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="hidden"]), select, textarea) {
    border-radius: var(--mds-control);
  }

  /* Medallion action accent, with explicit text roles for light and dark fills. */
  body[data-medallion-app="link-studio"] { --ls-accent: #f2cc76; }
  body[data-medallion-app="link-studio"] .ls-primary:hover { background: #ffe0a0; border-color: #ffe0a0; }
  html[data-theme="light"] body[data-medallion-app="link-studio"] .ls-stat-accent strong { color: #805500; }
  body[data-medallion-app="approval"] { --accent: #805500; --accent-2: #644100; --radius: var(--mds-radius); }
  body[data-medallion-app="approval"] :is(.brand-mark, .approval-count) { background: #f2cc76; color: #141a2e; }
  body[data-medallion-app="approval"] .btn-primary { background: #f2cc76; border-color: #f2cc76; color: #141a2e; }
  body[data-medallion-app="approval"] .btn-primary:hover { background: #ffe0a0; }
  body[data-medallion-app="moolah"] { --radius-lg: var(--mds-radius); --radius-md: var(--mds-control); }
  body[data-medallion-app="luxkey"] { --radius-md: var(--mds-control); --radius-lg: var(--mds-radius); }
  body[data-medallion-app="mail-cannon"] .mail-main button {
    min-height: 44px;
    border-radius: var(--mds-control) !important;
  }
  body[data-medallion-app="smile-more"] .smile-btn-sun {
    background: #f2cc76; border-color: #f2cc76; color: #141a2e; box-shadow: none;
  }

  @media (max-width: 768px) {
    body[data-medallion-app="crop-shoot"].studio .st-crumb-app,
    body[data-medallion-app="crop-shoot"].studio .st-crumb-sep { display: none; }
    body[data-medallion-app="approval"] .container > .grid {
      grid-template-columns: minmax(0, 1fr) !important;
    }
    body[data-medallion-app="approval"] .card-header { gap: 12px; }
    body[data-medallion-app="approval"] .approval-nav { flex-wrap: wrap; white-space: normal; }
    body[data-medallion-app="approval"] .approval-nav a { display: inline-flex; min-height: 44px; align-items: center; }
    body[data-medallion-app]:not(.studio):not([data-medallion-app="zeknova"])
      :is(input[type="text"], input[type="email"], input[type="search"], input[type="password"], select, textarea) {
      font-size: 16px;
      min-height: 44px;
    }
  }
  @media (prefers-reduced-motion: reduce) {
    body[data-medallion-app] :is(button, a, input, select, textarea, summary) {
      transition: none !important;
      scroll-behavior: auto !important;
    }
  }
}
