/* 모바일 우선 — 한 컬럼, 큰 탭 타깃 */
:root {
  --bg: #faf8f5;
  --card: #ffffff;
  --ink: #2b2723;
  --muted: #8a817a;
  --line: #e7e1d9;
  --accent: #c2410c;
  --ok: #15803d;
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  padding-bottom: 40px;
}
.hidden { display: none !important; }
.muted { color: var(--muted); font-weight: 400; font-size: 0.85em; }
.err { color: var(--accent); font-size: 0.9em; min-height: 1.2em; }

.topbar {
  position: sticky; top: 0; z-index: 10;
  background: var(--card); border-bottom: 1px solid var(--line);
  padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top));
}
.topbar strong { display: block; margin-bottom: 8px; }
.tabs { display: flex; gap: 8px; }
.tab {
  flex: 1; padding: 12px; border: 1px solid var(--line); border-radius: 999px;
  background: transparent; color: var(--muted); font-size: 15px; cursor: pointer;
}
.tab.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.badge {
  display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 999px;
  background: rgba(255,255,255,.25); font-size: 12px;
}

.tab-panel { max-width: 640px; margin: 0 auto; padding: 16px; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-bottom: 16px; display: flex; flex-direction: column; gap: 12px;
}
label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 14px; }
input, textarea, select {
  width: 100%; padding: 12px; border: 1px solid var(--line); border-radius: 10px;
  font-size: 16px; background: #fff; color: var(--ink); font-family: inherit;
}
textarea { resize: vertical; }
button { font-family: inherit; }
.primary {
  background: var(--accent); color: #fff; border: none; border-radius: 10px;
  padding: 14px; font-size: 16px; font-weight: 700; cursor: pointer;
}
.primary:disabled { opacity: .6; }
.ghost {
  background: #fff; color: var(--ink); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; font-size: 14px; cursor: pointer;
}

