/* TeslAppstore 2028 — extreme glass, Tesla-browser safe */
:root {
  --bg0: #05060d;
  --text: #f4f7ff;
  --muted: rgba(244, 247, 255, 0.62);
  --glass: rgba(18, 24, 40, 0.55);
  --glass-strong: rgba(12, 16, 28, 0.78);
  --stroke: rgba(255, 255, 255, 0.18);
  --stroke-hi: rgba(255, 255, 255, 0.35);
  --accent: #00e5ff;
  --danger: #ff5c7a;
  --radius: 22px;
  --header-h: 72px;
  --safe: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg0);
  color: var(--text);
  font-family: "SF Pro Display", "Segoe UI", system-ui, -apple-system, sans-serif;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
  overflow: hidden;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

/* Background layers */
.bg-root {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

#bgStill {
  position: absolute;
  inset: -4%;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  filter: saturate(1.05) brightness(0.72);
  animation: kenburns 48s ease-in-out infinite alternate;
  will-change: transform;
}

@keyframes kenburns {
  from { transform: scale(1.05) translate3d(0, 0, 0); }
  to { transform: scale(1.14) translate3d(-1.5%, 1%, 0); }
}

#bgThree {
  position: absolute;
  inset: 0;
}
#bgThree canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

.bg-vignette {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 50% 40%, transparent 0%, rgba(0,0,0,0.35) 55%, rgba(0,0,0,0.78) 100%),
    linear-gradient(180deg, rgba(0,0,0,0.35) 0%, transparent 18%, transparent 70%, rgba(0,0,0,0.65) 100%);
}

/* Glass utility */
.glass {
  background: var(--glass);
  border: 1px solid var(--stroke);
  box-shadow:
    0 10px 40px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

body:not(.lite) .glass {
  -webkit-backdrop-filter: blur(18px) saturate(1.3);
  backdrop-filter: blur(18px) saturate(1.3);
}

body.lite .glass {
  background: var(--glass-strong);
}

body.lite #bgStill {
  animation: none;
  filter: saturate(0.95) brightness(0.65);
}

/* Header — fixed height (no reflow when weather/clock updates) */
.app-header,
.hub-header {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  height: calc(var(--header-h) + var(--safe));
  min-height: calc(var(--header-h) + var(--safe));
  max-height: calc(var(--header-h) + var(--safe));
  padding: calc(6px + var(--safe)) 16px 6px;
  margin: 12px 14px 0;
  border-radius: 20px;
  overflow: hidden;
  box-sizing: border-box;
}

/*
 * Geometric center; reserved box so content never grows the bar.
 */
.header-center {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  width: min(42vw, 280px);
  height: 48px;
  text-align: center;
  pointer-events: none;
  overflow: hidden;
}

.header-center .location-weather {
  pointer-events: auto;
}

/* 24h clock — fixed metrics, no layout thrash */
.local-clock {
  display: block;
  margin: 0;
  height: 1.35em;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  line-height: 1.35em;
  text-align: center;
  font-family: "SF Mono", "Consolas", "Menlo", ui-monospace, monospace;
  color: #b8fbff;
  text-shadow:
    0 0 14px rgba(0, 229, 255, 0.4),
    0 0 1px rgba(255, 255, 255, 0.3);
  white-space: nowrap;
}

.clock-part {
  display: inline-block;
  min-width: 1.3em;
  text-align: center;
}

.clock-part--s {
  color: rgba(184, 251, 255, 0.7);
  font-weight: 500;
  text-shadow: 0 0 10px rgba(0, 229, 255, 0.25);
}

.clock-sep {
  display: inline-block;
  width: 0.4em;
  text-align: center;
  color: rgba(138, 247, 255, 0.5);
  font-weight: 400;
  letter-spacing: 0;
  animation: clock-breathe 1s steps(1, end) infinite;
}

.clock-sep--soft {
  color: rgba(138, 247, 255, 0.3);
  animation: none;
}

@keyframes clock-breathe {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0.28; }
}

.local-date {
  display: none; /* date lives on title= only — keeps bar tight */
}

