:root {
  color-scheme: dark;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #090b10;
  color: #f5f7fb;
  --panel: rgba(255, 255, 255, 0.08);
  --panel-strong: rgba(255, 255, 255, 0.14);
  --muted: #a9b1c3;
  --accent: #8ef3d2;
  --accent-strong: #33ddb1;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 8% 2%, rgba(71, 118, 230, 0.34), transparent 28rem),
    radial-gradient(circle at 92% 8%, rgba(51, 221, 177, 0.18), transparent 24rem),
    linear-gradient(180deg, #10131c 0%, #090b10 38rem);
}

button,
a {
  font: inherit;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2rem;
  align-items: end;
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 64px 0 28px;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

h1 {
  max-width: 760px;
  margin: 0;
  font-size: clamp(3rem, 9vw, 7rem);
  line-height: 0.86;
  letter-spacing: -0.08em;
}

.intro {
  max-width: 620px;
  margin: 24px 0 0;
  color: var(--muted);
  font-size: clamp(1rem, 2vw, 1.2rem);
  line-height: 1.6;
}

.controls {
  display: grid;
  gap: 12px;
  justify-items: end;
}

.control-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 154px;
  border: 0;
  border-radius: 999px;
  padding: 14px 20px;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #06100d;
  cursor: pointer;
  font-weight: 800;
  box-shadow: 0 18px 50px rgba(51, 221, 177, 0.2);
}

.primary-link {
  text-decoration: none;
}

.secondary-button {
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  padding: 13px 17px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  cursor: pointer;
  font-weight: 800;
}

.secondary-button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.danger-button {
  color: #ffd7d7;
}

.primary-button:disabled,
.primary-button.is-disabled {
  cursor: not-allowed;
  filter: grayscale(1);
  opacity: 0.55;
}

.status-text {
  max-width: 320px;
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  text-align: right;
}

.setup-panel,
.empty-state {
  width: min(860px, calc(100% - 32px));
  margin: 24px auto;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 28px;
  padding: 24px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.setup-panel h2,
.empty-state h2 {
  margin: 0 0 8px;
}

.setup-panel p,
.empty-state p {
  color: var(--muted);
  line-height: 1.6;
}

pre {
  overflow-x: auto;
  border-radius: 18px;
  padding: 16px;
  background: rgba(0, 0, 0, 0.32);
}

code {
  color: #d7fff4;
}

.credential-panel {
  display: grid;
  gap: 18px;
}

.credential-panel[hidden] {
  display: none;
}

.credential-panel h2 {
  margin-bottom: 0;
}

.credential-panel p {
  margin: 0;
}

.credential-form {
  display: grid;
  gap: 14px;
}

.credential-form label {
  display: grid;
  gap: 7px;
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.9rem;
  font-weight: 800;
}

.credential-form input {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 16px;
  padding: 14px 15px;
  background: rgba(0, 0, 0, 0.3);
  color: #fff;
  font: inherit;
  outline: none;
}

.credential-form input:focus {
  border-color: rgba(142, 243, 210, 0.72);
  box-shadow: 0 0 0 4px rgba(142, 243, 210, 0.12);
}

.form-message {
  min-height: 1.4em;
  color: var(--muted);
  font-size: 0.9rem;
}

.form-message.is-error {
  color: #ffb3b3;
}

details summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 800;
}

.landing-panels {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  width: min(1180px, calc(100% - 32px));
  margin: 20px auto 72px;
}

.landing-panel {
  min-height: 210px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 28px;
  padding: 22px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.11), rgba(255, 255, 255, 0.055));
  box-shadow: 0 20px 70px rgba(0, 0, 0, 0.2);
}

.landing-panel span {
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 900;
  letter-spacing: 0.16em;
}

.landing-panel h2 {
  margin: 54px 0 10px;
  font-size: 1.35rem;
}

.landing-panel p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.feed {
  width: min(1180px, calc(100% - 32px));
  margin: 22px auto 0;
  column-count: 4;
  column-gap: 18px;
}

.asset-card {
  position: relative;
  display: block;
  margin: 0 0 18px;
  overflow: hidden;
  break-inside: avoid;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 26px;
  background: var(--panel);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.22);
  transform: translateZ(0);
}

.asset-card-error {
  min-height: 180px;
  background: repeating-linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.05),
    rgba(255, 255, 255, 0.05) 12px,
    rgba(255, 255, 255, 0.1) 12px,
    rgba(255, 255, 255, 0.1) 24px
  );
}

.asset-button {
  position: relative;
  display: block;
  width: 100%;
  min-height: 120px;
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  cursor: zoom-in;
  text-align: left;
}

