* {
  box-sizing: border-box;
  scrollbar-width: none;
}

*::-webkit-scrollbar {
  display: none;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overscroll-behavior: none;
}

body {
  background: var(--bg-deep);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  height: 100vh;       /* fallback for older browsers */
  height: 100dvh;      /* modern: accounts for dynamic UI chrome */
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* Mobile-first: phone fills the viewport edge-to-edge, no bezel. */
#app {
  position: relative;
  width: 100vw;
  height: 100vh;       /* fallback for older browsers */
  height: 100dvh;      /* modern: accounts for dynamic UI chrome */
  --phone-width: 100vw;
  --phone-height: 100vh;
  --phone-height: 100dvh;
  background: var(--bg-deep);
  overflow: hidden;
  margin: 0 auto;
}

/* Tablet/desktop: phone is centered with bezel + shadow + rounded corners.
   The dark background outside makes the dead space look intentional. */
@media (min-width: 481px) {
  #app {
    width: min(430px, calc(90dvh * 0.46));
    height: min(932px, 95dvh);
    --phone-width: min(430px, calc(90dvh * 0.46));
    --phone-height: min(932px, 95dvh);
    border-radius: 48px;
    box-shadow:
      0 0 0 10px #1a1a1a,
      0 0 80px rgba(94, 230, 224, 0.05),
      0 40px 80px rgba(0, 0, 0, 0.6);
  }
}

/* Tall desktop: scale up so the phone uses available height. */
@media (min-width: 481px) and (min-height: 1001px) {
  #app {
    width: min(500px, calc(95dvh * 0.46));
    height: min(1080px, 95dvh);
    --phone-width: min(500px, calc(95dvh * 0.46));
    --phone-height: min(1080px, 95dvh);
  }
}

.view {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  transform: scale(0.96);
  transition: opacity 250ms ease-out, transform 250ms ease-out;
  pointer-events: none;
  display: flex;
  flex-direction: column;
}
.view.active {
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
}

.view--lock.exit {
  opacity: 0;
  transform: scale(0.95);
}
.view--home.enter {
  transform: scale(1.05);
}

/* Status bar */
.status-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: var(--status-bar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-5);
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--text-primary);
  z-index: 10;
  pointer-events: none;
}

.status-bar__left {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: 500;
  letter-spacing: 0.02em;
}

.status-bar__right {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.status-bar__signal {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 11px;
}
.status-bar__signal span {
  display: inline-block;
  width: 3px;
  background: var(--text-primary);
  border-radius: 1px;
}
.status-bar__signal span:nth-child(1) { height: 4px; }
.status-bar__signal span:nth-child(2) { height: 7px; }
.status-bar__signal span:nth-child(3) { height: 10px; }

.status-bar__wifi {
  width: 14px;
  height: 11px;
  opacity: 0.9;
}

.status-bar__battery {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
}
.status-bar__battery-icon {
  width: 22px;
  height: 11px;
  border: 1px solid var(--text-primary);
  border-radius: 3px;
  position: relative;
  padding: 1px;
}
.status-bar__battery-icon::after {
  content: '';
  position: absolute;
  right: -3px;
  top: 3px;
  width: 2px;
  height: 5px;
  background: var(--text-primary);
  border-radius: 0 1px 1px 0;
}
.status-bar__battery-fill {
  height: 100%;
  background: var(--text-primary);
  border-radius: 1px;
}

/* Home indicator */
.home-indicator {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  width: 134px;
  height: 5px;
  background: var(--text-tertiary);
  opacity: 0.6;
  border-radius: 3px;
  z-index: 11;
  cursor: pointer;
}

/* App headers (shared across apps) */
.app-shell {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg-deep);
  padding-top: var(--status-bar-height);
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-5);
  border-bottom: 1px solid var(--border);
  min-height: 56px;
  flex-shrink: 0;
}

.app-header__left,
.app-header__right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 32px;
}

.app-header__title {
  font-family: var(--font-display);
  font-size: 22px;
  color: var(--text-primary);
  letter-spacing: 0.01em;
}

.app-header__back {
  background: none;
  border: none;
  color: var(--accent-cyan);
  font-family: var(--font-body);
  font-size: 15px;
  cursor: pointer;
  padding: var(--space-2);
  display: flex;
  align-items: center;
  gap: 4px;
}

.app-header__icon-btn {
  background: none;
  border: none;
  color: var(--accent-cyan);
  font-size: 20px;
  cursor: pointer;
  padding: var(--space-2);
}

.app-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
  /* Clear the floating Casebook button (~88px from viewport bottom incl. home
     indicator + 16px gap + 48px button) and the Vibe Jam badge (~50px) so the
     last item in any app stays fully visible when scrolled to the bottom. */
  padding-bottom: calc(var(--home-indicator-height) + env(safe-area-inset-bottom, 0px) + 200px);
}
.app-body::-webkit-scrollbar {
  display: none;
}

.app-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  color: var(--text-tertiary);
  font-family: var(--font-display);
  font-style: italic;
  font-size: 18px;
  text-align: center;
  padding: var(--space-6);
  min-height: 50vh;
}

/* Settings */
.settings-section {
  padding: var(--space-5) var(--space-5) var(--space-3);
}
.settings-section__label {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  color: var(--text-tertiary);
  text-transform: uppercase;
  margin-bottom: var(--space-3);
}

.diff-cards {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.diff-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: var(--space-4);
  cursor: pointer;
  transition: border-color var(--transition-quick), background var(--transition-quick);
}
.diff-card--active {
  border-color: var(--accent-cyan);
  background: var(--bg-elevated);
}
.diff-card--disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.diff-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-2);
}
.diff-card__name {
  font-family: var(--font-display);
  font-size: 22px;
  color: var(--text-primary);
}
.diff-card__check {
  color: var(--accent-cyan);
  font-size: 18px;
}
.diff-card__desc {
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.settings-list { display: flex; flex-direction: column; }
.settings-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.settings-row__main { flex: 1; }
.settings-row__title {
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--text-primary);
  font-weight: 500;
  margin-bottom: 2px;
}
.settings-row__sub {
  font-family: var(--font-body);
  font-size: 12px;
  color: var(--text-secondary);
}
