:root {
  color-scheme: dark;
  --bg: #090b0f;
  --bg-2: #0f131a;
  --panel: rgba(17, 22, 30, 0.92);
  --panel-2: rgba(22, 29, 39, 0.86);
  --ink: #eef4f1;
  --muted: #91a0a7;
  --line: rgba(144, 167, 176, 0.22);
  --line-strong: rgba(89, 211, 188, 0.46);
  --cyan: #59d3bc;
  --cyan-2: #31a8d8;
  --green: #7ee787;
  --warn: #ffb86b;
  --danger: #ff6b7a;
  --magenta: #d384ff;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.42);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 22% 0%, rgba(89, 211, 188, 0.16), transparent 28%),
    radial-gradient(circle at 84% 16%, rgba(211, 132, 255, 0.11), transparent 24%),
    linear-gradient(135deg, #090b0f 0%, #10151d 48%, #090b0f 100%);
  color: var(--ink);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
  background-size: 36px 36px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.75), transparent 78%);
}

.topbar {
  min-height: 88px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(9, 11, 15, 0.76);
  backdrop-filter: blur(18px);
}

.eyebrow {
  display: block;
  margin-bottom: 5px;
  color: var(--cyan);
  font-size: 11px;
  font-weight: 760;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 760;
}

p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.status {
  min-width: 166px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(17, 22, 30, 0.92);
  color: var(--muted);
  text-align: center;
  font-size: 13px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.03);
}

.status.ok {
  color: var(--green);
  border-color: rgba(126, 231, 135, 0.38);
}

.status.warn {
  color: var(--warn);
  border-color: rgba(255, 184, 107, 0.44);
}

.layout {
  position: relative;
  display: grid;
  grid-template-columns: 380px minmax(0, 1fr);
  height: calc(100vh - 89px);
}

.panel {
  background: linear-gradient(180deg, rgba(17, 22, 30, 0.96), rgba(13, 17, 24, 0.96));
  border-right: 1px solid var(--line);
  overflow: auto;
}

.controls {
  padding: 18px;
}

section + section {
  margin-top: 18px;
}

.dropzone {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 116px;
  border: 1px dashed rgba(89, 211, 188, 0.52);
  border-radius: 10px;
  background:
    linear-gradient(135deg, rgba(89, 211, 188, 0.09), rgba(49, 168, 216, 0.05)),
    rgba(11, 16, 22, 0.7);
  cursor: pointer;
  overflow: hidden;
}

.dropzone::after {
  content: "";
  position: absolute;
  inset: 10px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 7px;
  pointer-events: none;
}

.dropzone input {
  display: none;
}

.dropzone span {
  font-weight: 760;
}

.dropzone small {
  margin-top: 6px;
  color: var(--muted);
}

.grid {
  display: grid;
  gap: 12px;
}

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

.field,
label {
  display: grid;
  gap: 7px;
  color: #c1cbd0;
  font-size: 12px;
  font-weight: 700;
}

.wide {
  grid-column: 1 / -1;
}

.input-action {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 74px;
  gap: 8px;
}

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(5, 8, 12, 0.82);
  color: var(--ink);
  outline: none;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.02);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--line-strong);
  box-shadow: 0 0 0 3px rgba(89, 211, 188, 0.11);
}

input[readonly] {
  color: #83ffe9;
  border-color: rgba(89, 211, 188, 0.32);
  background: rgba(89, 211, 188, 0.07);
}

input,
select {
  height: 40px;
  padding: 0 11px;
}

textarea {
  padding: 11px;
  resize: vertical;
  line-height: 1.45;
  font-size: 13px;
}

.priority-stack {
  display: grid;
  gap: 5px;
  margin-bottom: 12px;
  padding: 10px 12px;
  border: 1px solid rgba(89, 211, 188, 0.38);
  border-radius: 8px;
  background: rgba(89, 211, 188, 0.07);
}

