:root {
  --page: #f7f8fb;
  --panel: #ffffff;
  --panel-2: #fbfcfd;
  --ink: #172027;
  --muted: #63717d;
  --line: #dce3e8;
  --pin-red: #e60023;
  --teal: #0f9f9a;
  --teal-dark: #087b78;
  --coral: #ff7a66;
  --amber: #f2b84b;
  --blue: #3d72f5;
  --shadow: 0 18px 44px rgba(23, 32, 39, 0.11);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  font-family: Inter, "Noto Sans KR", AppleSDGothicNeo, "Malgun Gothic", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 78% 16%, rgba(230, 0, 35, 0.10), transparent 28%),
    radial-gradient(circle at 18% 88%, rgba(15, 159, 154, 0.11), transparent 30%),
    linear-gradient(135deg, rgba(61, 114, 245, 0.08), transparent 34%),
    var(--page);
  overflow: hidden;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
}

svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.app-shell {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  width: 100%;
  height: 100%;
}

.side-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100%;
  overflow-y: auto;
  background: rgba(255, 255, 255, 0.94);
  border-right: 1px solid var(--line);
  box-shadow: 10px 0 34px rgba(23, 32, 39, 0.06);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 22px;
  border-bottom: 1px solid var(--line);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  color: white;
  background: linear-gradient(135deg, var(--pin-red), var(--coral));
  border-radius: var(--radius);
}

.brand h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
  letter-spacing: 0;
}

.brand p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.panel-section {
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
}

.ad-slot {
  position: relative;
  display: grid;
  place-items: center;
  color: #8a98a4;
  background: rgba(255, 255, 255, 0.58);
  border: 1px dashed #c8d4dc;
  border-radius: var(--radius);
  overflow: hidden;
}

.ad-slot span {
  position: absolute;
  top: 8px;
  left: 10px;
  z-index: 1;
  font-size: 11px;
  font-weight: 800;
}

.ad-slot .adsbygoogle {
  width: 100%;
  min-height: inherit;
}

.ad-slot-sidebar {
  min-height: 72px;
  max-height: 72px;
  margin: 12px 22px 0;
}

.ad-slot-top,
.ad-slot-bottom {
  min-height: 58px;
  max-height: 58px;
  margin: 0 28px 10px;
}

.ad-slot-bottom {
  margin-top: 0;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 800;
}

.drop-zone {
  display: grid;
  place-items: center;
  min-height: 132px;
  padding: 18px;
  text-align: center;
  color: var(--muted);
  background: var(--panel-2);
  border: 1.5px dashed #b8c7d1;
  border-radius: 16px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, transform 0.2s;
}

.drop-zone:hover,
.drop-zone.drag-over,
.upload-zone.drag-over {
  background: #fff6f7;
  border-color: var(--pin-red);
  transform: translateY(-1px);
}

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

.drop-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  margin-bottom: 9px;
  color: var(--pin-red);
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.drop-zone strong {
  display: block;
  color: var(--ink);
  font-size: 16px;
}

.drop-zone small {
  display: block;
  margin-top: 4px;
  font-size: 12px;
}

.primary-button,
.download-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 44px;
  color: white;
  background: var(--pin-red);
  border-radius: 999px;
  font-weight: 800;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s, opacity 0.2s;
}

.download-button {
  background: var(--ink);
}

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

.primary-button:hover {
  background: #c9001f;
}

.primary-button.is-busy {
  opacity: 0.78;
}

.download-button:hover {
  background: #26343e;
}

.primary-button:disabled,
.download-button:disabled,
.segment:disabled,
.icon-button:disabled,
.preset-button:disabled,
input:disabled {
  cursor: not-allowed;
  opacity: 0.44;
  transform: none;
}

.control {
  margin-top: 16px;
}

.control label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.control output {
  color: var(--ink);
}

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

select {
  width: 100%;
  min-height: 40px;
  padding: 0 12px;
  color: var(--ink);
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-weight: 800;
}

select:disabled {
  opacity: 0.44;
}

.detail-presets {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 4px;
  background: #edf2f5;
  border-radius: var(--radius);
}

