/* 기획엔진 폼 · 글로시 블랙 + 라인아트 톤 · 모바일 우선 */
:root {
  --bg: #0b0b0d;
  --bg-elev: #16171b;
  --bg-card: #1c1e24;
  --line: #2b2d33;
  --line-hi: #3a3d45;
  --text: #f2f3f5;
  --text-dim: #a8adb8;
  --text-mute: #6e727b;
  --accent: #ffd54a;
  --accent-ink: #1a1500;
  --danger: #ff5b6b;
  --danger-soft: #4a1a20;
  --ok: #34d399;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  --radius: 14px;
  --radius-sm: 10px;
  --font: "Noto Sans KR", -apple-system, BlinkMacSystemFont, "Malgun Gothic",
    "맑은 고딕", system-ui, sans-serif;
  --tap: 44px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  min-height: 100dvh;
  overscroll-behavior-y: none;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(8px);
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
}
.brand .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent);
}
.brand strong {
  font-weight: 900;
  letter-spacing: -0.02em;
}
.brand .sub {
  color: var(--text-mute);
  font-size: 13px;
}
.save-indicator {
  font-size: 12px;
  color: var(--text-mute);
  transition: color 0.3s;
}
.save-indicator.saving {
  color: var(--accent);
}
.save-indicator.saved {
  color: var(--ok);
}

/* ---------- Progressbar ---------- */
.progressbar {
  display: flex;
  gap: 4px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-elev);
}
.progressbar .seg {
  flex: 1;
  height: 5px;
  border-radius: 3px;
  background: var(--line);
  position: relative;
  overflow: hidden;
  cursor: pointer;
}
.progressbar .seg.done {
  background: var(--accent);
}
.progressbar .seg.active {
  background: linear-gradient(90deg, var(--accent) 50%, var(--line) 50%);
}
.progressbar .seg .bad {
  position: absolute;
  top: -4px;
  right: -2px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--danger);
}

/* ---------- Main ---------- */
main {
  flex: 1;
  padding: 20px 18px 100px;
  max-width: 640px;
  margin: 0 auto;
  width: 100%;
}
.loading {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-mute);
}

/* ---------- Section ---------- */
.section-title {
  font-size: 12px;
  color: var(--accent);
  letter-spacing: 0.1em;
  font-weight: 700;
  margin: 4px 0 6px;
}
.section-heading {
  font-size: 22px;
  font-weight: 900;
  letter-spacing: -0.03em;
  margin: 0 0 24px;
}

/* ---------- Field ---------- */
.field {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 16px 18px;
  margin-bottom: 14px;
  transition: border-color 0.15s;
}
.field:focus-within {
  border-color: var(--line-hi);
}
.field.warn {
  border-color: rgba(255, 91, 107, 0.4);
}
.field-q {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 4px;
  line-height: 1.4;
}
.field-hint {
  color: var(--text-mute);
  font-size: 12.5px;
  margin-bottom: 10px;
}
.badge {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--danger-soft);
  color: var(--danger);
  margin-left: 6px;
  vertical-align: middle;
  font-weight: 700;
}
.badge.info {
  background: rgba(255, 213, 74, 0.14);
  color: var(--accent);
}

/* ---------- Buttons: 단일/복수 선택 ---------- */
.opt-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.opt {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  padding: 8px 14px;
  border-radius: 10px;
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid var(--line);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  user-select: none;
  transition: all 0.12s;
}
.opt:hover {
  border-color: var(--line-hi);
}
.opt.on {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
  font-weight: 700;
}
.opt.on:hover {
  filter: brightness(1.05);
}
.opt.warn.on {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

/* ---------- Text input ---------- */
.txt {
  width: 100%;
  min-height: var(--tap);
  padding: 10px 12px;
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 15px;
  transition: border-color 0.15s;
}
.txt:focus {
  outline: none;
  border-color: var(--accent);
}
.txt-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.txt-row .txt {
  flex: 1;
}
.mic {
  min-width: var(--tap);
  min-height: var(--tap);
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--text);
  border-radius: var(--radius-sm);
  font-size: 18px;
  cursor: pointer;
}
.mic.rec {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
  animation: pulse 1.2s infinite;
}
@keyframes pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(255, 91, 107, 0.5);
  }
  50% {
    box-shadow: 0 0 0 8px rgba(255, 91, 107, 0);
  }
}

/* ---------- Select ---------- */
.sel {
  width: 100%;
  min-height: var(--tap);
  padding: 10px 12px;
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 15px;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-dim) 50%),
    linear-gradient(-45deg, transparent 50%, var(--text-dim) 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%;
  background-size: 6px 6px;
  background-repeat: no-repeat;
  padding-right: 36px;
}

