:root {
  color-scheme: light;
  --ink: #3d2b24;
  --muted: #a08b82;
  --orange: #ef8b34;
  --orange-deep: #d86d1d;
  --line: rgba(90, 48, 28, 0.1);
  --shadow: 0 24px 60px rgba(120, 72, 36, 0.12);
  font-family: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
}

body {
  color: var(--ink);
  background: #eceae6;
}

body:not(.admin) {
  display: grid;
  place-items: center;
  min-height: 100%;
}

button, input, textarea { font: inherit; color: inherit; }

.stage {
  position: relative;
  width: min(100vw, calc(100dvh * 9 / 16));
  height: min(100dvh, calc(100vw * 16 / 9));
  aspect-ratio: 9 / 16;
  overflow: hidden;
  background: #f3f1ef;
  cursor: pointer;
}

.talking {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #f3f1ef;
  pointer-events: none;
}

.config-link, .back {
  color: rgba(150, 126, 114, 0.72);
  text-decoration: none;
  font-size: 14px;
}

.config-link {
  position: absolute;
  z-index: 4;
  top: 18px;
  right: 20px;
}

.config-link:hover, .back:hover { color: var(--ink); }

.dock {
  position: absolute;
  z-index: 4;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: min(560px, calc(100% - 28px));
  transform: translateX(-50%);
  pointer-events: none;
}

.captions {
  width: 100%;
  text-align: center;
  pointer-events: none;
}

.caption-user, .caption {
  margin: 0;
  line-height: 1.65;
}

.caption-user {
  color: rgba(168, 146, 134, 0.48);
  font-size: 13px;
}

.caption-user:empty { display: none; }

.caption {
  margin-top: 4px;
  color: rgba(146, 122, 110, 0.72);
  font-size: 15px;
  font-weight: 500;
  text-shadow: 0 1px 10px rgba(255, 250, 245, 0.85);
  overflow-wrap: anywhere;
}

.caption:empty { display: none; }

.status {
  margin: 0;
  color: rgba(160, 138, 126, 0.62);
  font-size: 12px;
  pointer-events: none;
}

.composer {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  align-items: center;
  width: 100%;
  padding: 8px;
  border-radius: 999px;
  background: rgba(255, 252, 248, 0.46);
  box-shadow: 0 10px 30px rgba(120, 72, 36, 0.06);
  pointer-events: auto;
}

.text-label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

#text {
  width: 100%;
  border: 0;
  background: transparent;
  padding: 10px 8px;
  outline: none;
  color: rgba(90, 64, 54, 0.82);
}

#text::placeholder { color: rgba(160, 138, 126, 0.7); }

.mic, .send, .ghost {
  border: 0;
  cursor: pointer;
}

.mic, .send {
  border-radius: 999px;
  padding: 10px 16px;
  background: rgba(239, 139, 52, 0.88);
  color: white;
  font-weight: 600;
}

.mic {
  background: rgba(255, 252, 248, 0.7);
  color: rgba(196, 112, 48, 0.85);
}

.send:hover, body[data-state="listening"] .mic {
  background: var(--orange-deep);
  color: white;
}

.mic:disabled { opacity: 0.45; cursor: not-allowed; }

body[data-state="listening"] .mic { animation: pulse 1.1s ease-in-out infinite; }

body.admin {
  min-height: 100%;
  overflow: auto;
}

.sheet {
  width: min(720px, calc(100% - 32px));
  margin: 28px auto 48px;
  padding: 28px 28px 22px;
  border-radius: 28px;
  background: rgba(255, 252, 248, 0.78);
  box-shadow: var(--shadow);
}

.sheet-head h1 {
  margin: 10px 0 6px;
  font-size: 32px;
  font-weight: 650;
}

.sheet-head p, .hint {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.sheet section {
  margin-top: 26px;
  padding-top: 8px;
}

.sheet h2 {
  margin: 0 0 8px;
  font-size: 18px;
}

.sheet label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 14px;
  color: #8d7368;
  font-size: 13px;
}

.sheet input, .sheet textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.86);
  color: var(--ink);
  outline: none;
}

.sheet textarea { resize: vertical; line-height: 1.55; }

.sheet input:focus, .sheet textarea:focus {
  box-shadow: 0 0 0 2px rgba(239, 139, 52, 0.28);
}

.sheet input[type="checkbox"] { width: auto; }

.check {
  flex-direction: row !important;
  align-items: center;
  gap: 8px;
}

.split {
  display: grid;
  grid-template-columns: 1.4fr 0.8fr 0.8fr;
  gap: 12px;
}

.sheet-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  margin-top: 22px;
}

.form-error { color: #b42318; font-size: 13px; }

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

@media (max-width: 700px) {
  .caption { font-size: 14px; }
  .split { grid-template-columns: 1fr; }
  .sheet { padding: 20px 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .mic { animation: none !important; }
}
