:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #05060a;
  color: #fbfaf6;
  --bg: #08090d;
  --panel: #111318;
  --panel-2: #17191f;
  --line: rgba(255, 255, 255, 0.14);
  --muted: rgba(251, 250, 246, 0.68);
  --faint: rgba(251, 250, 246, 0.46);
  --green: #33d6a6;
  --yellow: #f7c744;
  --red: #ff6a59;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  overflow-x: hidden;
}

body {
  background: #05060a;
}

button,
textarea,
input {
  font: inherit;
}

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

button {
  cursor: pointer;
}

button:disabled {
  cursor: default;
}

.app-shell {
  position: relative;
  width: 100%;
  max-width: min(460px, 100vw);
  min-height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
  background: linear-gradient(180deg, #111219 0%, var(--bg) 46%, #06070b 100%);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  min-height: calc(62px + env(safe-area-inset-top));
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(8, 9, 13, 0.92);
  backdrop-filter: blur(18px);
}

.brand {
  min-height: 44px;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: #fbfaf6;
  text-decoration: none;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 8px;
  background: #fbfaf6;
  color: #071013;
  font-size: 21px;
  font-weight: 900;
}

.brand-name {
  overflow: hidden;
  font-size: 18px;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ghost-button,
.text-button,
.primary-button,
.secondary-button,
.viewer-button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  text-decoration: none;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0;
}

.ghost-button,
.viewer-button {
  padding: 0 14px;
  background: rgba(255, 255, 255, 0.08);
  color: #fbfaf6;
}

.ghost-button:not(:disabled) {
  background: #fbfaf6;
  color: #071013;
}

.text-button {
  padding: 0 12px;
  background: rgba(255, 255, 255, 0.06);
  color: #fbfaf6;
}

.primary-button {
  min-width: 112px;
  padding: 0 16px;
  border-color: transparent;
  background: var(--green);
  color: #071013;
}

.primary-button:disabled {
  opacity: 0.64;
}

.secondary-button {
  padding: 0 12px;
  background: rgba(255, 255, 255, 0.07);
  color: rgba(251, 250, 246, 0.78);
}

.main-screen {
  min-height: calc(100dvh - 62px);
  padding: 14px 12px calc(24px + env(safe-area-inset-bottom));
}

.composer {
  min-width: 0;
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: #111318;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--green);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 30px;
  line-height: 1.02;
  font-weight: 900;
}

h2 {
  font-size: 24px;
  line-height: 1.05;
  font-weight: 900;
}

h3 {
  font-size: 18px;
  line-height: 1.08;
  font-weight: 900;
}

.subcopy {
  max-width: 100%;
  margin-top: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

textarea {
  width: 100%;
  min-width: 0;
  resize: vertical;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  padding: 13px;
  background: rgba(255, 255, 255, 0.07);
  color: #fbfaf6;
  font-size: 16px;
  line-height: 1.32;
  outline: none;
}

textarea:focus {
  border-color: rgba(51, 214, 166, 0.72);
  box-shadow: 0 0 0 3px rgba(51, 214, 166, 0.14);
}

.media-uploader {
  display: grid;
  gap: 9px;
}

.media-drop {
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 13px;
  border: 1px dashed rgba(255, 255, 255, 0.24);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.055);
  color: #fbfaf6;
}

.media-drop span,
.media-chip strong {
  font-size: 14px;
  font-weight: 900;
}

.media-drop small,
.media-chip small {
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

#mediaInput {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.media-list {
  display: grid;
  gap: 7px;
}

.media-chip {
  min-height: 44px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  padding: 8px 8px 8px 11px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.media-chip span {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.media-chip strong,
.media-chip small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.media-remove {
  min-width: 44px;
  min-height: 44px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.09);
  color: #fbfaf6;
  font-size: 20px;
  font-weight: 900;
}

.section-row {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin: 20px 2px 10px;
}

.hub-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.empty-state {
  padding: 14px;
  border: 1px dashed rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.hub-card {
  position: relative;
  width: 100%;
  min-height: 44px;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 0;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 8px;
  overflow: hidden;
  background: #12141a;
  color: #fbfaf6;
  text-align: left;
  text-decoration: none;
}

.hub-card.is-featured {
  grid-column: 1 / -1;
}

.hub-card:active {
  transform: translateY(1px);
}

.hub-cover {
  position: relative;
  width: 100%;
  aspect-ratio: 9 / 12;
  display: block;
  overflow: hidden;
  background: #07080d;
  z-index: 0;
}

.hub-card.is-featured .hub-cover {
  height: 260px;
  aspect-ratio: auto;
}

.hub-cover img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.hub-cover-fallback {
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 35% 18%, color-mix(in srgb, var(--cover-a, #33d6a6) 75%, white 12%), transparent 25%),
    linear-gradient(145deg, var(--cover-a, #33d6a6), var(--cover-b, #f7c744));
}

.hub-cover-fallback span {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border: 2px solid rgba(7, 16, 19, 0.6);
  border-radius: 8px;
  background: rgba(251, 250, 246, 0.88);
  color: #071013;
  font-size: 22px;
  font-weight: 900;
}

.hub-card-body {
  min-width: 0;
  display: grid;
  gap: 7px;
  padding: 10px;
}

.hub-card.is-featured .hub-card-body {
  position: absolute;
  z-index: 2;
  right: 0;
  bottom: 0;
  left: 0;
  padding: 58px 12px 12px;
  background: linear-gradient(180deg, transparent 0%, rgba(5, 6, 10, 0.88) 46%, rgba(5, 6, 10, 0.98) 100%);
  pointer-events: none;
}

.hub-card-title {
  min-width: 0;
  display: -webkit-box;
  overflow: hidden;
  font-size: 15px;
  line-height: 1.08;
  font-weight: 900;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.hub-card.is-featured .hub-card-title {
  font-size: 22px;
}

.hub-card-description {
  min-width: 0;
  display: -webkit-box;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.32;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.hub-card.is-featured .hub-card-description {
  font-size: 13px;
  -webkit-line-clamp: 2;
}

.hub-card-meta {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.hub-card strong {
  flex: 0 0 auto;
  color: var(--yellow);
  font-size: 12px;
  font-weight: 900;
}

.hub-card time {
  min-width: 0;
  overflow: hidden;
  color: var(--faint);
  font-size: 12px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-panel {
  display: grid;
  gap: 10px;
  margin-top: 12px;
  padding: 13px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.055);
}

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

.status-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.status-line strong {
  font-size: 15px;
  font-weight: 900;
}

.status-line span,
.status-panel p {
  color: rgba(251, 250, 246, 0.78);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
}

.pipeline {
  margin: 14px 0;
  padding: 0;
  list-style: none;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
}

.pipeline li {
  min-height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  color: var(--faint);
  font-size: 11px;
  font-weight: 900;
}

.pipeline li.active {
  border-color: var(--yellow);
  color: var(--yellow);
}

.pipeline li.done {
  border-color: rgba(51, 214, 166, 0.6);
  color: var(--green);
}

.results {
  margin-top: 18px;
}

.viewer {
  position: fixed;
  inset: 0;
  z-index: 50;
  width: 100%;
  max-width: min(460px, 100vw);
  margin: 0 auto;
  background: #07080d;
}

.viewer[hidden] {
  display: none;
}

.viewer-topbar {
  min-height: calc(58px + env(safe-area-inset-top));
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: end;
  gap: 10px;
  padding: calc(8px + env(safe-area-inset-top)) 10px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  background: #08090d;
}

.viewer-topbar strong {
  min-width: 0;
  overflow: hidden;
  padding-bottom: 12px;
  text-align: center;
  font-size: 14px;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.viewer-button {
  min-width: 62px;
}

#playFrame {
  width: 100%;
  height: calc(100dvh - 58px - env(safe-area-inset-top));
  border: 0;
  background: #07070c;
}

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

@media (min-width: 520px) {
  body {
    background: #111217;
  }

  .app-shell,
  .viewer {
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 22px 90px rgba(0, 0, 0, 0.42);
  }
}
