:root {
  color-scheme: dark;
  --bg: #0b0d10;
  --panel: #151922;
  --panel-soft: #1b202b;
  --line: rgba(255, 255, 255, 0.1);
  --text: #f4f7fb;
  --muted: #9ba7b7;
  --accent: #6ee7ff;
  --accent-strong: #f6d56f;
  --danger: #ff7a90;
}

* {
  box-sizing: border-box;
}

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

body {
  background:
    linear-gradient(135deg, rgba(110, 231, 255, 0.1), transparent 28%),
    linear-gradient(225deg, rgba(246, 213, 111, 0.1), transparent 32%),
    var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
textarea,
input {
  font: inherit;
}

button {
  border: 0;
}

.app-shell {
  min-height: 100vh;
  padding: 28px;
}

.studio {
  width: min(1440px, 100%);
  margin: 0 auto;
  display: grid;
  gap: 18px;
}

.studio__header,
.prompt-panel,
.output-section {
  border: 1px solid var(--line);
  background: rgba(21, 25, 34, 0.86);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.26);
}

.studio__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 24px;
  border-radius: 18px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(30px, 5vw, 56px);
  line-height: 1;
}

h2 {
  margin-bottom: 0;
  font-size: 20px;
}

.header-actions,
.result-actions {
  display: flex;
  gap: 10px;
}

.icon-button,
.secondary-button,
.generate-button {
  min-height: 44px;
  border-radius: 12px;
  color: var(--text);
  cursor: pointer;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    background 160ms ease;
}

.icon-button {
  min-width: 58px;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: #202633;
  font-weight: 800;
}

.icon-button:hover,
.icon-button.is-active {
  border-color: rgba(110, 231, 255, 0.7);
  background: rgba(110, 231, 255, 0.12);
}

.prompt-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 380px);
  gap: 18px;
  padding: 18px;
  border-radius: 18px;
}

.source-panel {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.source-tabs {
  display: flex;
  width: fit-content;
  max-width: 100%;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #0f131b;
  padding: 4px;
}

.source-tab {
  min-height: 38px;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 0 14px;
  font-size: 13px;
  font-weight: 850;
  white-space: nowrap;
}

.source-tab.is-active {
  background: rgba(110, 231, 255, 0.14);
  color: var(--text);
}

.source-pane {
  min-width: 0;
}

.prompt-field,
.controls label {
  display: grid;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

textarea {
  width: 100%;
  min-height: 118px;
  resize: vertical;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  outline: none;
  background: #0f131b;
  color: var(--text);
  padding: 18px;
  font-size: clamp(22px, 4vw, 42px);
  font-weight: 850;
  line-height: 1.12;
}

textarea:focus {
  border-color: rgba(110, 231, 255, 0.7);
  box-shadow: 0 0 0 4px rgba(110, 231, 255, 0.1);
}

.upload-dropzone {
  display: grid;
  place-items: center;
  min-height: 148px;
  border: 1px dashed rgba(255, 255, 255, 0.22);
  border-radius: 14px;
  background:
    linear-gradient(135deg, rgba(110, 231, 255, 0.08), transparent 44%),
    #0f131b;
  color: var(--text);
  cursor: pointer;
  padding: 22px;
  text-align: center;
}

.upload-dropzone:hover {
  border-color: rgba(110, 231, 255, 0.7);
}

.upload-dropzone input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.upload-dropzone__title {
  display: block;
  font-size: clamp(18px, 3vw, 30px);
  font-weight: 900;
}

.upload-dropzone__hint {
  display: block;
  max-width: 520px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.upload-preview {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.upload-preview img {
  width: 72px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(45deg, #202633 25%, transparent 25%),
    linear-gradient(-45deg, #202633 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #202633 75%),
    linear-gradient(-45deg, transparent 75%, #202633 75%),
    #111620;
  background-position:
    0 0,
    0 8px,
    8px -8px,
    -8px 0;
  background-size: 16px 16px;
  object-fit: contain;
}

.controls {
  display: grid;
  gap: 16px;
  align-content: end;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.generate-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 54px;
  padding: 0 20px;
  background: linear-gradient(135deg, #6ee7ff, #f6d56f);
  color: #0b0d10;
  font-size: 16px;
  font-weight: 900;
}

.generate-button:hover,
.secondary-button:hover,
.icon-button:hover {
  transform: translateY(-1px);
}

.generate-button:disabled {
  cursor: wait;
  filter: saturate(0.65) brightness(0.82);
  transform: none;
}

.material-section {
  display: grid;
  gap: 14px;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  padding: 0 4px;
}

.section-heading p {
  margin-bottom: 0;
  color: var(--muted);
}

.material-grid {
  display: grid;
  grid-template-columns: repeat(8, minmax(116px, 1fr));
  gap: 12px;
}

.material-card {
  display: grid;
  gap: 10px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(27, 32, 43, 0.9);
  color: var(--text);
  padding: 14px 10px 12px;
  cursor: pointer;
}

.material-card.is-active {
  border-color: rgba(110, 231, 255, 0.76);
  box-shadow: 0 0 0 3px rgba(110, 231, 255, 0.12);
}

.material-ball {
  position: relative;
  width: 74px;
  aspect-ratio: 1;
  margin: 0 auto;
  border-radius: 50%;
  overflow: hidden;
  background: var(--mat);
  box-shadow:
    inset -18px -24px 32px rgba(0, 0, 0, 0.45),
    inset 12px 10px 22px rgba(255, 255, 255, 0.24),
    0 12px 28px rgba(0, 0, 0, 0.32);
}

.material-ball::before {
  position: absolute;
  inset: 11% auto auto 17%;
  width: 24%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.82);
  filter: blur(2px);
  content: "";
}

.material-ball::after {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 28% 23%, rgba(255, 255, 255, 0.6), transparent 13%),
    linear-gradient(115deg, transparent 30%, rgba(255, 255, 255, 0.22), transparent 48%);
  mix-blend-mode: screen;
  content: "";
}

.material-card span {
  overflow: hidden;
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.material-card small {
  color: var(--muted);
  font-size: 12px;
}

.output-section {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 18px;
  padding: 18px;
  border-radius: 18px;
}

.canvas-wrap {
  min-width: 0;
  border-radius: 14px;
  background: #080a0e;
  overflow: hidden;
}

canvas {
  display: block;
  width: 100%;
  height: auto;
}

.result-panel {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 28px;
  padding: 8px 4px;
}

.result-panel p:not(.eyebrow) {
  color: var(--muted);
  line-height: 1.7;
}

.secondary-button {
  flex: 1;
  border: 1px solid var(--line);
  background: #202633;
  padding: 0 14px;
  font-weight: 800;
}

@media (max-width: 1120px) {
  .material-grid {
    grid-template-columns: repeat(4, minmax(120px, 1fr));
  }

  .output-section {
    grid-template-columns: 1fr;
  }

  .result-panel {
    flex-direction: row;
    align-items: end;
  }
}

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

  .studio__header,
  .section-heading,
  .result-panel {
    align-items: stretch;
    flex-direction: column;
  }

  .prompt-panel {
    grid-template-columns: 1fr;
  }

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

  .header-actions,
  .result-actions,
  .source-tabs {
    width: 100%;
  }

  .icon-button,
  .secondary-button,
  .source-tab {
    flex: 1;
  }
}
