:root {
  --bg: #fff8ef; --card: #ffffff; --ink: #2b2420; --sub: #6f625a; --line: #eadccd;
  --accent: #e8743b; --accent-ink: #ffffff; --soft: #fdebdc; --ok: #3f9b6a; --danger: #c2453a;
  --peach: #ffd9c2; --mint: #c9f0dc; --sky: #cfe6ff; --lemon: #fff1a8; --lilac: #e5d8ff;
  --r: 18px;
}
* { box-sizing: border-box; }
html { font-size: 19px; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", "Noto Sans KR", sans-serif;
  line-height: 1.5; padding-bottom: calc(96px + env(safe-area-inset-bottom));
}
.top { display: flex; align-items: baseline; gap: 12px; padding: 14px 20px; max-width: 980px; margin: 0 auto; }
.logo { font-size: 1.5rem; font-weight: 800; color: var(--ink); text-decoration: none; }
.tag { color: var(--sub); font-size: .9rem; }
main { max-width: 980px; margin: 0 auto; padding: 0 16px 24px; }
h1 { font-size: 1.5rem; margin: 8px 0 14px; }
h2 { font-size: 1.2rem; margin: 26px 0 10px; }
p { margin: 6px 0; }
.sub { color: var(--sub); }
.loading { color: var(--sub); padding: 40px 0; text-align: center; }

