:root {
  --ink:#2A2522; --soft:#6B635C; --sky:#D9ECF7; --meadow:#F2F1D5; --hair:#7FA3C0; --cheek:#F2B8BF;
  --line:2.5px solid var(--ink); --dlg:'Gamja Flower', sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: #fff; color: var(--ink); font-family: 'Poor Story', sans-serif; font-size: 16px; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .45; }
:focus-visible { outline: 3px solid #5B9BD5; outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
[hidden] { display: none !important; }

.phone { max-width: 480px; height: 100dvh; margin: 0 auto; display: flex; flex-direction: column; background: var(--meadow); }

header { padding: 10px 14px; display: flex; align-items: center; gap: 10px; background: #fff; border-bottom: var(--line); }
header .face { width: 40px; height: 40px; }
h1 { margin: 0; font-family: var(--dlg); font-weight: normal; font-size: 22px; line-height: 1.1; }
header small { color: var(--soft); font-size: 12px; }
#mode { margin-left: auto; min-height: 36px; padding: 0 12px; background: #fff; border: 2px solid var(--ink); border-radius: 14px; font-size: 13px; }

main { flex: 1; min-height: 0; display: flex; flex-direction: column; }
/* 하늘 → 풀밭 장면. 풀 무늬는 직접 그린 SVG */
#chat { background:
  url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='120'%3E%3Cg fill='none' stroke='%239CC583' stroke-width='2.2' stroke-linecap='round'%3E%3Cpath d='M16 34l-3-9M21 34l0-11M26 34l3-8'/%3E%3Cpath d='M96 96l-3-8M101 96l0-10M106 96l3-7'/%3E%3C/g%3E%3C/svg%3E"),
  linear-gradient(var(--sky), var(--meadow) 140px); }

.stage { position: relative; flex: 1; min-height: 0; }
.log { height: 100%; overflow-y: auto; padding: 14px; }
/* 추천 칩은 대화 위에 투명하게 띄움: 대화가 칩 뒤로 지나가 경계선이 안 생김 */
.stage:has(.chips:not(:empty)) .log { padding-bottom: 86px; }
.row { display: flex; margin: 10px 0; }
.row.me { justify-content: flex-end; margin-bottom: 14px; }
.me .bubble { max-width: 74%; padding: 6px 10px; background: #fff; border: 2px solid var(--hair); border-radius: 16px 16px 4px 16px; font-size: 16px; line-height: 1.4; word-break: keep-all; overflow-wrap: break-word; white-space: pre-wrap; }

/* 하치와레: 얼굴은 말풍선 왼쪽 위, 지문은 말풍선 밖 위, 말풍선엔 대사만 */
.row.hw { display: grid; grid-template-columns: 46px 1fr; column-gap: 10px; }
.face { width: 46px; height: 46px; border-radius: 50%; border: var(--line); background: #fff; }
.hw .face { grid-row: 1 / span 3; }
.act { margin: 2px 0 4px 6px; font-size: 13.5px; color: var(--soft); }
.act:empty { display: none; }
.hw .bubble { position: relative; justify-self: start; max-width: 82%; padding: 5px 8px 6px; background: #fff; border: var(--line);
  border-radius: 16px 15px 16px 14px / 14px 16px 15px 16px; font-family: var(--dlg); font-size: 17px; line-height: 1.35;
  word-break: keep-all; overflow-wrap: break-word; white-space: pre-wrap; }
/* 꼬리: 위쪽에서 얼굴을 가리킴 */
.hw .bubble::before { content: ""; position: absolute; left: -11px; top: 9px; width: 14px; height: 12px; background: #fff;
  border-left: var(--line); border-top: var(--line); border-radius: 4px 0 0 0; transform: skewX(35deg) rotate(-8deg); }
.dots { color: var(--soft); }

.fb { display: flex; gap: 2px; margin: 2px 0 0; }
.fb button { width: 34px; height: 34px; background: none; border: 0; color: var(--soft); display: grid; place-items: center; border-radius: 50%; }
.fb svg { width: 17px; height: 17px; }
.fb button[aria-pressed="true"] { background: var(--cheek); color: var(--ink); }

/* 추천 = 아직 안 보낸 내 말: 오른쪽 점선 말풍선 한 줄, 가로 스크롤 */
.reply { position: absolute; left: 0; right: 0; bottom: 0; padding: 2px 14px 8px; text-align: right; pointer-events: none; }
.reply > * { pointer-events: auto; }
.reply:has(.chips:empty) { display: none; }
.reply small { font-size: 12.5px; color: var(--soft); background: #ffffffb3; padding: 1px 6px; border-radius: 8px; }
.chips { display: flex; gap: 6px; margin-top: 4px; padding: 2px 0; overflow-x: auto; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips button:first-child { margin-left: auto; }
.chips button { flex: none; min-height: 40px; padding: 0 12px; background: #fffffff2; border: 2px dashed var(--hair); border-radius: 16px 16px 4px 16px; font-size: 15px; white-space: nowrap; }

form { display: flex; gap: 8px; padding: 10px 14px 6px; border-top: var(--line); background: var(--meadow); }
form input { flex: 1; min-width: 0; min-height: 46px; padding: 0 16px; background: #fff; border: var(--line); border-radius: 23px; font-size: 16px; }
form input:disabled { background: #F3F2EF; }
#send { width: 46px; height: 46px; flex: none; background: var(--sky); border: var(--line); border-radius: 50%; display: grid; place-items: center; padding: 0; }

.tone-body { flex: 1; overflow-y: auto; padding: 12px 14px; }
.tone-help { margin: 4px 0 10px; color: var(--soft); font-size: 14px; }
.tone-form { flex-direction: column; padding: 0; border: 0; background: none; }
.tone-form textarea { width: 100%; padding: 12px 14px; font: inherit; font-size: 16px; resize: none; background: #fff; border: var(--line); border-radius: 16px; }
.tone-bar { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; }
.tone-bar span { color: var(--soft); font-size: 13px; }
#tone-go { min-height: 44px; padding: 0 20px; background: var(--sky); border: var(--line); border-radius: 22px; }
#tone-go:disabled { opacity: .5; }
.card { margin: 14px 0 0; padding: 10px 14px; background: #fff; border: var(--line); border-radius: 16px; }
.card h2 { margin: 0 0 4px; font-size: 13px; font-weight: normal; color: var(--soft); }
.card p { margin: 0 0 6px; font-family: var(--dlg); font-size: 18px; line-height: 1.4; word-break: keep-all; overflow-wrap: break-word; }
.card button { min-height: 40px; padding: 0 14px; background: #fff; border: 2px solid var(--ink); border-radius: 14px; font-size: 14px; }

.notice { margin: 0; padding: 0 14px calc(8px + env(safe-area-inset-bottom)); text-align: center; font-size: 12px; color: var(--soft); background: var(--meadow); }

dialog { max-width: 320px; padding: 20px; background: #fff; color: var(--ink); text-align: center; border: var(--line); border-radius: 18px; }
dialog::backdrop { background: rgba(0,0,0,.35); }
dialog p { margin: 0 0 16px; line-height: 1.6; }
dialog button { min-height: 44px; padding: 0 20px; background: var(--sky); border: var(--line); border-radius: 22px; }

@media (min-width: 600px) { .phone { border-left: 1px dashed #D8D4CE; border-right: 1px dashed #D8D4CE; } }
