:root {
  --red: #b3261e; --red-d: #8c1d17; --red-l: #fbe9e7; --cream: #fbf6ee; --cream-d: #f1e8d8;
  --ink: #2b2522; --muted: #7b716a; --line: #e4d9c8; --green: #2f6b3a; --green-l: #e5f1e6; --amber: #9a6a00; --amber-l: #fff3d6;
  font-family: "Pretendard", "Malgun Gothic", "Apple SD Gothic Neo", system-ui, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--cream); color: var(--ink); font-size: 15px; line-height: 1.5; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 7px 14px; }
button:hover:not(:disabled) { border-color: var(--red); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: var(--red); border-color: var(--red); color: #fff; font-weight: 700; }
button.primary:hover:not(:disabled) { background: var(--red-d); }
button.ghost { background: transparent; }
button.small, .small { font-size: 13px; }
button.small { padding: 4px 10px; }
.muted { color: var(--muted); }
.error { color: var(--red); font-weight: 600; min-height: 1.2em; }
.ok { color: var(--green); font-weight: 700; }
h1 { font-size: 22px; margin: 4px 0; }
h2 { font-size: 17px; margin: 0 0 10px; display: flex; align-items: center; gap: 8px; }
h2 .num { background: var(--red); color: #fff; border-radius: 50%; width: 24px; height: 24px; display: inline-grid; place-items: center; font-size: 13px; }
select, input[type=text], input[type=password], textarea { border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; background: #fff; }
select:focus, input:focus, textarea:focus { outline: 2px solid #e8b4ae; border-color: var(--red); }

/* 로그인 */
.login-page { display: grid; place-items: center; min-height: 100vh; }
.login-card { background: #fff; padding: 32px 28px; border-radius: 16px; border: 1px solid var(--line); width: min(360px, 92vw); display: grid; gap: 10px; box-shadow: 0 6px 24px rgba(80, 40, 20, .08); }
.login-card .logo { font-size: 40px; text-align: center; }
.login-card h1 { text-align: center; }
.login-card p { margin: 0 0 6px; text-align: center; }
.login-card button { padding: 10px; }

/* 위 막대 */
.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 16px; padding: 10px 20px; background: #fff; border-bottom: 3px solid var(--red); flex-wrap: wrap; }
.brand { font-weight: 800; font-size: 18px; color: var(--red-d); }
.top nav { display: flex; gap: 6px; }
.tab { border-radius: 20px; }
.tab.on { background: var(--red); color: #fff; border-color: var(--red); }
.budget { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: 14px; }
.budget .bar { width: 140px; height: 8px; background: var(--cream-d); border-radius: 4px; overflow: hidden; }
.budget .bar i { display: block; height: 100%; background: var(--green); }
.budget.warn .bar i { background: var(--amber); }
.budget.out .bar i { background: var(--red); }
.banner { background: var(--red); color: #fff; text-align: center; padding: 10px; font-weight: 700; }

main { max-width: 1500px; margin: 0 auto; padding: 18px 20px 80px; }
.grid > div, .results > div, .two > div { min-width: 0; }
.grid { display: grid; grid-template-columns: minmax(340px, 430px) 1fr; gap: 18px; align-items: start; }
.card { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 16px; margin-bottom: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.field { display: grid; gap: 4px; margin-bottom: 10px; }
.field > span { font-size: 13px; color: var(--muted); font-weight: 600; }
.hint { font-size: 13px; color: var(--muted); margin: 4px 0 0; }

/* 사진·얼굴 */
.photo-wrap { position: relative; display: inline-block; max-width: 100%; border-radius: 10px; overflow: hidden; background: #eee; }
.photo-wrap img { display: block; max-width: 100%; max-height: 420px; }
.face { position: absolute; border: 3px solid #fff; border-radius: 50%; box-shadow: 0 0 0 2px var(--red); }
.face b { position: absolute; top: -12px; left: 50%; transform: translateX(-50%); background: var(--red); color: #fff; border-radius: 50%; width: 24px; height: 24px; display: grid; place-items: center; font-size: 13px; }
.face button { position: absolute; bottom: -10px; right: -10px; padding: 0 6px; font-size: 12px; border-radius: 10px; background: #fff; }
.recent { display: flex; gap: 6px; overflow-x: auto; padding: 4px 0; }
.recent img { height: 56px; border-radius: 6px; border: 2px solid transparent; cursor: pointer; }
.recent img.on { border-color: var(--red); }
.drop { border: 2px dashed var(--line); border-radius: 12px; padding: 18px; text-align: center; cursor: pointer; background: var(--cream); }
.drop:hover, .drop.over { border-color: var(--red); background: var(--red-l); }

.person { display: grid; grid-template-columns: 34px 1fr; gap: 8px; align-items: start; padding: 8px 0; border-top: 1px dashed var(--line); }
.person:first-child { border-top: 0; }
.person .no { background: var(--red); color: #fff; border-radius: 50%; width: 28px; height: 28px; display: grid; place-items: center; font-weight: 700; }
.person .est { font-size: 12px; color: var(--muted); }
.outfit-pick { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; }
.outfit-pick img { width: 46px; height: 62px; object-fit: cover; border-radius: 6px; border: 2px solid transparent; cursor: pointer; background: var(--cream); }
.outfit-pick img.on { border-color: var(--red); }

/* 지시문 칸 */
.sec { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin-bottom: 10px; background: #fffdf9; }
.sec.changed { border-color: var(--amber); background: var(--amber-l); }
.sec.disabled { opacity: .5; }
.sec header { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sec header strong { font-size: 15px; }
.sec .desc { font-size: 13px; color: var(--muted); margin: 2px 0 6px; }
.badge { font-size: 12px; padding: 1px 8px; border-radius: 10px; background: var(--amber); color: #fff; font-weight: 700; }
.badge.green { background: var(--green); }
.badge.gray { background: #999; }
.sec textarea, .full textarea { width: 100%; min-height: 60px; resize: vertical; font-family: Consolas, "D2Coding", monospace; font-size: 13px; line-height: 1.45; }
.sec header .sp { margin-left: auto; }
.warn { color: var(--amber); font-size: 13px; font-weight: 600; }
details.final pre, .prompt-pre { white-space: pre-wrap; word-break: break-word; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 10px; font-size: 12.5px; max-height: 420px; overflow: auto; font-family: Consolas, monospace; }
details summary { cursor: pointer; font-weight: 700; padding: 4px 0; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
mark { background: #ffe08a; }

/* 만들기 */
.make { position: sticky; bottom: 0; background: #fff; border: 2px solid var(--red); border-radius: 14px; padding: 12px 16px; display: flex; gap: 16px; align-items: center; flex-wrap: wrap; box-shadow: 0 -4px 16px rgba(0,0,0,.06); }
.make button.primary { padding: 10px 26px; font-size: 16px; }

/* 결과 */
.results { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.result { background: var(--cream); border-radius: 12px; padding: 12px; text-align: center; }
.result h3 { margin: 0 0 8px; font-size: 16px; }
.result img { width: 100%; max-width: 480px; border-radius: 6px; box-shadow: 0 3px 12px rgba(0,0,0,.15); background: #fff; }
.result .meta { font-size: 13px; color: var(--muted); margin-top: 6px; }
.spinner { width: 100%; max-width: 480px; aspect-ratio: 2/3; margin: 0 auto; display: grid; place-items: center; background: #fff; border-radius: 6px; color: var(--muted); }
.spinner::before { content: ""; width: 38px; height: 38px; border: 4px solid var(--cream-d); border-top-color: var(--red); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.submit-box { display: grid; gap: 8px; }
.submit-box textarea { min-height: 70px; }
.sent { background: var(--green-l); color: var(--green); padding: 10px 14px; border-radius: 10px; font-weight: 700; }

/* 기록 */
.list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.item { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px; cursor: pointer; display: grid; gap: 6px; }
.item:hover { border-color: var(--red); }
.item .thumbs { display: flex; gap: 6px; }
.item .thumbs img, .item .thumbs .ph { width: 50%; aspect-ratio: 1200/1800; object-fit: cover; border-radius: 6px; background: var(--cream); }
.item .ph { display: grid; place-items: center; font-size: 12px; color: var(--muted); }
.chips { display: flex; gap: 4px; flex-wrap: wrap; }
.chip { font-size: 12px; background: var(--cream-d); border-radius: 10px; padding: 1px 8px; }
.chip.amber { background: var(--amber-l); color: var(--amber); }

@media (max-width: 900px) {
  .grid, .results, .two { grid-template-columns: 1fr; }
  main { padding: 12px 10px 80px; }
  .budget { margin-left: 0; width: 100%; }
  .top { gap: 8px; }
  .make { position: static; }
}
