:root {
  color-scheme: dark;
  --bg: #0d0f11;
  --panel: #181b1f;
  --panel-strong: #22262b;
  --text: #f7f1e8;
  --muted: #b7b3ad;
  --line: rgba(255, 255, 255, 0.14);
  --accent: #d7b46a;
  --accent-strong: #f0ce82;
  --focus: #9ed8ff;
  font-family: "Noto Sans KR", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 18% 12%, rgba(215, 180, 106, 0.14), transparent 28rem),
    linear-gradient(135deg, #0d0f11 0%, #171a1d 46%, #111416 100%);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(100%, 552px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 24px;
}

.editor-panel,
.preview-panel {
  width: 100%;
}

.brand-block {
  margin-bottom: 22px;
  padding-top: 4px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent-strong);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.7rem, 17vw, 4.4rem);
  line-height: 0.9;
  letter-spacing: 0;
}

.intro {
  max-width: 32rem;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 0.94rem;
  line-height: 1.55;
}

.control-stack {
  display: grid;
  gap: 12px;
}

.drop-zone,
.file-row,
label:not(.drop-zone):not(.file-row) {
  display: grid;
  gap: 8px;
}

.drop-zone {
  min-height: 108px;
  align-content: center;
  padding: 18px;
  border: 1px dashed rgba(240, 206, 130, 0.55);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.055);
}

.drop-title {
  font-size: 1.04rem;
  font-weight: 800;
}

.drop-copy {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.photo-status {
  min-height: 1.25em;
  color: var(--accent-strong);
  font-size: 0.82rem;
  font-weight: 700;
}

.photo-status.is-error {
  color: #ffb4a8;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

label span {
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 700;
}

input[type="text"],
select {
  width: 100%;
  min-height: 46px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
  background: var(--panel);
  color: var(--text);
}

select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 19px, calc(100% - 12px) 19px;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}

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

input[type="color"] {
  width: 54px;
  height: 42px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

input[type="text"]:focus,
select:focus,
input[type="color"]:focus-visible,
input[type="checkbox"]:focus-visible,
input[type="range"]:focus-visible,
button:focus-visible,
.drop-zone:focus-within,
.file-row:focus-within {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.file-row {
  grid-template-columns: 1fr;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.file-row strong,
.file-row small {
  display: block;
}

.file-row small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.8rem;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.segmented button {
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
}

.segmented button.active {
  background: var(--accent);
  color: #17130a;
}

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

.drink-fields {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
}

.copy-fields {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
}

.copy-fields[hidden] {
  display: none;
}

.color-builder {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
}

.color-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.color-row strong,
.color-row small {
  display: block;
}

.color-row small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.8rem;
}

.range-row {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.toggle-row {
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.toggle-row strong,
.toggle-row small {
  display: block;
}

.toggle-row small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.35;
}

input[type="checkbox"] {
  width: 42px;
  height: 24px;
  margin: 0;
  accent-color: var(--accent-strong);
}

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

.primary-action {
  min-height: 50px;
  border: 0;
  border-radius: 8px;
  background: var(--accent-strong);
  color: #17130a;
  font-weight: 900;
}

.primary-action:active {
  transform: translateY(1px);
}

.preview-panel {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  align-items: end;
  justify-items: center;
  padding: 22px 14px calc(22px + env(safe-area-inset-bottom, 0px));
  background: rgba(6, 7, 8, 0.72);
  opacity: 0;
  pointer-events: none;
  transform: translateY(16px);
  transition: opacity 180ms ease, transform 180ms ease;
  backdrop-filter: blur(10px);
}

.preview-panel.is-open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.preview-sheet {
  width: min(100%, 430px);
  max-height: min(90vh, 760px);
  display: grid;
  gap: 12px;
  justify-items: center;
  overflow: auto;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 12px;
  background: rgba(13, 15, 17, 0.96);
  box-shadow: 0 26px 80px rgba(0, 0, 0, 0.55);
}

.preview-toolbar {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.preview-toolbar strong {
  font-size: 0.96rem;
  font-weight: 900;
}

.preview-close {
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 800;
}

.phone-frame {
  width: min(330px, calc(100vw - 64px), calc((100vh - 210px) * 0.5625));
  min-width: 220px;
  aspect-ratio: 9 / 16;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: #060708;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.42);
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 5px;
  background: #111;
}

.preview-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  text-align: center;
}

.preview-actions {
  width: 100%;
  display: grid;
}

.preview-actions .primary-action {
  min-height: 46px;
}

.preview-fab {
  position: fixed;
  right: calc(16px + env(safe-area-inset-right, 0px));
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  z-index: 45;
  min-height: 52px;
  padding: 0 18px;
  border: 0;
  border-radius: 999px;
  background: var(--accent-strong);
  color: #17130a;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.48);
  font-size: 0.95rem;
  font-weight: 900;
}

.preview-fab:active {
  transform: translateY(1px);
}

body.preview-open {
  overflow: hidden;
}

body.preview-open .preview-fab {
  display: none;
}

@media (min-width: 560px) {
  .app-shell {
    width: min(100%, 652px);
  }

  .drink-type-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 900px) {
  .app-shell {
    width: min(1180px, 100%);
    display: grid;
    grid-template-columns: minmax(320px, 440px) minmax(320px, 1fr);
    gap: 36px;
    align-items: center;
    padding: 24px;
  }

  .brand-block {
    margin-bottom: 26px;
    padding-top: 0;
  }

  h1 {
    font-size: clamp(2.6rem, 8vw, 5.4rem);
  }

  .intro {
    margin-top: 16px;
    font-size: 1rem;
    line-height: 1.65;
  }

  .field-grid {
    grid-template-columns: 1fr 1.15fr;
  }

  .drink-type-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .preview-fab,
  .preview-toolbar,
  .preview-actions {
    display: none;
  }

  body.preview-open {
    overflow: auto;
  }

  .preview-panel {
    position: static;
    inset: auto;
    z-index: auto;
    display: grid;
    align-items: center;
    justify-items: center;
    gap: 12px;
    padding: 0;
    background: transparent;
    opacity: 1;
    pointer-events: auto;
    transform: none;
    transition: none;
    backdrop-filter: none;
  }

  .preview-sheet {
    width: auto;
    max-height: none;
    overflow: visible;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }

  .phone-frame {
    width: min(420px, 76vw, calc((100vh - 84px) * 0.5625));
    min-width: 0;
  }
}
