/* ════════════════════════════════════
   Mobile — phone-style OS shell
   Hidden on desktop; shown on small screens.
   Breakpoint: narrow width OR short height (landscape phones).
   ════════════════════════════════════ */

#mobile { display: none; }

@media (max-width: 768px), (max-height: 500px) {
  /* hide the desktop metaphor entirely */
  #desktop,
  #dock,
  #dock-trigger,
  #dock-hint { display: none !important; }

  #mobile {
    display: block;
    position: fixed;
    top: 34px;                 /* below the fixed topbar */
    left: 0;
    right: 0;
    bottom: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* ── Home screen ── */
#mobile-home {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  padding: 22px 16px 32px;
  gap: 22px;
}

.m-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 18px 8px;
  align-content: start;
}

.m-app-icon {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  background: none;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 10px 4px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.m-app-icon:active {
  background: rgba(0, 0, 128, 0.45);
  border-color: rgba(255, 255, 255, 0.3);
}

.m-app-img {
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.m-app-img svg {
  width: 50px;
  height: 50px;
  filter: drop-shadow(0 3px 8px rgba(0, 0, 0, 0.7));
}

.m-app-label {
  font-family: var(--font);
  font-size: 8px;
  color: #fff;
  text-shadow:
    0 1px 4px rgba(0, 0, 0, 1),
    0 0 12px rgba(0, 0, 0, 0.85);
  text-align: center;
  transform: scaleY(1.3);
  transform-origin: top center;
  line-height: 1.5;
  word-break: break-word;
}

/* ── Full-screen app view ── */
#mobile-app {
  position: fixed;
  top: 34px;                   /* below the topbar */
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 900;
  display: flex;
  flex-direction: column;
  background: #c0c0c0;
}

#mobile-app[hidden] { display: none; }

#mobile-app-bar {
  flex-shrink: 0;
  height: 40px;
  display: flex;
  align-items: center;
  gap: 6px;
  background: #000080;
  border-bottom: 2px solid #000040;
  padding: 0 6px;
}

#mobile-app-title {
  flex: 1;
  min-width: 0;
  font-family: var(--font);
  font-size: 9px;
  color: #fff;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transform: scaleY(1.3);
  transform-origin: center;
}

.m-navbtn {
  flex-shrink: 0;
  min-width: 40px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid;
  border-color: #ffffff #808080 #808080 #ffffff;
  background: #c0c0c0;
  color: #000;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.m-navbtn:active {
  border-color: #808080 #ffffff #ffffff #808080;
}

/* Back — CSS left triangle (crisp, no font glyph needed). */
.m-nav-back::before {
  content: '';
  width: 0;
  height: 0;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-right: 9px solid #000;
}

/* Close — × in a font that actually has the glyph (the pixel font lacks it). */
.m-nav-close::before {
  content: '\2715';
  font-family: Arial, sans-serif;
  font-size: 14px;
  font-weight: bold;
  line-height: 1;
  color: #000;
}

/* Pages inject a root with position:absolute; inset:0 and their own scroll —
   this positioned, clipped container is what they fill. */
#mobile-app-body {
  flex: 1;
  position: relative;
  overflow: hidden;
}
