:root {
  color-scheme: light;
  --paper: #fbfbfa;
  --ink: #171817;
  --muted: rgba(23, 24, 23, .43);
  --line: rgba(23, 24, 23, .11);
  --copper: #a94320;
  --control-bg: #171817;
  --control-fg: #fff;
}

@font-face {
  font-family: "Voice Matter Rounded";
  src: url("./assets/fonts/ResourceHanRoundedCN-Heavy.ttf") format("truetype");
  font-weight: 900;
  font-display: block;
}

@font-face {
  font-family: "Noto Sans Thai Local";
  src: url("./assets/fonts/NotoSansThai-Bold.ttf") format("truetype");
  font-weight: 700;
  font-display: swap;
}

@font-face {
  font-family: "Noto Sans Lao Local";
  src: url("./assets/fonts/NotoSansLao-Bold.ttf") format("truetype");
  font-weight: 700;
  font-display: swap;
}

@font-face {
  font-family: "Noto Sans Khmer Local";
  src: url("./assets/fonts/NotoSansKhmer-Bold.ttf") format("truetype");
  font-weight: 700;
  font-display: swap;
}

@font-face {
  font-family: "Noto Sans Myanmar Local";
  src: url("./assets/fonts/NotoSansMyanmar-Bold.ttf") format("truetype");
  font-weight: 700;
  font-display: swap;
}

* { box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #fff;
  color: var(--ink);
  font-family: "Helvetica Neue", "PingFang SC", sans-serif;
}

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

#stage {
  position: relative;
  width: 100vw;
  height: 100vh;
  isolation: isolate;
  color: var(--ink);
  background: #fff;
}

#stage[data-scene="depth"] {
  --paper: #fbfbfa;
  --ink: #171817;
  --muted: rgba(23, 24, 23, .46);
  --line: rgba(23, 24, 23, .11);
  --copper: #a94320;
  --control-bg: rgba(24, 25, 24, .94);
  --control-fg: #fff;
  background: #fff;
}

#stage::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 20;
  pointer-events: none;
  opacity: .022;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 160 160' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.86' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.2'/%3E%3C/svg%3E");
}

#world {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  touch-action: none;
}

.depth-background {
  position: absolute;
  inset: -18px;
  z-index: 0;
  overflow: hidden;
  background: #fff url("./assets/pexels-max-vakhtbovych-7031577.jpg") center 45% / cover no-repeat;
  transform: translate3d(var(--bg-x, 0), var(--bg-y, 0), 0) scale(1.025);
  transition: opacity .55s ease;
  will-change: transform;
  filter: grayscale(1) saturate(0) contrast(.58) brightness(1.27);
}

.depth-background::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(to bottom, rgba(255,255,255,.2), rgba(255,255,255,.06) 55%, rgba(255,255,255,.38)),
    radial-gradient(ellipse at 50% 46%, transparent 20%, rgba(255,255,255,.12) 68%, rgba(255,255,255,.4) 100%);
}

#stage:not([data-scene="depth"]) .depth-background { opacity: 0; }

.topbar {
  position: absolute;
  inset: 0 0 auto;
  height: 98px;
  z-index: 5;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 42px;
  border-bottom: 1px solid var(--line);
  pointer-events: none;
}

#stage[data-scene="depth"] .topbar {
  background: linear-gradient(to bottom, rgba(255,255,255,.88), rgba(255,255,255,.22));
}

