/* A phone in landscape is still a phone, but a short desktop window is not,
   so the second arm asks for a touch pointer as well. */
@media (max-width: 760px), (max-height: 480px) and (pointer: coarse) {
  :root { --phone-top: 52px; --phone-tabs: 58px; }

  html, body { overflow: hidden; overscroll-behavior: none; }
  body { -webkit-text-size-adjust: 100%; }

  /* the desk stays in the document so its nodes keep their listeners, it just
     stops being the thing you look at */
  #app { display: none !important; }
  .noise { display: none; }

  .phone-shell[hidden] { display: none; }
  .phone-shell {
    position: fixed;
    inset: 0;
    z-index: 30;
    display: flex;
    flex-direction: column;
    background:
      radial-gradient(120% 60% at 50% 0%, rgba(90, 62, 120, .5), transparent 70%),
      var(--night);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  /* 16px or Safari zooms the whole page the moment a field takes focus */
  input, select, textarea { font-size: 16px !important; }
  .phone-shell button, .phone-shell label, .phone-shell a { touch-action: manipulation; }

  .phone-top {
    flex: 0 0 auto;
    height: var(--phone-top);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 12px;
    padding-top: env(safe-area-inset-top, 0px);
    box-sizing: content-box;
    border-bottom: 1px solid var(--line);
    background: rgba(16, 13, 24, .82);
    backdrop-filter: blur(14px);
  }
  .phone-top-where { display: flex; align-items: center; gap: 9px; flex: 1; min-width: 0; }
  .phone-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; }
  .phone-dot.is-live { background: #64d6ae; box-shadow: 0 0 9px #64d6ae; }
  .phone-dot.is-off { background: var(--ember); }
  .phone-top-copy { display: flex; flex-direction: column; min-width: 0; line-height: 1.15; }
  .phone-top-copy strong { font-size: 15px; font-weight: 750; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .phone-top-copy small { font-size: 11px; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .phone-top-button {
    flex: none;
    min-width: 40px;
    height: 36px;
    padding: 0 11px;
    border-radius: 11px;
    border: 1px solid var(--line);
    background: rgba(255,255,255,.05);
    color: var(--ink);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
  }

  .phone-body { flex: 1; min-height: 0; position: relative; }
  .phone-view {
    position: absolute;
    inset: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 12px 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
  }
  .phone-view[hidden] { display: none; }
  .phone-view-flush { padding: 0; gap: 0; }
  .phone-slot { display: flex; flex-direction: column; gap: 12px; }
  .phone-slot-fill { flex: 1; min-height: 0; }
  .phone-slot:empty { display: none; }

  .phone-heading {
    margin: 4px 2px -4px;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--faint);
  }
  .phone-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px;
    border-radius: 18px;
    border: 1px solid var(--line);
    background: var(--panel);
  }
  .phone-wide { width: 100%; justify-content: center; }
  .phone-empty { margin: 0; padding: 22px 14px; text-align: center; font-size: 12px; color: var(--faint); border: 1px dashed var(--line); border-radius: 16px; }

  .phone-rooms { display: flex; gap: 7px; overflow-x: auto; scrollbar-width: none; margin: -2px -12px 0; padding: 2px 12px 4px; }
  .phone-rooms::-webkit-scrollbar { display: none; }
  .phone-room {
    flex: none;
    display: flex;
    align-items: center;
    gap: 6px;
    height: 36px;
    padding: 0 14px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: rgba(255,255,255,.04);
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
  }
  .phone-room.active { color: #23160e; border-color: transparent; background: linear-gradient(135deg, var(--warm-bright), var(--warm)); }
  .phone-room i { font-style: normal; font-size: 11px; opacity: .8; }

  /* the panels that get carried over from the desk */
  .phone-shell .room-panel,
  .phone-shell .chat-dock,
  .phone-shell .rail-voice {
    position: static !important;
    left: auto !important; right: auto !important; top: auto !important; bottom: auto !important;
    width: 100% !important;
    max-width: none !important;
    height: auto !important;
    max-height: none !important;
    margin: 0 !important;
    transform: none !important;
    border-radius: 18px;
  }
  .phone-shell .room-panel { padding: 14px; overflow: visible; }
  .phone-shell .room-panel.panel-minimized { height: auto !important; }
  .phone-shell .panel-chrome { display: none !important; }
  .phone-shell .room-panel h1 { font-size: 21px; margin: 0 0 4px; }
  .phone-shell .room-panel h2 { font-size: 15px; }
  .phone-shell .panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
  .phone-shell .media-grid { height: auto; max-height: 260px; }
  .phone-shell .archive-columns { grid-template-columns: 1fr; height: auto; gap: 14px; }
  .phone-shell .activity-feed, .phone-shell .artifact-feed { max-height: 220px; }
  .phone-shell .radio-controls, .phone-shell .radio-actions { flex-wrap: wrap; }
  .phone-shell .radio-actions button, .phone-shell .door-invite button { flex: 1; }
  .phone-shell .door-head { flex-wrap: wrap; }
  .phone-shell .door-invite { display: flex; gap: 8px; }
  .phone-shell .door-invite .text-field { flex: 1; min-width: 0; }

  /* things a phone has no business doing */
  .phone-shell .office-edit-toggle,
  .phone-shell .place-volume,
  .phone-shell [data-open="captureModal"],
  .phone-shell .clip-upload,
  .phone-shell #clipsToggle,
  .phone-shell .tv-corner-pin { display: none !important; }
  .phone-shell #screensSection { display: none !important; }
  #feedViewerPlace { display: none; }
  .phone-shell .clips-section { border-top: 0; padding-top: 0; margin-top: 4px; }
  .phone-shell .clips-section.collapsed .clips-body { display: block; }

  .phone-tv { border-radius: 16px; overflow: hidden; background: #05040a; border: 1px solid var(--line); }
  .phone-tv:empty { display: none; }
  .phone-shell .projector-screen {
    position: relative !important;
    width: 100% !important;
    height: auto !important;
    aspect-ratio: 16 / 9;
    transform: none !important;
    border-radius: 0;
    clip-path: none !important;
  }
  .phone-shell .projector-empty h1 { font-size: 15px; }
  .phone-shell .projector-empty p { font-size: 11px; }
  .phone-feeds { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
  .phone-feeds:has(.phone-empty) { grid-template-columns: 1fr; }
  .phone-feed {
    position: relative;
    display: block;
    padding: 0;
    aspect-ratio: 16 / 9;
    border-radius: 14px;
    overflow: hidden;
    border: 1px solid var(--line);
    background: #05040a;
    cursor: pointer;
  }
  .phone-feed video { width: 100%; height: 100%; object-fit: cover; display: block; }
  .phone-feed-tag {
    position: absolute;
    left: 6px; right: 6px; bottom: 6px;
    display: flex; align-items: center; gap: 5px;
    padding: 4px 7px;
    border-radius: 9px;
    background: rgba(8,6,14,.72);
    font-size: 10px;
    font-weight: 700;
    color: var(--ink);
    text-align: left;
  }
  .phone-feed-tag span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  /* chat fills its tab, the composer never leaves the bottom */
  .phone-shell .chat-dock { flex: 1; min-height: 0; border-radius: 0; border: 0; background: none; backdrop-filter: none; }
  .phone-shell .chat-dock-toggle { display: none; }
  .phone-shell .chat-dock-body { flex: 1; height: auto !important; max-height: none !important; opacity: 1 !important; pointer-events: auto !important; }
  .phone-shell .chat-log { padding: 12px; gap: 9px; }
  .phone-shell .chat-text { font-size: 15px; }
  .phone-shell .chat-form { padding: 9px 10px; background: rgba(11,9,16,.7); }
  .phone-shell .chat-input, .phone-shell .chat-send { min-height: 44px; }
  .phone-shell .chat-send { width: 44px; }

  .phone-shell .rail-voice { background: var(--panel); border: 1px solid var(--line); padding: 12px; gap: 10px; }
  .phone-shell .rail-voice-toggle { display: none !important; }
  .phone-shell .rail-voice-list { max-height: none; }
  .phone-shell .rail-me { margin-top: 4px; }
  .phone-shell .rail-me-actions { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 8px; margin: 10px 0; }
  .phone-shell .rail-me-actions [hidden] { display: none !important; }
  .phone-shell .voice-mic { width: 100%; height: 46px; font-size: 18px; }
  .phone-shell .voice-connect { width: 100%; min-height: 46px; font-size: 15px; }

  .phone-you-head { flex-direction: row; align-items: center; gap: 12px; }
  .phone-you-face { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-size: 15px; font-weight: 800; color: #17111f; background: var(--warm); flex: none; }
  .phone-you-copy { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
  .phone-you-copy strong { font-size: 16px; }
  .phone-you-copy small { font-size: 12px; color: var(--faint); }
  .phone-shell .master-volume { display: flex !important; align-items: center; gap: 10px; width: 100% !important; min-width: 0 !important; padding: 12px 14px !important; border-radius: 18px; border: 1px solid var(--line); background: var(--panel); }
  .phone-shell .master-volume-slider { flex: 1; min-width: 0; }
  .phone-shell .master-volume output { display: block !important; width: 42px; text-align: right; font-size: 12px; color: var(--muted); }
  .phone-version { margin: 6px 0 0; text-align: center; font-size: 11px; color: var(--faint); }

  /* the call never leaves the screen once you are in it */
  .phone-callbar {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 10px 8px;
    padding: 9px 12px;
    border-radius: 14px;
    border: 1px solid rgba(100,214,174,.35);
    background: rgba(36,60,55,.7);
    color: var(--ink);
    text-align: left;
    cursor: pointer;
  }
  .phone-callbar[hidden] { display: none; }
  .phone-callbar-dot { width: 8px; height: 8px; border-radius: 50%; background: #64d6ae; box-shadow: 0 0 9px #64d6ae; flex: none; }
  .phone-callbar-copy { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.15; }
  .phone-callbar-copy strong { font-size: 13px; }
  .phone-callbar-copy small { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .phone-callbar-mic { flex: none; width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; font-size: 15px; background: rgba(255,255,255,.07); }
  .phone-callbar-mic.muted { background: rgba(235,101,80,.25); }

  .phone-tabs {
    flex: 0 0 auto;
    height: var(--phone-tabs);
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 2px;
    padding: 0 6px;
    border-top: 1px solid var(--line);
    background: rgba(16,13,24,.92);
    backdrop-filter: blur(14px);
  }
  .phone-tab {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    border: 0;
    background: none;
    color: var(--faint);
    cursor: pointer;
  }
  .phone-tab span { font-size: 17px; line-height: 1; }
  .phone-tab small { font-size: 10px; font-weight: 700; }
  .phone-tab.active { color: var(--warm); }
  .phone-tab-badge {
    position: absolute;
    top: 7px;
    left: 50%;
    margin-left: 4px;
    min-width: 15px;
    height: 15px;
    padding: 0 4px;
    border-radius: 999px;
    background: var(--ember);
    color: #fff;
    font-size: 9px;
    font-style: normal;
    font-weight: 800;
    display: grid;
    place-items: center;
  }
  .phone-tab-badge[hidden] { display: none; }

  /* shared chrome that still belongs on a phone */
  .modal { padding: 8px; }
  .modal-card { padding: 22px; }
  .capture-choices { grid-template-columns: 1fr; }
  .capture-choice { min-height: 105px; }
  #settingsModal .modal-card { max-height: calc(100dvh - 24px); }
  .settings-grid { grid-template-columns: 1fr; }
  .settings-tabs { overflow-x: auto; scrollbar-width: none; }
  .settings-tabs::-webkit-scrollbar { display: none; }
  .settings-tab { flex: 0 0 auto; white-space: nowrap; padding: 9px 13px; }
  /* keybinds only mean anything inside the desktop app */
  .settings-tab[data-settings-tab="keybinds"] { display: none; }
  .phone-hide { display: none !important; }
  .rooms-panel, .share-placer, .screen-share-menu, .voice-user {
    left: 8px !important; right: 8px !important;
    width: auto !important; max-width: none !important;
    top: auto !important; bottom: calc(var(--phone-tabs) + 12px) !important;
    max-height: 60dvh;
  }
  .feed-viewer { padding: 0; }
  .feed-viewer-video { width: 100vw; height: auto; max-height: 100dvh; object-fit: contain; }
  /* clear of the tab bar and the call bar that can sit above it */
  .toast-region { left: 8px; right: 8px; width: auto; bottom: calc(var(--phone-tabs) + 66px); }
  .visit-prompts { top: 72px; width: calc(100vw - 16px); }
}
