:root {
  color-scheme: dark;
  --bg: #020604;
  --panel: rgba(4, 16, 11, 0.78);
  --panel-strong: rgba(5, 24, 15, 0.92);
  --line: rgba(72, 255, 154, 0.18);
  --line-strong: rgba(72, 255, 154, 0.42);
  --text: #eafff3;
  --muted: #8ab79e;
  --green: #4aff9a;
  --green-soft: rgba(74, 255, 154, 0.16);
  --gold: #dfc179;
  --danger: #ff7575;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.48);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background:
    radial-gradient(circle at top left, rgba(74, 255, 154, 0.12), transparent 30rem),
    linear-gradient(135deg, #020604 0%, #06130d 55%, #010302 100%);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
label {
  font: inherit;
}

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

#matrixRain {
  position: fixed;
  inset: 0;
  z-index: 0;
  opacity: 0.34;
  pointer-events: none;
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(1500px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
  padding: 18px 20px;
  border: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: blur(18px);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--green);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 4vw, 4rem);
  line-height: 0.95;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 1.05rem;
}

.model-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  background: rgba(0, 24, 13, 0.72);
  color: var(--green);
  font-weight: 700;
  white-space: nowrap;
}

.top-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.language-switch {
  display: inline-flex;
  min-height: 42px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.26);
}

.language-btn {
  min-width: 82px;
  padding: 0 12px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 800;
}

.language-btn:last-child {
  border-right: 0;
}

.language-btn.active {
  background: var(--green-soft);
  color: var(--green);
}

.model-pill span {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--green);
  box-shadow: 0 0 18px var(--green);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(300px, 360px) minmax(320px, 1fr) minmax(360px, 1.2fr);
  gap: 18px;
  align-items: start;
}

.control-panel,
.fabric-panel,
.results-panel {
  border: 0;
  background: rgba(0, 8, 5, 0.36);
  box-shadow: none;
  backdrop-filter: blur(10px);
}

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

.fabric-panel,
.results-panel {
  min-height: 680px;
  padding: 18px;
}

.panel-section {
  display: grid;
  gap: 12px;
  padding: 12px;
  border: 1px solid rgba(72, 255, 154, 0.2);
  background: rgba(0, 12, 7, 0.42);
}

.section-heading {
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-heading span {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--line-strong);
  color: var(--green);
  font-size: 0.76rem;
  font-weight: 800;
}

.upload-zone {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 260px;
  overflow: hidden;
  border: 1px dashed var(--line-strong);
  background: linear-gradient(180deg, rgba(74, 255, 154, 0.08), rgba(0, 0, 0, 0.18));
  color: var(--muted);
  cursor: pointer;
}

.upload-zone input,
#fabricInput,
.style-card input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.upload-zone img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}

.upload-zone.has-image img {
  display: block;
}

.upload-zone.has-image .upload-copy {
  position: absolute;
  left: 10px;
  bottom: 10px;
  padding: 8px 10px;
  background: rgba(0, 0, 0, 0.62);
  color: var(--text);
}

.style-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.style-card {
  display: grid;
  gap: 5px;
  min-height: 84px;
  padding: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  cursor: pointer;
}

.style-card strong {
  color: var(--text);
  font-size: 0.9rem;
}

.style-card small {
  color: var(--muted);
  line-height: 1.25;
}

.style-card.selected {
  border-color: var(--green);
  background: var(--green-soft);
  box-shadow: inset 0 0 28px rgba(74, 255, 154, 0.08);
}

.toggle-line {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  color: var(--muted);
  cursor: pointer;
}

.toggle-line input {
  width: 18px;
  height: 18px;
  accent-color: var(--green);
}

.primary-action,
.secondary-action,
.ghost-action {
  border: 1px solid var(--line-strong);
  color: var(--text);
  cursor: pointer;
}

.primary-action {
  min-height: 54px;
  border-color: var(--green);
  background: linear-gradient(135deg, rgba(74, 255, 154, 0.96), rgba(21, 170, 86, 0.92));
  color: #00180b;
  font-weight: 900;
  box-shadow: 0 12px 42px rgba(74, 255, 154, 0.18);
}

.primary-action:disabled {
  cursor: wait;
  opacity: 0.72;
}

.secondary-action,
.ghost-action {
  display: inline-grid;
  place-items: center;
  min-height: 40px;
  padding: 0 14px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--green);
}

.ghost-action {
  color: var(--muted);
}

.status-text {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.status-text.error {
  color: var(--danger);
}

.panel-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.action-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.fabric-grid,
.results-grid {
  display: grid;
  gap: 12px;
  padding: 12px;
  border: 1px solid rgba(72, 255, 154, 0.18);
  background: rgba(0, 12, 7, 0.34);
}

.camera-panel {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
  padding: 12px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.28);
}

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

.camera-panel video {
  width: 100%;
  max-height: 360px;
  object-fit: cover;
  border: 1px solid var(--line-strong);
  background: #000;
}

.camera-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.compact {
  min-height: 42px;
  padding: 0 14px;
}

.fabric-grid {
  grid-template-columns: repeat(auto-fill, minmax(135px, 1fr));
}

.fabric-card {
  position: relative;
  min-height: 180px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.28);
  cursor: pointer;
}

.fabric-card img {
  width: 100%;
  height: 134px;
  object-fit: cover;
  display: block;
}

.fabric-card .fabric-name {
  padding: 10px;
  color: var(--text);
  font-size: 0.84rem;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.fabric-card.selected {
  border-color: var(--green);
  box-shadow: 0 0 0 2px rgba(74, 255, 154, 0.12), 0 0 28px rgba(74, 255, 154, 0.14);
}

.fabric-card.selected::after {
  content: var(--selected-label, "Selected");
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 5px 8px;
  background: rgba(0, 0, 0, 0.72);
  color: var(--green);
  font-size: 0.72rem;
  font-weight: 800;
}

.hint-line {
  margin-top: 14px;
  color: var(--muted);
  font-size: 0.85rem;
}

code {
  color: var(--gold);
}

.results-grid {
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}

.results-grid.empty {
  min-height: 560px;
  display: grid;
  place-items: center;
}

.empty-state {
  display: grid;
  justify-items: center;
  gap: 12px;
  max-width: 320px;
  text-align: center;
  color: var(--muted);
}

.empty-state h3 {
  margin-bottom: 0;
  color: var(--text);
}

.empty-state p {
  margin-bottom: 0;
}

.empty-orbit {
  width: 86px;
  height: 86px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  box-shadow: inset 0 0 32px rgba(74, 255, 154, 0.12), 0 0 32px rgba(74, 255, 154, 0.12);
}

.result-card {
  overflow: hidden;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.28);
}

.result-card img {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  display: block;
}

.result-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
  color: var(--muted);
  font-size: 0.86rem;
}

.result-meta strong {
  display: block;
  color: var(--text);
  font-size: 0.94rem;
}

.download-link {
  color: var(--green);
  text-decoration: none;
  font-weight: 800;
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: 340px 1fr;
  }

  .results-panel {
    grid-column: 1 / -1;
    min-height: auto;
  }
}

@media (max-width: 760px) {
  .app-shell {
    padding: 14px;
  }

  .topbar,
  .panel-title-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .top-actions {
    justify-content: flex-start;
    width: 100%;
  }

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

  .fabric-panel,
  .results-panel {
    min-height: auto;
  }

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