.identity { display: grid; gap: 5px; justify-self: start; }
.identity strong { font: 700 17px/1 Menlo, monospace; letter-spacing: .2em; }
.identity small { color: var(--muted); font: 500 8px/1.2 Menlo, monospace; letter-spacing: .13em; }
.counter { color: var(--copper); font: 700 8px/1 Menlo, monospace; letter-spacing: .15em; }
.counter b { font-size: 10px; }
.center-tools { display: flex; align-items: center; gap: 18px; pointer-events: auto; }
.center-tools label { display: flex; align-items: center; gap: 6px; color: var(--muted); font: 500 8px/1 Menlo, monospace; letter-spacing: .08em; }
.center-tools select {
  appearance: none;
  min-width: 84px;
  padding: 5px 18px 5px 7px;
  border: 1px solid var(--line);
  border-radius: 2px;
  outline: 0;
  color: var(--ink);
  background: color-mix(in srgb, var(--paper) 76%, transparent);
  font: 500 9px/1 "PingFang SC", sans-serif;
  cursor: pointer;
}
.status { justify-self: end; display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 11px; letter-spacing: .08em; }
.status i { width: 7px; height: 7px; border-radius: 50%; background: #c8bdb2; box-shadow: 0 0 0 5px rgba(169,67,32,.04); }
.status.listening { color: var(--copper); }
.status.listening i { background: var(--copper); animation: pulse 1.1s ease-in-out infinite; }

.horn {
  position: absolute;
  z-index: 4;
  left: -48px;
  top: 50%;
  width: 204px;
  height: 176px;
  transform: translateY(-50%);
  filter: drop-shadow(8px 15px 18px rgba(14,16,17,.13));
  pointer-events: none;
}

.horn svg { display: block; width: 100%; height: 100%; overflow: visible; }

.utterance {
  position: absolute;
  z-index: 5;
  left: 42px;
  bottom: 122px;
  display: grid;
  gap: 7px;
  pointer-events: none;
}

.utterance small { color: var(--copper); font: 500 8px/1 Menlo, monospace; letter-spacing: .16em; }
.utterance span { max-width: min(52vw, 760px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 400 17px/1.2 "Songti SC", serif; color: var(--muted); }

.controls {
  position: absolute;
  z-index: 8;
  inset: auto 0 0;
  height: 96px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 42px;
  border-top: 1px solid var(--line);
  background: rgba(255,255,255,.78);
  backdrop-filter: blur(12px);
}

#stage[data-scene="depth"] .controls {
  background: rgba(255,255,255,.76);
  box-shadow: 0 -18px 40px rgba(35, 34, 30, .045);
}

#text-form { justify-self: start; display: flex; align-items: center; gap: 13px; }
#text-form label, .actions button { color: var(--muted); font-size: 10px; letter-spacing: .1em; }
#text-input { width: 165px; padding: 8px 0; border: 0; border-bottom: 1px solid var(--line); outline: 0; background: transparent; color: var(--ink); font-size: 12px; }
#text-input:focus { border-bottom-color: var(--copper); }
#text-input::placeholder { color: var(--muted); }

#mic-button {
  justify-self: center;
  width: 236px;
  height: 60px;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 20px 0 12px;
  border: 0;
  border-radius: 31px;
  background: var(--control-bg);
  color: var(--control-fg);
  box-shadow: 0 16px 30px rgba(24,22,19,.2);
  cursor: pointer;
  transition: transform .18s ease, background .18s ease;
}

#mic-button:hover { transform: translateY(-2px); }
#mic-button:active { transform: translateY(0) scale(.985); }
#mic-button[aria-pressed="true"] { background: var(--copper); }
#mic-button b { flex: 1; text-align: left; font-size: 13px; letter-spacing: .05em; }
.mic-icon { position: relative; width: 39px; height: 39px; flex: 0 0 39px; border-radius: 50%; background: var(--copper); }
#mic-button[aria-pressed="true"] .mic-icon { background: rgba(255,255,255,.2); }
.mic-icon::before { content: ""; position: absolute; left: 16px; top: 9px; width: 7px; height: 13px; border: 2px solid white; border-radius: 6px; }
.mic-icon::after { content: ""; position: absolute; left: 13px; top: 18px; width: 13px; height: 9px; border: 2px solid white; border-top: 0; border-radius: 0 0 9px 9px; }
.mic-icon i { position: absolute; left: 19px; top: 27px; width: 2px; height: 5px; background: white; }

.actions { justify-self: end; display: flex; align-items: center; gap: 22px; }
.actions button { padding: 8px 0; border: 0; border-bottom: 1px solid var(--line); background: transparent; cursor: pointer; }
.actions button:hover { color: var(--copper); border-color: var(--copper); }

.shortcut { position: absolute; z-index: 9; right: 42px; bottom: 8px; color: rgba(23,24,23,.22); font: 500 7px/1 Menlo, monospace; letter-spacing: .1em; pointer-events: none; }

@keyframes pulse { 50% { box-shadow: 0 0 0 10px rgba(169,67,32,.12); } }

@media (max-width: 820px) {
  .topbar { padding: 0 22px; }
  .identity small, .counter, .center-tools label, #text-form, .shortcut { display: none; }
  .controls { grid-template-columns: 1fr auto; padding: 0 22px; }
  #mic-button { justify-self: start; }
  .actions { grid-column: 2; }
  .actions #demo-button { display: none; }
  .utterance { left: 22px; }
}

@media (min-width: 821px) and (max-width: 1150px) {
  .topbar { padding-inline: 24px; grid-template-columns: auto 1fr auto; gap: 20px; }
  .center-tools { justify-self: center; gap: 9px; }
  .counter, .identity small { display: none; }
  .identity strong { font-size: 13px; letter-spacing: .12em; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .depth-background { transform: none; }
}

#stage[data-exhibit="true"] .topbar,
#stage[data-exhibit="true"] .controls,
#stage[data-exhibit="true"] .utterance,
#stage[data-exhibit="true"] .shortcut {
  visibility: hidden;
  pointer-events: none;
}

#stage[data-exhibit="true"] #box-room { inset: 0; }
