/* ===== Tokens ===== */
:root {
  --bg: #F7F5F0;
  --surface: #FFFFFF;
  --point: #3D6B5E;
  --point-dark: #2E5147;
  --point-soft: #E4EDE9;
  --text: #25302B;
  --text-sub: #5C6B64;
  --line: #E2DED5;
  --warn-bg: #FBF1DC;
  --warn-text: #8A6A1E;
  --info-bg: #E8EFF2;
  --info-text: #355B6B;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 2px 12px rgba(40, 52, 47, 0.08);
  --font: "Apple SD Gothic Neo", "Noto Sans KR", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

button, input, select { font-family: inherit; }

/* ===== App bar ===== */
.appbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 30;
}
.appbar__brand { display: flex; align-items: center; gap: 12px; }
.appbar__logo { font-size: 24px; }
.appbar__titles { display: flex; flex-direction: column; }
.appbar__title { font-size: 18px; font-weight: 700; margin: 0; }
.appbar__sub { font-size: 12px; color: var(--text-sub); margin: 0; }

.appbar__actions { display: flex; align-items: center; gap: 8px; }
.lang-select {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  background: var(--point-soft);
  color: var(--point-dark);
  transition: background .15s, opacity .15s;
}
.btn--primary { background: var(--point); color: #fff; }
.btn--primary:hover { background: var(--point-dark); }
.btn--ghost { background: transparent; border-color: var(--line); color: var(--text-sub); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.iconbtn {
  width: 38px; height: 38px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--radius-sm);
  font-size: 16px;
  cursor: pointer;
  color: var(--text);
  transition: background .15s, border-color .15s;
}
.iconbtn:hover { background: var(--point-soft); border-color: var(--point-soft); }
.iconbtn:disabled { opacity: .4; cursor: not-allowed; }

/* ===== Mode tabs ===== */
.tabbar {
  display: flex;
  gap: 4px;
  padding: 0 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 61px;
  z-index: 19;
}
.tab {
  border: none;
  background: transparent;
  padding: 11px 18px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-sub);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tab.is-active { color: var(--point); border-bottom-color: var(--point); }

/* ===== Edit view ===== */
#edit-view { padding: 0 0 60px; }
#edit-view > .dropzone { margin: 24px auto; }

.edit-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 100px;
  z-index: 15;
}
.edit-toolbar__group { display: flex; align-items: center; gap: 8px; }
.edit-count { font-size: 13px; color: var(--text-sub); font-variant-numeric: tabular-nums; }
.edit-hint { font-size: 12px; color: var(--text-sub); padding: 10px 18px 0; margin: 0; }

.thumb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
  padding: 16px 18px;
}
.thumb-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
  transition: border-color .12s, transform .12s, box-shadow .12s;
  cursor: grab;
}
.thumb-card.is-selected { border-color: var(--point); box-shadow: 0 0 0 2px var(--point-soft); }
.thumb-card.is-dragging { opacity: .4; }
.thumb-card.is-droptarget { border-color: var(--point); transform: scale(1.02); }

.thumb-card__imgwrap {
  position: relative;
  aspect-ratio: 3 / 4;
  background: #EFEDE6;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.thumb-card__img {
  max-width: 100%; max-height: 100%;
  transition: transform .2s;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.12);
}
.thumb-card__spinner { font-size: 12px; color: var(--text-sub); }
.thumb-card__check {
  position: absolute; top: 6px; left: 6px;
  width: 20px; height: 20px; cursor: pointer; accent-color: var(--point);
}
.thumb-card__badge {
  position: absolute; bottom: 6px; right: 6px;
  background: rgba(37,48,43,.72); color: #fff;
  font-size: 10px; padding: 2px 6px; border-radius: 10px;
}
.thumb-card__foot {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 8px; gap: 4px; border-top: 1px solid var(--line);
}
.thumb-card__label { font-size: 11px; color: var(--text-sub); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thumb-card__btns { display: flex; gap: 2px; flex: 0 0 auto; }
.mini-btn {
  border: none; background: var(--point-soft); color: var(--point-dark);
  width: 22px; height: 22px; border-radius: 5px; cursor: pointer; font-size: 12px;
  display: inline-flex; align-items: center; justify-content: center; padding: 0;
}
.mini-btn:hover { background: var(--point); color: #fff; }

@media (max-width: 640px) {
  .tabbar { top: 57px; }
  .edit-toolbar { top: 95px; justify-content: center; }
  .thumb-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; padding: 12px; }
}

/* ===== Banners ===== */
.banners { display: flex; flex-direction: column; gap: 1px; }
.banner {
  padding: 10px 18px;
  font-size: 13px;
  display: flex; align-items: center; gap: 8px;
}
.banner--warn { background: var(--warn-bg); color: var(--warn-text); }
.banner--info { background: var(--info-bg); color: var(--info-text); }
.banner__close { margin-left: auto; cursor: pointer; opacity: .6; background: none; border: none; font-size: 14px; color: inherit; }

/* ===== Toolbar ===== */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 61px;
  z-index: 20;
}
.toolbar__group { display: flex; align-items: center; gap: 8px; }
.page-indicator { min-width: 66px; text-align: center; font-size: 14px; font-variant-numeric: tabular-nums; color: var(--text-sub); }

