/* Phase 4B-4D: iPhone visual polish */
#wall {
  background:
    radial-gradient(ellipse 64% 60% at 76% 22%, rgba(237, 173, 197, 0.34), transparent 75%),
    radial-gradient(ellipse 90% 58% at 17% 72%, rgba(83, 102, 185, 0.56), transparent 72%),
    linear-gradient(145deg, #09162e, #3c425f 48%, #151a32) !important;
}
#homeL .icon {
  border-radius: 16px;
  box-shadow:
    0 2px 9px #0003,
    inset 0 0 0 0.5px #fff4;
  overflow: hidden;
}
#homeL .dock {
  background: rgba(232, 234, 247, 0.24);
  border: 1px solid #fff3;
  box-shadow: 0 7px 28px #050a2340;
  backdrop-filter: blur(28px) saturate(1.9);
  -webkit-backdrop-filter: blur(28px) saturate(1.9);
}
#homeL .widget {
  border: 1px solid #ffffff44;
  box-shadow: 0 6px 22px #080b2240;
}
#homeL .lbl {
  text-shadow: 0 1px 5px #0009;
  font-weight: 550;
}
#island {
  transition:
    width 0.38s cubic-bezier(0.18, 0.85, 0.18, 1),
    height 0.38s;
  box-shadow: 0 1px 2px #0005;
  pointer-events: none;
}
#island.jai-island-call {
  height: 39px;
  display: flex;
  align-items: center;
  color: #fff;
  font-weight: 650;
}
.jai-island-dot {
  font-size: 12px;
  color: #34c759;
}
.jai-island-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.jai-island-wave {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 20px;
}
.jai-island-wave i {
  display: block;
  width: 3px;
  height: 7px;
  background: #38d873;
  border-radius: 3px;
  animation: jai-wave 0.7s ease-in-out infinite alternate;
}
.jai-island-wave i:nth-child(2) {
  animation-delay: -0.2s;
}
.jai-island-wave i:nth-child(3) {
  animation-delay: -0.4s;
}
.jai-island-wave i:nth-child(4) {
  animation-delay: -0.1s;
}
@keyframes jai-wave {
  to {
    height: 17px;
  }
}
#ios-overlay[data-panel='notifications'] {
  background: linear-gradient(140deg, #22283bde, #49516be8);
}
#ios-overlay .ios-notif {
  width: 100%;
  align-items: center;
  background: rgba(249, 250, 255, 0.87);
}
#ios-overlay .ios-notif-icon {
  background: #08c45f;
  color: #fff;
  width: 36px;
  height: 36px;
  flex: none;
  border-radius: 9px;
  display: grid;
  place-items: center;
}
#ios-overlay .ios-empty-notif {
  text-align: center;
  opacity: 0.8;
  margin-top: 48px;
}
#ios-overlay .ios-cc {
  max-height: 100%;
  overflow: auto;
}
#hb {
  touch-action: none;
}
#phone,
#screen {
  overscroll-behavior: contain;
}
@media (prefers-reduced-motion: reduce) {
  #island {
    transition: none !important;
  }
  .jai-island-wave i {
    animation: none !important;
  }
}

/* Keep browser keyboards inside the simulated viewport; preserve app styling. */
#phone.mob {
  height: var(--phone-height, 100dvh) !important;
}
#phone {
  --phone-height: 100dvh;
}
#homeL[aria-hidden='true'] {
  pointer-events: none;
}
.thread-messages,
.app-content {
  min-height: 0;
  touch-action: pan-y;
}
textarea,
input {
  user-select: text;
  -webkit-user-select: text;
}
button:focus-visible {
  outline: 2px solid #007aff;
  outline-offset: 3px;
}
#boot-retry {
  color: white;
  border: 1px solid #777;
  border-radius: 12px;
  padding: 12px;
}
/* Reserve the status area while lists scroll under the phone chrome. */
.line-modern.social-line-list .app-content {
  padding-bottom: 115px;
}
#phone:has(#ios-overlay) #sb,
#phone:has(#ios-overlay) #hb {
  color: white;
}
#phone:has(#ios-overlay) #hb i {
  background: white;
}

.home-meta {
  pointer-events: none;
}

#island.jai-island-call {
  width: 148px;
  font-size: 11px;
  gap: 6px;
  padding: 0 9px;
}

#phone.short .hgrid {
  bottom: 125px;
  overflow-y: auto;
  align-content: start;
  scrollbar-width: none;
  padding-bottom: 8px;
}
@media (max-height: 640px) {
  #phone .hgrid {
    row-gap: 8px;
  }
  #phone .widget {
    height: 120px;
    aspect-ratio: auto;
  }
  #phone .hgrid .icon {
    width: 52px;
    height: 52px;
  }
  #phone .hgrid .app {
    gap: 3px;
  }
}

/* Only app lists scroll; focus must not pan the outer phone canvas. */
html,
body,
#phone,
#screen {
  overflow: clip;
}
/* Let narrow phone columns shrink without clipping widget corners. */
#homeL .hgrid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
#homeL .hgrid .app {
  width: 100%;
  max-width: 74px;
}

/* Simulated cellular service; the browser/iPhone status bar is untouched. */
#sb .status-network {
  font-size: 12px;
  font-weight: 650;
  letter-spacing: -0.4px;
  line-height: 1;
}
@media (max-width: 350px) {
  #sb {
    padding-right: 22px;
  }
  #sb .r {
    gap: 4px;
  }
}

.home-meta {
  display: flex;
  justify-content: center;
  opacity: 1;
}
.home-search {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border: 1px solid #ffffff12;
  border-radius: 24px;
  background: #ffffff24;
  box-shadow:
    inset 0 1px 2px #ffffff12,
    0 2px 5px #0002;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  color: #ffffffbf;
  font-size: 13px;
  font-weight: 500;
}
.home-search svg {
  width: 13px;
  height: 13px;
}
.jai-island-dot {
  color: #ff9f0a;
}
#island.jai-island-call {
  justify-content: space-between;
}
#homeL [data-app='line'] .icon,
[data-app='line'] .icon {
  position: relative;
}
.line-app-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  border-radius: 12px;
  background: #ff3b30;
  color: white;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 500;
}
.app[data-app='line'] .icon {
  overflow: visible;
}

/* Solid two-tone battery reference, aligned with the cellular status cluster. */
#sb .r {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  height: 16px;
}
#sb .r svg {
  display: block;
  flex-shrink: 0;
  fill: currentColor;
}
#sb .status-signal {
  width: 19px;
  height: 14px;
}
#sb .status-battery {
  width: 29px;
  height: 15px;
  margin-left: 1px;
}
#sb .status-network {
  display: flex;
  align-items: center;
  height: 15px;
  line-height: 15px;
}
@media (max-width: 350px) {
  #sb .r {
    gap: 4px;
  }
}

/* Single Calendar widget: keep a compact block with icons filling its right side. */
#homeL .hgrid {
  grid-auto-flow: row dense;
}
#homeL .widget.wcal {
  grid-row: span 2;
  align-self: stretch;
  height: auto;
  min-height: 0;
}
#homeL button[data-app='settings']:disabled {
  opacity: 1;
  cursor: default;
  -webkit-text-fill-color: currentColor;
}
