/* 내 캐러셀 공장 — 공통 모양. 색은 요청문\캐러셀_디자인_기준.md 「2. 색」을 따른다. */

@font-face { font-family: "Pretendard"; font-weight: 400; font-style: normal; font-display: swap; src: url("/fonts/Pretendard-Regular.woff2") format("woff2"); }
@font-face { font-family: "Pretendard"; font-weight: 500; font-style: normal; font-display: swap; src: url("/fonts/Pretendard-Medium.woff2") format("woff2"); }
@font-face { font-family: "Pretendard"; font-weight: 600; font-style: normal; font-display: swap; src: url("/fonts/Pretendard-SemiBold.woff2") format("woff2"); }
@font-face { font-family: "Pretendard"; font-weight: 700; font-style: normal; font-display: swap; src: url("/fonts/Pretendard-Bold.woff2") format("woff2"); }
@font-face { font-family: "Pretendard"; font-weight: 800; font-style: normal; font-display: swap; src: url("/fonts/Pretendard-ExtraBold.woff2") format("woff2"); }

:root {
  --brand-1: #8134af;
  --brand-2: #dd2a7b;
  --insta: linear-gradient(135deg, #f58529, #dd2a7b, #8134af, #515bd4);
  --bg: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --white: #ffffff;
  --danger: #ef4444;
  --line: #e5e7eb;
  --soft: #f9fafb;
  --radius: 12px;
  --pad: 24px;
  --gap: 32px;
  --status-h: 52px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Pretendard", "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
  font-size: 17px;
  line-height: 1.6;
  word-break: keep-all;
  overflow-wrap: anywhere;
  padding-bottom: calc(var(--status-h) + 16px);
}

h1, h2, h3 { line-height: 1.3; margin: 0; }

/* ── 머리 부분 ── */
.top {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.top-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 16px 24px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.logo {
  font-size: 26px;
  font-weight: 800;
  background: var(--insta);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  min-width: 0;
}
.logo .ver {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  -webkit-text-fill-color: var(--muted);
  vertical-align: middle;
}

/* ── 탭 줄 ── */
.tabs {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: thin;
}
.tab {
  position: relative;
  flex: 0 0 auto;
  min-height: 52px;
  padding: 0 16px;
  border: 0;
  background: none;
  font: inherit;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  cursor: pointer;
}
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--text); font-weight: 700; }
.tab[aria-selected="true"]::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 0;
  height: 4px;
  border-radius: 4px 4px 0 0;
  background: var(--insta);
}
.tab:focus-visible { outline: 3px solid var(--brand-1); outline-offset: -3px; border-radius: 8px; }

/* ── 본문 ── */
.main {
  max-width: 1080px;
  margin: 0 auto;
  padding: var(--gap) 24px;
}
.panel > * + * { margin-top: var(--gap); }
.panel-desc { margin: 0; font-size: 19px; font-weight: 600; }

/* ── 공통 부품 ── */
.card {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: var(--pad);
  box-shadow: 0 1px 3px rgba(31, 41, 55, 0.06);
}

.empty {
  min-height: 240px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: center;
  background: var(--soft);
  border-style: dashed;
}
.empty p { margin: 0; max-width: 36em; }
.empty small { color: var(--muted); font-size: 15px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: var(--soft); }
.btn:focus-visible { outline: 3px solid var(--brand-1); outline-offset: 2px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary {
  border: 0;
  background: var(--insta);
  color: var(--white);
}
.btn-primary:hover { background: var(--insta); filter: brightness(1.05); }
.btn-danger {
  border: 1px solid var(--danger);
  color: var(--danger);
  background: var(--bg);
}
.btn-danger:hover { background: #fef2f2; }
.btn-ghost { border-color: transparent; }

.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.table th { font-weight: 700; color: var(--muted); font-size: 15px; }

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--brand-1);
  color: var(--white);
  font-size: 14px;
  font-weight: 700;
}
.chip {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--soft);
  font-size: 15px;
}

/* ── 입력 칸 ── */
.field + .field { margin-top: var(--pad); }
.field label, .field .label { display: block; font-weight: 700; margin-bottom: 8px; }
.field input, .field select, .field textarea {
  width: 100%;
  max-width: 320px;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid #d1d5db;
  border-radius: var(--radius);
  font: inherit;
  color: var(--text);
  background: var(--bg);
}
.field input:focus { outline: 3px solid rgba(129, 52, 175, 0.35); border-color: var(--brand-1); }
.field input[aria-invalid="true"] { border-color: var(--danger); }
.hint { margin: 6px 0 0; color: var(--muted); font-size: 15px; }
.error { margin: 6px 0 0; color: var(--danger); font-weight: 600; }
.readonly { margin: 0; font-size: 20px; font-weight: 700; }