/* segmented control */
.seg { border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); }
.seg__btn {
  border: none; background: transparent; padding: 8px 16px; cursor: pointer;
  font-size: 14px; color: var(--text-sub); font-weight: 500;
}
.seg__btn.is-active { background: var(--point); color: #fff; }

/* ===== Progress ===== */
.progress { display: flex; align-items: center; gap: 12px; padding: 8px 18px; background: var(--surface); border-bottom: 1px solid var(--line); }
.progress__bar { flex: 1; height: 6px; background: var(--point-soft); border-radius: 99px; overflow: hidden; }
.progress__fill { display: block; height: 100%; width: 0%; background: var(--point); transition: width .2s; }
.progress__label { font-size: 12px; color: var(--text-sub); white-space: nowrap; }

/* ===== Stage ===== */
.stage { padding: 24px 16px 60px; display: flex; justify-content: center; }

/* Dropzone */
.dropzone {
  width: 100%;
  max-width: 560px;
  margin-top: 24px;
}
.dropzone__inner {
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 48px 24px;
  text-align: center;
  transition: border-color .15s, background .15s;
}
.dropzone.is-drag .dropzone__inner { border-color: var(--point); background: var(--point-soft); }
.dropzone__icon { font-size: 44px; }
.dropzone__title { font-size: 17px; font-weight: 700; margin: 14px 0 6px; }
.dropzone__hint { font-size: 13px; color: var(--text-sub); margin: 0 0 20px; }

/* Viewer */
.viewer { width: 100%; display: flex; justify-content: center; }
.page-wrap {
  position: relative;
  background: var(--surface);
  box-shadow: var(--shadow);
  border-radius: 4px;
  max-width: 100%;
  line-height: 0;
}
.page-canvas { display: block; max-width: 100%; height: auto; border-radius: 4px; }

/* Overlay layer (translation boxes) */
.overlay {
  position: absolute;
  inset: 0;
  line-height: normal;
  pointer-events: none;
}
.overlay.is-hidden { display: none; }

.tblock {
  position: absolute;
  overflow: hidden;
  display: flex;
  align-items: center;
  background: var(--surface);
  color: var(--text);
  border-radius: 3px;
  padding: 0 1px;
  pointer-events: auto;
  white-space: normal;
  word-break: break-word;
  line-height: 1.12;
  box-shadow: 0 0 0 1px rgba(61,107,94,0.06);
  transition: box-shadow .12s;
}
.tblock:hover {
  overflow: visible;
  height: auto !important;
  min-height: 0;
  z-index: 5;
  box-shadow: 0 2px 10px rgba(40,52,47,0.18);
  background: #fff;
}
.tblock--pending { background: var(--point-soft); color: transparent; }

/* ===== Settings drawer ===== */
.backdrop {
  position: fixed; inset: 0; background: rgba(20,28,24,0.4); z-index: 40;
}
.drawer {
  position: fixed; top: 0; right: 0; height: 100%;
  width: min(420px, 100%);
  background: var(--bg);
  z-index: 50;
  display: flex; flex-direction: column;
  box-shadow: -4px 0 24px rgba(40,52,47,0.16);
  animation: slideIn .2s ease;
}
@keyframes slideIn { from { transform: translateX(100%); } to { transform: translateX(0); } }
.drawer__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px; border-bottom: 1px solid var(--line); background: var(--surface);
}
.drawer__title { font-size: 16px; margin: 0; font-weight: 700; }
.drawer__body { padding: 16px 18px 40px; overflow-y: auto; display: flex; flex-direction: column; gap: 20px; }