.location-weather {
  display: block;
  width: 100%;
  height: 1.2em;
  margin: 0;
  padding: 0;
  border: 0;
  font-size: 0.7rem;
  line-height: 1.2em;
  color: rgba(220, 226, 238, 0.88);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.location-weather:active,
.location-weather.is-press {
  opacity: 0.85;
}

.weather-entry {
  display: inline;
  margin: 0 0.35em;
  white-space: nowrap;
  color: rgba(216, 221, 232, 0.92);
}

.weather-entry strong {
  color: #f0f6ff;
  font-weight: 650;
}

.brand {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  flex: 0 1 auto;
  max-width: 28%;
}

.brand__title {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1.15;
  background: linear-gradient(90deg, #fff, #8af7ff 55%, #ffc38a);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand__sub {
  font-size: 0.68rem;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-actions {
  position: relative;
  z-index: 2;
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  justify-content: flex-end;
  flex: 0 0 auto;
  max-width: 42%;
}

.header-actions .btn {
  min-height: 40px;
  padding: 8px 12px;
  font-size: 0.85rem;
}

@media (max-width: 720px) {
  .header-center {
    width: min(48vw, 200px);
  }
  .local-clock {
    font-size: 1.05rem;
    letter-spacing: 0.08em;
  }
  .brand__sub {
    display: none;
  }
  .header-actions .btn {
    min-height: 38px;
    padding: 6px 10px;
    font-size: 0.8rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .clock-sep { animation: none; }
}

.btn {
  appearance: none;
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  border-radius: 999px;
  padding: 12px 16px;
  font-size: 0.95rem;
  font-weight: 600;
  min-height: 48px;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s ease;
}

.btn:active { transform: scale(0.96); }

.btn.active {
  background: rgba(0, 229, 255, 0.18);
  border-color: rgba(0, 229, 255, 0.55);
  color: #b8fbff;
}

.btn--primary {
  background: linear-gradient(135deg, rgba(0, 229, 255, 0.35), rgba(255, 120, 80, 0.28));
  border-color: var(--stroke-hi);
}

/* Main grid */
main {
  position: relative;
  z-index: 1;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 18px 28px;
  -webkit-overflow-scrolling: touch;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 16px;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  min-height: 128px;
  padding: 18px 16px 14px;
  border-radius: var(--radius);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  transition: transform 0.12s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--accent, #00e5ff);
  opacity: 0.9;
  border-radius: 4px 0 0 4px;
}

.card:active,
.card.is-press { transform: scale(0.97); }

/* Brand logo cards (Tesla / SpaceX) */
.card--brand {
  min-height: 148px;
  justify-content: flex-end;
  background: linear-gradient(160deg, rgba(255,255,255,0.1), rgba(0,0,0,0.35));
}
.card--tesla {
  background:
    radial-gradient(circle at 70% 20%, rgba(0, 229, 255, 0.18), transparent 45%),
    linear-gradient(160deg, rgba(40, 44, 52, 0.75), rgba(8, 10, 16, 0.7));
}
.card--spacex {
  background:
    radial-gradient(circle at 30% 30%, rgba(100, 160, 255, 0.22), transparent 50%),
    linear-gradient(160deg, rgba(20, 28, 48, 0.8), rgba(6, 8, 14, 0.72));
}
.card__logo {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 72px;
  margin-bottom: 4px;
}
.logo-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.logo-svg--tesla {
  width: 88px;
  height: 88px;
  display: block;
}
.logo-svg--spacex {
  width: 150px;
  height: 50px;
  display: block;
}
.logo-mark--tesla .tesla-t {
  transform-origin: 100px 100px;
  animation: tesla-breathe 3.6s ease-in-out infinite;
}
.logo-mark--tesla .tesla-wing {
  transform-origin: 100px 40px;
  animation: tesla-wing 4.2s ease-in-out infinite;
}
.logo-mark--tesla .logo-pulse {
  transform-origin: 100px 100px;
  animation: logo-ring 2.8s ease-out infinite;
}
.logo-mark--spacex .sx-text {
  animation: sx-shimmer 3.2s ease-in-out infinite;
}
.logo-mark--spacex .sx-trail {
  stroke-dasharray: 220;
  stroke-dashoffset: 220;
  animation: sx-trail 2.4s ease-in-out infinite;
}
@keyframes tesla-breathe {
  0%, 100% { transform: scale(1); opacity: 0.95; }
  50% { transform: scale(1.04); opacity: 1; }
}
@keyframes tesla-wing {
  0%, 100% { opacity: 0.75; }
  50% { opacity: 1; }
}
@keyframes logo-ring {
  0% { opacity: 0.55; transform: scale(0.92); }
  70% { opacity: 0; transform: scale(1.08); }
  100% { opacity: 0; transform: scale(1.08); }
}
@keyframes sx-shimmer {
  0%, 100% { opacity: 0.88; }
  50% { opacity: 1; }
}
@keyframes sx-trail {
  0% { stroke-dashoffset: 220; opacity: 0.2; }
  50% { stroke-dashoffset: 0; opacity: 0.9; }
  100% { stroke-dashoffset: -40; opacity: 0.15; }
}
body.lite .logo-mark--tesla .tesla-t,
body.lite .logo-mark--tesla .logo-pulse,
body.lite .logo-mark--spacex .sx-text,
body.lite .logo-mark--spacex .sx-trail {
  animation: none;
}

/* Pointer / touch shared press */
.btn:active,
.btn.is-press { transform: scale(0.96); }
.btn {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.card {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.card--edit {
  border-color: rgba(0, 229, 255, 0.45);
  box-shadow: 0 0 0 1px rgba(0, 229, 255, 0.15), 0 10px 40px rgba(0, 0, 0, 0.35);
}

.card--add {
  align-items: center;
  justify-content: center;
  border-style: dashed;
  background: rgba(255, 255, 255, 0.04);
}

.card--add::before { display: none; }

.card__icon {
  font-size: 2rem;
  line-height: 1;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.35));
}

.card__label {
  margin-top: 12px;
  font-size: 1.05rem;
  font-weight: 650;
  letter-spacing: 0.01em;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card__meta {
  margin-top: 6px;
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.card__actions {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  gap: 6px;
}

.chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid var(--stroke);
}

.chip--danger {
  color: #ffb3c0;
  border-color: rgba(255, 92, 122, 0.5);
}

/* Footer */
.app-footer {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 20px 14px;
  color: var(--muted);
  font-size: 0.75rem;
}

.app-footer a {
  color: #9ae8ff;
  text-decoration: none;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.55);
}

.modal.open { display: flex; }

.modal__panel {
  width: min(520px, 100%);
  border-radius: 24px;
  padding: 22px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal__title {
  margin: 0 0 14px;
  font-size: 1.25rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.field label {
  font-size: 0.78rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.field input {
  appearance: none;
  border: 1px solid var(--stroke);
  background: rgba(0, 0, 0, 0.35);
  color: var(--text);
  border-radius: 14px;
  padding: 14px 14px;
  font-size: 1.05rem;
  min-height: 52px;
  outline: none;
}

.field input:focus {
  border-color: rgba(0, 229, 255, 0.65);
  box-shadow: 0 0 0 3px rgba(0, 229, 255, 0.15);
}

.icon-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 4px 0 14px;
}

.icon-pick {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.06);
  font-size: 1.25rem;
  cursor: pointer;
}

.modal__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.btn--ghost {
  background: transparent;
}

.btn--danger {
  background: rgba(255, 92, 122, 0.2);
  border-color: rgba(255, 92, 122, 0.55);
  color: #ffd0d9;
}

@media (min-width: 1100px) {
  .card-grid {
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 18px;
  }
  .card { min-height: 140px; }
}

@media (prefers-reduced-motion: reduce) {
  #bgStill { animation: none; }
  .card, .btn { transition: none; }
}


/* Elon's Latest X — in-page audio player */
.audio-player {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(3, 6, 14, 0.72);
  backdrop-filter: blur(10px);
}
.audio-player.open { display: flex; }
.audio-player__panel {
  position: relative;
  width: min(720px, 100%);
  padding: 28px 28px 24px;
  border-radius: 28px;
}
.audio-player__close {
  position: absolute;
  top: 14px;
  right: 14px;
  min-width: 52px;
  min-height: 52px;
}
.audio-player__eyebrow {
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.7;
  margin-bottom: 8px;
}
.audio-player__title {
  font-size: clamp(1.25rem, 2.4vw, 1.7rem);
  line-height: 1.25;
  margin: 0 48px 8px 0;
}
.audio-player__sub {
  margin: 0 0 22px;
  opacity: 0.75;
  font-size: 1rem;
}
.audio-player__controls {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 14px;
}
.audio-player__play {
  min-width: 140px;
  min-height: 64px;
  font-size: 1.2rem;
}
.audio-player__time {
  font-variant-numeric: tabular-nums;
  font-size: 1.05rem;
  opacity: 0.9;
}
.audio-player__seek {
  width: 100%;
  height: 28px;
}


/* Split still inside audio overlay */
.audio-player__art {
  margin: 0 0 16px;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid var(--stroke);
  background: rgba(0, 0, 0, 0.35);
  max-height: min(42vh, 360px);
}
.audio-player__art-img {
  display: block;
  width: 100%;
  height: auto;
  max-height: min(42vh, 360px);
  object-fit: contain;
  background: #000;
}
