:root {
  --bg: #f6f4ef;
  --card: #ffffff;
  --ink: #1b1b1d;
  --muted: #7a776f;
  --line: #e5e1d8;
  --accent: #ff6a3d;
  --accent-ink: #ffffff;
  --soft: #ece8df;
  --radius: 16px;
  /* 아래 값들은 관리자 > 디자인에서 바꾸면 덮어써짐 (inc/theme_css.php) */
  --on-ink: #ffffff;          /* 진한 버튼(검색·선택된 스타일) 위 글씨 */
  --accent-soft: #fff4f0;     /* 선택된 비율·좋아요 버튼 배경 */
  --gap: 14px;                /* 갤러리 이미지 사이 간격 */
  --item-shadow: none;        /* 갤러리 이미지 그림자 */
  --item-shadow-hover: none;
  --item-zoom: 1.04;          /* 마우스 올렸을 때 확대 */
  --box-shadow: 0 10px 30px -18px rgba(0,0,0,.25);   /* 입력창 그림자 */
  --overlay: rgba(20,18,15,.6);                       /* 상세창 뒤 어둡게 */
  --modal-bg: var(--card);
  --modal-ink: var(--ink);
  --modal-muted: var(--muted);
  --modal-line: var(--line);
  --modal-soft: var(--soft);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Pretendard Variable", Pretendard, -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }

.top { padding: 18px 24px; }
.logo { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; letter-spacing: -0.02em; color: var(--ink); text-decoration: none; }
.logo-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); }

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 24px 80px; }

/* ---------- 상단 ---------- */
.hero { max-width: 720px; margin: 40px auto 28px; text-align: center; }
.hero h1 { margin: 0; font-size: clamp(30px, 5vw, 46px); line-height: 1.2; letter-spacing: -0.035em; font-weight: 800; }
.sub { margin: 14px 0 0; color: var(--muted); }

.gen { max-width: 720px; margin: 0 auto; }

.search { display: flex; gap: 8px; flex: 1; max-width: 560px; }
.search input {
  flex: 1; min-width: 0; height: 48px; padding: 0 18px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--card); outline: none;
}
.search input:focus { border-color: var(--ink); }
.search button {
  height: 48px; padding: 0 22px; border: 0; border-radius: 999px;
  background: var(--ink); color: var(--on-ink); font-weight: 600; cursor: pointer;
}

