/* MultiplyOS UI v1 (flagged). Every other rule added here must be
   prefixed html[data-ui="multiplyos"] so the legacy UI is untouched when the flag is off. */
/* The only unflagged rule: added artwork must stay hidden in the legacy UI. */
.mos-brand-new { display: none; }

/* Approved artwork replaces only the shell lockups. */
html[data-ui="multiplyos"] .mos-brand-legacy { display: none; }
html[data-ui="multiplyos"] .mos-brand-new {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  max-width: 270px;
  min-width: 0;
  flex-wrap: wrap;
}
html[data-ui="multiplyos"] .mos-brand-new img:first-child { width: 48px; height: auto; flex: none; }
html[data-ui="multiplyos"] .mos-brand-new img + img { width: 210px; max-width: calc(100% - 60px); height: auto; min-width: 0; }

html[data-ui="multiplyos"] .mos-shell__header .mos-brand-new {
  padding: 12px;
  max-width: 294px;
  border-radius: 12px;
  background: var(--mos-nav-background);
}

/* Keep saying which app this is: the app name sits under the new lockup, as it did under the old one. */
html[data-ui="multiplyos"] .mos-brand-context {
  flex-basis: 100%;
  font-size: 0.7em;
  font-weight: 600;
  line-height: 1.3;
  color: var(--mos-nav-muted);
}

/* Apple-standard type (owner ruling 5 Oct 2026): 13px on desktop, 17px on phones. */
html[data-ui="multiplyos"] {
  --mos-font-size: calc(13px * var(--mos-ts, 1));
  --mos-line-height: 1.4;
  --mos-control-height: 32px;
  --mos-main-button-height: 36px;
}
@media (max-width: 767px), (pointer: coarse) {
  html[data-ui="multiplyos"] {
    --mos-font-size: calc(17px * var(--mos-ts, 1));
    --mos-line-height: 1.35;
    --mos-control-height: 44px;
    /* phone main button 56px minimum: Ashley ruling 5 Oct 2026 */
    --mos-main-button-height: 56px;
  }
}

/* Keep rem spacing stable; the reading size belongs to the pastor screens. */
html[data-ui="multiplyos"]:has(.mos-shell) {
  font-size: 16px; /* mos-text-ignore: the root never scales (rem spacing stays put) */
  color-scheme: light;
}
html[data-ui="multiplyos"] body:has(.mos-shell) {
  background: var(--mos-background);
}
html[data-ui="multiplyos"] .mos-shell {
  --mo-ink: var(--mos-text);
  --mo-muted: var(--mos-muted);
  --mo-page: var(--mos-background);
  --mo-card: var(--mos-surface);
  --mo-field: var(--mos-surface);
  --mo-inset: var(--mos-surface-soft);
  --mo-line: var(--mos-border);
  --mo-accent: var(--mos-primary);
  --mo-accent-tint: var(--mos-surface-soft);
  --mo-btn-fill: var(--mos-primary);
  --mo-btn-ink: var(--mos-on-primary);
  --mo-btn-hover: var(--mos-primary-hover);
  --mo-danger: var(--mos-danger);
  --mo-danger-ink: var(--mos-background);
  --mo-module-ink: var(--mos-text);
  --mo-font: var(--mos-font-family);
  /* Redeclare aliases here: root aliases otherwise retain the legacy values. */
  --background: var(--mos-background);
  --surface: var(--mos-surface);
  --surface-2: var(--mos-surface-soft);
  --border: var(--mos-border);
  --border-strong: var(--mos-control-border);
  --foreground: var(--mos-text);
  --muted: var(--mos-muted);
  --accent: var(--mos-primary);
  --accent-2: var(--mos-text);
  --on-accent: var(--mos-on-primary);
  --danger: var(--mos-danger);
  min-width: 0;
  min-height: 100dvh;
  background: var(--mos-background);
  color: var(--mos-text);
  font-family: var(--mos-font-family);
  font-size: var(--mos-font-size);
  line-height: var(--mos-line-height);
  overflow-wrap: anywhere;
}