.field { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin: 0; background: var(--surface); }
.field__legend { font-size: 13px; font-weight: 700; color: var(--point-dark); padding: 0 6px; }
.field__row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 7px 0; font-size: 14px; }
.field__row--stack { flex-direction: column; align-items: stretch; gap: 6px; }
.field__row--check { justify-content: flex-start; gap: 8px; cursor: pointer; }
.field__row select, .field__row input[type="text"], .field__row input[type="password"] {
  padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--bg); color: var(--text); font-size: 14px; min-width: 0;
}
.field__row--stack select, .field__row--stack input { width: 100%; }
.field__row > select { flex: 1; max-width: 200px; }
.field__note { font-size: 12px; color: var(--text-sub); margin: 8px 0 0; line-height: 1.45; }

/* ===== SEO content (intro + FAQ) ===== */
.seo-content {
  max-width: 760px;
  margin: 0 auto;
  padding: 8px 18px 40px;
}
.seo-intro { font-size: 14px; color: var(--text-sub); line-height: 1.7; margin: 0 0 28px; }
.seo-faq-title { font-size: 18px; font-weight: 700; color: var(--text); margin: 0 0 14px; }
.seo-faq-list details {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  margin-bottom: 8px;
  overflow: hidden;
}
.seo-faq-list summary {
  cursor: pointer;
  padding: 13px 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  list-style: none;
}
.seo-faq-list summary::-webkit-details-marker { display: none; }
.seo-faq-list summary::after { content: "+"; float: right; color: var(--point); font-weight: 700; }
.seo-faq-list details[open] summary::after { content: "–"; }
.seo-faq-list .faq-a { padding: 0 16px 14px; font-size: 13.5px; color: var(--text-sub); line-height: 1.65; }

/* ===== Guide / onboarding modal ===== */
.guide-overlay {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(20, 28, 24, 0.46);
  display: flex; align-items: center; justify-content: center;
  padding: 18px;
}
.guide-modal {
  position: relative;
  width: min(480px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 12px 40px rgba(40, 52, 47, 0.28);
  padding: 26px 24px 18px;
  animation: guidePop .18s ease;
}
@keyframes guidePop { from { transform: translateY(8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.guide-x {
  position: absolute; top: 12px; right: 12px;
  width: 32px; height: 32px;
  border: none; background: transparent; border-radius: 8px;
  font-size: 17px; color: var(--text-sub); cursor: pointer;
}
.guide-x:hover { background: var(--point-soft); color: var(--point-dark); }
.guide-title { font-size: 19px; font-weight: 700; margin: 0 28px 8px 0; color: var(--text); }
.guide-lead { font-size: 13.5px; color: var(--text-sub); line-height: 1.6; margin: 0 0 16px; }
.guide-list { list-style: none; margin: 0 0 16px; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.guide-list li {
  font-size: 13.5px; line-height: 1.55; color: var(--text);
  background: var(--bg); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 11px 13px;
}
.guide-list b { color: var(--point-dark); }
.guide-note {
  font-size: 12.5px; color: var(--warn-text); background: var(--warn-bg);
  border-radius: var(--radius-sm); padding: 10px 12px; margin: 0 0 18px; line-height: 1.55;
}
.guide-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.guide-dontshow { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--text-sub); cursor: pointer; }
.guide-dontshow input { width: 16px; height: 16px; accent-color: var(--point); cursor: pointer; }

@media (max-width: 480px) {
  .guide-modal { padding: 22px 18px 16px; }
  .guide-foot { flex-direction: column-reverse; align-items: stretch; gap: 10px; }
  .guide-foot .btn { width: 100%; }
  .guide-dontshow { justify-content: center; }
}

/* ===== Footer ===== */
.appfoot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 20px 18px 28px;
  font-size: 12px;
  color: var(--text-sub);
  border-top: 1px solid var(--line);
  background: var(--surface);
}
.appfoot a { color: var(--point); text-decoration: none; }
.appfoot a:hover { text-decoration: underline; }
.appfoot__sep { opacity: .5; }

/* ===== Responsive (mobile) ===== */
@media (max-width: 640px) {
  body { font-size: 14px; }
  .appbar { padding: 10px 14px; }
  .appbar__title { font-size: 16px; }
  .toolbar { top: 57px; padding: 8px 12px; gap: 8px; justify-content: center; }
  .toolbar__group { flex: 0 0 auto; }
  .btn--primary { padding: 9px 14px; }
  .seg__btn { padding: 8px 14px; }
  .stage { padding: 16px 8px 48px; }
  .page-indicator { min-width: 56px; }
  /* hide labels-only refinement: keep translate button text */
}

@media (max-width: 380px) {
  .appbar__sub { display: none; }
  #btn-translate { font-size: 13px; padding: 8px 10px; }
}
