:root {
  --ink: #eff8ff;
  --ink-soft: rgba(205, 229, 255, 0.68);
  --dark: #030713;
  --rail: #071426;
  --rail-soft: #10243d;
  --line: rgba(118, 190, 255, 0.18);
  --mint: #38d6ff;
  --coral: #5b8cff;
  --violet: #8a7dff;
  --amber: #67e8f9;
  --blue: #73b9ff;
  --stage: #07111f;
  --stage-line: rgba(93, 174, 255, 0.22);
  --stage-ink: #e9f5ff;
  --rail-width: 228px;
  --card-width: 150px;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.32);
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
  letter-spacing: 0;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 18% 12%, rgba(56, 214, 255, 0.18), transparent 30%),
    radial-gradient(circle at 0% 78%, rgba(91, 140, 255, 0.16), transparent 34%),
    linear-gradient(160deg, #020611 0%, #061426 48%, #081b34 100%),
    var(--dark);
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(rgba(115, 185, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(115, 185, 255, 0.035) 1px, transparent 1px);
  background-size: 42px 42px;
  opacity: 0.72;
}

button,
input,
a {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
}

.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.icon {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.app-shell {
  display: grid;
  grid-template-columns: var(--rail-width) minmax(0, 1fr);
  width: 100vw;
  height: 100vh;
  min-height: 100vh;
  padding: 0;
  gap: 0;
  overflow: hidden;
}

.deck-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 14px;
  height: 100vh;
  min-height: 100vh;
  padding: 28px 8px 14px 24px;
  overflow: hidden;
  background:
    radial-gradient(circle at 18% 8%, rgba(80, 80, 80, 0.18), transparent 28%),
    linear-gradient(180deg, rgba(16, 16, 16, 0.98) 0%, rgba(10, 10, 10, 0.98) 48%, rgba(5, 5, 5, 0.99) 100%);
  box-shadow:
    inset -1px 0 rgba(180, 180, 180, 0.2),
    inset -28px 0 70px rgba(0, 0, 0, 0.18);
}

.deck-panel::after {
  content: none;
}

.deck-header,
.portal-card {
  position: relative;
  z-index: 1;
}

.deck-header {
  display: block;
  min-height: 56px;
}

.deck-intro {
  display: grid;
  gap: 10px;
  margin: 2px 0 4px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.35);
}

.deck-tagline {
  margin: 0;
  color: #d3d8dd;
  font-size: 0.72rem;
  line-height: 1.35;
}

.brand-logo {
  display: block;
  width: min(218px, 100%);
  height: auto;
  margin-left: -3px;
  filter:
    drop-shadow(0 0 18px rgba(56, 214, 255, 0.16))
    drop-shadow(0 10px 20px rgba(0, 0, 0, 0.34));
}

.brand-home {
  display: inline-block;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.card-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-top: 10px;
  align-content: start;
}

.portal-card {
  position: relative;
  display: block;
  width: 100%;
  max-width: var(--card-width);
  min-height: 46px;
  transform: none;
}

.portal-card.is-active .card-main {
  border-color: rgba(56, 214, 255, 0.68);
  box-shadow:
    0 0 0 1px rgba(56, 214, 255, 0.18),
    0 0 28px rgba(56, 214, 255, 0.12),
    0 18px 38px rgba(0, 0, 0, 0.3);
}

.portal-card.is-dragging {
  opacity: 0.42;
}

.portal-card.drag-over .card-main {
  border-color: var(--mint);
}

.card-main {
  position: relative;
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  width: 100%;
  min-width: 0;
  min-height: 46px;
  padding: 8px 10px;
  color: inherit;
  text-align: left;
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--card-accent, var(--mint)) 26%, transparent), transparent 56%),
    linear-gradient(135deg, rgba(22, 51, 87, 0.95), rgba(8, 21, 39, 0.98));
  border: 1px solid rgba(120, 196, 255, 0.18);
  border-left: 4px solid var(--card-accent, var(--mint));
  border-radius: 8px;
  cursor: pointer;
  overflow: hidden;
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

.card-main::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(280px circle at 50% 50%, rgba(56, 214, 255, 0.18), transparent 62%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease;
}

.card-main:hover,
.card-main:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(56, 214, 255, 0.42);
  box-shadow:
    0 0 0 1px rgba(56, 214, 255, 0.16),
    0 10px 22px rgba(0, 0, 0, 0.28),
    0 0 22px rgba(56, 214, 255, 0.09);
}

.card-main:hover::after,
.card-main:focus-visible::after {
  opacity: 1;
}

.card-icon-image {
  display: block;
  width: 32px;
  height: 32px;
  object-fit: cover;
  object-position: center;
  border-radius: 0;
}