/* This app follows the OS theme; there is no application theme preference. */
@media (prefers-color-scheme: dark) {
  html[data-ui="multiplyos"]:has(.mos-shell) {
    --mos-background: #0B1220;
    --mos-surface: #131E2F;
    --mos-surface-raised: #19263A;
    --mos-surface-soft: #223249;
    --mos-text: #F2F6FC;
    --mos-muted: #B4C2D6;
    --mos-border: #34465E;
    --mos-control-border: #8396AF;
    --mos-primary: #8CBFFF;
    --mos-primary-hover: #B8D7FF;
    --mos-on-primary: #061629;
    --mos-focus: #8CBFFF;
    --mos-nav-background: #060B12;
    --mos-nav-text: #F2F6FC;
    --mos-nav-muted: #B4C2D6;
    --mos-nav-active: #193355;
    --mos-success: #8CE2B3;
    --mos-success-tint: #133C2B;
    --mos-warning: #FFE095;
    --mos-warning-tint: #493805;
    --mos-danger: #FFB4BE;
    --mos-danger-tint: #49202B;
    --mos-info: #8CBFFF;
    --mos-info-tint: #18385E;
    color-scheme: dark;
  }
}

/* Override small utility/kit type without multiplying nested em sizes. */
html[data-ui="multiplyos"] .mos-shell :where(p, label, button, input, select, textarea, summary, small, .prose-script, .mo-why, .mos-brand-context, [class*="text-"]) {
  font-family: var(--mos-font-family);
  font-size: var(--mos-font-size);
  line-height: var(--mos-line-height);
}
/* Typing fields never under 16px at any text size (iPhone zooms the page otherwise). */
html[data-ui="multiplyos"] .mos-shell :where(input, select, textarea) {
  font-size: max(16px, var(--mos-font-size));
}
html[data-ui="multiplyos"] .mos-shell :is(h1, h2, h3, h4, h5, h6) {
  font-size: var(--mos-font-size);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.01em;
}
html[data-ui="multiplyos"] .mos-shell h1 {
  font-size: calc(26px * var(--mos-ts-display, 1));
  font-weight: 700;
  letter-spacing: -0.02em;
}
html[data-ui="multiplyos"] .mos-shell h2 {
  font-size: calc(17px * var(--mos-ts, 1));
}
html[data-ui="multiplyos"] .mos-shell .uppercase {
  text-transform: none;
  letter-spacing: normal;
}
html[data-ui="multiplyos"] .mos-shell .text-accent:not(a) {
  color: var(--mos-text);
}
html[data-ui="multiplyos"] .mos-shell span[class~="bg-accent/10"] {
  background: var(--mos-surface-soft);
  border-color: var(--mos-border);
}
html[data-ui="multiplyos"] .mos-shell :is(.flex, .inline-flex) {
  min-width: 0;
  flex-wrap: wrap;
}
html[data-ui="multiplyos"] .mos-shell .truncate:not(select) {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
}

/* A single navy header band, using the existing white artwork and context. */
html[data-ui="multiplyos"] .mos-shell__header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--mos-border);
  background: var(--mos-nav-background);
  color: var(--mos-nav-text);
}
html[data-ui="multiplyos"] .mos-shell__header > div {
  max-width: 1000px;
  gap: 24px;
}
html[data-ui="multiplyos"] .mos-shell__header a {
  min-width: 0;
  max-width: 100%;
  color: var(--mos-nav-text);
}
html[data-ui="multiplyos"] .mos-shell__header :is(.text-muted, .opacity-60) {
  color: var(--mos-nav-muted);
  opacity: 1;
}
html[data-ui="multiplyos"] .mos-shell__header .mos-brand-context img {
  display: inline-block;
  width: 24px;
  height: auto;
  vertical-align: middle;
}
html[data-ui="multiplyos"] .mos-shell__main {
  width: 100%;
  max-width: 1000px;
  min-width: 0;
  padding: 32px 24px calc(48px + env(safe-area-inset-bottom));
}

