:root {
  color-scheme: light;
  --ink: #191b22;
  --muted: #657080;
  --line: rgba(31, 41, 55, 0.12);
  --surface: rgba(255, 255, 255, 0.9);
  --panel: #f7f8fb;
  --accent: #e53245;
  --accent-dark: #bd1830;
  --teal: #009e91;
  --gold: #f4b13d;
  --violet: #6852d9;
  --shadow: 0 24px 70px rgba(20, 27, 37, 0.16);
  --soft-shadow: 0 14px 34px rgba(20, 27, 37, 0.1);
}

* {
  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;
  color: var(--ink);
  background:
    linear-gradient(120deg, rgba(229, 50, 69, 0.18), transparent 34rem),
    linear-gradient(250deg, rgba(0, 158, 145, 0.16), transparent 32rem),
    #f4f6fb;
  overflow-x: hidden;
}

button,
select,
input {
  font: inherit;
}

button,
select {
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease, background 160ms ease;
}

.page-glow {
  position: fixed;
  inset: auto -10vw -22vh auto;
  width: 50vw;
  height: 50vw;
  pointer-events: none;
  background: radial-gradient(circle, rgba(244, 177, 61, 0.28), transparent 62%);
}

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

.workspace {
  display: grid;
  gap: 18px;
}

.topbar,
.controls,
.preview-panel,
.drop-zone,
.summary-panel {
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.72);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

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

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 18px;
}

.brand-mark {
  width: 74px;
  height: 74px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 8px;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--violet));
  box-shadow: 0 14px 26px rgba(229, 50, 69, 0.3);
  font-weight: 900;
  letter-spacing: 0;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
  font-size: 0.76rem;
}

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

h1 {
  margin-bottom: 8px;
  font-size: clamp(2.2rem, 6vw, 5rem);
  line-height: 0.95;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 8px;
}

.hero-copy {
  max-width: 620px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 1.05rem;
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 18px;
  align-items: stretch;
}

.drop-zone {
  position: relative;
  min-height: 360px;
  border-radius: 8px;
  border: 1px dashed rgba(229, 50, 69, 0.38);
  display: grid;
  place-items: center;
  align-content: center;
  gap: 14px;
  padding: 38px 22px;
  text-align: center;
  overflow: hidden;
}

.drop-zone::before {
  content: "";
  position: absolute;
  inset: 18px;
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(229, 50, 69, 0.08), transparent 55%),
    repeating-linear-gradient(135deg, rgba(25, 27, 34, 0.045) 0 1px, transparent 1px 14px);
  opacity: 0.75;
  z-index: -1;
}

.drop-zone.is-dragging {
  transform: translateY(-3px) scale(1.005);
  border-color: var(--accent);
  background: rgba(255, 248, 249, 0.96);
  box-shadow: 0 30px 90px rgba(229, 50, 69, 0.22);
}

.drop-zone input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.drop-icon {
  width: 88px;
  height: 88px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--gold));
  border-radius: 8px;
  box-shadow: 0 18px 34px rgba(229, 50, 69, 0.28);
}

.drop-icon svg {
  width: 48px;
  height: 48px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.drop-zone h2 {
  margin-bottom: 0;
  font-size: clamp(1.8rem, 4vw, 3.1rem);
  line-height: 1;
}

.drop-zone p,
.panel-head p {
  color: var(--muted);
  margin-bottom: 0;
}

.summary-panel {
  display: grid;
  gap: 14px;
  padding: 16px;
  border-radius: 8px;
}

.summary-card {
  min-height: 96px;
  display: grid;
  align-content: center;
  gap: 6px;
  padding: 18px;
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.85), rgba(247, 248, 251, 0.92)),
    linear-gradient(135deg, rgba(0, 158, 145, 0.1), rgba(104, 82, 217, 0.08));
  border: 1px solid var(--line);
}

.summary-card span {
  color: var(--muted);
  font-weight: 800;
  font-size: 0.8rem;
  text-transform: uppercase;
}

.summary-card strong {
  font-size: 1.65rem;
  line-height: 1;
}

.primary-button,
.ghost-button,
.card-actions button {
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  min-height: 44px;
}

