:root {
  --bg: #edf1f4;
  --bg-warm: #f6f8fa;
  --panel: rgba(249, 251, 253, 0.92);
  --panel-solid: #fdfefe;
  --ink: #13212f;
  --muted: #6b7a89;
  --accent: #2f6f9b;
  --accent-soft: #c7d8e6;
  --accent-dark: #214f70;
  --line: rgba(19, 33, 47, 0.1);
  --shadow: 0 22px 56px rgba(27, 43, 59, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(122, 156, 184, 0.16), transparent 26%),
    radial-gradient(circle at right center, rgba(170, 184, 198, 0.12), transparent 28%),
    linear-gradient(135deg, #f4f7fa 0%, #e8edf2 100%);
}

.app-shell {
  width: min(1520px, calc(100vw - 40px));
  margin: 0 auto;
  padding: 24px 0 34px;
}

.toolbar,
.workspace {
  display: grid;
  gap: 24px;
}

.toolbar {
  position: relative;
  z-index: 20;
}

.workspace {
  position: relative;
  z-index: 1;
}

.upload-card,
.canvas-panel,
.result-panel {
  background: var(--panel);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.upload-card {
  position: relative;
  z-index: 25;
}

.upload-card,
.result-panel {
  padding: 24px;
}

.upload-card {
  display: grid;
  gap: 22px;
}

.toolbar-header {
  display: grid;
  grid-template-columns: 1.25fr 0.85fr;
  gap: 22px;
  align-items: start;
}

.section-label {
  margin: 0 0 10px;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-weight: 700;
  color: var(--accent-dark);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  max-width: 13ch;
  font-size: clamp(2rem, 3.4vw, 3.4rem);
  line-height: 1;
  letter-spacing: -0.03em;
}

h2 {
  font-size: 1.6rem;
  line-height: 1;
  letter-spacing: -0.02em;
}

.toolbar-note,
.panel-header p,
.upload-dropzone small {
  color: var(--muted);
}

.toolbar-meta {
  display: grid;
  gap: 14px;
  justify-items: end;
  align-content: start;
  justify-self: end;
}

.toolbar-note {
  max-width: 38ch;
  justify-self: end;
  font-size: 0.98rem;
  line-height: 1.6;
}

.portal-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(33, 79, 112, 0.18);
  color: var(--accent-dark);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 700;
  box-shadow: 0 10px 22px rgba(33, 79, 112, 0.08);
  transition: transform 140ms ease, box-shadow 140ms ease, border-color 140ms ease;
}

.portal-link:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(33, 79, 112, 0.12);
  border-color: rgba(33, 79, 112, 0.18);
}

.toolbar-grid {
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(320px, 1fr);
  gap: 18px;
  align-items: stretch;
}

.toolbar-side {
  display: grid;
  gap: 16px;
  align-content: start;
  padding: 18px 20px;
  border-radius: 20px;
  background: rgba(243, 247, 250, 0.88);
  border: 1px solid rgba(19, 33, 47, 0.06);
}

.upload-picker {
  position: relative;
  isolation: isolate;
  z-index: 30;
}

.upload-dropzone {
  width: 100%;
  display: grid;
  place-items: center;
  min-height: 178px;
  border: 1.5px dashed rgba(33, 79, 112, 0.34);
  border-radius: 20px;
  background:
    linear-gradient(180deg, rgba(250, 253, 255, 1) 0%, rgba(232, 240, 246, 0.98) 100%);
  text-align: center;
  cursor: pointer;
  padding: 20px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.72);
}

.upload-dropzone span {
  font-size: 1.02rem;
  font-weight: 700;
  color: var(--ink);
}

.upload-dropzone small {
  color: var(--accent-dark);
  font-weight: 600;
}

.upload-menu {
  position: absolute;
  top: calc(100% + 12px);
  left: 0;
  right: 0;
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(33, 79, 112, 0.3);
  border-radius: 18px;
  background: #eef5fa;
  box-shadow: 0 22px 48px rgba(27, 43, 59, 0.22);
  z-index: 50;
  opacity: 1;
}

.upload-menu button {
  background: linear-gradient(180deg, #466f8a 0%, #34586f 100%);
  box-shadow: 0 8px 18px rgba(52, 88, 111, 0.18);
}

.gallery-controls {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
}

.gallery-controls span {
  text-align: center;
  font-weight: 700;
  color: var(--accent-dark);
}

.controls {
  display: grid;
}

.controls label {
  display: grid;
  gap: 10px;
}

.controls span {
  font-weight: 600;
}

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

button,
.download-link {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 50px;
  padding: 0 18px;
  border: 0;
  border-radius: 14px;
  background: linear-gradient(180deg, #3b7ca8 0%, #2b668f 100%);
  color: white;
  font-size: 0.94rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: transform 140ms ease, opacity 140ms ease, box-shadow 140ms ease;
  box-shadow: 0 8px 20px rgba(47, 111, 155, 0.16);
}

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

button:not(:disabled):hover,
.download-link:hover {
  transform: translateY(-1px);
}

.workspace {
  grid-template-columns: minmax(680px, 1.1fr) minmax(520px, 0.92fr);
  align-items: start;
}

.canvas-panel {
  padding: 20px;
  min-height: 740px;
}

.panel-header {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

#editorCanvas,
#resultCanvas {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 24px;
}

#editorCanvas {
  background:
    linear-gradient(45deg, rgba(24, 35, 45, 0.03) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(24, 35, 45, 0.03) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(24, 35, 45, 0.03) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(24, 35, 45, 0.03) 75%);
  background-size: 24px 24px;
  background-position: 0 0, 0 12px, 12px -12px, -12px 0;
}

#resultCanvas {
  background: var(--panel-solid);
  border: 1px solid rgba(19, 33, 47, 0.12);
}

.result-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
  padding: 12px;
  border-radius: 18px;
  background: rgba(244, 248, 251, 0.9);
  border: 1px solid rgba(19, 33, 47, 0.06);
}

.result-tools > input[type="text"] {
  flex: 1 1 220px;
}

.result-tools > input[type="range"] {
  flex: 1 1 140px;
  min-width: 140px;
}

.result-tools > button,
.result-tools > .toggle-chip {
  flex: 0 0 auto;
}

input[type="text"] {
  width: 100%;
  min-height: 48px;
  border: 1px solid rgba(19, 33, 47, 0.12);
  border-radius: 12px;
  padding: 0 16px;
  font: inherit;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.98);
}

input[type="color"] {
  width: 52px;
  min-height: 48px;
  border: 1px solid rgba(19, 33, 47, 0.12);
  border-radius: 12px;
  padding: 6px;
  background: rgba(255, 255, 255, 0.98);
}

.toggle-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid rgba(19, 33, 47, 0.12);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.98);
  cursor: pointer;
  font-weight: 600;
}

.toggle-chip input {
  display: none;
}

.download-link {
  margin-top: 16px;
}

.hidden {
  display: none;
}

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

  .toolbar-note {
    justify-self: start;
  }

  .toolbar-meta {
    justify-items: start;
  }

  .canvas-panel {
    min-height: auto;
  }
}

@media (max-width: 980px) {
  .app-shell {
    width: min(100vw - 20px, 1400px);
    padding-top: 20px;
  }

  .result-tools {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 720px) {
  .gallery-controls,
  .result-tools {
    grid-template-columns: 1fr;
  }

  h1 {
    max-width: none;
  }
}