.card { background: var(--card); border: 2px solid var(--line); border-radius: var(--r); padding: 18px; margin: 12px 0; }
.btn {
  display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%;
  min-height: 64px; padding: 12px 18px; margin: 10px 0; border: 0; border-radius: var(--r);
  background: var(--accent); color: var(--accent-ink); font: inherit; font-size: 1.15rem; font-weight: 700;
  cursor: pointer; text-decoration: none; text-align: center;
}
.btn.ghost { background: var(--soft); color: var(--ink); }
.btn.line { background: transparent; color: var(--ink); border: 2px solid var(--line); }
.btn.small { min-height: 52px; font-size: 1rem; width: auto; margin: 6px 0; }
.btn:disabled { opacity: .5; cursor: default; }
.btn:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible { outline: 4px solid #f3b38f; outline-offset: 2px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > .btn { flex: 1 1 140px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.grid .btn { margin: 0; flex-direction: column; min-height: 96px; font-size: 1.05rem; }
.choice { background: var(--soft); color: var(--ink); border: 3px solid transparent; }
.choice[aria-pressed="true"] { border-color: var(--accent); background: #ffe1cc; }
.choice .big { font-size: 2rem; line-height: 1; }
.choice small { font-weight: 500; color: var(--sub); font-size: .8rem; }

label { display: block; font-weight: 700; margin: 16px 0 6px; }
input, textarea {
  width: 100%; font: inherit; font-size: 1.1rem; padding: 14px 16px; min-height: 60px;
  border: 2px solid var(--line); border-radius: 14px; background: #fff; color: var(--ink);
}
textarea { min-height: 96px; resize: vertical; }
.hint { color: var(--sub); font-size: .85rem; margin-top: 4px; }
.err { color: var(--danger); font-weight: 700; min-height: 1.5em; }

.tabs { display: flex; gap: 8px; margin: 10px 0 4px; }
.tabs .btn { margin: 0; }

.house-hero { display: flex; align-items: center; gap: 16px; border-radius: var(--r); padding: 18px; margin: 10px 0; }
.house-hero .face { font-size: 3.4rem; line-height: 1; background: #fff; border-radius: 50%; width: 84px; height: 84px; display: flex; align-items: center; justify-content: center; flex: none; }
.house-hero .name { font-size: 1.3rem; font-weight: 800; }
.c-peach { background: var(--peach); } .c-mint { background: var(--mint); } .c-sky { background: var(--sky); }
.c-lemon { background: var(--lemon); } .c-lilac { background: var(--lilac); }

.houses { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.house-card { border-radius: var(--r); padding: 16px; border: 2px solid rgba(0,0,0,.05); }
.house-card .head { display: flex; gap: 12px; align-items: center; }
.house-card .face { font-size: 2.4rem; background: #fff; border-radius: 50%; width: 64px; height: 64px; display: flex; align-items: center; justify-content: center; flex: none; }
.house-card .btn { margin-bottom: 0; }

.chat { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; }
.bubble { max-width: 86%; padding: 12px 16px; border-radius: 18px; white-space: pre-wrap; word-break: break-word; }
.bubble.res { background: #fff; border: 2px solid var(--line); align-self: flex-start; border-top-left-radius: 6px; }
.bubble.me { background: #ffe1cc; align-self: flex-end; border-top-right-radius: 6px; }
.bubble .who { display: block; font-size: .8rem; color: var(--sub); font-weight: 700; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.chips .btn { width: auto; flex: 1 1 auto; min-height: 56px; margin: 0; font-size: 1rem; }
.say { display: flex; gap: 8px; }
.say input { flex: 1; }
.say .btn { width: auto; margin: 0; min-width: 110px; }

.gb-item { border-top: 2px dashed var(--line); padding: 12px 0; display: flex; gap: 10px; align-items: flex-start; justify-content: space-between; }
.gb-item:first-child { border-top: 0; }
.gb-item .text { white-space: pre-wrap; word-break: break-word; }
.gb-item .meta { color: var(--sub); font-size: .8rem; }
.gb-item .btn { flex: none; }

.visit { border-left: 8px solid var(--line); }
.visit.new { border-left-color: var(--accent); }
.visit .title { font-weight: 800; font-size: 1.1rem; }
.pill { display: inline-block; background: var(--accent); color: #fff; border-radius: 999px; padding: 2px 10px; font-size: .8rem; font-weight: 800; margin-left: 6px; }
details { margin: 8px 0; }
summary { cursor: pointer; font-weight: 700; min-height: 48px; display: flex; align-items: center; }

.bottom {
  position: fixed; left: 0; right: 0; bottom: 0; display: flex; background: #fff; border-top: 2px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom); z-index: 10;
}
.bottom a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 76px; color: var(--sub); text-decoration: none; font-weight: 700; font-size: .95rem; position: relative; }
.bottom a span { font-size: 1.7rem; line-height: 1.1; }
.bottom a.on { color: var(--accent); background: var(--soft); }
#badge { position: absolute; top: 8px; left: calc(50% + 10px); background: var(--danger); color: #fff; border-radius: 999px; min-width: 26px; height: 26px; font-size: .85rem; display: flex; align-items: center; justify-content: center; padding: 0 6px; }
#badge[hidden], #toast[hidden] { display: none; }
#toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(96px + env(safe-area-inset-bottom)); background: var(--ink); color: #fff; padding: 14px 20px; border-radius: 14px; font-weight: 700; z-index: 20; max-width: 92vw; }

.scene { display: block; width: 100%; height: auto; image-rendering: pixelated; image-rendering: crisp-edges; border-radius: var(--r); border: 3px solid #6b4529; margin: 10px 0; background: #bfe3a1; }
.agents { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.agent { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 84px; padding: 10px 14px; border-radius: var(--r); border: 2px solid var(--line); background: #fff; font: inherit; color: inherit; text-align: left; cursor: pointer; }
.agent.st-working { border-color: #7fd1a3; }
.agent.offline { opacity: .65; }
.agent .sprite { width: 64px; height: 64px; image-rendering: pixelated; flex: none; background: #e9f5df; border-radius: 12px; }
.agent-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1; }
.agent-name { font-weight: 800; font-size: 1.05rem; overflow-wrap: anywhere; }
.agent-meta { color: var(--sub); font-size: .85rem; }
.pill.st-working { background: var(--ok); } .pill.st-idle { background: #6f8fd6; } .pill.st-done { background: #8a7f76; }
.agent-meta .pill { margin-left: 0; }
.ctx { position: relative; display: block; height: 22px; background: #f1e6da; border-radius: 999px; overflow: hidden; }
.ctx-fill { position: absolute; left: 0; top: 0; bottom: 0; background: #f3b38f; }
.ctx-text { position: relative; font-size: .75rem; font-weight: 700; padding-left: 10px; line-height: 22px; }
.agent-detail { padding: 6px 10px 10px; }
#device-token { font-family: ui-monospace, Menlo, monospace; font-size: .9rem; }

@media (min-width: 760px) {
  html { font-size: 20px; }
  .two { display: grid; grid-template-columns: 1.2fr 1fr; gap: 20px; align-items: start; }
  .bottom { left: 50%; transform: translateX(-50%); max-width: 640px; border: 2px solid var(--line); border-bottom: 0; border-radius: 20px 20px 0 0; }
}
