:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #101114;
  color: #f2f2ec;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(41, 63, 79, 0.9), rgba(16, 17, 20, 0.98) 46%),
    #101114;
}

button,
input,
select,
textarea {
  font: inherit;
}

.shell {
  width: min(1440px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(360px, 0.62fr) minmax(620px, 1.38fr);
  gap: 18px;
  min-height: calc(100vh - 64px);
}

.composer,
.result-panel {
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(18, 20, 23, 0.82);
  border-radius: 8px;
  padding: 22px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.28);
}

.title-row,
.block-heading,
.viewer-toolbar,
.toolbar-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.eyebrow {
  margin: 0 0 6px;
  color: #8ad7bd;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  font-size: 34px;
  line-height: 1.05;
}

h2 {
  font-size: 15px;
}

.status {
  flex: 0 0 auto;
  border: 1px solid rgba(138, 215, 189, 0.42);
  border-radius: 999px;
  color: #b7f2df;
  padding: 7px 10px;
  font-size: 12px;
}

form {
  display: grid;
  gap: 13px;
  margin-top: 28px;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 4px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
}

.tab-button {
  min-height: 38px;
  border: 1px solid transparent;
  background: transparent;
  color: #c8d7d2;
  font-size: 13px;
}

.tab-button.active {
  border-color: rgba(138, 215, 189, 0.48);
  background: rgba(138, 215, 189, 0.16);
  color: #d8fff1;
}

.tab-panel {
  display: none;
  gap: 13px;
}

.tab-panel.active {
  display: grid;
}

.project-box {
  display: grid;
  grid-template-columns: 0.85fr 1.15fr;
  gap: 12px;
}

.project-box > div {
  display: grid;
  gap: 8px;
}

.project-hint,
.settings-list {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.055);
  color: #c8d7d2;
  font-size: 13px;
  line-height: 1.45;
  padding: 12px;
}

.settings-list {
  display: grid;
  gap: 10px;
}

.settings-list > div {
  display: grid;
  gap: 4px;
}

.settings-list strong {
  color: #f2f2ec;
  font-size: 12px;
  text-transform: uppercase;
}

label {
  color: #d8d8d0;
  font-size: 13px;
  font-weight: 700;
}

textarea,
input,
select {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.065);
  color: #f5f2ea;
  outline: none;
  padding: 13px 14px;
}

textarea {
  resize: vertical;
  min-height: 190px;
  line-height: 1.45;
}

select option {
  background: #15181c;
}

textarea:focus,
input:focus,
select:focus {
  border-color: #8ad7bd;
  box-shadow: 0 0 0 3px rgba(138, 215, 189, 0.14);
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.grid > div {
  display: grid;
  gap: 8px;
}

button {
  border: 0;
  border-radius: 8px;
  background: #8ad7bd;
  color: #0c1814;
  cursor: pointer;
  font-weight: 800;
  min-height: 44px;
  padding: 0 16px;
}

.download-link {
  min-height: 32px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(138, 215, 189, 0.12);
  color: #d8fff1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
  padding: 0 14px;
  text-decoration: none;
}

.download-link.disabled {
  opacity: 0.45;
  pointer-events: none;
}

.secondary {
  border: 1px solid rgba(138, 215, 189, 0.35);
  background: rgba(138, 215, 189, 0.12);
  color: #d8fff1;
}

.activity {
  min-height: 38px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.055);
  color: #c8d7d2;
  display: flex;
  align-items: center;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 700;
}

.activity.working {
  border-color: rgba(138, 215, 189, 0.55);
  color: #d8fff1;
  background: linear-gradient(90deg, rgba(138, 215, 189, 0.18), rgba(138, 215, 189, 0.04));
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.ghost {
  min-height: 32px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: #f2f2ec;
  font-size: 12px;
}

.result-panel {
  display: grid;
  grid-template-rows: auto minmax(420px, 1fr) auto auto auto auto;
  gap: 14px;
  min-width: 0;
}

.viewer-toolbar {
  min-width: 0;
}

.viewer-toolbar h2 {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preview {
  height: clamp(420px, 64vh, 760px);
  border-radius: 8px;
  background:
    linear-gradient(145deg, rgba(138, 215, 189, 0.18), transparent 32%),
    linear-gradient(315deg, rgba(233, 106, 86, 0.18), transparent 38%),
    #191c20;
  padding: 12px;
  overflow: hidden;
}

.preview-inner {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  border: 1px dashed rgba(255, 255, 255, 0.22);
  border-radius: 6px;
  color: #bbb8ad;
  text-align: center;
  padding: 18px;
  overflow: hidden;
}

.preview-inner img,
.preview-inner video {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 6px;
  object-fit: contain;
}

.preview-inner video {
  background: #0d0f12;
}

.gallery-block {
  display: grid;
  gap: 9px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: 13px;
}

.gallery {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 118px;
  gap: 10px;
  min-height: 152px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.gallery-item {
  width: 118px;
  height: 152px;
  min-height: 152px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
  display: grid;
  grid-template-rows: 1fr 34px;
  color: #f2f2ec;
}

.gallery-item img {
  width: 100%;
  height: 100%;
  min-height: 0;
  object-fit: contain;
  display: block;
  background: #0d0f12;
}

.gallery-item span {
  display: block;
  min-width: 0;
  overflow: hidden;
  padding: 8px;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.empty-gallery {
  align-self: center;
  color: #bbb8ad;
  font-size: 13px;
}

.result-block {
  display: grid;
  gap: 9px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: 13px;
}

pre {
  overflow: auto;
  min-height: 54px;
  max-height: 180px;
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  color: #ebe8df;
  line-height: 1.45;
}

.image-dialog {
  width: min(96vw, 1320px);
  height: min(94vh, 920px);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: #0e1013;
  color: #f2f2ec;
  padding: 14px;
}

.image-dialog::backdrop {
  background: rgba(0, 0, 0, 0.72);
}

.dialog-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.image-dialog img {
  display: block;
  width: 100%;
  height: calc(100% - 48px);
  object-fit: contain;
  background: #15181c;
  border-radius: 6px;
}

.error {
  color: #ffb0a0;
}

@media (max-width: 880px) {
  .workspace,
  .grid,
  .project-box {
    grid-template-columns: 1fr;
  }

  .preview {
    height: clamp(360px, 58vh, 620px);
  }

  .shell {
    width: min(100% - 20px, 1180px);
    padding: 10px 0;
  }

  .workspace {
    min-height: auto;
  }

  h1 {
    font-size: 28px;
  }
}
