:root {
  --bg: #08111f;
  --bg-alt: #122033;
  --panel: rgba(13, 22, 38, 0.78);
  --panel-strong: rgba(17, 28, 46, 0.9);
  --line: rgba(138, 168, 205, 0.14);
  --line-strong: rgba(138, 168, 205, 0.28);
  --text: #edf4ff;
  --muted: #9db2cb;
  --accent: #56a3ff;
  --accent-soft: #8fd2ff;
  --success: #4dd5a3;
  --shadow: 0 30px 80px rgba(1, 7, 16, 0.5);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Instrument Sans", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(86, 163, 255, 0.2), transparent 24%),
    radial-gradient(circle at 80% 10%, rgba(143, 210, 255, 0.16), transparent 22%),
    radial-gradient(circle at 50% 100%, rgba(77, 213, 163, 0.08), transparent 26%),
    linear-gradient(160deg, #08111f 0%, #0d1626 45%, #122033 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    linear-gradient(transparent 0 94%, rgba(255, 255, 255, 0.018) 94% 100%),
    linear-gradient(90deg, transparent 0 96%, rgba(255, 255, 255, 0.014) 96% 100%);
  background-size: 100% 8px, 8px 100%;
  pointer-events: none;
}

.noise {
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.2) 0.5px, transparent 0.7px),
    radial-gradient(circle at 80% 80%, rgba(255, 255, 255, 0.14) 0.45px, transparent 0.7px);
  background-size: 30px 30px, 36px 36px;
  opacity: 0.2;
  pointer-events: none;
}

.app-shell {
  position: relative;
  width: min(1240px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1rem 0 3rem;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.hero {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 1.5rem;
  padding: 2rem;
  align-items: end;
}

.eyebrow,
.section-label {
  margin: 0 0 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.24em;
  font-size: 0.78rem;
  color: var(--accent);
}

.hero h1,
.section-head h2 {
  margin: 0;
  font-family: "Bebas Neue", sans-serif;
  font-weight: 400;
  letter-spacing: 0.03em;
}

.hero h1 {
  max-width: 9ch;
  font-size: clamp(3.8rem, 8vw, 7rem);
  line-height: 0.92;
}

.hero-copy p:last-child {
  max-width: 42rem;
  color: var(--muted);
  line-height: 1.7;
  font-size: 1.02rem;
}

.hero-stats {
  display: grid;
  gap: 1rem;
}

.hero-stats div,
.hero-stat-link,
.library-card,
.pattern-card,
.detail-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(138, 168, 205, 0.08);
  border-radius: 22px;
}

.hero-stats div,
.hero-stat-link {
  padding: 1rem 1.15rem;
}

.hero-stats strong {
  display: block;
  font-size: 1.35rem;
  color: var(--success);
}

.hero-stat-link {
  display: block;
  text-decoration: none;
  transition: transform 160ms ease, border-color 160ms ease, background-color 160ms ease;
}

.hero-stat-link:hover,
.hero-stat-link:focus-visible {
  transform: translateY(-2px);
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.06);
}

.hero-stats span,
.pattern-time,
.pattern-revised,
.detail-text,
.library-card p {
  color: var(--muted);
}

.hero-actions,
.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.library-theme-field {
  min-width: 12rem;
  max-width: 14rem;
}

.library-theme-field span {
  margin-bottom: 0.35rem;
}

.library-theme-field select {
  min-width: 0;
}

.library-refresh-button {
  padding: 1rem 1.35rem;
  min-height: 3.55rem;
}

.checkbox-field {
  display: flex;
  align-items: start;
  gap: 0.8rem;
  margin: 0 0 1.1rem;
  padding: 0.95rem 1rem;
  border: 1px solid rgba(138, 168, 205, 0.12);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  line-height: 1.55;
}

.checkbox-field input {
  margin-top: 0.15rem;
  accent-color: var(--accent);
}

.generator-section .inline-actions {
  flex-wrap: nowrap;
}