/* Share readable type and hit areas, but only box controls already styled as buttons. */
html[data-ui="multiplyos"] .mos-shell :is(button, .btn) {
  min-width: var(--mos-control-height);
  min-height: var(--mos-control-height);
  max-width: 100%;
  height: auto;
  background-image: none;
  font-size: var(--mos-font-size);
  font-weight: 600;
  line-height: var(--mos-line-height);
  white-space: normal;
  overflow-wrap: anywhere;
  box-shadow: none;
}
html[data-ui="multiplyos"] .mos-shell :is(button, .btn):where(.btn, .btn-main, .btn-primary, .border, .bg-accent) {
  padding: 6px 14px;
  border: 1px solid var(--mos-control-border);
  border-radius: 12px;
  background: var(--mos-surface);
  color: var(--mos-text);
  text-decoration: none;
}
html[data-ui="multiplyos"] .mos-shell :is(button, .btn):where(.btn, .btn-main, .btn-primary, .border, .bg-accent):hover {
  background: var(--mos-surface-soft);
}
/* Upload, Change/Done, and other legacy text controls stay quiet, including when pressed. */
html[data-ui="multiplyos"] .mos-shell button:not(.btn, .btn-main, .btn-primary, .border, .bg-accent) {
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--mos-primary);
  box-shadow: none;
}
html[data-ui="multiplyos"] .mos-shell button.border {
  border: 2px solid var(--mos-border);
  background: var(--mos-surface);
}
html[data-ui="multiplyos"] .mos-shell :is(button.border[aria-pressed="true"], button.border-accent, button.bg-accent) {
  background: var(--mos-info-tint);
  border: 2px solid var(--mos-primary);
  box-shadow: none;
}
html[data-ui="multiplyos"] .mos-shell :is(.btn-main, .btn-primary) {
  min-height: var(--mos-main-button-height);
  background: var(--mos-primary);
  border-color: var(--mos-primary);
  color: var(--mos-on-primary);
}
html[data-ui="multiplyos"] .mos-shell :is(.btn-main, .btn-primary):hover {
  background: var(--mos-primary-hover);
  border-color: var(--mos-primary-hover);
}
html[data-ui="multiplyos"] .mos-shell button.rounded-full {
  width: 64px;
  height: 64px;
  min-width: 64px;
  padding: 0;
  border-radius: 50%;
}
/* Retry owns the primary action while an error/stall recovery form is visible. */
html[data-ui="multiplyos"] .mos-shell[data-mos-screen="player"]:has(form .btn-primary) button.rounded-full.btn-primary {
  --on-accent: var(--mos-text);
  background: var(--mos-surface);
  border-color: var(--mos-control-border);
  color: var(--mos-text);
}
html[data-ui="multiplyos"] .mos-shell__main a:not(.btn) {
  min-height: var(--mos-control-height);
  color: var(--mos-primary);
  text-underline-offset: 4px;
}
html[data-ui="multiplyos"] .mos-shell__main a.underline {
  display: inline-flex;
  align-items: center;
}
html[data-ui="multiplyos"] .mos-shell .card {
  min-width: 0;
  border: 1px solid var(--mos-border);
  border-radius: 22px;
  background: var(--mos-surface);
  box-shadow: none;
}

/* Library rows remain one link; only the title gets ink and optional hover emphasis. */
html[data-ui="multiplyos"] .mos-shell[data-mos-screen="home"] a.card[href^="/sermon/"] {
  align-items: flex-start;
  gap: 12px;
}
html[data-ui="multiplyos"] .mos-shell[data-mos-screen="home"] a.card[href^="/sermon/"] > .min-w-0 {
  flex: 1;
  min-width: 0;
}
html[data-ui="multiplyos"] .mos-shell[data-mos-screen="home"] a.card[href^="/sermon/"] > .min-w-0 > .truncate {
  color: var(--mos-text);
  font-weight: 600;
}
html[data-ui="multiplyos"] .mos-shell[data-mos-screen="home"] a.card[href^="/sermon/"]:hover > .min-w-0 > .truncate {
  text-decoration: underline;
}
/* StatusPill's existing classes identify ready, processing/queued, and error. */
html[data-ui="multiplyos"] .mos-shell[data-mos-screen="home"] a.card > span.rounded-full {
  flex: none;
  white-space: nowrap;
  color: var(--mos-warning);
  background: var(--mos-warning-tint);
  border-color: var(--mos-warning);
}
html[data-ui="multiplyos"] .mos-shell[data-mos-screen="home"] a.card > span.rounded-full.text-accent-2 {
  color: var(--mos-success);
  background: var(--mos-success-tint);
  border-color: var(--mos-success);
}
html[data-ui="multiplyos"] .mos-shell[data-mos-screen="home"] a.card > span.rounded-full.text-danger {
  color: var(--mos-danger);
  background: var(--mos-danger-tint);
  border-color: var(--mos-danger);
}
@media (min-width: 600px) {
  html[data-ui="multiplyos"] .mos-shell[data-mos-screen="home"] a.card[href^="/sermon/"] {
    flex-wrap: nowrap;
  }
}

