/* iPhone / PWA офис — тёмный Higgsfield, нативные жесты iOS, без белых дыр.
   Включается: html.phone-ios-root + body.phone-ios (ставит app.js / index). */

html.phone-ios-root,
html.phone-ios-root body,
html.phone-ios-root body.ui-pro,
html.phone-ios-root body.ui-simple,
body.phone-ios {
  --bg: #070b0e !important;
  --panel: #141c22 !important;
  --ink: #f5fbfd !important;
  --muted: #b7c9d2 !important;
  --line: rgba(158, 228, 220, 0.16) !important;
  --accent: #7fe0d4 !important;
  --accent-ink: #041416 !important;
  --accent-soft: rgba(127, 224, 212, 0.16) !important;
  --warn: #f0c27a !important;
  --danger: #ff8e86 !important;
  --bubble-me: #1e3a42 !important;
  --bubble: #182229 !important;
  --radius: 16px !important;
  --shadow: 0 10px 28px -18px rgba(0, 0, 0, 0.75) !important;
  --ios-sep: #2a4a52 !important;
  --ios-group: #141c22 !important;
  --ios-label: #9eb0ba !important;
  --field: #0a1218 !important;
  --font-ui: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif !important;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", system-ui, sans-serif !important;
  color-scheme: dark !important;
  background: #070b0e !important;
  color: #f5fbfd !important;
  font-family: var(--font-ui) !important;
  font-weight: 500;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

/* Higgsfield wallpaper — вертикальный слой */
html.phone-ios-root body.phone-ios::before,
html.phone-ios-root body.ui-pro.phone-ios::before {
  content: "" !important;
  display: block !important;
  position: fixed !important;
  inset: 0 !important;
  z-index: 0 !important;
  pointer-events: none !important;
  background:
    linear-gradient(180deg, rgba(7, 11, 14, 0.55) 0%, rgba(7, 11, 14, 0.82) 42%, #070b0e 78%),
    url("/app/s/office-bg-iphone.webp?v=1") center top / cover no-repeat,
    #070b0e !important;
}

/* Не трогаем оверлеи (toast/nudge/…) — иначе position:fixed сбивается в relative
   и уведомления «падают» вниз под приложение в поток документа. */
html.phone-ios-root body.phone-ios > *:not(.toast):not(.nudge):not(.smola-pet):not(.sp-toast):not(.mobile-nav):not(.sheet-wrap):not(.call-overlay):not(.cc-panel):not(.talk):not(.pat-lock):not(.unlock):not(.modal):not(.dialog),
html.phone-ios-root .shell {
  position: relative;
  z-index: 1;
}

html.phone-ios-root body.phone-ios > .toast,
html.phone-ios-root body.phone-ios > .nudge,
html.phone-ios-root body.phone-ios > .smola-pet,
html.phone-ios-root body.phone-ios > .sp-toast {
  position: fixed !important;
  z-index: 100050 !important; /* выше таббара 99999 */
}

html.phone-ios-root body.phone-ios > .toast {
  left: 12px !important;
  right: 12px !important;
  bottom: calc(64px + env(safe-area-inset-bottom, 0px) + (var(--toast-i, 0) * 62px)) !important;
  max-width: none !important;
}

html.phone-ios-root body.phone-ios > .nudge {
  top: calc(10px + env(safe-area-inset-top, 0px)) !important;
  right: 10px !important;
  bottom: auto !important;
}

/* Читаемый светлый текст везде (кроме primary) */
body.phone-ios,
body.phone-ios .page,
body.phone-ios .card,
body.phone-ios .lead,
body.phone-ios .muted,
body.phone-ios label,
body.phone-ios th,
body.phone-ios td,
body.phone-ios .kpi,
body.phone-ios h1,
body.phone-ios h2,
body.phone-ios h3,
body.phone-ios p,
body.phone-ios li,
body.phone-ios .chip,
body.phone-ios .pill,
body.phone-ios .ios-more-lab,
body.phone-ios .ios-more-a,
body.phone-ios input,
body.phone-ios select,
body.phone-ios textarea,
body.phone-ios button.ghost,
body.phone-ios button:not(.primary):not(.danger) {
  color: #f5fbfd !important;
  opacity: 1 !important;
}

body.phone-ios .muted,
body.phone-ios .lead,
body.phone-ios .ios-more-lab,
body.phone-ios .ios-more-a small {
  color: #b7c9d2 !important;
}

body.phone-ios button.primary {
  color: #041416 !important;
  -webkit-text-fill-color: #041416;
  background: linear-gradient(135deg, #9ee4dc, #7bc8d8) !important;
  border: 0 !important;
  box-shadow: 0 8px 20px -12px rgba(126, 224, 212, 0.7) !important;
}

body.phone-ios button.danger {
  color: #ff8e86 !important;
  background: #2a1618 !important;
}

body.phone-ios input::placeholder,
body.phone-ios textarea::placeholder {
  color: #8fa3ae !important;
  opacity: 1 !important;
}

body.phone-ios .brand,
body.phone-ios .page h1 {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.03em;
  color: #ffffff !important;
}

body.phone-ios .page h1 {
  font-size: 32px;
  line-height: 1.12;
  margin: 6px 0 8px;
  text-shadow: 0 1px 12px rgba(0, 0, 0, 0.35);
}

body.phone-ios .page > p.lead {
  font-size: 15px;
  color: #b7c9d2 !important;
  margin: 0 0 18px;
  line-height: 1.4;
}

/* Карточки — сплошные тёмные «листы» iOS */
body.phone-ios .card,
body.phone-ios .kpi,
body.phone-ios .easy-tile,
body.phone-ios .simple-home .big-tile,
body.phone-ios .ios-more-group,
body.phone-ios .inb,
body.phone-ios .people,
body.phone-ios .thread,
body.phone-ios .composer,
body.phone-ios .sheet,
body.phone-ios .login .card {
  background: rgba(20, 28, 34, 0.94) !important;
  background-image: none !important;
  border: 1px solid #2a4a52 !important;
  border-radius: 16px !important;
  box-shadow: 0 12px 32px -22px rgba(0, 0, 0, 0.85) !important;
  color: #f5fbfd !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

body.phone-ios .card {
  margin-bottom: 12px;
  padding: 14px 16px;
}

body.phone-ios .card h2,
body.phone-ios .card h3 {
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -0.02em;
}

body.phone-ios button {
  border-radius: 14px;
  min-height: 48px;
  font-weight: 650;
  font-size: 16px;
}

body.phone-ios button.ghost {
  color: #9ee4dc !important;
  background: rgba(127, 224, 212, 0.08) !important;
  border: 1px solid rgba(127, 224, 212, 0.22) !important;
}

body.phone-ios input,
body.phone-ios select,
body.phone-ios textarea {
  border-radius: 14px !important;
  border: 1px solid #3a6570 !important;
  background: #0a1218 !important;
  color: #f5fbfd !important;
  min-height: 48px;
  font-size: 17px;
  padding: 12px 14px;
}

body.phone-ios input:focus,
body.phone-ios select:focus,
body.phone-ios textarea:focus {
  outline: none;
  border-color: rgba(127, 224, 212, 0.55) !important;
  box-shadow: 0 0 0 3px rgba(127, 224, 212, 0.16) !important;
}

/* Главный экран — плитки */
body.phone-ios .simple-home {
  display: grid !important;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 0 0 16px;
}

body.phone-ios .simple-home .big-tile {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  min-height: 112px;
  padding: 16px;
  text-decoration: none;
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

body.phone-ios .simple-home .big-tile span {
  font-size: 28px;
  line-height: 1;
}

body.phone-ios .easy-card .easy-h {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 12px;
}

body.phone-ios .easy-tile {
  padding: 14px 16px;
  min-height: 64px;
}

body.phone-ios .easy-tile.primary {
  background: rgba(127, 224, 212, 0.14) !important;
  border-color: rgba(127, 224, 212, 0.28) !important;
}

/* Скрыть десктопные виджеты */
body.phone-ios .office-float,
body.phone-ios .smola-pet,
body.phone-ios .mobile-fav,
body.phone-ios .m-fav-star,
body.phone-ios .ui-mode-bar {
  display: none !important;
}

/* Прокрутка документа (WebView / Capacitor) */
html.phone-ios-root,
html.phone-ios-root body.phone-ios {
  height: auto !important;
  max-height: none !important;
  min-height: 100% !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  position: static !important;
  overscroll-behavior-y: auto !important;
  -webkit-overflow-scrolling: touch !important;
  touch-action: pan-y !important;
}

body.phone-ios .shell {
  display: flex !important;
  flex-direction: column !important;
  grid-template-columns: unset !important;
  width: 100% !important;
  height: auto !important;
  max-height: none !important;
  min-height: 100dvh !important;
  overflow: visible !important;
  position: relative !important;
  background: transparent !important;
}

body.phone-ios nav.side {
  display: none !important;
}

body.phone-ios main {
  display: block !important;
  flex: none !important;
  width: 100% !important;
  height: auto !important;
  max-height: none !important;
  min-height: 0 !important;
  overflow: visible !important;
  background: transparent !important;
}

body.phone-ios .view {
  display: none;
  height: auto !important;
  max-height: none !important;
  overflow: visible !important;
  flex: none !important;
}

body.phone-ios .view.on {
  display: block !important;
}

body.phone-ios .page,
body.phone-ios .page.desk-page,
body.phone-ios .page.fn-page,
body.phone-ios .page.ob-page,
body.phone-ios .notes-wrap {
  display: block !important;
  flex: none !important;
  width: 100% !important;
  max-width: 100% !important;
  height: auto !important;
  min-height: 0 !important;
  max-height: none !important;
  overflow: visible !important;
  -webkit-overflow-scrolling: touch !important;
  padding: 10px 14px calc(104px + env(safe-area-inset-bottom, 0)) !important;
  background: transparent !important;
  box-sizing: border-box;
}

/* Чат / ИИ — внутренняя прокрутка */
body.phone-ios[data-view="msg"] .shell,
body.phone-ios[data-view="ai"] .shell,
body.phone-ios[data-view="desk"] .shell {
  height: 100dvh !important;
  max-height: 100dvh !important;
  overflow: hidden !important;
}

body.phone-ios[data-view="msg"] main,
body.phone-ios[data-view="ai"] main,
body.phone-ios[data-view="desk"] main,
body.phone-ios[data-view="msg"] .view.on,
body.phone-ios[data-view="ai"] .view.on,
body.phone-ios[data-view="desk"] .view.on {
  height: 100% !important;
  max-height: 100% !important;
  overflow: hidden !important;
  display: flex !important;
  flex-direction: column !important;
}

body.phone-ios[data-view="msg"] .chatwrap,
body.phone-ios[data-view="ai"] .thread,
body.phone-ios[data-view="desk"] .desk-page {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  overflow: hidden !important;
}

body.phone-ios[data-view="msg"] .msgs,
body.phone-ios[data-view="ai"] .msgs,
body.phone-ios[data-view="ai"] #ai-msgs,
body.phone-ios[data-view="desk"] .desk-chat {
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch !important;
  touch-action: pan-y !important;
  flex: 1 1 auto !important;
  min-height: 0 !important;
}

/* Нижний таббар — как iOS, тёмный */
html.phone-ios-root .mobile-nav,
body.phone-ios .mobile-nav {
  display: grid !important;
  visibility: visible !important;
  opacity: 1 !important;
  pointer-events: auto !important;
  grid-template-columns: repeat(5, 1fr);
  gap: 0;
  overflow: visible !important;
  position: fixed !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  top: auto !important;
  transform: none !important;
  z-index: 99999 !important;
  padding: 6px 2px calc(8px + env(safe-area-inset-bottom, 0)) !important;
  background: rgba(10, 16, 20, 0.96) !important;
  border-top: 1px solid #2a4a52 !important;
  box-shadow: 0 -12px 36px -18px rgba(0, 0, 0, 0.9) !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  max-width: 100vw;
  min-height: calc(54px + env(safe-area-inset-bottom, 0));
}

html.phone-ios-root .mobile-nav a,
body.phone-ios .mobile-nav a {
  min-width: 0;
  min-height: 50px;
  padding: 4px 2px 2px;
  font-size: 10px;
  font-weight: 600;
  color: #9eb0ba !important;
  border-radius: 0;
  background: transparent !important;
  text-align: center;
  text-decoration: none;
  position: relative;
}

body.phone-ios .mobile-nav a .ico {
  display: block;
  font-size: 23px;
  line-height: 1.15;
  margin-bottom: 2px;
}

body.phone-ios .mobile-nav a.on {
  color: #9ee4dc !important;
  font-weight: 700;
}

body.phone-ios .mobile-nav a .mnav-star,
body.phone-ios .mobile-nav a.mnav-pin {
  display: none;
}

body.phone-ios .mobile-nav .badge {
  position: absolute;
  top: 0;
  right: 16%;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  font-size: 10px;
  background: #ff5a52;
  color: #fff !important;
  border-radius: 999px;
}

/* Экран «Ещё» */
.ios-more {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: none;
  flex-direction: column;
  background:
    linear-gradient(180deg, rgba(7, 11, 14, 0.72), #070b0e 40%),
    url("/app/s/office-bg-iphone.webp?v=1") center top / cover no-repeat,
    #070b0e;
  padding-top: env(safe-area-inset-top, 0);
  color: #f5fbfd;
}

body.phone-ios.ios-more-open .ios-more {
  display: flex;
}

.ios-more-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px 8px;
}

.ios-more-head h2 {
  margin: 0;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: #fff !important;
}

.ios-more-head button {
  background: transparent;
  color: #9ee4dc !important;
  font-size: 17px;
  font-weight: 500;
  min-height: 44px;
  padding: 8px 4px;
}

.ios-more-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  padding: 0 16px calc(28px + env(safe-area-inset-bottom, 0));
}

.ios-more-group {
  background: rgba(20, 28, 34, 0.96) !important;
  border-radius: 14px;
  margin-bottom: 22px;
  overflow: hidden;
  border: 1px solid #2a4a52;
}

.ios-more-lab {
  font-size: 12px;
  font-weight: 650;
  color: #9eb0ba !important;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0 4px 8px;
  margin: 0;
}

.ios-more-a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  min-height: 48px;
  color: #f5fbfd !important;
  text-decoration: none;
  font-size: 17px;
  border-bottom: 0.5px solid #2a4a52;
  background: transparent !important;
}

.ios-more-a:last-child {
  border-bottom: 0;
}

.ios-more-a .ico {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-size: 16px;
  background: rgba(127, 224, 212, 0.14);
}

.ios-more-a .chev {
  margin-left: auto;
  color: #7a8e98;
  font-size: 18px;
  font-weight: 300;
}

.ios-more-a small {
  display: block;
  color: #9eb0ba !important;
  font-size: 13px;
  font-weight: 400;
  margin-top: 1px;
}

body.phone-ios.pwa-standalone {
  padding-top: env(safe-area-inset-top, 0);
}

/* Логин на iPhone */
body.phone-ios.login-page,
html.phone-ios-root body.login-page {
  min-height: 100dvh;
}

body.phone-ios .login,
body.phone-ios.login-page .login {
  padding: 24px 18px calc(28px + env(safe-area-inset-bottom, 0));
}

body.phone-ios .login .card {
  max-width: 420px;
  margin: 0 auto;
  padding: 22px 18px;
}

/* Таблицы / списки читаемые */
body.phone-ios table {
  background: transparent !important;
  color: #f5fbfd !important;
}

body.phone-ios th,
body.phone-ios td {
  border-color: #2a4a52 !important;
}

body.phone-ios .msg.me,
body.phone-ios .bubble-me {
  background: #1e3a42 !important;
  color: #f5fbfd !important;
}

body.phone-ios .msg.them,
body.phone-ios .bubble {
  background: #182229 !important;
  color: #f5fbfd !important;
}