.generator-section .inline-actions > .primary-button,
.generator-section .inline-actions > .ghost-button {
  flex: 1 1 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  padding: 1rem 1.3rem;
  font-size: 1rem;
}

.primary-button,
.ghost-button,
.secondary-link,
.mini-button {
  border: 0;
  border-radius: 999px;
  font: inherit;
  cursor: pointer;
  text-decoration: none;
  transition: transform 160ms ease, background-color 160ms ease, border-color 160ms ease, opacity 160ms ease;
}

.primary-button,
.ghost-button,
.secondary-link {
  padding: 0.9rem 1.05rem;
}

.mini-button {
  padding: 0.72rem 0.9rem;
}

.primary-button {
  color: #07111e;
  background: linear-gradient(135deg, #8fd2ff, #56a3ff 65%, #3f85ff);
  font-weight: 700;
  box-shadow: 0 16px 30px rgba(86, 163, 255, 0.24);
}

.ghost-button,
.secondary-link,
.mini-button {
  color: var(--text);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(138, 168, 205, 0.16);
}

.primary-button:hover,
.ghost-button:hover,
.secondary-link:hover,
.mini-button:hover,
.primary-button:focus-visible,
.ghost-button:focus-visible,
.secondary-link:focus-visible,
.mini-button:focus-visible {
  transform: translateY(-2px);
}

.ghost-button:hover,
.secondary-link:hover,
.mini-button:hover,
.ghost-button:focus-visible,
.secondary-link:focus-visible,
.mini-button:focus-visible {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--line-strong);
}

.primary-button:disabled,
.ghost-button:disabled,
.mini-button:disabled {
  opacity: 0.55;
  cursor: default;
  transform: none;
}

.grid-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
  gap: 1.25rem;
  margin-top: 1.25rem;
}

.grid-layout > .panel,
.results-panel {
  padding: 1.5rem;
}

.results-panel {
  margin-top: 1.25rem;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.section-head h2 {
  font-size: 2.2rem;
}

.badge,
.mini-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  background: rgba(86, 163, 255, 0.09);
  border: 1px solid rgba(86, 163, 255, 0.16);
  color: var(--accent-soft);
}

.badge {
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
}

.mini-badge {
  padding: 0.35rem 0.65rem;
  font-size: 0.78rem;
}

.field {
  display: grid;
  gap: 0.55rem;
  margin-bottom: 1rem;
}

.field span {
  color: var(--muted);
  font-size: 0.94rem;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  border: 1px solid rgba(138, 168, 205, 0.12);
  background: rgba(7, 14, 25, 0.62);
  color: var(--text);
  border-radius: 18px;
  padding: 0.95rem 1rem;
  font: inherit;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.field input:disabled {
  opacity: 0.6;
}

.field textarea {
  resize: vertical;
  min-height: 7rem;
}

.generator-section {
  display: grid;
  gap: 0.25rem;
}

.subsection-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.35rem;
}

.subsection-label {
  margin: 0;
  font-size: 0.86rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-soft);
}

.field input:focus-visible,
.field textarea:focus-visible,
.field select:focus-visible {
  outline: 2px solid rgba(86, 163, 255, 0.24);
  outline-offset: 2px;
}

.generator-divider {
  height: 1px;
  margin: 2.4rem 0 2.2rem;
  background: linear-gradient(90deg, rgba(138, 168, 205, 0.04), rgba(138, 168, 205, 0.3), rgba(138, 168, 205, 0.04));
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.12);
}

.generator-section-photo {
  padding-top: 0.9rem;
}

.controls-grid,
.library-list,
.pattern-grid,
.gallery-groups {
  display: grid;
  gap: 1rem;
}

