@font-face {
  font-family: "Pretendard";
  src: url("./PretendardVariable.ttf") format("truetype");
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
}

@font-face {
  font-family: "BookkMyungjo-Lt";
  src: url("https://cdn.jsdelivr.net/gh/woffz/a1@main/Bookk/BookkMyungjo-Lt.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

:root {
  --app-bg: #f7f7f7;
  --ink: #111111;
  --line: #1b1b1b;
  --accent-color: hsl(220 82% 48%);
  --accent-soft: hsl(220 70% 42% / 0.34);
  --ui-font-stack: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  color: var(--ink);
  font-family: var(--ui-font-stack);
}

button,
input,
select,
textarea {
  font-family: var(--ui-font-stack);
}

html {
  background: var(--app-bg);
}

body {
  background-color: var(--app-bg);
  background-image:
    linear-gradient(
      to bottom,
      rgba(247, 247, 247, 1) 0%,
      rgba(247, 247, 247, 0) 14%,
      rgba(247, 247, 247, 0) 86%,
      rgba(247, 247, 247, 1) 100%
    ),
    repeating-linear-gradient(
      to right,
      rgba(0, 0, 0, 0.045) 0,
      rgba(0, 0, 0, 0.045) 1px,
      transparent 1px,
      transparent 28px
    ),
    repeating-linear-gradient(
      to bottom,
      rgba(0, 0, 0, 0.045) 0,
      rgba(0, 0, 0, 0.045) 1px,
      transparent 1px,
      transparent 28px
    );
  background-attachment: fixed;
  overflow-x: hidden;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.app-shell {
  min-height: 100vh;
  padding: calc(env(safe-area-inset-top) + 106px) 10px calc(env(safe-area-inset-bottom) + 112px);
}

.top-bar {
  position: fixed;
  left: 50%;
  width: min(calc(100% - 24px), 576px);
  transform: translateX(-50%);
  bottom: calc(env(safe-area-inset-bottom) + 12px);
  z-index: 30;
  margin: 0;
  padding: 4px;
  background: #e2e2e2;
  border: 0.5px solid rgba(0, 0, 0, 0.1);
  border-radius: 99px;
  box-shadow: 0 0 0 1px #ffffff, 0 8px 24px rgba(0, 0, 0, 0.05);
}

.style-carousel {
  display: flex;
  gap: 4px;
  width: 100%;
  padding-left: max(0px, calc((100% - 48px) / 2));
  padding-right: max(0px, calc((100% - 48px) / 2));
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-padding-left: max(0px, calc((100% - 48px) / 2));
  scroll-padding-right: max(0px, calc((100% - 48px) / 2));
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.style-carousel::-webkit-scrollbar {
  display: none;
}

.style-chip {
  flex: 0 0 auto;
  scroll-snap-align: center;
}

.style-chip-btn {
  display: grid;
  place-items: center;
  min-width: 48px;
  width: 48px;
  height: 48px;
  padding: 0;
  border-radius: 99px;
  border: 0.5px solid rgba(0, 0, 0, 0.1);
  background: transparent;
  transition: opacity 120ms ease, background-color 120ms ease;
  cursor: pointer;
}

.style-thumb {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 0.5px solid rgba(17, 17, 17, 0.16);
  box-shadow: none;
  overflow: hidden;
}

.style-thumb-text {
  display: inline-block;
  white-space: nowrap;
  line-height: 1;
  user-select: none;
}

.style-thumb-text-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transform-origin: center center;
  will-change: transform;
}

.style-name {
  display: none;
}

.style-chip:not(.active) .style-chip-btn {
  opacity: 0.33;
}

.style-chip.active .style-chip-btn {
  background: #ffffff;
  border-color: rgba(0, 0, 0, 0.1);
  opacity: 1;
}

.style-chip.active .style-thumb {
  border-color: rgba(17, 17, 17, 0.16);
}

.editor-root {
  display: grid;
  gap: 4px;
  margin-top: 4px;
  width: min(100%, 600px);
  margin-left: auto;
  margin-right: auto;
}

.block-set {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 375px;
}

.section-controls {
  position: absolute;
  top: 50%;
  left: max(2px, calc(50% - 184px));
  transform: translateY(-50%);
  width: 26px;
  height: 375px;
  z-index: 4;
}

.section-move-controls {
  position: absolute;
  top: 50%;
  left: 0;
  transform: translateY(-50%);
  width: 26px;
  display: grid;
  gap: 4px;
}

.section-ctrl-btn {
  width: 26px;
  height: 26px;
  border: 0.5px solid rgba(0, 0, 0, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.7);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  color: #111111;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  display: grid;
  place-items: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  cursor: pointer;
}

.section-ctrl-btn-delete {
  position: absolute;
  left: 0;
  bottom: 8px;
}

.section-ctrl-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

.carousel-shell {
  position: relative;
  width: clamp(300px, 100%, 600px);
  margin: 0 auto;
  overflow: hidden;
  --edge-fade: clamp(14px, 8%, 44px);
}

.carousel-track {
  display: flex;
  gap: 14px;
  width: 100%;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-snap-stop: always;
  overscroll-behavior-x: contain;
  touch-action: auto;
  padding-left: max(0px, calc((100% - 300px) / 2));
  padding-right: max(0px, calc((100% - 300px) / 2));
  scroll-padding-left: max(0px, calc((100% - 300px) / 2));
  scroll-padding-right: max(0px, calc((100% - 300px) / 2));
  scrollbar-width: none;
  cursor: grab;
  -webkit-mask-image: linear-gradient(
    to right,
    transparent 0,
    #000000 var(--edge-fade),
    #000000 calc(100% - var(--edge-fade)),
    transparent 100%
  );
  mask-image: linear-gradient(
    to right,
    transparent 0,
    #000000 var(--edge-fade),
    #000000 calc(100% - var(--edge-fade)),
    transparent 100%
  );
  -webkit-mask-size: 100% 100%;
  mask-size: 100% 100%;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
}

.carousel-track::-webkit-scrollbar {
  display: none;
}

.carousel-track.is-dragging {
  cursor: grabbing;
}

.template-slide {
  flex: 0 0 300px;
  width: 300px;
  height: 375px;
  scroll-snap-align: start;
  padding: 0;
}

.template-canvas {
  width: 300px;
  height: 375px;
  border: 0;
  background: var(--frame-bg, #ffffff);
  color: var(--frame-fg, #111111);
  padding: 16px;
  display: grid;
  gap: 12px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 0 0 1px #ffffff;
}

.template-root-shadow-layer {
  position: absolute;
  pointer-events: none;
  z-index: 0;
  background: transparent;
}

.layout-hero-bottom {
  grid-template-rows: 1fr 148px;
}

.layout-image-top {
  grid-template-rows: 148px 1fr;
}

.layout-reviews {
  grid-template-rows: auto auto 1fr 82px;
}

.layout-designer {
  display: block;
  padding: 0;
  gap: 0;
}

.layout-designer .designer-node {
  position: relative;
  min-width: 10px;
  min-height: 10px;
}

.layout-designer > .designer-node {
  z-index: 1;
}

.layout-designer .designer-text-node {
  white-space: pre-wrap;
  word-break: keep-all;
  outline: none;
  font-family: inherit;
}

.text-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.editable {
  outline: none;
  min-height: 1em;
  white-space: pre-wrap;
  word-break: keep-all;
  font-family: inherit;
}

.editable.is-editing {
  opacity: 0.5 !important;
}

.editable:focus {
  outline: 1px solid rgba(17, 17, 17, 0.42);
  outline-offset: -1px;
}

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

.review-card {
  border: 1px solid var(--accent-soft, rgba(17, 17, 17, 0.34));
  border-radius: 10px;
  padding: 8px;
  font-size: 12px;
  line-height: 1.4;
  background: rgba(17, 17, 17, 0.02);
}

.image-slot {
  position: relative;
  display: block;
  -webkit-appearance: none;
  appearance: none;
  border: 1px solid var(--accent-soft, rgba(17, 17, 17, 0.24));
  border-radius: 10px;
  background: #ececec;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  color: #222222;
  width: 100%;
  height: 100%;
  cursor: pointer;
  overflow: hidden;
}

.image-slot span {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  text-align: center;
  font-family: var(--ui-font-stack);
  font-size: 12px;
  padding: 10px;
  z-index: 1;
}

.image-slot:not(.has-image)::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    135deg,
    rgba(17, 17, 17, 0.06) 0 8px,
    rgba(17, 17, 17, 0) 8px 16px
  );
}

.image-slot.has-image {
  border-style: solid;
  background-size: cover !important;
  background-position: center center;
  background-repeat: no-repeat;
}

.icon-slot {
  position: relative;
  border: 1px dashed var(--accent-soft, rgba(17, 17, 17, 0.5));
  border-radius: 8px;
  background: color-mix(in srgb, var(--accent-color, #111111) 10%, transparent);
  color: var(--accent-color, #111111);
  display: grid;
  place-items: center;
  cursor: default;
  overflow: hidden;
}

.icon-slot span {
  font-size: 9px;
  line-height: 1;
  font-weight: 600;
  letter-spacing: 0.04em;
  opacity: 0.66;
}

.icon-slot.has-icon {
  border-style: solid;
  background: currentColor;
}

.editor-actions {
  width: 300px;
  max-width: 300px;
  margin: 12px auto 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.add-block-btn {
  width: 146px;
  min-width: 146px;
  height: 40px;
  margin: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 999px;
  background: #111111;
  min-height: 40px;
  padding: 0 14px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  cursor: pointer;
}

.add-block-btn:active {
  background: #000000;
}

.download-btn {
  width: 146px;
  min-width: 146px;
  height: 40px;
  margin: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0.5px solid rgba(0, 0, 0, 0.1);
  border-radius: 999px;
  background: #ffffff;
  min-height: 40px;
  padding: 0 14px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  color: #111111;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
  cursor: pointer;
}

.download-btn:active {
  background: #f4f4f4;
}

.download-btn:disabled {
  opacity: 0.7;
  cursor: wait;
}

.add-icon,
.download-icon {
  width: 20px;
  height: 20px;
  object-fit: contain;
}

.add-label {
  line-height: 1;
  white-space: nowrap;
}

.download-label {
  line-height: 1;
  white-space: nowrap;
}

.empty-state {
  border: 1px dashed #252525;
  border-radius: 14px;
  background: #ffffff;
  padding: 18px;
  text-align: center;
  font-family: var(--ui-font-stack);
  font-size: 13px;
}

.template-canvas .editable[data-role="title"] {
  color: var(--accent-color, var(--frame-fg, #111111));
}

[data-template-theme="dark"] .template-canvas .editable[data-role="body"] {
  color: rgba(242, 242, 242, 0.9);
}

[data-template-theme="dark"] .template-canvas .review-card {
  background: rgba(255, 255, 255, 0.04);
}

[data-template-theme="dark"] .template-canvas .image-slot {
  background: #202020;
  color: #f1f1f1;
}

[data-template-theme="dark"] .template-canvas .icon-slot {
  border-color: rgba(255, 255, 255, 0.36);
  background: rgba(255, 255, 255, 0.08);
}

[data-template-theme="dark"] .template-canvas .editable:focus {
  outline-color: rgba(255, 255, 255, 0.42);
}

.top-controls {
  position: fixed;
  left: 50%;
  top: calc(env(safe-area-inset-top) + 12px);
  width: min(calc(100% - 24px), 576px);
  transform: translateX(-50%);
  z-index: 31;
}

.top-meta {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2px;
  margin-bottom: 8px;
}

.top-logo {
  height: 20px;
  width: auto;
  object-fit: contain;
  display: block;
}

.auth-btn {
  height: 32px;
  padding: 0 12px;
  border: 0.5px solid rgba(0, 0, 0, 0.1);
  border-radius: 999px;
  background: #ffffff;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  color: #111111;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  cursor: pointer;
}

.bottom-tabs {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) 36px;
  gap: 4px;
  padding: 4px;
  background: rgba(226, 226, 226, 0.5);
  border: 0.5px solid rgba(0, 0, 0, 0.1);
  border-radius: 99px;
  box-shadow: 0 0 0 1px #ffffff, 0 8px 24px rgba(0, 0, 0, 0.05);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
}

.tab-btn {
  min-height: 36px;
  height: 36px;
  padding: 0 12px;
  border: 0.5px solid rgba(0, 0, 0, 0.1);
  border-radius: 999px;
  background: transparent;
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: #111111;
  transition: opacity 120ms ease, background-color 120ms ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  cursor: pointer;
}

.tab-icon {
  width: 20px;
  height: 20px;
  object-fit: contain;
}

.tab-btn:not(.active) {
  opacity: 0.33;
}

.tab-btn.active {
  background: #ffffff;
  color: #111111;
  opacity: 1;
}

.tab-label {
  line-height: 1;
}

.hue-toggle {
  width: 36px;
  height: 36px;
  border: 0.5px solid rgba(0, 0, 0, 0.1);
  border-radius: 50%;
  background: #ffffff;
  display: grid;
  place-items: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  cursor: pointer;
}

.hue-toggle::before {
  content: "";
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 0.5px solid rgba(0, 0, 0, 0.14);
  background: var(--accent-color, #111111);
}

.hue-toggle.active {
  background: #ffffff;
}

.hue-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: min(260px, calc(100vw - 24px));
  padding: 10px;
  border-radius: 12px;
  background: #ffffff;
  border: 0.5px solid rgba(0, 0, 0, 0.12);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}

.hue-label {
  display: block;
  margin-bottom: 8px;
  font-size: 12px;
  line-height: 1.3;
}

.hue-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hue-slider {
  width: 100%;
  flex: 1;
  height: 24px;
  margin: 0;
  padding: 0 2px;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  border-radius: 999px;
  border: 0;
  background: transparent;
}

.hue-slider::-webkit-slider-runnable-track {
  height: 20px;
  border-radius: 999px;
  background: linear-gradient(
    to right,
    hsl(0 90% 55%),
    hsl(60 90% 55%),
    hsl(120 90% 55%),
    hsl(180 90% 55%),
    hsl(240 90% 55%),
    hsl(300 90% 55%),
    hsl(360 90% 55%)
  );
}

.hue-slider::-moz-range-track {
  height: 20px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(
    to right,
    hsl(0 90% 55%),
    hsl(60 90% 55%),
    hsl(120 90% 55%),
    hsl(180 90% 55%),
    hsl(240 90% 55%),
    hsl(300 90% 55%),
    hsl(360 90% 55%)
  );
}

.hue-slider::-webkit-slider-thumb {
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 0;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.hue-slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 0;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.neutral-tone {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 0.5px solid rgba(0, 0, 0, 0.16);
  background: #ffffff;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.neutral-tone::before {
  content: "";
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--tone-swatch, #111111);
}

.neutral-tone.active {
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.12);
}

@media (max-width: 360px) {
  .app-shell {
    padding-left: 0;
    padding-right: 0;
  }

  .editor-root {
    padding: 0;
  }
}