.preset-button {
  min-height: 34px;
  color: var(--muted);
  background: transparent;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.preset-button.active {
  color: var(--ink);
  background: white;
  box-shadow: 0 5px 15px rgba(23, 32, 39, 0.08);
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 4px;
  background: #edf2f5;
  border-radius: var(--radius);
}

.segment {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 38px;
  color: var(--muted);
  background: transparent;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.segment svg {
  width: 15px;
  height: 15px;
}

.segment.active {
  color: var(--ink);
  background: white;
  box-shadow: 0 5px 15px rgba(23, 32, 39, 0.08);
}

.icon-button {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  color: var(--muted);
  background: #edf2f5;
  border-radius: var(--radius);
  cursor: pointer;
}

.icon-button:hover {
  color: var(--ink);
  background: #e2ebef;
}

.swatches {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 9px;
}

.swatch {
  height: 38px;
  border: 2px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(23, 32, 39, 0.12);
}

.swatch.active {
  border-color: var(--ink);
}

.checker,
.checker-bg {
  background-image:
    linear-gradient(45deg, #d9e1e6 25%, transparent 25%),
    linear-gradient(-45deg, #d9e1e6 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #d9e1e6 75%),
    linear-gradient(-45deg, transparent 75%, #d9e1e6 75%);
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  background-size: 20px 20px;
  background-color: #f7fafc;
}

.white {
  background: #ffffff;
}

.dark {
  background: #151a1f;
}

.mint {
  background: #b8f2df;
}

.coral {
  background: #ffb09f;
}

.panel-footer {
  margin-top: auto;
  padding: 18px 22px 22px;
}

.workspace {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  min-width: 0;
  height: 100%;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 28px 14px;
}

.top-bar h2 {
  margin: 0;
  font-size: 22px;
}

.top-bar p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.file-meta {
  max-width: 360px;
  padding: 10px 12px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.canvas-stage {
  display: grid;
  place-items: start center;
  min-height: 0;
  padding: 18px 28px 16px;
}

.empty-state {
  display: grid;
  place-items: center;
  width: min(620px, 100%);
  min-height: min(48vh, 460px);
  padding: 44px 30px;
  text-align: center;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(255, 255, 255, 0.86)),
    radial-gradient(circle at 22% 15%, rgba(230, 0, 35, 0.10), transparent 28%);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
}

.empty-state:hover,
.empty-state.drag-over {
  border-color: rgba(230, 0, 35, 0.38);
  box-shadow: 0 24px 70px rgba(23, 32, 39, 0.14);
  transform: translateY(-2px);
}

.center-upload-visual {
  display: grid;
  place-items: center;
  width: 220px;
  height: 154px;
  color: #94a4af;
  background:
    linear-gradient(45deg, #eef3f6 25%, transparent 25%),
    linear-gradient(-45deg, #eef3f6 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #eef3f6 75%),
    linear-gradient(-45deg, transparent 75%, #eef3f6 75%);
  background-color: #fbfcfd;
  background-position: 0 0, 0 12px, 12px -12px, -12px 0;
  background-size: 24px 24px;
  border: 1px solid #d9e3e9;
  border-radius: 22px;
}

.empty-state svg {
  width: 210px;
  height: 140px;
  color: #8da0ac;
  stroke-width: 3;
}

.center-upload-copy {
  display: grid;
  gap: 8px;
  margin-top: 24px;
}

.center-upload-copy strong {
  margin: 0;
  color: var(--ink);
  font-size: 28px;
  font-weight: 900;
}

.center-upload-copy small {
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.center-upload-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 136px;
  min-height: 44px;
  margin-top: 22px;
  color: white;
  background: var(--pin-red);
  border-radius: 999px;
  font-weight: 900;
  box-shadow: 0 14px 28px rgba(230, 0, 35, 0.20);
}

.center-upload-action svg {
  width: 17px;
  height: 17px;
  color: white;
}

.canvas-wrap {
  position: relative;
  display: grid;
  place-items: center;
  max-width: 100%;
  max-height: 100%;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.canvas-wrap.bg-white {
  background: #ffffff;
}

.canvas-wrap.bg-dark {
  background: #151a1f;
}

.canvas-wrap.bg-mint {
  background: #b8f2df;
}

.canvas-wrap.bg-coral {
  background: #ffb09f;
}

#editorCanvas {
  display: block;
  max-width: calc(100vw - 430px);
  max-height: calc(100vh - 150px);
  width: auto;
  height: auto;
  background: transparent;
  cursor: none;
}

.brush-cursor {
  position: absolute;
  display: none;
  width: 42px;
  height: 42px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  box-shadow: 0 0 0 1px white, inset 0 0 0 1px white;
  pointer-events: none;
  transform: translate(-50%, -50%);
}

@media (max-width: 920px) {
  body {
    overflow: auto;
  }

  .app-shell {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100%;
  }

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

  .workspace {
    min-height: 620px;
  }

  .ad-slot-top,
  .ad-slot-bottom {
    margin-right: 18px;
    margin-left: 18px;
  }

  .ad-slot-top {
    min-height: 52px;
    max-height: 52px;
  }

  .ad-slot-bottom {
    display: none;
  }

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

  #editorCanvas {
    max-width: calc(100vw - 56px);
    max-height: 70vh;
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