/* ---------- Stepper ---------- */
.stepper {
  display: inline-flex;
  align-items: center;
  gap: 0;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.stepper button {
  min-width: var(--tap);
  min-height: var(--tap);
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 20px;
  cursor: pointer;
}
.stepper button:hover {
  background: var(--line);
}
.stepper .val {
  min-width: 48px;
  text-align: center;
  font-weight: 700;
  padding: 0 8px;
}

/* ---------- MBTI 토글4 ---------- */
.mbti {
  display: grid;
  gap: 8px;
}
.mbti-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.mbti-row .lbl {
  width: 60px;
  color: var(--text-mute);
  font-size: 12px;
}
.mbti-row .opt {
  flex: 1;
}
.mbti-result {
  font-weight: 900;
  font-size: 22px;
  letter-spacing: 0.1em;
  color: var(--accent);
  text-align: center;
  padding: 8px;
  margin-top: 4px;
  background: var(--bg-elev);
  border-radius: var(--radius-sm);
  border: 1px dashed var(--line-hi);
}

/* ---------- 3단토글 (♥ / ― / ✕) ---------- */
.tone-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
}
.tone-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.tone-row .n {
  font-size: 14px;
}
.tone-tri {
  display: inline-flex;
  gap: 4px;
}
.tone-tri button {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text-mute);
  font-size: 18px;
  cursor: pointer;
}
.tone-tri button.on-like {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}
.tone-tri button.on-neutral {
  background: var(--text-mute);
  color: #000;
  border-color: var(--text-mute);
}
.tone-tri button.on-dislike {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

/* ---------- Calendar ---------- */
.cal-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.cal-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.cal-quick .opt {
  padding: 6px 10px;
  min-height: 36px;
  font-size: 13px;
}

/* ---------- Repeat row (2-4 상품 TOP3) ---------- */
.repeat-3 {
  display: grid;
  gap: 8px;
}
.repeat-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 8px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.repeat-row .row-lbl {
  grid-column: 1 / -1;
  font-size: 12px;
  color: var(--text-mute);
}

/* ---------- 조건부 아이 서브블록 ---------- */
.sub-block {
  margin-top: 12px;
  padding: 12px;
  border-left: 3px solid var(--accent);
  background: rgba(255, 213, 74, 0.05);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.sub-block .field-q {
  font-size: 13px;
  color: var(--accent);
}

/* ---------- Bottom bar ---------- */
.bottombar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  gap: 10px;
  padding: 12px 18px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0));
  background: var(--bg);
  border-top: 1px solid var(--line);
  z-index: 10;
}
.step-indicator {
  flex: 1;
  text-align: center;
  color: var(--text-mute);
  font-size: 13px;
  align-self: center;
}
.btn {
  min-height: 48px;
  padding: 12px 20px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}
.btn:hover {
  border-color: var(--line-hi);
}
.btn.primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}
.btn.primary:hover {
  filter: brightness(1.05);
}
.btn.ghost {
  background: transparent;
}
.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ---------- Done view ---------- */
.done-view {
  text-align: center;
  padding: 20px 0;
}
.done-view .check {
  width: 72px;
  height: 72px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: var(--ok);
  color: #000;
  font-size: 42px;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
}
.done-view h2 {
  font-size: 22px;
  font-weight: 900;
  margin: 0 0 6px;
}
.done-view .sub {
  color: var(--text-mute);
  margin: 0 0 20px;
}
.summary-card-wrap {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 14px;
}
#summaryCanvas {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  display: block;
  margin: 0 auto;
}
.summary-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}
.summary-actions .btn {
  flex: 1;
}
.raw-summary {
  text-align: left;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 20px;
}
.raw-summary summary {
  cursor: pointer;
  color: var(--text-mute);
  font-size: 13px;
}
.raw-summary pre {
  white-space: pre-wrap;
  font-family: inherit;
  font-size: 13px;
  margin: 10px 0 0;
  line-height: 1.6;
}
.company-id {
  font-size: 12px;
  color: var(--text-mute);
}
.company-id code {
  background: var(--bg-elev);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11px;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(-10px);
  padding: 10px 18px;
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: 999px;
  font-weight: 700;
  font-size: 14px;
  opacity: 0;
  transition: all 0.25s;
  z-index: 100;
  pointer-events: none;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---------- Responsive tweak ---------- */
@media (min-width: 720px) {
  main {
    padding: 32px 24px 100px;
  }
  .section-heading {
    font-size: 26px;
  }
}
