:root {
  color-scheme: light;
  --paper: #faf9fc;
  --white: #fff;
  --ink: #161d28;
  --muted: #586272;
  --line: #e9e4ef;
  --accent: #e8ddff;
  --radius: 24px;
  font-family: Inter, "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100dvh; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .5; }
:focus-visible { outline: 3px solid #4c6db3; outline-offset: 3px; }
[hidden] { display: none !important; }

.app {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  width: min(620px, 100%);
  margin: 0 auto;
  padding: 0 18px max(22px, env(safe-area-inset-bottom));
}

.header {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 55px;
  padding-top: env(safe-area-inset-top);
}

.header h1 { margin: 0; font-size: 1.19rem; letter-spacing: -.05em; }

.quiet {
  min-height: 40px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  background: var(--white);
  font-size: .83rem;
  font-weight: 650;
  white-space: nowrap;
}

.quiet:hover, .settings[aria-expanded="true"] { background: #efebfa; }

.presence {
  position: sticky;
  top: 0;
  align-self: start;
  z-index: 2;
  padding: 3px 0 6px;
  background: var(--paper);
}

.stage {
  position: relative;
  height: clamp(250px, 57svh, 545px);
  overflow: hidden;
  border-radius: var(--radius);
  isolation: isolate;
  border: 1px solid var(--line);
  background: var(--white);
}

.stage[data-panel-open] { height: clamp(180px, 37svh, 360px); }

.portrait {
  position: absolute;
  inset: 9px 0 0;
}

.avatar {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center bottom;
}

#avatar-motion { pointer-events: none; }

.stage-controls { display: flex; align-items: center; gap: 8px; }
.stop-reply {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 44px;
  padding: 7px 13px;
  border: 1px solid #ffffff85;
  border-radius: 100px;
  background: #fff7f2;
  color: #312131;
  font-size: .83rem;
  font-weight: 750;
  white-space: nowrap;
}

.stop-reply::before { width: 8px; height: 8px; border-radius: 2px; background: #b03c53; content: ""; }
.stop-reply:hover { background: #fce5e4; }

.stage-footer {
  position: absolute;
  z-index: 1;
  inset: auto 12px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 6px 11px;
  border: 1px solid #e6dded;
  border-radius: 100px;
  background: #faf7fff2;
  color: #403751;
  font-size: .78rem;
  font-weight: 650;
}

.status::before {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #b8c2d1;
  content: "";
}

.stage[data-state="listening"] .status::before,
.stage[data-state="talking"] .status::before { background: #8a60c2; }
.stage[data-state="thinking"] .status::before,
.stage[data-state="connecting"] .status::before { background: #f7d78b; }

.workspace { display: grid; align-content: start; gap: 8px; min-width: 0; }
.panel {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--white);
}

.bubble {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-height: 46px;
  margin-bottom: 8px;
  padding: 10px 12px;
  border-radius: 15px;
  background: #f4f0f8;
}

.bubble p {
  flex: 1;
  max-height: 5.4em;
  overflow: auto;
  overflow-wrap: anywhere;
  margin: 0;
  font-size: .93rem;
  line-height: 1.6;
}

.read { min-height: 30px; padding: 4px 8px; font-size: .74rem; }
.ask { display: flex; align-items: center; gap: 8px; }

input, select {
  width: 100%;
  min-width: 0;
  min-height: 46px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  font-size: 1rem;
}

input::placeholder { color: var(--muted); }
.ask button {
  flex: 0 0 46px;
  min-height: 46px;
  border: 0;
  border-radius: 12px;
  background: var(--ink);
  color: #fff;
  font-size: 1.35rem;
}

.ask button:hover { background: #34425a; }
.actions { display: grid; grid-template-columns: 1.15fr 1fr 1fr; gap: 8px; }
.actions button, .primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 54px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: #fff;
  color: var(--ink);
  font-size: .91rem;
  font-weight: 700;
}

.actions button:hover, .actions button[aria-expanded="true"] { background: #efebfa; }
.actions .primary, .primary { border-color: #e0d2fa; background: var(--accent); }
.actions .primary:hover, .primary:hover { background: #dbcbfa; }
.actions .primary[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.actions button::before { flex: 0 0 auto; content: ""; }
#talk::before {
  width: 2px;
  height: 14px;
  margin: 0 4px;
  border-radius: 2px;
  background: currentColor;
  box-shadow: -4px 2px 0 -0.2px currentColor, 4px -2px 0 -0.2px currentColor;
}

#camera::before {
  width: 15px;
  height: 12px;
  border: 1.5px solid currentColor;
  border-radius: 4px;
  background: radial-gradient(circle, currentColor 1.5px, transparent 2px);
}

#schedule::before {
  width: 14px;
  height: 14px;
  border: 1.5px solid currentColor;
  border-radius: 3px;
  background: linear-gradient(transparent 25%, currentColor 25% 36%, transparent 36%);
}

.notice, .help { margin: 0; font-size: .85rem; line-height: 1.55; color: var(--muted); }
.notice { padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.panel h2 { margin: 0 0 14px; font-size: 1.2rem; letter-spacing: -.035em; }
.panel-form, .events { display: grid; gap: 10px; }
.panel-form label { display: grid; gap: 6px; min-width: 0; color: var(--muted); font-size: .85rem; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.events { list-style: none; margin: 0 0 14px; padding: 0; }
.events li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: #f1f3ed;
  overflow-wrap: anywhere;
}

.events small { display: block; margin-top: 3px; color: var(--muted); }
video { display: block; width: 100%; max-height: 38dvh; margin-bottom: 12px; border-radius: 15px; background: #151e35; }
.help { margin-top: 8px; }

@media (max-width: 700px) {
  .app { max-width: 490px; padding-inline: 12px; }
  .header { min-height: 50px; }
  .stage { border-radius: 20px; }
  .panel { padding: 15px; border-radius: 19px; }
  .actions button { min-height: 49px; padding-inline: 6px; font-size: .86rem; }
}
