/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:       #0b0d13;
  --card:     #161923;
  --surface:  #1f2330;
  --border:   rgba(255,255,255,.13);
  --accent:   #8b5cf6;
  --accent2:  #a855f7;
  --text:     #f1f5f9;
  --muted:    #94a3b8;
  --gradient: linear-gradient(135deg, #8b5cf6 0%, #a855f7 50%, #ec4899 100%);
  --green:    #10b981;
  --red:      #f87171;
}

html, body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ── 배경 그리드 ────────────────────────────────────────────── */
.bg-grid {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image:
    linear-gradient(rgba(124,58,237,.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(124,58,237,.03) 1px, transparent 1px);
  background-size: 40px 40px;
}
body > * { position: relative; z-index: 1; }

/* ── 헤더 ──────────────────────────────────────────────────── */
.top-header {
  position: sticky; top: 0; z-index: 200;
  height: 52px;
  background: rgba(8,9,14,.88);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.top-header-inner {
  max-width: 860px; margin: 0 auto;
  height: 100%; padding: 0 20px;
  display: flex; align-items: center; gap: 10px;
}
.logo-mark { font-size: 1.1rem; background: var(--gradient); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.logo-text  { font-size: 1rem; font-weight: 800; letter-spacing: -.02em; }
.header-spacer { flex: 1; }
.header-link { font-size: 0.82rem; color: #cbd5e1; text-decoration: none; padding: 4px 8px; border-radius: 6px; transition: color .15s; }
.header-link:hover { color: var(--text); }
.balance-badge { font-size: 0.8rem; font-weight: 700; background: rgba(139,92,246,.2); color: #c4b5fd; border: 1px solid rgba(139,92,246,.35); padding: 4px 11px; border-radius: 20px; }
.user-name { font-size: 0.8rem; color: #cbd5e1; }
.header-logout { font-size: 0.75rem; color: #cbd5e1; background: none; border: 1px solid var(--border); border-radius: 6px; padding: 4px 10px; cursor: pointer; transition: all .15s; }
.header-logout:hover { border-color: var(--accent); color: var(--text); }

/* ── 메인 레이아웃 ──────────────────────────────────────────── */
.main-wrap {
  max-width: 720px; margin: 0 auto;
  padding: 40px 20px 80px;
  min-height: calc(100vh - 52px);
  display: flex; flex-direction: column;
}

/* ── 입력 화면 ──────────────────────────────────────────────── */
.sec-input {
  display: flex; flex-direction: column; align-items: center;
  gap: 28px;
}

.input-hero {
  text-align: center; padding-top: 20px;
}
.input-hero h1 {
  font-size: 2rem; font-weight: 800; letter-spacing: -.03em;
  background: var(--gradient); -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  margin-bottom: 10px;
}
.input-hero p {
  font-size: 0.92rem; color: #cbd5e1; line-height: 1.7;
}

/* ── Composer (통합 입력창) ─────────────────────────────────── */
.composer {
  width: 100%;
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: 18px;
  overflow: hidden;
  transition: border-color .2s;
}
.composer:focus-within {
  border-color: rgba(124,58,237,.5);
  box-shadow: 0 0 0 3px rgba(124,58,237,.08);
}

/* 드래그 오버 상태 */
.composer.drag-over {
  border-color: var(--accent);
  border-style: dashed;
  box-shadow: 0 0 0 4px rgba(124,58,237,.15), inset 0 0 60px rgba(124,58,237,.06);
  position: relative;
}
.composer.drag-over::after {
  content: '📎 파일을 여기에 놓으세요';
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(8,9,14,.82); backdrop-filter: blur(2px);
  color: #c4b5fd; font-size: 1rem; font-weight: 700;
  border-radius: 16px; z-index: 10;
  pointer-events: none;
}

/* 첨부 미리보기 */
.attach-preview {
  padding: 12px 16px 0;
  display: flex; flex-wrap: wrap; gap: 8px;
}
.attach-item {
  display: flex; align-items: center; gap: 7px;
  background: rgba(124,58,237,.12); border: 1px solid rgba(124,58,237,.25);
  border-radius: 8px; padding: 6px 10px;
  font-size: 0.78rem; color: #a78bfa;
}
.attach-item-name { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-remove {
  background: none; border: none; color: var(--muted);
  cursor: pointer; padding: 0; font-size: 0.85rem; line-height: 1;
}
.attach-remove:hover { color: var(--red); }

/* 텍스트 입력 */
.composer-input {
  width: 100%;
  background: transparent; border: none; outline: none;
  color: var(--text); font-size: 1rem; line-height: 1.7;
  padding: 18px 20px 10px;
  resize: none; font-family: inherit;
  min-height: 130px;
}
.composer-input::placeholder { color: #8b95a8; }

/* 툴바 */
.composer-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px 14px;
  border-top: 1px solid rgba(255,255,255,.05);
  gap: 8px;
}
.toolbar-left  { display: flex; gap: 6px; align-items: center; }
.toolbar-right { display: flex; gap: 10px; align-items: center; }

.tool-btn {
  display: flex; align-items: center; gap: 5px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; color: #cbd5e1; font-size: 0.82rem;
  padding: 7px 13px; cursor: pointer; transition: all .15s;
}
.tool-btn:hover { border-color: rgba(124,58,237,.4); color: var(--text); }
.tool-btn svg { flex-shrink: 0; }

.cost-hint { font-size: 0.78rem; color: #cbd5e1; }

.send-btn {
  display: flex; align-items: center; gap: 7px;
  background: var(--gradient); border: none; border-radius: 10px;
  color: #fff; font-size: 0.85rem; font-weight: 700;
  padding: 9px 20px; cursor: pointer; transition: opacity .15s, transform .1s;
  white-space: nowrap;
}
.send-btn:hover { opacity: .9; transform: translateY(-1px); }
.send-btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }

/* 옵션 패널 */
.opt-panel {
  border-top: 1px solid rgba(255,255,255,.05);
  padding: 16px 18px 18px;
}
.opt-row { display: flex; gap: 24px; flex-wrap: wrap; }
.opt-group { display: flex; flex-direction: column; gap: 8px; }
.opt-label { font-size: 0.7rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; }
.opt-chips { display: flex; gap: 6px; flex-wrap: wrap; }

.chip {
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: 20px; color: #cbd5e1; font-size: 0.82rem;
  padding: 6px 14px; cursor: pointer; transition: all .15s; white-space: nowrap;
}
.chip:hover { border-color: rgba(139,92,246,.5); color: var(--text); }
.chip.active {
  background: rgba(139,92,246,.2); border-color: var(--accent); color: #d8ccff;
  font-weight: 700;
}

/* hidden */
.hidden { display: none !important; }

/* ── Q&A 화면 ───────────────────────────────────────────────── */
.qa-wrap {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 20px; padding: 32px 28px;
}
.qa-header { margin-bottom: 28px; }
.qa-badge {
  display: inline-block; background: rgba(124,58,237,.15);
  border: 1px solid rgba(124,58,237,.3); color: #a78bfa;
  font-size: 0.72rem; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; padding: 4px 12px; border-radius: 20px;
  margin-bottom: 12px;
}
.qa-title { font-size: 1.1rem; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.qa-sub { font-size: 0.87rem; color: #cbd5e1; }

/* 질문 블록 */
.qa-question {
  margin-bottom: 26px; padding-bottom: 26px;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.qa-question:last-of-type { border-bottom: none; padding-bottom: 0; }

.qa-q-num { font-size: 0.7rem; font-weight: 700; color: var(--accent2); letter-spacing: .07em; text-transform: uppercase; margin-bottom: 6px; }
.qa-q-text { font-size: 0.92rem; font-weight: 600; color: var(--text); margin-bottom: 12px; line-height: 1.45; }

.qa-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.qa-opts.wide { grid-template-columns: 1fr; }

.qa-opt {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: 10px; padding: 10px 13px; cursor: pointer;
  transition: all .15s; user-select: none;
}
.qa-opt:hover { border-color: rgba(124,58,237,.45); }
.qa-opt.sel { background: rgba(124,58,237,.1); border-color: var(--accent); }

.qa-opt-dot {
  width: 17px; height: 17px; border-radius: 50%;
  border: 2px solid var(--border); flex-shrink: 0;
  display: grid; place-items: center; transition: all .15s;
}
.qa-opt.sel .qa-opt-dot { border-color: var(--accent); background: var(--accent); }
.qa-opt-dot::after {
  content: ''; width: 7px; height: 7px; border-radius: 50%;
  background: #fff; display: none;
}
.qa-opt.sel .qa-opt-dot::after { display: block; }
.qa-opt-label { font-size: 0.83rem; color: var(--text); line-height: 1.3; }

.qa-text-input {
  width: 100%; background: var(--surface); border: 1.5px solid var(--border);
  border-radius: 10px; color: var(--text); font-size: 0.88rem;
  padding: 11px 13px; font-family: inherit; resize: vertical; min-height: 60px;
  transition: border-color .15s;
}
.qa-text-input:focus { outline: none; border-color: var(--accent); }

/* Q&A 버튼 */
.qa-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }
.qa-btn-skip {
  background: none; border: 1px solid var(--border); color: var(--muted);
  border-radius: 9px; padding: 10px 18px; font-size: 0.82rem; cursor: pointer;
  transition: all .15s;
}
.qa-btn-skip:hover { border-color: var(--accent); color: var(--text); }
.qa-btn-submit {
  background: var(--gradient); border: none; color: #fff;
  border-radius: 9px; padding: 11px 26px; font-size: 0.88rem; font-weight: 700;
  cursor: pointer; transition: opacity .15s;
}
.qa-btn-submit:hover { opacity: .9; }
.qa-btn-submit:disabled { opacity: .45; cursor: not-allowed; }

/* ── 진행 화면 ──────────────────────────────────────────────── */
.prog-wrap {
  display: flex; flex-direction: column; align-items: center;
  padding: 40px 20px;
}

.prog-icon-ring {
  position: relative; width: 72px; height: 72px; margin-bottom: 24px;
}
.prog-spinner {
  position: absolute; inset: 0;
  border-radius: 50%;
  border: 3px solid rgba(124,58,237,.15);
  border-top-color: var(--accent);
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.prog-icon-inner {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem;
  background: var(--gradient); -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}

.prog-title { font-size: 1.3rem; font-weight: 700; margin-bottom: 8px; text-align: center; }
.prog-msg   { font-size: 0.9rem; color: #cbd5e1; text-align: center; min-height: 22px; margin-bottom: 24px; max-width: 460px; }

.prog-bar-outer {
  width: 100%; max-width: 440px; height: 6px;
  background: rgba(255,255,255,.06); border-radius: 99px;
  overflow: hidden; margin-bottom: 8px;
}
.prog-bar-fill {
  height: 100%; background: var(--gradient); border-radius: 99px;
  transition: width .5s ease;
}
.prog-pct-row {
  display: flex; justify-content: space-between;
  width: 100%; max-width: 440px;
  font-size: 0.73rem; color: var(--muted); margin-bottom: 28px;
}
.prog-elapsed { opacity: .7; }

/* 단계 표시 */
.prog-steps {
  display: flex; align-items: center; gap: 0;
  margin-bottom: 28px;
}
.prog-step {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  min-width: 64px;
}
.prog-step-dot {
  width: 11px; height: 11px; border-radius: 50%;
  background: rgba(255,255,255,.12); border: 2px solid var(--border);
  transition: all .3s;
}
.prog-step.done .prog-step-dot  { background: var(--accent); border-color: var(--accent); box-shadow: 0 0 8px rgba(124,58,237,.5); }
.prog-step.active .prog-step-dot{ background: transparent; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(124,58,237,.18); animation: pulse 1.2s ease infinite; }
@keyframes pulse { 0%,100%{ box-shadow: 0 0 0 3px rgba(124,58,237,.18); } 50%{ box-shadow: 0 0 0 6px rgba(124,58,237,.06); } }
.prog-step span  { font-size: 0.68rem; color: var(--muted); text-align: center; }
.prog-step.done span, .prog-step.active span { color: var(--text); }
.prog-step-line { flex: 1; height: 1px; background: rgba(255,255,255,.08); min-width: 24px; margin-bottom: 16px; }

/* 진행 로그 */
.prog-log-wrap { width: 100%; max-width: 480px; margin-top: 8px; }
.prog-log-label { font-size: 0.68rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; margin-bottom: 8px; }
.prog-log-box {
  background: rgba(0,0,0,.3); border: 1px solid rgba(255,255,255,.07);
  border-radius: 10px; padding: 10px 14px;
  font-size: 0.75rem; font-family: monospace; color: #94a3b8;
  max-height: 120px; overflow-y: auto; line-height: 1.85;
}

/* ── 완료 화면 ──────────────────────────────────────────────── */
.done-wrap {
  display: flex; flex-direction: column; align-items: center;
  padding: 48px 20px;
}
.done-check {
  width: 64px; height: 64px; border-radius: 50%;
  background: rgba(16,185,129,.12); border: 2px solid rgba(16,185,129,.35);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.8rem; color: var(--green); margin-bottom: 20px;
}
.done-title { font-size: 1.5rem; font-weight: 800; margin-bottom: 6px; }
.done-sub { font-size: 0.9rem; color: #cbd5e1; margin-bottom: 28px; text-align: center; max-width: 360px; }

.done-btns { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-bottom: 20px; }
.done-btn-primary {
  background: var(--gradient); border: none; color: #fff;
  border-radius: 10px; padding: 12px 24px; font-size: 0.88rem; font-weight: 700;
  cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px;
  transition: opacity .15s;
}
.done-btn-primary:hover { opacity: .88; }
.done-btn-secondary {
  background: var(--card); border: 1px solid var(--border); color: var(--text);
  border-radius: 10px; padding: 12px 22px; font-size: 0.85rem;
  cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px;
  transition: border-color .15s;
}
.done-btn-secondary:hover { border-color: rgba(124,58,237,.5); }
.done-btn-new {
  background: none; border: none; color: var(--muted); font-size: 0.8rem;
  cursor: pointer; transition: color .15s; padding: 6px;
}
.done-btn-new:hover { color: var(--text); }

/* ── 오류 화면 ──────────────────────────────────────────────── */
.err-wrap {
  display: flex; flex-direction: column; align-items: center;
  text-align: center; padding: 48px 20px;
}
.err-icon { font-size: 2.4rem; margin-bottom: 14px; }
.err-title { font-size: 1.2rem; font-weight: 700; margin-bottom: 8px; }
.err-msg { font-size: 0.9rem; color: #cbd5e1; margin-bottom: 24px; max-width: 400px; line-height: 1.6; }
.err-btns { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

/* ── 공유 헤더 (history / interactive 등) ──────────────────── */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(8,9,14,.88); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border); padding: 0 24px; height: 52px;
}
.header-inner {
  max-width: 1100px; margin: 0 auto; height: 100%;
  display: flex; align-items: center; gap: 16px;
}
.site-logo { font-size: 1rem; font-weight: 800; color: var(--text); text-decoration: none; letter-spacing: -.01em; flex-shrink: 0; }
.header-nav { display: flex; gap: 4px; flex: 1; }
.header-nav .nav-link { font-size: 0.8rem; color: var(--muted); text-decoration: none; padding: 5px 10px; border-radius: 6px; transition: all .15s; }
.header-nav .nav-link:hover { color: var(--text); background: rgba(255,255,255,.05); }
.header-right { display: flex; align-items: center; gap: 10px; }
.user-badge { font-size: 0.76rem; color: var(--muted); background: rgba(255,255,255,.05); padding: 4px 10px; border-radius: 20px; }
.btn-logout { font-size: 0.73rem; color: var(--muted); background: none; border: 1px solid rgba(255,255,255,.1); border-radius: 6px; padding: 4px 10px; cursor: pointer; transition: all .15s; }
.btn-logout:hover { border-color: var(--accent); color: var(--text); }

/* ── 반응형 ─────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .input-hero h1 { font-size: 1.55rem; }
  .qa-opts { grid-template-columns: 1fr; }
  .opt-row { flex-direction: column; gap: 14px; }
  .done-btns { flex-direction: column; align-items: stretch; }
  .err-btns { flex-direction: column; align-items: stretch; }
}

/* ── 보완 요청 박스 ──────────────────────────────────────────── */
.revise-box {
  width: 100%; max-width: 520px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 14px; margin: 4px 0 18px; overflow: hidden;
  transition: border-color .2s;
}
.revise-box:focus-within { border-color: rgba(124,58,237,.45); }
.revise-head {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 18px; cursor: pointer; user-select: none;
  font-size: 0.88rem; font-weight: 700; color: var(--text);
  transition: background .15s;
}
.revise-head:hover { background: rgba(255,255,255,.03); }
.revise-cost {
  font-size: 0.72rem; font-weight: 600; color: #a78bfa;
  background: rgba(124,58,237,.12); border: 1px solid rgba(124,58,237,.25);
  padding: 2px 9px; border-radius: 12px;
}
.revise-arrow { margin-left: auto; color: var(--muted); font-size: 0.8rem; transition: transform .2s; }
.revise-box.open .revise-arrow { transform: rotate(180deg); }
.revise-body { padding: 0 18px 16px; }
.revise-input {
  width: 100%; background: var(--surface); border: 1.5px solid var(--border);
  border-radius: 10px; color: var(--text); font-size: 0.88rem;
  padding: 12px 14px; font-family: inherit; resize: vertical;
  min-height: 76px; line-height: 1.6; transition: border-color .15s;
}
.revise-input:focus { outline: none; border-color: var(--accent); }
.revise-actions {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-top: 10px;
}
.revise-hint { font-size: 0.76rem; color: #94a3b8; }
.revise-submit {
  background: var(--gradient); border: none; color: #fff;
  border-radius: 9px; padding: 9px 20px; font-size: 0.83rem; font-weight: 700;
  cursor: pointer; white-space: nowrap; transition: opacity .15s;
}
.revise-submit:hover { opacity: .9; }
.revise-submit:disabled { opacity: .45; cursor: not-allowed; }
