/* 색과 글꼴은 원본 앱의 opal_style.dart(달빛 테마)에서 가져왔다. */
@font-face {
  font-family: "Manrope";
  src: url("fonts/Manrope-Variable.ttf") format("truetype");
  font-weight: 200 800;
  font-display: swap;
}

:root {
  --background: #101216;
  --panel: #1b1e24;
  --ink: #eaeff4;
  --muted: #a5adb8;
  --accent: #d3dce7;
  --soft: #292e37;
  --line: #3c434e;
  --on-silver: #181c23;
  --error: #ffb4ab;
  /* 대화 상태별 빛깔: 원본 구체의 대기/듣기/생각/말하기 색 */
  --glow: 120 130 145;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

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

body {
  background:
    radial-gradient(120% 70% at 50% -10%, rgba(47, 57, 70, .55), rgba(47, 57, 70, 0) 70%),
    var(--background);
  color: var(--ink);
  font-family: "Manrope", "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  font-weight: 600;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

.app {
  height: 100dvh;
  max-width: 560px;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 16px max(20px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  gap: 12px;
}

.app[data-state="listening"] { --glow: 86 196 190; }
.app[data-state="hearing"]   { --glow: 86 196 190; }
.app[data-state="thinking"]  { --glow: 150 122 226; }
.app[data-state="speaking"]  { --glow: 226 186 96; }
.app[data-state="error"]     { --glow: 255 140 130; }

.top { display: flex; align-items: center; justify-content: space-between; }
.wordmark { font-size: 22px; font-weight: 700; letter-spacing: .01em; }

.chip {
  display: inline-flex; align-items: center; gap: 8px;
  max-width: 70%;
  padding: 8px 14px;
  border: .7px solid #505a69; border-radius: 999px;
  background: rgba(27, 30, 36, .6); color: var(--muted);
  font: inherit; font-size: 13px; cursor: pointer;
}
.chip span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: #707986; }
.dot.on { background: #8bc6af; }
.dot.warn { background: #e2ba60; }

.stage {
  position: relative;
  display: grid; align-content: center; justify-items: center;
  gap: 14px; min-height: 0; text-align: center;
}

.halo {
  position: absolute; top: 50%; left: 50%;
  width: min(74vw, 46dvh, 380px); aspect-ratio: 1;
  translate: -50% -62%;
  border-radius: 50%;
  background: radial-gradient(circle, rgb(var(--glow) / .5), rgb(var(--glow) / 0) 68%);
  scale: var(--halo-scale, 1);
  transition: background .5s ease;
  pointer-events: none;
}

.bono {
  position: relative;
  width: min(52vw, 32dvh, 260px); aspect-ratio: 1;
  filter: drop-shadow(0 18px 30px rgba(0, 0, 0, .45));
  scale: var(--bono-scale, 1);
  animation: float 6s ease-in-out infinite;
}
#eyes { transform-origin: 100px 75px; transition: transform .09s ease; }
#eyes.blink { transform: scaleY(.08); }
.app[data-state="thinking"] #eyes { transform: translateY(-5px); }

@keyframes float { 0%, 100% { translate: 0 0; } 50% { translate: 0 -6px; } }

.status { margin: 6px 0 0; font-size: 20px; }
.hint { margin: 0; min-height: 1.4em; font-size: 14px; color: var(--muted); font-weight: 500; text-wrap: balance; }
.app[data-state="error"] .hint { color: var(--error); }

.talk {
  display: grid; gap: 8px;
  padding: 14px 16px;
  border: .7px solid var(--line); border-radius: 18px;
  background: rgba(27, 30, 36, .7);
  max-height: 26dvh; overflow-y: auto;
}
.line { margin: 0; display: grid; grid-template-columns: 44px 1fr; gap: 8px; font-size: 15px; line-height: 1.5; font-weight: 500; }
.who { color: var(--muted); font-size: 12px; padding-top: 3px; }
.you { color: var(--muted); }
.line span:last-child:empty::before { content: "…"; opacity: .4; }

.controls { display: grid; gap: 8px; justify-items: center; }

button { font-family: inherit; }
.primary {
  width: 100%; min-height: 58px;
  border: 0; border-radius: 999px;
  background: linear-gradient(180deg, #f1f5fa, #adb8c8);
  color: var(--on-silver);
  font-size: 18px; font-weight: 700; cursor: pointer;
  box-shadow: 0 10px 24px rgba(0, 0, 0, .3);
}
.primary:disabled { background: var(--soft); color: #707986; box-shadow: none; cursor: default; }
.ghost {
  min-height: 44px; padding: 0 18px;
  border: 0; border-radius: 999px; background: transparent;
  color: var(--muted); font-size: 15px; font-weight: 600; cursor: pointer;
}
.ghost:hover { color: var(--ink); }
.small { min-height: 42px; font-size: 15px; width: auto; padding: 0 20px; }
.ghost.small { border: .7px solid var(--line); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

dialog {
  width: min(92vw, 460px); padding: 0;
  border: .7px solid var(--line); border-radius: 22px;
  background: var(--panel); color: var(--ink);
}
dialog::backdrop { background: rgba(0, 0, 0, .55); }
.sheet { display: grid; gap: 8px; padding: 22px; }
.sheet h2 { margin: 0; font-size: 20px; }
.sheet-note { margin: 0 0 6px; color: var(--muted); font-size: 14px; font-weight: 500; line-height: 1.5; }
.sheet label { margin-top: 10px; font-size: 13px; color: var(--muted); }
.sheet-small { margin: 0; font-size: 12.5px; color: var(--muted); font-weight: 500; line-height: 1.5; }
select {
  width: 100%; min-height: 46px; padding: 0 12px;
  border: .7px solid var(--line); border-radius: 12px;
  background: var(--soft); color: var(--ink);
  font: inherit; font-size: 15px;
}
.meter { height: 8px; border-radius: 999px; background: var(--soft); overflow: hidden; }
.meter-fill { height: 100%; width: 0; border-radius: inherit; background: #56c4be; transition: width .08s linear; }
.sheet-actions { display: flex; justify-content: space-between; gap: 8px; margin-top: 14px; }
#testSound { justify-self: start; }

@media (prefers-reduced-motion: reduce) {
  .bono { animation: none; }
  .halo, #eyes { transition: none; }
}

/* ── 톱니바퀴와 관리자 설정 창 ── */
.top-actions { display: flex; align-items: center; gap: 8px; min-width: 0; }
.top-actions .chip { max-width: 100%; min-width: 0; }
.icon-button {
  flex: none; display: grid; place-items: center;
  width: 40px; height: 40px;
  border: .7px solid #505a69; border-radius: 50%;
  background: rgba(27, 30, 36, .6); color: var(--muted); cursor: pointer;
}
.icon-button:hover { color: var(--ink); }

.sheet input, .sheet textarea {
  width: 100%; padding: 12px;
  border: .7px solid var(--line); border-radius: 12px;
  background: var(--soft); color: var(--ink);
  font: inherit; font-size: 15px; font-weight: 500;
}
.sheet input { min-height: 46px; padding-block: 0; }
.sheet textarea { resize: vertical; line-height: 1.55; min-height: 120px; }
.sheet label { display: flex; justify-content: space-between; }
.count { font-variant-numeric: tabular-nums; }
.sheet-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.sheet-row > div { display: grid; gap: 8px; align-content: start; }
.sheet-error { margin: 0; min-height: 1.3em; font-size: 13.5px; color: var(--error); }
.sheet-ok { margin: 0; font-size: 13.5px; color: #8bc6af; }
.sheet-error:empty, .sheet-ok:empty { display: none; }
.sheet-actions.quiet { margin-top: 0; }
.ghost.plain { border: 0; padding: 0 6px; font-size: 13.5px; }
dialog { max-height: 92dvh; overflow-y: auto; }

/* ── 안경 연결 창 (껍데기 앱 안에서만) ── */
.glasses-info {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 14px 16px; border: .7px solid var(--line); border-radius: 14px; background: var(--soft);
}
.glasses-info span { color: var(--muted); font-size: 14px; font-weight: 500; }
.device-list { display: grid; gap: 8px; }
.device-list:empty { display: none; }
.device-row {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  min-height: 54px; padding: 0 16px;
  border: .7px solid var(--line); border-radius: 14px;
  background: var(--soft); color: var(--ink);
  font-size: 16px; font-weight: 600; text-align: left; cursor: pointer;
}
.device-row span { color: var(--muted); font-size: 13px; font-weight: 500; }

/* ── 숫자 4자리 비밀번호 ── */
.sheet input.pin { font-size: 24px; letter-spacing: .5em; text-align: center; font-variant-numeric: tabular-nums; }
.sheet input.pin::placeholder { font-size: 14px; letter-spacing: 0; }
.pin-change { margin-top: 6px; border-top: .7px solid var(--line); padding-top: 12px; }
.pin-change summary { cursor: pointer; color: var(--muted); font-size: 13.5px; }
.pin-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin: 10px 0 6px; }

/* ── 안경 카메라 시험 ── */
.camera-check { display: grid; gap: 8px; justify-items: start; }
.camera-check img { width: 100%; border-radius: 14px; border: .7px solid var(--line); }

/* ── 마이크 기준(소리 크기 문) ── */
.gate-meter { position: relative; height: 14px; border-radius: 999px; background: var(--soft); overflow: hidden; }
.gate-meter .meter-fill { transition: width .06s linear; }
.gate-mark { position: absolute; top: 0; bottom: 0; width: 3px; margin-left: -1px; background: #e2ba60; }
.sheet input[type="range"] { min-height: 32px; padding: 0; border: 0; background: transparent; accent-color: #d3dce7; }
#gateCalibrate { justify-self: start; }

/* 화면 맨 아래의 작은 판 표시 */
.build { font-size: 11px; color: #5b6472; font-weight: 500; min-height: 1em; }

/* Bono가 안경으로 보는 중: 생각 중과 같은 빛깔 */
.app[data-state="looking"] { --glow: 150 122 226; }
