/* MultiplyOS phone layer. Load after tokens.css and multiplyos-ui.css.
   Phone defaults; the same markup gets room at 768px. No app selectors. */
html[data-ui="multiplyos"] { --mos-tabbar-h: 56px; }

/* One main button, within thumb reach. The shell owns the tabs and their safe area. */
html[data-ui="multiplyos"] .mos-actionbar {
  box-sizing: border-box;
  position: fixed;
  z-index: 30;
  inset-inline: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--mos-border);
  background: var(--mos-surface);
  color: var(--mos-text);
  box-shadow: 0 12px 32px rgb(0 0 0 / .14);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}
html[data-ui="multiplyos"] body:has(.mos-shell__tabbar:not([hidden])) .mos-actionbar {
  bottom: calc(var(--mos-tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: 12px;
}
html[data-ui="multiplyos"] .mos-actionbar__hint {
  margin: 0;
  font-size: 15px;
  line-height: 20px;
  color: var(--mos-muted);
  overflow-wrap: anywhere;
}
html[data-ui="multiplyos"] .mos-actionbar .mos-button--main {
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: max(56px, var(--mos-main-h));
  padding: 12px 16px;
  border: 1px solid var(--mos-primary);
  border-radius: var(--mos-radius-control);
  background: var(--mos-primary);
  color: var(--mos-on-primary);
  font: 600 17px/1.35 var(--mos-font-family);
  text-align: center;
  text-decoration: none;
  overflow-wrap: anywhere;
  cursor: pointer;
}
html[data-ui="multiplyos"] body:has(.mos-actionbar) .mos-shell__main {
  /* Room for tabs, the button, and a hint wrapping to three lines. */
  padding-bottom: calc(var(--mos-tabbar-h) + 156px + env(safe-area-inset-bottom));
}
html[data-ui="multiplyos"]:has(.mos-actionbar) {
  scroll-padding-bottom: calc(var(--mos-tabbar-h) + 156px + env(safe-area-inset-bottom));
}

/* An ordinary, labelled table becomes one record per card. */
html[data-ui="multiplyos"] .mos-rows {
  display: block;
  width: 100%;
  max-width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
html[data-ui="multiplyos"] .mos-rows thead {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
html[data-ui="multiplyos"] .mos-rows tbody { display: grid; gap: 8px; }
html[data-ui="multiplyos"] .mos-rows tbody tr {
  box-sizing: border-box;
  position: relative;
  isolation: isolate;
  display: grid;
  gap: 8px;
  min-width: 0;
  padding: 12px 16px;
  border: 1px solid var(--mos-border);
  border-radius: 12px;
  background: var(--mos-surface);
}
html[data-ui="multiplyos"] .mos-rows td {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 0;
  font-size: 17px;
  color: var(--mos-text);
  text-align: end;
}
html[data-ui="multiplyos"] .mos-rows td::before {
  content: attr(data-label);
  font-size: 15px;
  font-weight: 400;
  color: var(--mos-muted);
  text-align: start;
}
html[data-ui="multiplyos"] .mos-rows td:first-child {
  display: block;
  font-size: 17px;
  font-weight: 600;
  text-align: start;
}
html[data-ui="multiplyos"] .mos-rows td:first-child::before { content: none; }
html[data-ui="multiplyos"] .mos-rows a { color: var(--mos-primary); }
html[data-ui="multiplyos"] .mos-rows td:first-child > a {
  display: flex;
  align-items: center;
  min-height: 44px;
  color: var(--mos-text);
}
html[data-ui="multiplyos"] .mos-rows td:first-child > a::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  border-radius: 12px;
}
html[data-ui="multiplyos"] .mos-rows td:first-child > a:focus-visible::after {
  outline: 3px solid var(--mos-focus);
  outline-offset: 2px;
}
html[data-ui="multiplyos"] .mos-rows__action :is(a, button) {
  position: relative;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
}

html[data-ui="multiplyos"] .mos-stack {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
}
html[data-ui="multiplyos"] .mos-stack > * { min-width: 0; max-width: 100%; }
/* Only the last child comes first; the remaining children retain their order. */
html[data-ui="multiplyos"] .mos-stack--reverse > :last-child { order: -1; }

/* Put the dialog beside the page shell so inert can protect the background. */
html[data-ui="multiplyos"] .mos-sheet {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  align-items: end;
  font: 17px/1.4 var(--mos-font-family);
  color: var(--mos-text);
}
html[data-ui="multiplyos"] .mos-sheet[hidden] { display: none; }
html[data-ui="multiplyos"] body:has(.mos-sheet:not([hidden])) { overflow: hidden; }
html[data-ui="multiplyos"] .mos-sheet__scrim {
  position: absolute;
  inset: 0;
  background: var(--mos-text);
  opacity: .24;
}
/* Depth of field (rules card): what sits behind a sheet blurs, the way iOS does. */
html[data-ui="multiplyos"] .mos-sheet:not([hidden]) .mos-sheet__scrim {
  opacity: 1;
  background: rgb(0 0 0 / 0.24);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
}
html[data-ui="multiplyos"] .mos-sheet__panel {
  box-sizing: border-box;
  position: relative;
  width: 100%;
  min-width: 0;
  max-height: calc(100dvh - 48px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  border: 1px solid var(--mos-border);
  border-radius: 16px 16px 0 0;
  background: var(--mos-surface);
  box-shadow: 0 12px 32px rgb(0 0 0 / .14);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  overflow-wrap: anywhere;
  transform: translateY(0);
  transition: transform 240ms ease-out;
}
@starting-style {
  html[data-ui="multiplyos"] .mos-sheet:not([hidden]) .mos-sheet__panel { transform: translateY(100%); }
}
html[data-ui="multiplyos"] .mos-sheet__panel::before {
  content: "";
  display: block;
  width: 36px;
  height: 4px;
  margin: 0 auto 16px;
  border-radius: 2px;
  background: var(--mos-muted);
}
html[data-ui="multiplyos"] .mos-sheet__title {
  margin: 0 88px 16px 0;
  min-height: 44px;
  font-size: 20px;
  font-weight: 600;
  line-height: 1.4;
}
html[data-ui="multiplyos"] .mos-sheet__close {
  position: absolute;
  top: 36px;
  inset-inline-end: 16px;
  min-width: 72px;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--mos-control-border);
  border-radius: var(--mos-radius-control);
  background: var(--mos-surface);
  color: var(--mos-text);
  font: 600 17px/1.35 var(--mos-font-family);
  cursor: pointer;
}

html[data-ui="multiplyos"] .mos-header--thin {
  box-sizing: border-box;
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 12px;
  height: 56px;
  min-height: 56px;
  max-height: 56px;
  padding: 0 16px;
  border-bottom: 1px solid var(--mos-border);
  background: var(--mos-surface);
  color: var(--mos-text);
  box-shadow: 0 12px 32px rgb(0 0 0 / .14);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}
html[data-ui="multiplyos"] .mos-header__brand {
  display: flex;
  align-items: center;
  flex: none;
  min-height: 44px;
  min-width: 44px;
}
html[data-ui="multiplyos"] .mos-header__brand img { height: 28px; width: auto; }
html[data-ui="multiplyos"] .mos-header__title {
  flex: 1;
  min-width: 0;
  margin: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 17px;
  font-weight: 600;
}
html[data-ui="multiplyos"] .mos-header--thin .mos-header__action {
  box-sizing: border-box;
  flex: none;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  border: 1px solid var(--mos-control-border);
  border-radius: var(--mos-radius-control);
  color: var(--mos-text);
  background: var(--mos-surface);
}
html[data-ui="multiplyos"] .mos-header__action svg { width: 24px; height: 24px; }

html[data-ui="multiplyos"] .mos-shell__main :is(input, select) {
  box-sizing: border-box;
  min-width: 0;
  max-width: 100%;
  min-height: max(56px, var(--mos-control-h));
  font-size: max(17px, var(--mos-font-size));
  scroll-margin-block: 72px;
}
html[data-ui="multiplyos"] :is(.mos-actionbar, .mos-sheet, .mos-header--thin, .mos-rows, .mos-list) :focus-visible {
  outline: 3px solid var(--mos-focus);
  outline-offset: 2px;
}
html[data-ui="multiplyos"] .mos-shell__tabbar[hidden] { display: none; }

/* These two existing components get phone-only polish: no desktop resets that
   could erase a host kit's list layout or its shell-owned navigation. */
@media (max-width: 767px) {
  html[data-ui="multiplyos"] .mos-list { padding: 0; margin: 0; list-style: none; }
  html[data-ui="multiplyos"] .mos-list > li { min-width: 0; }
  html[data-ui="multiplyos"] .mos-list :is(.mos-list__row, li > a, li > button) {
    box-sizing: border-box;
    display: flex;
    align-items: center;
    width: 100%;
    min-height: 56px;
    padding: 0 16px;
    gap: 12px;
    color: var(--mos-text);
    font-size: 17px;
    text-decoration: none;
  }
  html[data-ui="multiplyos"] .mos-list__text { flex: 1; min-width: 0; }
  html[data-ui="multiplyos"] .mos-list__text > * {
    display: block;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }
  html[data-ui="multiplyos"] .mos-list__secondary { color: var(--mos-muted); font-size: 15px; }
  html[data-ui="multiplyos"] .mos-list__chevron { flex: none; width: 20px; height: 20px; margin-inline-start: auto; }
  html[data-ui="multiplyos"] .mos-shell__tabbar {
    box-sizing: border-box;
    height: calc(var(--mos-tabbar-h) + env(safe-area-inset-bottom));
    padding: 0 8px env(safe-area-inset-bottom);
  }
  html[data-ui="multiplyos"] .mos-shell .mos-shell__tabbar > :is(a, button) {
    min-height: 44px;
    height: calc(var(--mos-tabbar-h) - 1px);
    padding: 4px 2px;
  }
  html[data-ui="multiplyos"] .mos-shell__tabbar :is(a, button, span) { font-size: 12px !important; }
}

@media (min-width: 768px) {
  html[data-ui="multiplyos"] .mos-actionbar {
    position: static;
    align-items: flex-end;
    padding: 16px 0;
    border: 0;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
  html[data-ui="multiplyos"] .mos-actionbar .mos-button--main { width: auto; min-height: max(44px, var(--mos-main-h)); }
  html[data-ui="multiplyos"] body:has(.mos-actionbar) .mos-shell__main { padding-bottom: 36px; }
  html[data-ui="multiplyos"]:has(.mos-actionbar) { scroll-padding-bottom: 36px; }
  html[data-ui="multiplyos"] .mos-rows { display: table; }
  html[data-ui="multiplyos"] .mos-rows thead {
    position: static;
    display: table-header-group;
    width: auto;
    height: auto;
    margin: 0;
    overflow: visible;
    clip-path: none;
    white-space: normal;
  }
  html[data-ui="multiplyos"] .mos-rows tbody { display: table-row-group; }
  html[data-ui="multiplyos"] .mos-rows tbody tr {
    position: static;
    isolation: auto;
    display: table-row;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
  }
  html[data-ui="multiplyos"] .mos-rows :is(th, td),
  html[data-ui="multiplyos"] .mos-rows td:first-child {
    display: table-cell;
    padding: 12px 16px;
    border-bottom: 1px solid var(--mos-border);
    font-size: inherit;
    text-align: start;
  }
  html[data-ui="multiplyos"] .mos-rows td::before,
  html[data-ui="multiplyos"] .mos-rows td:first-child > a::after { content: none; }
  html[data-ui="multiplyos"] .mos-stack { flex-direction: row; align-items: center; gap: 16px; }
  html[data-ui="multiplyos"] .mos-stack--reverse > :last-child { order: 0; }
  html[data-ui="multiplyos"] .mos-sheet { place-items: center; padding: 24px; }
  html[data-ui="multiplyos"] .mos-sheet__panel { max-width: 560px; border-radius: 16px; transition: none; transform: none; }
  html[data-ui="multiplyos"] .mos-sheet__panel::before { display: none; }
  html[data-ui="multiplyos"] .mos-sheet__close { top: 16px; }
  html[data-ui="multiplyos"] .mos-shell__main :is(input, select) { min-height: max(44px, var(--mos-control-h)); font-size: max(15px, var(--mos-font-size)); }
}
@media (prefers-reduced-motion: reduce) {
  html[data-ui="multiplyos"] .mos-sheet__panel { transition: none; transform: none; }
}