.primary-button {
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #fff;
  padding: 0 20px;
  font-weight: 900;
  box-shadow: 0 12px 24px rgba(229, 50, 69, 0.24);
}

.primary-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 30px rgba(229, 50, 69, 0.3);
}

.ghost-button {
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  padding: 0 16px;
  border: 1px solid var(--line);
  font-weight: 800;
}

.ghost-button:hover {
  background: #fff;
  transform: translateY(-1px);
}

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

.controls {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  padding: 18px;
  border-radius: 8px;
}

.controls label {
  display: grid;
  gap: 9px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 850;
}

.controls select,
.controls input[type="range"] {
  width: 100%;
}

.controls select {
  min-height: 46px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 8px 18px rgba(20, 27, 37, 0.06);
}

.controls select:focus,
.controls input[type="range"]:focus {
  outline: 3px solid rgba(229, 50, 69, 0.18);
  outline-offset: 2px;
}

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

#qualityValue {
  color: var(--ink);
  font-weight: 900;
}

.preview-panel {
  border-radius: 8px;
  padding: 20px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.panel-head h2 {
  font-size: 1.55rem;
}

.empty-state {
  min-height: 150px;
  display: grid;
  place-items: center;
  color: var(--muted);
  border: 1px dashed rgba(101, 112, 128, 0.34);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.7), rgba(247, 248, 251, 0.95)),
    repeating-linear-gradient(45deg, rgba(101, 112, 128, 0.08) 0 1px, transparent 1px 13px);
}

.empty-state[hidden] {
  display: none;
}

.image-grid {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.image-card {
  position: relative;
  display: grid;
  grid-template-rows: 172px auto auto;
  gap: 11px;
  padding: 11px;
  border: 1px solid rgba(31, 41, 55, 0.1);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--soft-shadow);
  overflow: hidden;
}

.image-card::before {
  content: attr(data-index);
  position: absolute;
  top: 18px;
  left: 18px;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: rgba(25, 27, 34, 0.76);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 900;
  z-index: 1;
}

.image-card:hover {
  transform: translateY(-3px);
  border-color: rgba(229, 50, 69, 0.32);
  box-shadow: 0 20px 42px rgba(20, 27, 37, 0.15);
}

.image-card.is-drag-over {
  outline: 3px solid var(--teal);
  outline-offset: 2px;
}

.thumb-wrap {
  height: 172px;
  border-radius: 8px;
  background:
    linear-gradient(45deg, #edf0f4 25%, transparent 25%),
    linear-gradient(-45deg, #edf0f4 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #edf0f4 75%),
    linear-gradient(-45deg, transparent 75%, #edf0f4 75%);
  background-size: 18px 18px;
  background-position: 0 0, 0 9px, 9px -9px, -9px 0;
  overflow: hidden;
  display: grid;
  place-items: center;
}

.thumb-wrap img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.image-meta {
  min-width: 0;
}

.image-meta strong,
.image-meta span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.image-meta strong {
  font-size: 0.98rem;
}

.image-meta span {
  color: var(--muted);
  font-size: 0.88rem;
}

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

.card-actions button {
  background: #f2f5f8;
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 900;
}

.card-actions button:hover {
  background: #e8edf3;
  transform: translateY(-1px);
}

.card-actions button[data-action="remove"]:hover {
  background: #ffe8eb;
  color: var(--accent-dark);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  max-width: min(520px, calc(100% - 32px));
  padding: 13px 16px;
  border-radius: 8px;
  background: #191b22;
  color: #fff;
  box-shadow: var(--shadow);
  z-index: 10;
}

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

  .summary-panel {
    grid-template-columns: repeat(3, 1fr);
  }

  .topbar,
  .panel-head {
    align-items: stretch;
    flex-direction: column;
  }

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

  .primary-button,
  .ghost-button {
    width: 100%;
  }
}

@media (max-width: 620px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
    padding: 10px 0 18px;
  }

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

  .brand-mark {
    width: 60px;
    height: 60px;
  }

  h1 {
    font-size: 2.45rem;
  }

  .drop-zone {
    min-height: 285px;
  }

  .summary-panel,
  .controls {
    grid-template-columns: 1fr;
  }
}