.gen {
  background: var(--card); border: 1px solid var(--line); border-radius: 22px;
  padding: 18px 18px 14px; box-shadow: var(--box-shadow);
  transition: box-shadow .2s;
}
.gen:focus-within { box-shadow: var(--box-shadow), 0 0 0 1px var(--line); }
.gen textarea {
  width: 100%; height: 96px; resize: none; border: 0; outline: none; background: transparent;
  font-size: 17px; line-height: 1.6; transition: height .2s;
}
.ratios { display: flex; gap: 6px; padding: 4px 0 8px; }
.ratio-chip {
  display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--line); background: var(--bg); color: var(--muted);
  border-radius: 10px; padding: 6px 12px; font-size: 13px; cursor: pointer; transition: all .15s;
}
.ratio-chip i { display: inline-block; height: 14px; border: 1.5px solid currentColor; border-radius: 3px; }
.ratio-chip i[style*="1280 / 720"] { height: 11px; }
.ratio-chip:hover { color: var(--ink); border-color: var(--ink); }
.ratio-chip.on { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.styles {
  display: flex; flex-wrap: nowrap; gap: 5px; padding: 4px 0 12px;
  overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.styles::-webkit-scrollbar { display: none; }
/* 넘칠 때만 오른쪽 끝을 흐리게 → 옆으로 더 있다는 표시 */
.styles.more-right { -webkit-mask-image: linear-gradient(90deg, #000 88%, transparent); mask-image: linear-gradient(90deg, #000 88%, transparent); }
.style-chip {
  flex: none; white-space: nowrap;
  border: 1px solid var(--line); background: var(--bg); color: var(--muted);
  border-radius: 999px; padding: 5px 10px; font-size: 13px; cursor: pointer; transition: all .15s;
}
.style-chip:hover { color: var(--ink); border-color: var(--ink); }
.style-chip.on { background: var(--ink); border-color: var(--ink); color: var(--on-ink); font-weight: 600; }
.gen-foot { display: flex; align-items: center; gap: 14px; padding-top: 10px; border-top: 1px solid var(--soft); }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: var(--muted); cursor: pointer; }
.check input { accent-color: var(--accent); }
.count { margin-left: auto; font-size: 13px; color: var(--muted); }
.msg { margin: 10px 2px 0; font-size: 14px; color: var(--muted); min-height: 0; }
.msg:empty { display: none; }
.msg.err { color: #d23b1f; }

.btn-primary, .btn-line {
  display: inline-flex; align-items: center; justify-content: center;
  height: 44px; padding: 0 22px; border-radius: 999px; font-weight: 700;
  text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn-primary { border: 0; background: var(--accent); color: var(--accent-ink); }
.btn-primary:disabled { opacity: .5; cursor: default; }
.btn-line { border: 1px solid var(--line); background: var(--card); color: var(--ink); }
.link { border: 0; background: none; padding: 0; color: var(--muted); font-size: 14px; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }

/* ---------- 생성 결과 ---------- */
.result { max-width: 720px; margin: 18px auto 0; }
.result-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; align-items: start; }
.result-grid.r-16x9 { grid-template-columns: 1fr 1fr; }
.result-grid.r-16x9 .slot:first-child { grid-column: 1 / -1; }
.slot { position: relative; aspect-ratio: 1; border-radius: var(--radius); overflow: hidden; background: var(--soft); }
.slot img { display: block; }
.slot.loading::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(100deg, transparent 20%, rgba(255,255,255,.55) 50%, transparent 80%);
  animation: shimmer 1.4s infinite;
}
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
.slot img { width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; animation: fadein .4s; }
@keyframes fadein { from { opacity: 0; transform: scale(.98); } to { opacity: 1; transform: none; } }
.slot .dl {
  position: absolute; right: 8px; bottom: 8px; height: 34px; padding: 0 14px; border-radius: 999px;
  background: rgba(255,255,255,.92); color: #1b1b1d; font-size: 13px; font-weight: 700;
  text-decoration: none; display: inline-flex; align-items: center;
}
.slot .fail { position: absolute; inset: 0; display: grid; place-items: center; padding: 12px; text-align: center; font-size: 13px; color: var(--muted); }

.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.tag {
  border: 1px solid var(--line); background: var(--card); border-radius: 999px;
  padding: 4px 12px; font-size: 13px; color: var(--ink); cursor: pointer;
}
.tag:hover { border-color: var(--ink); }

/* ---------- 리스트 ---------- */
.list { margin-top: 64px; }
.list-head { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; }
.search-info { margin: -4px 0 16px; font-size: 14px; color: var(--muted); }
.search-info b, #searchText { color: var(--ink); font-weight: 600; }
.sort { display: flex; gap: 4px; margin-left: auto; background: var(--soft); padding: 4px; border-radius: 999px; }
.sort button { border: 0; background: none; padding: 6px 14px; border-radius: 999px; font-size: 14px; color: var(--muted); cursor: pointer; }
.sort button.on { background: var(--card); color: var(--ink); font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,.08); }

.grid { display: flex; gap: var(--gap); align-items: flex-start; }   /* 열 개수는 JS가 정함: PC 6, 태블릿 4, 모바일 2 */
.mcol { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: var(--gap); }
.item { position: relative; display: block; width: 100%; border-radius: var(--radius); overflow: hidden; background: var(--soft); cursor: zoom-in; border: 0; padding: 0;
        box-shadow: var(--item-shadow); transition: box-shadow .25s, transform .25s; }
.item:hover { box-shadow: var(--item-shadow-hover); }
.item img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform .35s; }
.item:hover img { transform: scale(var(--item-zoom)); }
.item .cap {
  position: absolute; inset: auto 0 0 0; padding: 28px 12px 10px; font-size: 13px; color: #fff; text-align: left;
  background: linear-gradient(transparent, rgba(0,0,0,.55)); opacity: 0; transition: opacity .25s;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.item:hover .cap { opacity: 1; }

.ad-tile { display: block; border: 1px solid var(--line); background: var(--card); cursor: pointer; text-decoration: none; color: inherit; }
.ad-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ad-html { width: 100%; height: 100%; display: grid; place-items: center; overflow: hidden; }
.ad-badge {
  position: absolute; top: 8px; left: 8px; padding: 1px 7px; border-radius: 99px;
  background: rgba(0,0,0,.5); color: #fff; font-size: 11px; font-weight: 600; letter-spacing: .04em; pointer-events: none;
}

/* 입력창 위 / 생성 결과 아래 가로 배너 */
.ad-strip { position: relative; max-width: 720px; margin: 0 auto 14px; border-radius: 12px; overflow: hidden; text-align: center; }
.ad-strip img { width: 100%; height: auto; display: block; }
.ad-strip a { display: block; }
.ad-strip .ad-badge { top: 6px; left: 6px; }
.ad-mid { margin-top: 18px; }

/* 상세 창 배너 (오른쪽 아래) */
.m-ad { margin-top: auto; }
.m-ad .ad-tile { position: relative; display: block; border-radius: 12px; overflow: hidden; }
.m-ad .ad-tile img { width: 100%; height: auto; display: block; }
.m-ad .ad-html { min-height: 120px; }

.empty { text-align: center; color: var(--muted); padding: 40px 0; }
.more-wrap { display: flex; justify-content: center; margin-top: 28px; }
.btn-more {
  height: 48px; min-width: 200px; padding: 0 28px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  font-weight: 600; cursor: pointer; transition: border-color .15s;
}
.btn-more:hover { border-color: var(--ink); }
.btn-more:disabled { color: var(--muted); cursor: default; }

/* ---------- 모달 ---------- */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; }
.modal-back { position: absolute; inset: 0; background: var(--overlay); }
.modal-box {
  position: relative; display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 24px;
  width: min(980px, 100%); max-height: calc(100vh - 40px); overflow: auto;
  background: var(--modal-bg); color: var(--modal-ink); border-radius: 22px; padding: 20px;
  /* 상세창 안에서는 상세창 전용 색을 씀 */
  --card: var(--modal-bg); --ink: var(--modal-ink); --muted: var(--modal-muted); --line: var(--modal-line); --soft: var(--modal-soft);
}
.modal-img { display: flex; justify-content: center; align-items: flex-start; }
.modal-img img { max-width: 100%; max-height: calc(100vh - 80px); width: auto; height: auto; border-radius: 14px; object-fit: contain; background: var(--soft); }
.modal-img img:not([src]) { width: 100%; aspect-ratio: 1; }
.modal-x { position: absolute; top: 10px; right: 14px; border: 0; background: none; font-size: 28px; line-height: 1; color: var(--muted); cursor: pointer; z-index: 1; }
.modal-side { display: flex; flex-direction: column; gap: 14px; padding-top: 18px; }
.preview { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--muted); }
.circle { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; box-shadow: 0 0 0 3px var(--card), 0 0 0 4px var(--line); }
.m-text { margin: 0; font-size: 15px; }
.m-text::before { content: "만든 문장"; display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.modal-side .tags { margin-top: 0; }
.m-actions { display: flex; gap: 8px; }
.m-actions .btn-primary { flex: 1; }
.m-react { display: flex; align-items: center; gap: 8px; }
.react {
  display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--card); color: var(--muted);
  font-size: 14px; cursor: pointer; transition: all .15s;
}
.react svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.react:hover { color: var(--ink); border-color: var(--ink); }
.react.on { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.react.on svg { fill: currentColor; fill-opacity: .15; }
.report-link { margin-left: auto; font-size: 13px; }
.m-report { display: flex; flex-direction: column; gap: 6px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); font-size: 14px; }
.m-report-title { margin: 0 0 2px; font-weight: 600; }
.m-report label { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.m-report input { accent-color: var(--accent); }
.m-report textarea { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; resize: none; font-size: 13px; background: var(--card); }
.m-report-foot { display: flex; justify-content: flex-end; align-items: center; gap: 12px; }
.btn-sm { height: 34px; padding: 0 16px; font-size: 13px; }
.m-stat { margin: 0; font-size: 12px; color: var(--muted); }
body.noscroll { overflow: hidden; }

/* ---------- 모바일 ---------- */
@media (max-width: 720px) {
  .wrap { padding: 0 16px 60px; }
  .top { padding: 14px 16px; }
  .hero { margin: 20px auto 20px; }
  .result-grid { gap: 8px; }
  .grid, .mcol { gap: calc(var(--gap) * .7); }
  .list { margin-top: 44px; }
  .list-head { flex-direction: column; align-items: stretch; gap: 10px; }
  .search { max-width: none; }
  .sort { margin-left: 0; align-self: flex-start; }
  .item .cap { display: none; }

  /* 생성 박스: 평소 한 줄, 터치하면 펼침 */
  .gen { padding: 10px 14px; border-radius: 18px; }
  .gen:not(.open) textarea { height: 28px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
  .gen:not(.open) .gen-foot, .gen:not(.open) .styles, .gen:not(.open) .ratios { display: none; }
  .gen.open textarea { height: 110px; }

  .modal { padding: 0; place-items: end center; }
  .modal-box { grid-template-columns: 1fr; border-radius: 22px 22px 0 0; max-height: 92vh; padding: 16px; gap: 12px; }
  .modal-side { padding-top: 0; }
}

/* ---------- 하단 ---------- */
.foot { border-top: 1px solid var(--line); margin-top: 40px; }
.foot-in { max-width: 1180px; margin: 0 auto; padding: 24px; display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.foot nav { display: flex; gap: 16px; }
.foot a { color: var(--muted); text-decoration: none; }
.foot a:hover { color: var(--ink); }
.foot b { color: var(--ink); font-weight: 600; }
.foot p { margin: 0; }

/* ---------- 약관 페이지 ---------- */
.doc { max-width: 760px; margin: 24px auto 0; background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 36px 40px; line-height: 1.75; }
.doc h1 { font-size: 26px; letter-spacing: -0.02em; margin: 0 0 20px; }
.doc h2 { font-size: 17px; margin: 30px 0 8px; }
.doc h3 { font-size: 15px; margin: 20px 0 6px; }
.doc p { margin: 0 0 12px; }
.doc ul { margin: 0 0 12px; padding-left: 20px; }
.doc li { margin-bottom: 4px; }
@media (max-width: 720px) { .doc { padding: 24px 18px; border-radius: 14px; } .foot-in { padding: 20px 16px; } }

/* ---------- 문의 팝업 ---------- */
.contact { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 20px; }
.contact-back { position: absolute; inset: 0; background: var(--overlay); }
.contact-card { position: relative; width: min(420px, 100%); background: var(--modal-bg); color: var(--modal-ink); border-radius: 18px; padding: 26px 24px 22px; text-align: center; }
.contact-card h3 { margin: 0 0 8px; font-size: 19px; }
.contact-card p { margin: 0 0 16px; font-size: 14px; color: var(--modal-muted); }
.contact-mail { padding: 14px; border-radius: 12px; background: var(--modal-soft); font-size: 17px; font-weight: 600; word-break: break-all; user-select: all; margin-bottom: 16px; }
.contact-actions { display: flex; gap: 8px; justify-content: center; }
.contact-actions .btn-line { background: var(--modal-bg); color: var(--modal-ink); border-color: var(--modal-line); }
.contact-x { position: absolute; top: 8px; right: 12px; border: 0; background: none; font-size: 26px; color: var(--modal-muted); cursor: pointer; }