.four-up {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.three-up {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.one-up {
  grid-template-columns: 1fr;
}

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

.photo-toolbar {
  display: grid;
  grid-template-columns: minmax(180px, 240px) auto auto;
  gap: 0.75rem;
  align-items: end;
}

.photo-style-field {
  margin-bottom: 0;
}

.detail-label {
  margin: 0 0 0.35rem;
  color: var(--muted);
  font-size: 0.84rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.detail-card {
  padding: 1rem;
  margin-top: 0.35rem;
}

.detail-text {
  margin: 0;
  line-height: 1.65;
}

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

.gallery-groups {
  gap: 1.25rem;
}

.gallery-theme-group {
  display: grid;
  gap: 1rem;
  padding: 1.15rem;
  border: 1px solid rgba(138, 168, 205, 0.1);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.03);
}

.gallery-theme-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.gallery-theme-label {
  margin: 0;
  color: var(--accent-soft);
  font-size: 1.05rem;
  font-weight: 700;
}

.gallery-pattern-grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.85rem;
}

.pattern-grid {
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  align-items: start;
}

.empty-grid::before {
  content: attr(data-empty-message);
  display: grid;
  place-items: center;
  min-height: 11rem;
  border-radius: 22px;
  border: 1px dashed rgba(138, 168, 205, 0.18);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.03);
}

.library-card {
  padding: 1.15rem;
  display: grid;
  gap: 0.85rem;
}

.library-card h3 {
  margin: 0;
  font-size: 1.1rem;
}

.library-card p {
  margin: 0;
  line-height: 1.7;
}

.pattern-card {
  overflow: hidden;
  display: grid;
  min-width: 0;
  align-self: start;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(138, 168, 205, 0.08);
  border-radius: 22px;
}

.pattern-card-compact .pattern-content {
  padding: 0.85rem;
  gap: 0.65rem;
}

.pattern-card-compact .pattern-prompt {
  font-size: 0.92rem;
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.pattern-card-compact .pattern-time,
.pattern-card-compact .pattern-revised {
  font-size: 0.82rem;
}

.pattern-preview-wrap {
  aspect-ratio: 1;
  background:
    linear-gradient(180deg, rgba(233, 241, 252, 0.94), rgba(208, 223, 242, 0.96)),
    linear-gradient(135deg, rgba(86, 163, 255, 0.08), transparent);
}

.pattern-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.pattern-content {
  padding: 1rem;
  display: grid;
  gap: 0.8rem;
  min-width: 0;
}

.pattern-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.pattern-prompt,
.pattern-revised,
.pattern-time {
  margin: 0;
}

.pattern-prompt {
  line-height: 1.6;
  font-weight: 500;
  color: var(--text);
}

.pattern-revised {
  font-size: 0.92rem;
  line-height: 1.55;
}

.pattern-time {
  font-size: 0.84rem;
}

.card-actions {
  padding: 0 1rem 1rem;
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
  min-width: 0;
}

.gallery-pattern-type-field {
  margin-bottom: 0;
}

.gallery-pattern-type-field span {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.gallery-pattern-type-field select {
  padding: 0.72rem 0.9rem;
  border-radius: 16px;
}

.card-actions .mini-button {
  width: 100%;
  text-align: center;
  min-width: 0;
}

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

@media (max-width: 980px) {
  .four-up,
  .three-up,
  .one-up,
  .two-up,
  .library-list,
  .pattern-grid {
    grid-template-columns: 1fr;
  }

  .photo-toolbar {
    grid-template-columns: 1fr;
  }

  .generator-section .inline-actions {
    flex-wrap: wrap;
  }

  .library-theme-field {
    min-width: 100%;
    max-width: none;
  }
}

@media (max-width: 720px) {
  .app-shell {
    width: min(100% - 1rem, 1240px);
  }

  .panel,
  .results-panel,
  .grid-layout > .panel {
    padding: 1.1rem;
    border-radius: 22px;
  }

  .hero h1,
  .section-head h2 {
    font-size: clamp(2.6rem, 11vw, 4rem);
  }

  .section-head {
    flex-direction: column;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    transition: none !important;
  }
}