.asset-button img {
  display: block;
  width: 100%;
  height: auto;
  min-height: 130px;
  object-fit: cover;
  transition: transform 220ms ease, filter 220ms ease;
}

.asset-card:hover img {
  filter: saturate(1.08) contrast(1.04);
  transform: scale(1.025);
}

.asset-overlay {
  position: absolute;
  inset: auto 0 0;
  padding: 58px 16px 16px;
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.82));
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.asset-card:hover .asset-overlay,
.asset-button:focus-visible .asset-overlay {
  opacity: 1;
  transform: translateY(0);
}

.asset-overlay h2 {
  margin: 0;
  overflow: hidden;
  font-size: 0.98rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.asset-overlay p {
  margin: 5px 0 0;
  color: #d7deeb;
  font-size: 0.78rem;
}

.type-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  border-radius: 999px;
  padding: 7px 10px;
  background: rgba(0, 0, 0, 0.64);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 800;
  backdrop-filter: blur(12px);
}

.sentinel {
  display: flex;
  justify-content: center;
  gap: 8px;
  min-height: 110px;
  padding: 34px 0 58px;
}

.sentinel span {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.28);
}

.sentinel.is-loading span {
  animation: pulse 840ms ease-in-out infinite alternate;
  background: var(--accent);
}

.sentinel.is-loading span:nth-child(2) {
  animation-delay: 120ms;
}

.sentinel.is-loading span:nth-child(3) {
  animation-delay: 240ms;
}

.viewer {
  width: min(980px, calc(100% - 24px));
  max-height: calc(100vh - 24px);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 28px;
  padding: 0;
  overflow: hidden;
  background: #080a0f;
  color: #fff;
  box-shadow: var(--shadow);
}

.viewer::backdrop {
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(8px);
}

.viewer img {
  display: block;
  width: 100%;
  max-height: 76vh;
  object-fit: contain;
  background: #030407;
}

.viewer-close {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 1;
  border: 0;
  border-radius: 999px;
  padding: 10px 14px;
  background: rgba(0, 0, 0, 0.62);
  color: #fff;
  cursor: pointer;
  font-weight: 800;
}

.viewer-meta {
  padding: 18px 20px 20px;
}

.viewer-meta h2 {
  margin: 0;
  overflow-wrap: anywhere;
}

.viewer-meta p {
  margin: 8px 0 0;
  color: var(--muted);
}

.reels-body {
  height: 100vh;
  height: 100svh;
  overflow: hidden;
  background: #020307;
}

.reels-topbar {
  position: fixed;
  top: max(14px, env(safe-area-inset-top));
  left: 50%;
  z-index: 20;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  width: min(760px, calc(100% - 24px));
  padding: 9px 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  background: rgba(5, 7, 12, 0.64);
  box-shadow: 0 18px 58px rgba(0, 0, 0, 0.34);
  backdrop-filter: blur(18px);
  transform: translateX(-50%);
}

.reels-topbar p {
  margin: 0;
  overflow: hidden;
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.85rem;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ghost-link,
.ghost-button,
.rail-button {
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  cursor: pointer;
  font-weight: 800;
  text-decoration: none;
}

.ghost-link,
.ghost-button {
  padding: 9px 12px;
  font-size: 0.83rem;
}

.ghost-button:disabled,
.rail-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.reels-shell {
  height: 100vh;
  height: 100svh;
  overflow-x: hidden;
  overflow-y: auto;
  background: #020307;
  scroll-behavior: smooth;
  scroll-snap-type: y mandatory;
  overscroll-behavior-y: contain;
  scrollbar-width: none;
}

.reels-shell::-webkit-scrollbar {
  display: none;
}

.reels-feed {
  min-height: 100vh;
  min-height: 100svh;
}

.reel-slide {
  position: relative;
  display: grid;
  place-items: center;
  height: 100vh;
  height: 100svh;
  min-height: 580px;
  overflow: hidden;
  background: #03050a;
  scroll-snap-align: start;
  scroll-snap-stop: always;
}

.reel-backdrop {
  position: absolute;
  inset: -5%;
  width: 110%;
  height: 110%;
  opacity: 0.32;
  filter: blur(34px) saturate(1.3) brightness(0.65);
  object-fit: cover;
  transform: scale(1.06);
}

.reel-frame {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: min(100vw, 520px);
  height: 100vh;
  height: 100svh;
  background: rgba(0, 0, 0, 0.46);
  box-shadow: 0 0 120px rgba(0, 0, 0, 0.5);
}

.reel-media {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

.reel-meta {
  position: absolute;
  left: 50%;
  bottom: max(26px, env(safe-area-inset-bottom));
  z-index: 3;
  width: min(500px, calc(100% - 104px));
  padding: 120px 18px 18px;
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.74));
  transform: translateX(-50%);
  pointer-events: none;
}

