html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

.mobile-bottom-nav {
  display: none;
}

.team-chat-channel-bar {
  display: none;
}

.mobile-connection-banner {
  position: sticky;
  z-index: 100000;
  top: 0;
  width: 100%;
  padding: max(10px, env(safe-area-inset-top)) 18px 10px;
  border-bottom: 1px solid rgba(120, 53, 15, 0.18);
  background: #fff4df;
  color: #713f12;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.4;
  text-align: center;
  box-shadow: 0 8px 24px rgba(82, 48, 13, 0.12);
}

.mobile-connection-banner[hidden] {
  display: none;
}

@media (pointer: coarse) {
  button,
  input,
  select,
  textarea,
  a {
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(44, 143, 214, 0.14);
  }
}

@media (max-width: 900px), (max-width: 980px) and (max-height: 500px) {
  #setupView .workspace-mobile-topbar {
    top: calc(var(--view-as-banner-height, 0px) + env(safe-area-inset-top, 0px));
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 2px 10px rgba(24, 58, 130, 0.08);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  #setupView .workspace-mobile-menu-toggle {
    border-radius: 10px;
    background: linear-gradient(135deg, #ff7659, #f59b42);
    box-shadow: 0 4px 12px rgba(230, 105, 61, 0.22);
  }

  #setupView #setupPracticeHeroCard .practice-hero-visual {
    display: grid;
    grid-template-columns: minmax(0, 1.08fr) minmax(132px, 0.92fr);
    align-items: center;
    gap: 0;
    min-height: 0;
    padding: 14px;
  }

  #setupView #setupPracticeHeroCard .practice-hero-preview-frame {
    position: relative;
    inset: auto;
    width: 100%;
    max-width: none;
    height: 150px;
    border-radius: 20px;
  }

  #setupView #setupPracticeHeroCard .practice-hero-preview-plate {
    position: relative;
    z-index: 2;
    inset: auto;
    left: -12px;
    width: calc(100% + 12px);
    max-width: none;
    padding: 12px;
    border-radius: 12px;
  }

  #setupView #setupPracticeHeroCard .practice-hero-preview-frame.hidden + .practice-hero-preview-plate {
    grid-column: 1 / -1;
    left: 0;
    width: 100%;
  }

  #setupView #prospectRow {
    margin-top: 0;
  }

  #setupHistoryCard .history-filter-trigger {
    width: 44px;
    min-width: 44px;
    min-height: 44px;
    padding: 0;
    justify-content: center;
  }

  #setupHistoryCard .history-filter-trigger .history-filter-label {
    display: none;
  }

  #setupView .workspace-main {
    padding-bottom: calc(104px + env(safe-area-inset-bottom, 0px));
  }

  body.team-chat-view-active {
    --mobile-chat-resting-bottom: max(72px, calc(63px + max(7px, env(safe-area-inset-bottom, 0px))));
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
  }

  html:has(body.team-chat-view-active) {
    height: 100%;
    overflow: hidden;
  }

  body.team-chat-view-active #setupView .workspace-mobile-topbar,
  body.team-chat-view-active #setupView #workspaceHeader {
    display: none;
  }

  body.team-chat-view-active #setupView .workspace-main {
    height: 100dvh;
    min-height: 0;
    gap: 0;
    padding: 0;
  }

  body.team-chat-view-active #setupTeamChatCard {
    position: fixed;
    z-index: 150;
    top: var(--view-as-banner-height, 0px);
    right: 0;
    bottom: var(--mobile-chat-resting-bottom);
    left: 0;
    width: auto;
    height: auto;
    min-height: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    grid-template-rows: minmax(0, 1fr);
  }

  body.team-chat-view-active #setupTeamChatCard .team-chat-channel-bar {
    display: none;
  }

  .team-chat-channel-select-label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  .team-chat-channel-select-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
  }

  .team-chat-channel-select-wrap::after {
    content: "";
    position: absolute;
    right: 13px;
    width: 8px;
    height: 8px;
    border-right: 2px solid #516584;
    border-bottom: 2px solid #516584;
    transform: translateY(-2px) rotate(45deg);
    pointer-events: none;
  }

  #teamChatChannelSelect {
    min-height: 44px;
    min-width: 176px;
    padding: 8px 38px 8px 16px;
    border: 1px solid rgba(206, 220, 246, 0.96);
    border-radius: 14px;
    appearance: none;
    -webkit-appearance: none;
    background: #fff;
    color: #14284e;
    font: inherit;
    font-size: 16px;
    font-weight: 900;
    text-align: center;
    box-shadow: 0 8px 22px rgba(28, 54, 108, 0.08);
  }

  #teamChatChannelSelect:focus-visible {
    outline: 3px solid rgba(49, 87, 216, 0.34);
    outline-offset: 2px;
  }

  body.team-chat-view-active .support-widget,
  body.team-chat-view-active .admin-online-widget {
    visibility: hidden;
    pointer-events: none;
  }

  .mobile-bottom-nav {
    position: fixed;
    z-index: 160;
    right: 0;
    bottom: 0;
    left: 0;
    display: grid;
    grid-template-columns: repeat(var(--mobile-nav-item-count, 5), minmax(0, 1fr));
    align-items: stretch;
    gap: 3px;
    min-height: 72px;
    padding:
      7px
      max(7px, env(safe-area-inset-right, 0px))
      max(7px, env(safe-area-inset-bottom, 0px))
      max(7px, env(safe-area-inset-left, 0px));
    border: 0;
    border-top: 1px solid rgba(255, 255, 255, 0.13);
    border-radius: 0;
    background: rgba(9, 28, 67, 0.97);
    box-shadow: 0 18px 42px rgba(7, 23, 63, 0.34);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    transform: translateY(0);
    opacity: 1;
    transition:
      transform 260ms cubic-bezier(0.22, 0.8, 0.28, 1),
      opacity 180ms ease;
    will-change: transform, opacity;
  }

  body.team-chat-view-active.team-chat-composer-focused #setupTeamChatCard {
    top: var(--view-as-banner-height, 0px);
    bottom: max(var(--mobile-chat-resting-bottom), var(--mobile-keyboard-inset, 0px));
    transform: none;
  }

  html.native-keyboard-metrics body.team-chat-view-active.team-chat-composer-focused #setupTeamChatCard {
    bottom: max(var(--mobile-chat-resting-bottom), var(--mobile-native-keyboard-inset, 0px));
    transition: bottom var(--mobile-keyboard-animation-duration, 250ms) var(--mobile-keyboard-animation-easing, ease-out);
  }

  body.team-chat-view-active.team-chat-composer-focused .mobile-bottom-nav {
    transform: translateY(110%);
    opacity: 0;
    pointer-events: none;
  }

  #setupHistoryCard .history-dashboard-head {
    flex-direction: row;
    align-items: center;
  }

  #setupHistoryCard .history-toolbar {
    margin-left: auto;
  }

  #setupHistoryCard .history-item {
    position: relative;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
    gap: 12px 14px;
    padding: 14px;
  }

  #setupHistoryCard .history-main {
    grid-column: 1 / -1;
    min-width: 0;
    padding-right: 42px;
  }

  #setupHistoryCard .history-cell {
    min-width: 0;
  }

  #setupHistoryCard .history-date {
    flex-flow: row wrap;
    column-gap: 5px;
  }

  #setupHistoryCard .history-menu-cell {
    position: absolute;
    z-index: 2;
    top: 12px;
    right: 12px;
  }

  .mobile-bottom-nav-button {
    position: relative;
    min-width: 0;
    min-height: 56px;
    padding: 5px 3px 4px;
    border: 0;
    border-radius: 16px;
    background: transparent;
    color: rgba(230, 239, 255, 0.68);
    box-shadow: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    font-size: 10px;
    font-weight: 800;
    line-height: 1;
    white-space: nowrap;
  }

  .mobile-bottom-nav-button:hover {
    background: rgba(255, 255, 255, 0.07);
  }

  .mobile-bottom-nav-button.active {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
  }

  .mobile-bottom-nav-button.active::before {
    content: "";
    position: absolute;
    top: 3px;
    left: 50%;
    width: 22px;
    height: 3px;
    border-radius: 999px;
    background: #ff7659;
    transform: translateX(-50%);
  }

  .mobile-bottom-nav-button:focus-visible {
    outline: 3px solid #91b8ff;
    outline-offset: 1px;
  }

  .mobile-bottom-nav-icon {
    position: relative;
    width: 25px;
    height: 25px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .mobile-bottom-nav-icon svg {
    width: 23px;
    height: 23px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .mobile-bottom-nav-badge {
    position: absolute;
    top: -7px;
    right: -10px;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    border: 2px solid #091c43;
    border-radius: 999px;
    background: #ff7659;
    color: #fff;
    font-size: 9px;
    font-weight: 900;
    line-height: 14px;
    text-align: center;
  }

  .team-chat-dock .tcd-rail {
    visibility: hidden;
    pointer-events: none;
  }

  body.mobile-primary-nav-active .support-widget,
  body.mobile-primary-nav-active .admin-online-widget {
    bottom: calc(100px + env(safe-area-inset-bottom, 0px));
  }

  #practiceView .practice-shell > .workspace-sidebar {
    display: none;
  }

  #practiceView .practice-shell,
  #practiceView .practice-page-main {
    gap: 10px;
  }

  #practiceView .practice-page-topbar {
    min-height: 44px;
    flex-direction: row;
    align-items: center;
  }

  #practiceView .back-link {
    min-height: 44px;
  }

  #practiceView .practice-stage-card {
    padding: 12px;
    border-radius: 20px;
  }

  #practiceView .practice-stage-card.compact-precall .call-board {
    min-height: 190px;
    grid-template-columns: 92px minmax(0, 1fr);
    gap: 8px;
    padding: 8px;
  }

  #practiceView .practice-stage-card.compact-precall .prospect-card {
    padding: 8px;
    border-radius: 15px;
  }

  #practiceView .practice-stage-card.compact-precall .avatar-block {
    height: 78px;
    border-radius: 13px;
  }

  #practiceView .practice-stage-card.compact-precall .prospect-identity {
    margin-top: 2px;
    padding: 4px;
  }

  #practiceView .practice-stage-card.compact-precall .avatar-meta span:first-child {
    font-size: 12px;
  }

  #practiceView .practice-stage-card.compact-precall .prospect-address,
  #practiceView .practice-stage-card.compact-precall .prospect-timer {
    display: none;
  }

  #practiceView .practice-stage-card.compact-precall .conversation-screen {
    min-height: 172px;
  }

  #practiceView .practice-control-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  #practiceView .practice-control-card,
  #practiceView .practice-control-card.primary {
    width: 100%;
    min-width: 0;
    padding: 8px;
  }

  #practiceView .practice-control-card.primary {
    grid-column: 1 / -1;
    order: -1;
  }

  #practiceView .practice-stage-card.compact-precall .practice-control-card:not(.primary) {
    display: none;
  }

  #practiceView .practice-control-card .icon-button {
    width: 44px;
    height: 44px;
  }
}

@media (max-width: 980px) and (max-height: 500px) {
  #setupView .workspace-main {
    padding-bottom: calc(82px + env(safe-area-inset-bottom, 0px));
  }

  .mobile-bottom-nav {
    bottom: 0;
    min-height: 60px;
    padding:
      5px
      max(7px, env(safe-area-inset-right, 0px))
      max(5px, env(safe-area-inset-bottom, 0px))
      max(7px, env(safe-area-inset-left, 0px));
    border-radius: 0;
  }

  body.team-chat-view-active {
    --mobile-chat-resting-bottom: max(60px, calc(53px + max(5px, env(safe-area-inset-bottom, 0px))));
  }

  .mobile-bottom-nav-button {
    min-height: 48px;
    padding: 3px 2px 2px;
    gap: 1px;
    font-size: 9px;
  }

  .mobile-bottom-nav-icon,
  .mobile-bottom-nav-icon svg {
    width: 21px;
    height: 21px;
  }

}

@media (prefers-reduced-motion: reduce) {
  html:focus-within {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  body.team-chat-view-active #setupTeamChatCard,
  .mobile-bottom-nav {
    transition: none;
  }
}
