:root {
  color-scheme: dark;
  --bg: #000000;
  --panel: #1c1c1e;
  --panel-2: #2c2c2e;
  --panel-3: #3a3a3c;
  --text: #f5f5f7;
  --muted: #a1a1a6;
  --line: rgba(255, 255, 255, 0.12);
  --blue: #0a84ff;
  --green: #30d158;
  --orange: #ff9f0a;
  --red: #ff453a;
  --purple: #bf5af2;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
textarea {
  font: inherit;
}

button {
  color: inherit;
}

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

.app-shell {
  width: min(100%, 1440px);
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0 16px;
  background: rgba(0, 0, 0, 0.82);
  backdrop-filter: blur(22px);
}

.brand {
  min-width: 0;
}

.top-links {
  display: inline-flex;
  flex: 0 0 auto;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(44, 44, 46, 0.82);
}

.top-links a {
  min-height: 34px;
  padding: 8px 12px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 760;
}

.top-links a.active {
  background: var(--panel-3);
  color: var(--text);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--blue);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.8rem, 4vw, 3rem);
  font-weight: 750;
}

h2 {
  font-size: clamp(1.1rem, 2vw, 1.5rem);
  font-weight: 720;
}

h3 {
  font-size: 1rem;
  font-weight: 700;
}

.domain-pill,
.status-badge {
  flex: 0 0 auto;
  max-width: 48vw;
  overflow: hidden;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(44, 44, 46, 0.86);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-badge.running {
  color: var(--orange);
}

.status-badge.complete {
  color: var(--green);
}

.status-badge.failed,
.status-badge.cancelled {
  color: var(--red);
}

.hidden {
  display: none !important;
}

.consumer-shell {
  display: grid;
  grid-template-columns: minmax(280px, 430px) minmax(320px, 1fr);
  gap: 12px;
  align-items: start;
}

.phone-panel {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.hero-flow {
  position: sticky;
  top: 84px;
}

.hero-copy {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
}

.hero-copy h2 {
  font-size: clamp(2.2rem, 11vw, 4.6rem);
  line-height: 0.96;
}

.hero-copy p,
.result-copy {
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.45;
}

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

.big-form label span {
  color: var(--text);
  font-size: 1.05rem;
}

.big-form textarea {
  min-height: 116px;
  padding: 16px;
  border-radius: 8px;
  font-size: 1.2rem;
  line-height: 1.35;
}

.upload-drop {
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 148px;
  padding: 18px;
  border: 1px dashed rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  background: var(--panel-2);
  text-align: center;
}

.upload-drop input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.upload-icon {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--blue);
  color: white;
}

.upload-drop strong {
  font-size: 1.1rem;
}

.upload-drop small {
  max-width: 100%;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.88rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.jumbo-button {
  min-height: 64px;
  width: 100%;
  border-radius: 8px;
  font-size: 1.2rem;
}

.result-panel {
  grid-column: 2;
}

.gallery-panel {
  grid-column: 2;
}

.consumer-shell.gallery-route .gallery-panel {
  grid-column: 1 / -1;
  order: -1;
}

.consumer-shell.gallery-route .hero-flow {
  position: static;
}

.simple-status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.large-progress {
  height: 10px;
}

#consumer-canvas {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 4;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #050506;
}

.result-copy {
  margin-top: 12px;
}

.big-link {
  min-height: 50px;
  flex: 1 1 140px;
  border-radius: 8px;
}

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

.gallery-card {
  display: grid;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.gallery-thumb {
  display: grid;
  place-items: center;
  aspect-ratio: 16 / 10;
  background:
    linear-gradient(145deg, rgba(10, 132, 255, 0.28), transparent 48%),
    linear-gradient(40deg, rgba(48, 209, 88, 0.2), transparent 54%),
    #101014;
}

.gallery-thumb span {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  font-weight: 850;
}

.gallery-body {
  display: grid;
  gap: 8px;
  padding: 10px;
}

.gallery-body h3,
.gallery-body p {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gallery-body p {
  color: var(--muted);
  font-size: 0.82rem;
}

.gallery-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.mini-button {
  min-height: 38px;
  min-width: 0;
  padding: 0 8px;
  border-radius: 8px;
  font-size: 0.86rem;
}

.studio-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.82fr) minmax(420px, 1.18fr);
  gap: 12px;
  align-items: start;
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.create-panel,
.pipeline-panel,
.artifact-panel,
.log-panel,
.preview-panel {
  padding: 14px;
}

.preview-panel,
.artifact-panel {
  grid-column: 2;
}

.create-panel,
.pipeline-panel,
.log-panel {
  grid-column: 1;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.section-head.compact {
  margin-bottom: 10px;
}

.source-form {
  display: grid;
  gap: 10px;
}

label {
  display: grid;
  gap: 6px;
  min-width: 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 650;
}

input,
textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  outline: none;
}

input {
  min-height: 44px;
  padding: 0 12px;
}

textarea {
  resize: vertical;
  min-height: 160px;
  padding: 11px 12px;
  line-height: 1.45;
}

input:focus,
textarea:focus {
  border-color: rgba(10, 132, 255, 0.78);
  box-shadow: 0 0 0 3px rgba(10, 132, 255, 0.18);
}

.file-label input {
  padding: 10px 12px;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.primary-button,
.secondary-button,
.icon-button,
.tab-button,
.project-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 720;
}

.primary-button {
  flex: 1 1 180px;
  background: var(--blue);
  color: white;
}

.secondary-button,
.icon-button,
.tab-button,
.project-button {
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
}

.secondary-button {
  flex: 0 0 auto;
  padding: 0 14px;
}

.compact-button {
  min-height: 36px;
  padding: 0 10px;
  font-size: 0.86rem;
}

.icon-button {
  width: 42px;
  padding: 0;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.46;
}

.project-list-block {
  margin-top: 16px;
}

.project-list {
  display: grid;
  gap: 8px;
  max-height: 280px;
  overflow: auto;
}

.project-button {
  justify-content: space-between;
  width: 100%;
  min-height: 52px;
  padding: 8px 10px;
  text-align: left;
}

.project-button.active {
  border-color: rgba(10, 132, 255, 0.72);
  background: rgba(10, 132, 255, 0.18);
}

.project-button span {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-button small,
.muted {
  color: var(--muted);
  font-size: 0.78rem;
}

.progress-shell {
  overflow: hidden;
  height: 8px;
  margin-bottom: 12px;
  border-radius: 999px;
  background: var(--panel-2);
}

.progress-bar {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--blue);
  transition: width 180ms ease;
}

#stage-canvas {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #050506;
}

.preview-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.preview-stats div {
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.preview-stats span,
.preview-stats strong {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preview-stats span {
  color: var(--muted);
  font-size: 0.76rem;
}

.preview-stats strong {
  margin-top: 3px;
  font-size: 1.05rem;
}

.pipeline-list {
  display: grid;
  gap: 8px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.pipeline-item {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  gap: 10px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.stage-dot {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  background: var(--panel-3);
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
}

.pipeline-item.running .stage-dot {
  color: #1b1300;
  background: var(--orange);
}

.pipeline-item.complete .stage-dot {
  color: #061307;
  background: var(--green);
}

.pipeline-item h3,
.pipeline-item p {
  min-width: 0;
  overflow-wrap: anywhere;
}

.pipeline-item p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.36;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111113;
}

.tab-button {
  min-width: 0;
  min-height: 34px;
  padding: 0 8px;
  color: var(--muted);
  font-size: 0.82rem;
  white-space: nowrap;
}

.tab-button.active {
  background: var(--panel-3);
  color: var(--text);
}

.artifact-content {
  display: grid;
  gap: 10px;
  max-height: 650px;
  margin-top: 12px;
  overflow: auto;
}

.empty-state {
  display: block;
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  line-height: 1.45;
}

.artifact-card {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.artifact-card h3 {
  overflow-wrap: anywhere;
}

.artifact-card p,
.artifact-card li {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.42;
  overflow-wrap: anywhere;
}

.artifact-card p {
  margin-top: 6px;
}

.metadata-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.metadata-row span {
  max-width: 100%;
  overflow: hidden;
  padding: 5px 7px;
  border-radius: 999px;
  background: #111113;
  color: var(--muted);
  font-size: 0.76rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.event-log {
  display: grid;
  gap: 8px;
  max-height: 340px;
  overflow: auto;
}

.event-row {
  display: grid;
  gap: 4px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.event-row strong,
.event-row span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.event-row strong {
  font-size: 0.82rem;
}

.event-row span {
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.35;
}

.event-row.success strong {
  color: var(--green);
}

.event-row.warning strong {
  color: var(--orange);
}

.event-row.error strong {
  color: var(--red);
}

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

  .hero-flow {
    position: static;
  }

  .result-panel,
  .gallery-panel {
    grid-column: 1;
  }

  .studio-grid {
    grid-template-columns: 1fr;
  }

  .create-panel,
  .pipeline-panel,
  .log-panel,
  .preview-panel,
  .artifact-panel {
    grid-column: 1;
  }

  .preview-panel {
    order: -1;
  }
}

@media (max-width: 620px) {
  .app-shell {
    padding-left: 10px;
    padding-right: 10px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .top-links {
    justify-content: space-between;
    width: 100%;
  }

  .top-links a {
    flex: 1;
    text-align: center;
  }

  .domain-pill {
    max-width: 100%;
  }

  .phone-panel {
    padding: 14px;
  }

  .gallery-list {
    grid-template-columns: 1fr;
  }

  .segmented {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .tab-button {
    white-space: normal;
  }

  .preview-stats {
    grid-template-columns: 1fr;
  }
}