.reel-meta h2 {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: clamp(1rem, 3.5vw, 1.28rem);
  line-height: 1.2;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.72);
}

.reel-meta p {
  margin: 8px 0 0;
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.86rem;
  line-height: 1.45;
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.75);
}

.reel-badge {
  position: absolute;
  top: max(82px, calc(env(safe-area-inset-top) + 82px));
  right: max(18px, calc((100vw - 520px) / 2 + 18px));
  z-index: 4;
  border-radius: 999px;
  padding: 8px 11px;
  background: rgba(0, 0, 0, 0.52);
  color: #fff;
  font-size: 0.74rem;
  font-weight: 900;
  backdrop-filter: blur(14px);
}

.reel-slide.needs-gesture::after {
  content: "Tap to play";
  position: absolute;
  z-index: 5;
  border-radius: 999px;
  padding: 12px 16px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  font-weight: 900;
}

.reels-rail {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(28px, env(safe-area-inset-bottom));
  z-index: 22;
  display: grid;
  gap: 10px;
}

.rail-button {
  width: 62px;
  min-height: 48px;
  padding: 8px;
  background: rgba(8, 10, 16, 0.58);
  font-size: 0.77rem;
  backdrop-filter: blur(16px);
}

.icon-rail-button {
  display: grid;
  place-items: center;
}

.icon-rail-button svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.install-banner {
  position: fixed;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 60;
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  width: min(720px, calc(100% - 36px));
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 28px;
  padding: 14px;
  background: rgba(7, 10, 17, 0.86);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
}

.install-banner img {
  width: 58px;
  height: 58px;
  border-radius: 18px;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.28);
}

.install-banner h2 {
  margin: 0;
  font-size: 1rem;
}

.install-banner p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.4;
}

.install-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.reels-message {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 30;
  width: min(680px, calc(100% - 28px));
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 28px;
  padding: 24px;
  background: rgba(8, 10, 16, 0.88);
  box-shadow: var(--shadow);
  transform: translate(-50%, -50%);
}

.reels-message h1,
.reel-empty h1 {
  margin: 0 0 10px;
  font-size: clamp(2rem, 7vw, 4rem);
  line-height: 0.9;
  letter-spacing: -0.06em;
}

.reels-message p,
.reel-empty p {
  color: var(--muted);
  line-height: 1.6;
}

.reel-empty-frame {
  align-content: center;
  padding: 24px;
  text-align: center;
}

@keyframes pulse {
  from {
    opacity: 0.35;
    transform: translateY(0);
  }
  to {
    opacity: 1;
    transform: translateY(-7px);
  }
}

@media (max-width: 980px) {
  .hero {
    grid-template-columns: 1fr;
  }

  .controls {
    justify-items: start;
  }

  .control-buttons {
    justify-content: flex-start;
  }

  .status-text {
    text-align: left;
  }

  .feed {
    column-count: 3;
  }

  .landing-panels {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 700px) {
  .hero {
    width: min(100% - 24px, 1180px);
    padding-top: 38px;
  }

  .feed {
    width: min(100% - 18px, 1180px);
    column-count: 2;
    column-gap: 10px;
  }

  .asset-card {
    margin-bottom: 10px;
    border-radius: 18px;
  }

  .asset-overlay {
    display: none;
  }

  .reels-topbar {
    width: calc(100% - 16px);
  }

  .reels-topbar p {
    font-size: 0.76rem;
  }

  .ghost-link,
  .ghost-button {
    padding: 8px 10px;
  }

  .reel-slide {
    min-height: 100svh;
  }

  .reel-frame {
    width: 100vw;
  }

  .reel-meta {
    width: calc(100% - 86px);
    bottom: max(16px, env(safe-area-inset-bottom));
    padding-right: 10px;
    padding-left: 10px;
  }

  .reel-badge {
    right: 12px;
  }

  .reels-rail {
    right: 10px;
    bottom: max(18px, env(safe-area-inset-bottom));
  }

  .rail-button {
    width: 54px;
  }

  .install-banner {
    right: 10px;
    bottom: 10px;
    grid-template-columns: 48px 1fr;
    width: calc(100% - 20px);
  }

  .install-banner img {
    width: 48px;
    height: 48px;
  }

  .install-actions {
    grid-column: 1 / -1;
  }
}

@media (max-width: 430px) {
  h1 {
    font-size: 3.25rem;
  }

  .feed {
    column-count: 1;
  }
}