html[data-ui="multiplyos"] .mos-shell :is(.field, textarea) {
  min-height: var(--mos-control-height);
  min-width: 0;
  max-width: 100%;
  padding: 6px 10px;
  border: 1px solid var(--mos-control-border);
  border-radius: 12px;
  background: var(--mos-surface);
  color: var(--mos-text);
  box-shadow: none;
}
html[data-ui="multiplyos"] .mos-shell select.field { padding-inline-end: 48px; }
html[data-ui="multiplyos"] .mos-shell .field:focus {
  border-color: var(--mos-control-border);
}
html[data-ui="multiplyos"] .mos-shell :is(.field, textarea)::placeholder {
  color: var(--mos-muted);
  opacity: 1;
}
html[data-ui="multiplyos"] .mos-shell .dropzone {
  border-color: var(--mos-control-border);
  border-radius: 12px;
}
html[data-ui="multiplyos"] .mos-shell .dropzone[data-drag="true"] {
  border-color: var(--mos-text);
}
html[data-ui="multiplyos"] .mos-shell .dropzone > .pointer-events-none {
  background: var(--mos-surface-soft);
  color: var(--mos-text);
}

/* The native scrubber keeps its keyboard behavior and a full 48px hit area. */
html[data-ui="multiplyos"] .mos-shell .timeline {
  display: block;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  height: 48px;
  margin-inline: 0;
  accent-color: var(--mos-text);
}
html[data-ui="multiplyos"] .mos-shell .timeline + div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px 16px;
}
html[data-ui="multiplyos"] .mos-shell .timeline + div > span:last-child {
  grid-column: 2;
  grid-row: 1;
  text-align: end;
}
html[data-ui="multiplyos"] .mos-shell #player-status-line {
  grid-column: 1 / -1;
  grid-row: 2;
  padding: 0;
  text-align: start;
}
html[data-ui="multiplyos"] .mos-shell[data-mos-screen="player"] ol button .tabular-nums {
  width: auto;
}
html[data-ui="multiplyos"] .mos-shell[data-mos-screen="player"] ol button .truncate {
  flex: 1 1 160px;
}
html[data-ui="multiplyos"] .mos-shell[data-mos-screen="voices"] .card > .flex-1 {
  flex-basis: 260px;
}
html[data-ui="multiplyos"] .mos-shell :focus-visible {
  outline: 3px solid var(--mos-focus);
  outline-offset: 4px;
  box-shadow: none;
}
/* The existing next-step animation paints a glowing shadow on the main button. */
html[data-ui="multiplyos"] .mos-shell .mo-next {
  animation: none;
  box-shadow: none;
}

@media (max-width: 767px), (pointer: coarse) {
  html[data-ui="multiplyos"] .mos-shell h1 { font-size: calc(28px * var(--mos-ts-display, 1)); }
  html[data-ui="multiplyos"] .mos-shell h2 { font-size: calc(20px * var(--mos-ts, 1)); }
  html[data-ui="multiplyos"] .mos-shell :is(button, .btn):where(.btn, .btn-main, .btn-primary, .border, .bg-accent) {
    padding: 10px 18px;
  }
  html[data-ui="multiplyos"] .mos-shell :is(.field, textarea) { padding: 10px 14px; }
}
@media (max-width: 599px) {
  html[data-ui="multiplyos"] .mos-shell__header { padding: 16px; }
  html[data-ui="multiplyos"] .mos-shell__main {
    padding: 24px 16px calc(32px + env(safe-area-inset-bottom));
  }
  html[data-ui="multiplyos"] .mos-shell .card { padding: 16px; }
  html[data-ui="multiplyos"] .mos-shell :is(.btn-main, .btn-primary):not(.rounded-full) {
    width: 100%;
  }
  html[data-ui="multiplyos"] .mos-shell[data-mos-screen="player"] .card > .flex:has(> .rounded-full.btn-primary) {
    gap: 16px;
  }
  html[data-ui="multiplyos"] .mos-shell[data-mos-screen="player"] .card > .flex:has(> .rounded-full.btn-primary) > div {
    flex-basis: 100%;
    gap: 12px;
  }
  html[data-ui="multiplyos"] .mos-shell[data-mos-screen="player"] ol {
    grid-template-columns: minmax(0, 1fr);
  }
  html[data-ui="multiplyos"] .mos-shell[data-mos-screen="voices"] .card > button:last-child {
    width: 100%;
  }
}
@media (prefers-reduced-motion: reduce) {
  html[data-ui="multiplyos"] .mos-shell,
  html[data-ui="multiplyos"] .mos-shell *,
  html[data-ui="multiplyos"] .mos-shell *::before,
  html[data-ui="multiplyos"] .mos-shell *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