/* ── 설정 판 ── */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(17, 24, 39, 0.45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 48px 16px calc(var(--status-h) + 16px);
  overflow-y: auto;
}
.overlay[hidden] { display: none; }
.sheet { width: 100%; max-width: 560px; }
.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: var(--pad);
}
.sheet-head h2 { font-size: 22px; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: var(--gap); }

/* 설정 판 — AI 연결 구역 */
.ai-box {
  margin-top: var(--gap);
  padding: 20px;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.ai-box h3 { font-size: 18px; margin-bottom: 12px; }
.ai-info { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0 0 16px; }
.ai-info dt { color: var(--muted); }
.ai-info dd { margin: 0; font-weight: 600; min-width: 0; }
.ai-info .is-bad { color: var(--danger); }
.ai-result { margin: 12px 0 0; font-weight: 600; }
.ai-result:empty { display: none; }
.ai-result.is-ok { color: #047857; }
.ai-result.is-bad { color: var(--danger); }
.ai-result small { display: block; color: var(--muted); font-weight: 400; font-size: 14px; }
.logs {
  margin: var(--pad) 0 0;
  max-height: 280px;
  overflow: auto;
  padding: 16px;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-family: Consolas, "D2Coding", monospace;
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ── ① 수집 ── */
.card-title { font-size: 20px; margin-bottom: var(--pad); }
.list-title { font-size: 20px; margin-bottom: 16px; }
.opt, .req { font-size: 13px; font-weight: 600; margin-left: 6px; color: var(--muted); }
.req { color: var(--brand-2); }
.ref-form .field input, .ref-form .field textarea { max-width: none; }
.field textarea { padding: 12px 14px; line-height: 1.5; resize: vertical; }
.field input[type="file"] { padding: 10px 14px; }
.field textarea:focus { outline: 3px solid rgba(129, 52, 175, 0.35); border-color: var(--brand-1); }
.field textarea[aria-invalid="true"] { border-color: var(--danger); }
.field-row { display: grid; grid-template-columns: 160px 1fr; gap: var(--pad); margin-top: var(--pad); }
.field-row .field + .field { margin-top: 0; }
.field-row + .field { margin-top: var(--pad); }
.ref-form .actions { margin-top: var(--pad); }
.ref-form .error { margin-top: var(--pad); }
.howto { margin: 0; padding-left: 1.4em; text-align: left; }
.ref-list { display: flex; flex-direction: column; gap: 16px; }
.ref { padding: 16px; }
.ref-head { display: flex; gap: 16px; align-items: flex-start; cursor: pointer; border-radius: 8px; }
.ref-head:focus-visible { outline: 3px solid var(--brand-1); outline-offset: 4px; }
.ref-thumb { flex: 0 0 auto; width: 96px; height: 120px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); background: #e5e7eb; }
.ref-thumb-none { display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 14px; }
.ref-text { min-width: 0; flex: 1; }
.ref-text p { margin: 0; }
.ref-cap { font-weight: 600; }
.ref-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px !important; color: var(--muted); font-size: 15px; }
.ref-note { margin-top: 6px !important; font-size: 15px; }
.ref-body { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.ref-full { margin: 0 0 16px; white-space: pre-wrap; }
.ref-shots { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.ref-shots img { flex: 0 0 auto; height: 280px; width: auto; border-radius: 8px; border: 1px solid var(--line); }
.ref-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; justify-content: flex-end; }
.ref-actions .btn { min-height: 44px; text-decoration: none; }
#ref-usage { margin-top: 16px; }
#ref-usage.is-warn { color: #b45309; font-weight: 700; }

/* ── 아래 공통 상태 줄 ── */
.status {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 60;
  min-height: var(--status-h);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: var(--bg);
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 16px;
}
.status.is-busy { color: var(--text); font-weight: 600; }
.status.is-toast { color: var(--white); background: var(--text); font-weight: 600; }
.status.is-error { color: var(--white); background: var(--danger); font-weight: 600; }

/* ── 모바일 ── */
@media (max-width: 720px) {
  .top-inner { padding: 12px 16px 4px; }
  .logo { font-size: 22px; }
  .tabs { padding: 0 8px; }
  .tab { padding: 0 12px; }
  .main { padding: 24px 16px; }
  .card { padding: 20px; }
  .field input, .field select, .field textarea { max-width: none; }
  .actions { flex-direction: column; }
  .actions .btn { width: 100%; }
  .ai-box { padding: 16px; }
  .ai-box .btn { width: 100%; }
  .overlay { padding: 16px 12px calc(var(--status-h) + 12px); }
  .status { padding: 10px 16px; }
  .field-row { grid-template-columns: 1fr; }
  .ref-thumb { width: 72px; height: 90px; }
  .ref-shots img { height: 220px; }
}