.card-main:focus-visible {
  outline: 3px solid rgba(56, 214, 255, 0.28);
  outline-offset: 2px;
}

.card-grip {
  display: none;
  place-items: center;
  color: rgba(205, 229, 255, 0.48);
  cursor: grab;
}

.card-grip .icon {
  width: 16px;
  height: 16px;
  stroke-width: 4;
}

.card-copy {
  min-width: 0;
}

.card-copy strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-copy strong {
  color: #ffffff;
  font-size: 0.84rem;
  line-height: 1.2;
}

.portal-stage {
  position: relative;
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  width: 100%;
  min-width: 0;
  height: 100vh;
  min-height: 100vh;
  overflow: hidden;
  background: var(--stage);
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.portal-frame-shell {
  position: relative;
  height: 100vh;
  min-height: 100vh;
  overflow: hidden;
  background: #070b0a;
}

.landing-page {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 26px;
  padding: 28px;
  text-align: center;
  color: #e8f3ff;
}

.landing-logo {
  width: clamp(180px, 26vw, 320px);
  height: auto;
  filter: drop-shadow(0 14px 26px rgba(0, 0, 0, 0.4));
}

.landing-box {
  width: min(860px, 92vw);
  padding: clamp(18px, 3vw, 28px);
  border: 1px solid rgba(132, 186, 255, 0.24);
  border-radius: 8px;
  background:
    linear-gradient(145deg, rgba(14, 33, 57, 0.8), rgba(6, 14, 30, 0.88));
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.34);
}

.landing-box p {
  margin: 0;
  line-height: 1.6;
  color: #d2e6ff;
}

.landing-box p + p {
  margin-top: 14px;
}

.landing-portal-row {
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 16px;
  padding: 10px 12px;
  border: 1px solid rgba(120, 196, 255, 0.14);
  border-radius: 10px;
  background: linear-gradient(125deg, rgba(23, 45, 76, 0.34), rgba(10, 23, 44, 0.2));
  text-align: left;
  margin-top: 14px;
  cursor: pointer;
  overflow: hidden;
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

.landing-portal-row::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(380px circle at var(--mx, 50%) var(--my, 50%), rgba(56, 214, 255, 0.2), transparent 58%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease;
}

.landing-portal-row:hover,
.landing-portal-row:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(56, 214, 255, 0.42);
  background: linear-gradient(125deg, rgba(24, 55, 94, 0.58), rgba(12, 32, 63, 0.42));
  box-shadow:
    0 0 0 1px rgba(56, 214, 255, 0.18),
    0 10px 26px rgba(0, 0, 0, 0.34),
    0 0 24px rgba(56, 214, 255, 0.1);
}

.landing-portal-row:hover::after,
.landing-portal-row:focus-visible::after {
  opacity: 1;
}

.landing-portal-row p {
  margin: 0;
  padding-top: 6px;
}

.landing-portal-icon {
  display: block;
  width: 72px;
  height: 72px;
  object-fit: cover;
  object-position: center;
  flex: 0 0 auto;
  margin-bottom: 0;
}

.landing-portal-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  flex: 0 0 72px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  outline: 0;
  cursor: pointer;
  overflow: hidden;
}

.portal-frame-shell iframe {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 100vh;
  border: 0;
  background: #050505;
}

.empty-state,
.frame-loading,
.frame-fallback {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 18px;
  padding: 24px;
  color: #66716b;
  text-align: center;
}

.empty-state {
  display: none !important;
}

.portal-illustration {
  position: relative;
  width: min(360px, 62vw);
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(88, 239, 189, 0.2), transparent 42%),
    linear-gradient(315deg, rgba(255, 138, 91, 0.18), transparent 42%),
    #f8fbf8;
  border: 1px solid var(--stage-line);
  border-radius: 8px;
  box-shadow: 0 18px 48px rgba(23, 33, 29, 0.12);
}

.portal-illustration span {
  position: absolute;
  display: block;
  background: #ffffff;
  border: 1px solid var(--stage-line);
  border-radius: 6px;
}

.portal-illustration span:nth-child(1) {
  left: 24px;
  top: 24px;
  width: 26%;
  height: 72%;
  border-left: 5px solid var(--mint);
}

.portal-illustration span:nth-child(2) {
  right: 24px;
  top: 24px;
  width: 58%;
  height: 30%;
  border-top: 5px solid var(--coral);
}

.portal-illustration span:nth-child(3) {
  right: 24px;
  bottom: 24px;
  width: 58%;
  height: 34%;
  border-top: 5px solid var(--violet);
}

