:root {
  --blue-900: #0b2559;
  --blue-700: #164fa6;
  --blue-600: #1e63d0;
  --blue-500: #2f79f0;
  --blue-100: #e7f0ff;
  --blue-50: #f3f8ff;
  --ink-900: #0e1b2e;
  --ink-600: #5b6b85;
  --ink-400: #8fa0bd;
  --line: #e4ebf7;
  --white: #ffffff;
  --danger: #e5484d;
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 10px;
  --shadow-soft: 0 20px 50px -20px rgba(20, 50, 110, 0.18);
  --shadow-btn: 0 10px 24px -8px rgba(47, 121, 240, 0.45);
}

* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  padding: 0;
}
body {
  font-family: "Inter", sans-serif;
  background:
    radial-gradient(1200px 600px at 100% -10%, #e9f2ff 0%, transparent 60%),
    radial-gradient(1000px 700px at -10% 110%, #eaf3ff 0%, transparent 55%),
    #f5f9ff;
  min-height: 100vh;
  color: var(--ink-900);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 20px;
}

h1,
h2,
h3,
h4 {
  font-family: "Sora", sans-serif;
  margin: 0;
}

.app-shell {
  width: 100%;
  max-width: 1180px;
  background: var(--white);
  border-radius: 32px;
  box-shadow: var(--shadow-soft);
  overflow: hidden;
  border: 1px solid var(--line);
}

/* ---------- TOP BAR ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 32px;
  background: linear-gradient(135deg, var(--blue-700) 0%, var(--blue-500) 100%);
  color: var(--white);
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  backdrop-filter: blur(4px);
}
.brand-text {
  font-family: "Sora", sans-serif;
  font-weight: 700;
  font-size: 19px;
  letter-spacing: 0.2px;
}
.brand-text span {
  font-weight: 500;
  opacity: 0.75;
  font-size: 13px;
  display: block;
  font-family: "Inter", sans-serif;
  margin-top: 1px;
}
.topbar-actions {
  display: flex;
  gap: 10px;
}
.pill-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 100px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.12);
  color: var(--white);
  font-family: "Inter", sans-serif;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.18s ease;
}
.pill-btn:hover {
  background: rgba(255, 255, 255, 0.22);
}
.pill-btn.solid {
  background: var(--white);
  color: var(--blue-700);
  border: 1px solid transparent;
}
.pill-btn.solid:hover {
  background: #eff5ff;
}

/* ---------- MAIN GRID ---------- */
.editor-grid {
  display: grid;
  grid-template-columns: 300px 1fr;
  min-height: 640px;
}

/* ---------- LEFT PANEL ---------- */
.panel-left {
  border-right: 1px solid var(--line);
  padding: 26px 22px;
  background: linear-gradient(180deg, var(--blue-50) 0%, var(--white) 240px);
  display: flex;
  flex-direction: column;
  gap: 26px;
  overflow-y: auto;
  max-height: 640px;
}
.section-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--blue-700);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-label i {
  font-size: 12px;
}

.upload-card {
  border: 2px dashed var(--blue-100);
  background: var(--blue-50);
  border-radius: var(--radius-md);
  padding: 18px 14px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
}
.upload-card:hover {
  border-color: var(--blue-500);
  background: var(--white);
}
.upload-card i {
  font-size: 22px;
  color: var(--blue-600);
  margin-bottom: 8px;
}
.upload-card p {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--blue-700);
}
.upload-card small {
  color: var(--ink-400);
  font-size: 11px;
}