.priority-stack span {
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.priority-stack strong {
  color: #83ffe9;
  font-size: 12px;
}

.dimension-note {
  padding: 10px 12px;
  border: 1px solid rgba(144, 167, 176, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

button {
  min-height: 40px;
  border: 1px solid rgba(144, 167, 176, 0.28);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(31, 41, 54, 0.96), rgba(18, 24, 33, 0.96));
  color: var(--ink);
  cursor: pointer;
  font-weight: 740;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
}

button:hover {
  border-color: rgba(89, 211, 188, 0.72);
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  transform: none;
}

#renderAllButton,
#downloadButton,
#saveButton {
  background: linear-gradient(135deg, rgba(89, 211, 188, 0.95), rgba(49, 168, 216, 0.95));
  border-color: rgba(89, 211, 188, 0.72);
  color: #04100f;
}

.meter-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
}

progress {
  width: 100%;
  height: 10px;
  margin-top: 9px;
  accent-color: var(--cyan);
}

.connection-note {
  margin-top: 10px;
  min-height: 34px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(5, 8, 12, 0.66);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.connection-note.ok {
  color: var(--green);
  border-color: rgba(126, 231, 135, 0.38);
}

.connection-note.warn {
  color: var(--warn);
  border-color: rgba(255, 184, 107, 0.44);
}

.connection-note.pending {
  color: var(--cyan);
  border-color: rgba(89, 211, 188, 0.44);
}

.workspace {
  min-width: 0;
  display: grid;
  grid-template-rows: 52px minmax(0, 1fr) 120px;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(12, 16, 23, 0.62);
  backdrop-filter: blur(16px);
}

.tab {
  width: 92px;
  min-height: 34px;
  font-size: 13px;
}

.tab.active {
  background: rgba(89, 211, 188, 0.16);
  border-color: rgba(89, 211, 188, 0.58);
  color: var(--cyan);
}

.viewer {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: auto;
  padding: 24px;
  background:
    linear-gradient(90deg, rgba(89, 211, 188, 0.08) 1px, transparent 1px),
    linear-gradient(rgba(89, 211, 188, 0.08) 1px, transparent 1px),
    radial-gradient(circle at center, rgba(89, 211, 188, 0.08), transparent 48%),
    #070a0f;
  background-size: 32px 32px, 32px 32px, auto, auto;
}

.viewer.dragging {
  outline: 2px solid var(--cyan);
  outline-offset: -12px;
}

.viewer.dragging .empty {
  border-color: rgba(89, 211, 188, 0.86);
  color: var(--cyan);
  transform: scale(1.02);
}

canvas {
  max-width: 100%;
  max-height: 100%;
  background: #0c1016;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  box-shadow: var(--shadow);
}

.empty {
  position: absolute;
  display: grid;
  gap: 8px;
  justify-items: center;
  min-width: min(430px, calc(100% - 48px));
  color: var(--muted);
  background: rgba(12, 16, 23, 0.84);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 26px 28px;
  text-align: center;
  box-shadow: var(--shadow);
  transition: transform 120ms ease, border-color 120ms ease, color 120ms ease;
}

.empty strong {
  color: var(--ink);
  font-size: 18px;
}

.empty span {
  font-size: 13px;
}

.empty.hidden {
  display: none;
}

.filmstrip {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 13px 14px;
  border-top: 1px solid var(--line);
  background: rgba(9, 11, 15, 0.86);
}

.tile-card {
  flex: 0 0 136px;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: rgba(17, 22, 30, 0.88);
}

.tile-card.active {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(89, 211, 188, 0.11);
}

.tile-card canvas {
  display: block;
  width: 134px;
  height: 76px;
  object-fit: cover;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.tile-card div {
  display: flex;
  justify-content: space-between;
  padding: 7px 8px;
  color: var(--muted);
  font-size: 12px;
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
    height: auto;
  }

  .panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .workspace {
    height: 72vh;
  }

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