.empty-state p,
.frame-loading p,
.frame-fallback p {
  margin: 0;
  font-weight: 800;
}

.frame-loading {
  color: #d8e3de;
  place-items: center;
  align-content: center;
  padding: 24px;
  background:
    radial-gradient(circle at 50% 42%, rgba(70, 70, 70, 0.12), transparent 34%),
    #050505;
}

.frame-loader-head {
  display: grid;
  grid-template-columns: auto auto;
  align-items: center;
  justify-content: center;
  gap: 14px;
  width: min(520px, 62vw);
}

.frame-loader-logo {
  width: clamp(84px, 9vw, 116px);
  height: clamp(84px, 9vw, 116px);
  object-fit: cover;
  object-position: center;
  opacity: 0.94;
  filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.3));
}

.frame-loader-track {
  position: relative;
  width: clamp(180px, 39vw, 315px);
  height: 3px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
}

.frame-loader-bar {
  position: absolute;
  inset: 0 auto 0 0;
  width: 36%;
  border-radius: 999px;
  background: linear-gradient(90deg, #ff2121, #ff4343);
  box-shadow: 0 0 12px rgba(255, 48, 48, 0.62);
  animation: tubedeck-load-sweep 1.12s ease-in-out infinite;
  will-change: transform;
}

@keyframes tubedeck-load-sweep {
  0% {
    transform: translateX(-110%);
  }
  50% {
    transform: translateX(120%);
  }
  100% {
    transform: translateX(280%);
  }
}

.frame-fallback {
  color: #f4fff9;
  background:
    radial-gradient(circle at 50% 42%, rgba(88, 239, 189, 0.12), transparent 34%),
    linear-gradient(135deg, rgba(255, 42, 42, 0.08), transparent 30%),
    #070b0a;
}

.frame-fallback p {
  font-size: clamp(2rem, 5vw, 4.8rem);
  letter-spacing: 0;
  text-transform: uppercase;
}

[hidden] {
  display: none !important;
}

.mobile-top-sensor {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 22px;
  z-index: 50;
}

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
    height: 100dvh;
  }

  .deck-panel {
    display: grid;
    grid-template-rows: auto auto auto;
    gap: 10px;
    height: auto;
    min-height: 0;
    padding: 14px 14px 10px;
    background: transparent;
    box-shadow: none;
  }

  .deck-header {
    min-height: 0;
  }

  .brand-logo {
    width: min(144px, 100%);
    margin-left: 0;
  }

  .deck-intro {
    display: none;
  }

  .card-list {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    max-height: none;
  }

  .portal-card {
    width: 100%;
    transform: none;
  }

  .portal-stage,
  .portal-frame-shell,
  .portal-frame-shell iframe {
    min-height: 0;
    height: 100%;
  }

  .app-shell.mobile-deck-hidden {
    grid-template-rows: minmax(0, 1fr);
  }

  .app-shell.mobile-deck-hidden .deck-panel {
    display: none;
  }

  .app-shell.mobile-deck-peek .deck-panel {
    display: grid;
  }
}

@media (max-width: 560px) {
  .deck-panel {
    grid-template-columns: auto 1fr;
    grid-template-rows: auto;
    align-items: center;
    column-gap: 10px;
    height: 60px;
    min-height: 60px;
    max-height: 60px;
    padding: 6px 12px;
    overflow: hidden;
  }

  .deck-header {
    grid-column: 1;
    grid-row: 1;
  }

  .deck-intro {
    display: none;
  }

  .card-list {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
    display: grid;
    grid-template-columns: repeat(3, auto);
    gap: 8px;
    margin-top: 0;
  }

  .brand-logo {
    width: 122px;
    height: auto;
  }

  .landing-page {
    gap: 16px;
    padding: 20px 14px;
  }

  .landing-box {
    width: min(560px, 94vw);
    padding: 16px;
  }

  .landing-portal-row {
    flex-direction: row;
    align-items: flex-start;
    text-align: left;
    padding: 10px;
  }

  .landing-portal-row p {
    padding-top: 6px;
  }

  .portal-card {
    width: auto;
    max-width: none;
    min-height: 0;
  }

  .card-main {
    grid-template-columns: 1fr;
    width: 64px;
    height: 64px;
    min-height: 64px;
    padding: 0;
    gap: 0;
    justify-items: center;
    align-items: center;
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
    border-radius: 0;
    outline: 0;
    overflow: hidden;
  }

  .card-icon-image {
    display: block;
    width: 64px;
    height: 64px;
    object-fit: contain;
  }

  .card-grip,
  .card-copy {
    display: none;
  }

  .portal-card.is-active .card-main {
    border: 0 !important;
    box-shadow: none !important;
  }
}