.warn { max-width: 640px; margin: 12px auto 0; padding: 10px 16px; color: var(--accent);
  background: #fff3ed; border: 1px solid #f6d3c1; border-radius: 10px; font-size: 14px; }

/* 결과 카드 / 큐 카드 */
.post { gap: 10px; }
.post h3 { margin: 0; font-size: 17px; }
.post .meta { color: var(--muted); font-size: 13px; }
.status-chip { display: inline-block; padding: 3px 10px; border-radius: 999px;
  background: #f0ebe3; font-size: 12px; font-weight: 700; }
/* 충분성 게이트 판정 칩 */
.mode-chip { display: inline-block; margin-left: 6px; padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 700; }
.mode-info { background: #e6f4ec; color: var(--ok); }
.mode-impression { background: #f0ebe3; color: var(--muted); }

/* 수집된 장소 사실(그라운딩) — 접힘 기본, read-only. 기존 카드 톤 재사용 */
.facts { border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.facts-summary {
  list-style: none; cursor: pointer; user-select: none;
  display: flex; align-items: center; gap: 8px;
  padding: 9px 12px; font-size: 13px; font-weight: 700; color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}
.facts-summary::-webkit-details-marker { display: none; }
.facts-ico { font-size: 13px; line-height: 1; }
.facts-label { flex: 1; min-width: 0; }
.facts-count {
  display: inline-block; min-width: 18px; text-align: center;
  padding: 1px 8px; border-radius: 999px; background: #f0ebe3;
  font-size: 12px; font-weight: 700; color: var(--muted);
}
.facts-summary::after {
  content: "⌄"; color: var(--muted); font-size: 14px; line-height: 1;
  transform: translateY(-2px); transition: transform .15s ease;
}
.facts[open] .facts-summary::after { transform: translateY(1px) rotate(180deg); }
.facts[open] .facts-summary { border-bottom: 1px solid var(--line); }
.facts-summary:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 10px; }
.facts-list {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 10px 12px 12px; max-height: 168px; overflow-y: auto;
  -webkit-overflow-scrolling: touch; overscroll-behavior: contain;  /* 부모 카드 스크롤 체이닝 차단 */
}
.facts-list:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 0 0 10px 10px; }
.fact-chip {
  display: inline-block; max-width: 100%;
  padding: 5px 10px; border-radius: 999px;
  border: 1px solid var(--line); background: #faf8f5;
  font-size: 12px; font-weight: 400; color: var(--muted);
  line-height: 1.45; overflow-wrap: anywhere; cursor: default;  /* 토큰 통째로 유지, 불가피할 때만 분리 */
}
/* 사실 출처 배지: [verified]=공식(녹색) / [blog]=블로그(muted) */
.fact-src { display: inline-block; font-size: 10px; font-weight: 700; padding: 1px 5px;
  border-radius: 6px; margin-right: 5px; vertical-align: middle; }
.fact-verified .fact-src { background: #e6f4ec; color: var(--ok); }
.fact-verified { border-color: #cfe8d9; }
.fact-blog .fact-src { background: #f0ebe3; color: var(--muted); }

/* 사실 밖 정보 검수 경고(차단 아님) — accent 톤, 기본 펼침 */
.gflags { border: 1px solid #f6d3c1; border-radius: 10px; background: #fff3ed; }
.gflag-summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; font-size: 13px; font-weight: 700; color: var(--accent); }
.gflag-summary::-webkit-details-marker { display: none; }
.gflag-ico { line-height: 1; }
.gflag-label { flex: 1; min-width: 0; }
.gflag-count { display: inline-block; min-width: 18px; text-align: center; padding: 1px 8px;
  border-radius: 999px; background: var(--accent); color: #fff; font-size: 12px; font-weight: 700; }
.gflag-list { display: flex; flex-direction: column; gap: 6px; padding: 2px 12px 12px; }
.gflag-item { display: flex; gap: 8px; align-items: baseline; font-size: 13px; }
.gflag-type { flex: 0 0 auto; font-size: 11px; font-weight: 700; color: #fff;
  background: var(--accent); border-radius: 6px; padding: 1px 7px; }
.gflag-claim { color: var(--ink); overflow-wrap: anywhere; }
.gflags-incomplete { font-size: 12px; color: var(--muted); padding: 7px 11px;
  border: 1px dashed var(--line); border-radius: 10px; background: #faf8f5; }

/* 사진: '실제 게시될 비율'로 표시(셀의 aspect-ratio 를 fit 결과로 인라인 지정) */
.photos { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-start; }
.photo-block { width: calc(50% - 5px); max-width: 190px; display: flex; flex-direction: column; gap: 4px; }
.photo-block .ph { position: relative; width: 100%; background: #f0ebe3;
  border-radius: 8px; overflow: hidden; }
.photos img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photos .cover-tag { position: absolute; left: 4px; top: 4px; background: var(--accent);
  color: #fff; font-size: 10px; padding: 1px 6px; border-radius: 999px; }
.photos .mkcover { position: absolute; right: 4px; top: 4px; font-size: 10px; cursor: pointer;
  padding: 2px 6px; border-radius: 999px; border: none; background: rgba(0,0,0,.55); color: #fff; }
.fit-badge { position: absolute; left: 4px; bottom: 4px; font-size: 10px; font-weight: 700;
  padding: 1px 7px; border-radius: 999px; background: rgba(0,0,0,.62); color: #fff; }
.fit-badge.warn { background: var(--accent); }
.fit-ctl { display: flex; gap: 4px; }
.fit-ctl button { flex: 1; padding: 5px 2px; font-size: 11px; border-radius: 7px;
  border: 1px solid var(--line); background: #fff; color: var(--ink); cursor: pointer; }
.fit-ctl button.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.fit-ctl.focus button { font-size: 10px; padding: 4px 2px; color: var(--muted); }
.fit-ctl.focus button.on { color: #fff; }

.tagline { font-size: 13px; color: var(--muted); word-break: break-all; }
.actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(80px, 1fr)); gap: 8px; }
.actions .danger { color: var(--accent); border-color: #f0c4b2; }

/* 캡션 재생성 행 (③) */
.regen-row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.regen-row input, .regen-row .tpl-select { flex: 1 1 100%; }
.regen-row button { flex: 1; white-space: nowrap; }

/* 업로드 진행바 (④) */
.progress { position: relative; height: 22px; border-radius: 999px; background: #f0ebe3;
  overflow: hidden; border: 1px solid var(--line); }
.progress .bar { height: 100%; width: 0%; background: var(--accent);
  transition: width .15s linear; border-radius: 999px; }
.progress .pct { position: absolute; inset: 0; display: flex; align-items: center;
  justify-content: center; font-size: 12px; font-weight: 700; color: var(--ink); }

/* 진행 단계 체크리스트(실제 백엔드 단계 반영) */
.steps { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); margin-bottom: 16px; }
.step { display: flex; align-items: center; gap: 10px; font-size: 14px; padding: 5px 0; }
.step-ico { flex: 0 0 18px; text-align: center; font-weight: 700; color: var(--muted); }
.step-label { flex: 0 0 auto; font-weight: 600; color: var(--ink); }
.step-msg { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.step-pending { opacity: .5; }
.step-pending .step-label { font-weight: 400; }
.step-done .step-ico { color: var(--ok); }
.step-skipped .step-ico { color: var(--muted); }
.step-warning .step-ico { color: var(--accent); }
.step-error .step-ico, .step-error .step-label { color: var(--accent); }
.steps .spinner { border-color: rgba(0,0,0,.18); border-top-color: var(--accent); }

/* 게시 기록 (②) */
.hist-row { display: flex; gap: 12px; align-items: center; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; margin-bottom: 10px; }
.hist-thumb { width: 64px; height: 64px; flex: 0 0 64px; border-radius: 8px;
  overflow: hidden; background: #f0ebe3; }
.hist-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.hist-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.hist-date { font-size: 12px; color: var(--muted); }
.hist-cap { font-size: 14px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.filter-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.filter-row button { padding: 8px 12px; border-radius: 999px; border: 1px solid var(--line);
  background: #fff; font-size: 13px; cursor: pointer; }
.filter-row button.on { background: var(--ink); color: #fff; border-color: var(--ink); }

.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card { width: 100%; max-width: 360px; }
.login-card h1 { font-size: 20px; margin: 0; }

/* 확인 모달 */
.modal-card { width: 100%; max-width: 380px; }
.modal-card h3 { margin: 0; font-size: 18px; }
.modal-card #modal-msg { white-space: pre-line; color: var(--ink); }
.modal-actions { display: flex; gap: 8px; margin-top: 4px; }
.modal-actions button { flex: 1; }
.modal-ok-danger { background: var(--accent); }

/* 게시 버튼 / 인스타 링크 */
.publish-btn { background: #c1338a; color: #fff; border: none; border-radius: 10px;
  padding: 13px; font-size: 15px; font-weight: 700; cursor: pointer; }
.publish-btn:disabled { opacity: .6; }
.ig-link { display: inline-block; margin-top: 4px; color: #c1338a; font-weight: 700;
  font-size: 14px; text-decoration: none; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px;
  font-size: 14px; z-index: 200; }

.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.4);
  border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; vertical-align: -3px; }
/* 흰 배경(.ghost) 버튼 위에서도 보이는 어두운 변형 */
.ghost .spinner { border-color: rgba(0,0,0,.2); border-top-color: var(--ink); }
@keyframes spin { to { transform: rotate(360deg); } }