.filter-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.filter-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 6px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--line);
  background: var(--white);
  cursor: pointer;
  font-family: "Inter", sans-serif;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-600);
  transition: all 0.16s ease;
}
.filter-chip i {
  font-size: 16px;
  color: var(--blue-500);
}
.filter-chip:hover {
  border-color: var(--blue-300, #a9c8ff);
  transform: translateY(-1px);
}
.filter-chip.active {
  background: linear-gradient(135deg, var(--blue-600), var(--blue-500));
  border-color: transparent;
  color: var(--white);
  box-shadow: var(--shadow-btn);
}
.filter-chip.active i {
  color: var(--white);
}

.range-card {
  background: var(--blue-50);
  border-radius: var(--radius-md);
  padding: 16px;
}
.range-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.range-head .name {
  font-weight: 700;
  font-size: 13px;
  color: var(--ink-900);
}
.range-head .value {
  font-weight: 700;
  font-size: 13px;
  color: var(--blue-600);
  background: var(--white);
  padding: 2px 10px;
  border-radius: 100px;
  border: 1px solid var(--blue-100);
}
input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 100px;
  background: var(--blue-100);
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--white);
  border: 4px solid var(--blue-600);
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(30, 99, 208, 0.4);
}
input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--white);
  border: 4px solid var(--blue-600);
  cursor: pointer;
}

.transform-row {
  display: flex;
  gap: 8px;
}
.icon-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 4px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--line);
  background: var(--white);
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-600);
  transition: all 0.16s ease;
}
.icon-btn i {
  font-size: 16px;
  color: var(--blue-500);
}
.icon-btn:hover {
  border-color: var(--blue-500);
  transform: translateY(-1px);
}
.icon-btn.flipped {
  background: var(--blue-100);
  border-color: var(--blue-500);
}

.reset-link {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px;
  border-radius: 100px;
  background: transparent;
  border: 1.5px solid var(--line);
  color: var(--ink-600);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  margin-top: auto;
  transition: all 0.16s ease;
}
.reset-link:hover {
  border-color: var(--danger);
  color: var(--danger);
}

/* ---------- RIGHT / CANVAS ---------- */
.panel-right {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px;
  background:
    linear-gradient(180deg, var(--blue-50) 0%, transparent 200px),
    repeating-conic-gradient(#f4f8ff 0% 25%, #ffffff 0% 50%) 0/24px 24px;
  position: relative;
}

.canvas-frame {
  width: 100%;
  max-width: 460px;
  aspect-ratio: 1/1;
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
}
.canvas-frame .empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: var(--ink-400);
  padding: 20px;
  text-align: center;
}
.canvas-frame .empty-state i {
  font-size: 44px;
  color: var(--blue-100);
}
.canvas-frame .empty-state p {
  font-weight: 600;
  color: var(--ink-600);
  font-size: 14px;
  margin: 0;
}
.canvas-frame .empty-state small {
  font-size: 12px;
  color: var(--ink-400);
}
.canvas-frame img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: none;
}
.canvas-frame img.active {
  display: block;
}

.bottom-actions {
  display: flex;
  gap: 12px;
  margin-top: 26px;
  width: 100%;
  max-width: 460px;
}
.btn-primary {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 15px;
  border-radius: 100px;
  border: none;
  background: linear-gradient(135deg, var(--blue-600), var(--blue-500));
  color: var(--white);
  font-family: "Inter", sans-serif;
  font-weight: 700;
  font-size: 14.5px;
  cursor: pointer;
  box-shadow: var(--shadow-btn);
  transition:
    transform 0.15s ease,
    box-shadow 0.15s ease;
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 30px -10px rgba(47, 121, 240, 0.55);
}
.btn-primary:active {
  transform: translateY(0);
}
.btn-primary.ghost {
  background: var(--white);
  color: var(--blue-700);
  border: 1.5px solid var(--blue-100);
  box-shadow: none;
  flex: 0 0 auto;
  padding: 15px 22px;
}
.btn-primary.ghost:hover {
  background: var(--blue-50);
}

#file-upload {
  display: none;
}

::-webkit-scrollbar {
  width: 6px;
}
::-webkit-scrollbar-thumb {
  background: var(--blue-100);
  border-radius: 100px;
}

@media (max-width: 860px) {
  .editor-grid {
    grid-template-columns: 1fr;
  }
  .panel-left {
    border-right: none;
    border-bottom: 1px solid var(--line);
    max-height: none;
  }
  .topbar {
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    padding: 18px 20px;
  }
  .panel-right {
    padding: 24px 20px;
  }
}
