:root {
  --bg: #141b1a;
  --surface: #202a28;
  --edge: #364540;
  --ink: #edf2e8;
  --muted: #becac1;
  --accent: #cce4b4;
  --accent-dim: #799770;
  --danger: #ffc9b9;
  color-scheme: dark;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: radial-gradient(ellipse at 68% 0%, #23332d 0, var(--bg) 67%);
}

button {
  color: inherit;
  font: inherit;
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

.room {
  width: min(100%, 440px);
  margin: 0 auto;
  padding: clamp(24px, 6vh, 60px) 24px 24px;
  padding-bottom: max(24px, env(safe-area-inset-bottom), var(--tg-content-safe-area-inset-bottom, 0px));
}

.room-header {
  margin-bottom: clamp(20px, 4.5vh, 38px);
}

.brand {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: .79rem;
  font-weight: 650;
  letter-spacing: .03em;
}

h1 {
  margin: 0;
  font-family: Georgia, serif;
  font-size: clamp(2.15rem, 8.4vw, 3rem);
  font-weight: normal;
  letter-spacing: -.035em;
  line-height: 1;
}

h2 {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: .9rem;
  font-weight: 500;
}

.mentors {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  max-height: clamp(126px, 31vh, 232px);
  max-height: clamp(126px, 31dvh, 232px);
  padding: 4px;
  margin: -4px;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  scrollbar-color: var(--accent-dim) var(--bg);
  scrollbar-width: thin;
}

.mentor {
  display: flex;
  min-height: 102px;
  padding: 11px 8px 10px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid var(--edge);
  border-radius: 17px;
  background: var(--surface);
  cursor: pointer;
}

.mentor[aria-pressed="true"] {
  border-color: var(--accent-dim);
  background: #2b3a31;
  box-shadow: inset 0 0 0 1px #738b6966;
}

.mentor:disabled {
  cursor: default;
}

.mentor:disabled[aria-pressed="false"] {
  opacity: .60;
}

.mentor img {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  object-fit: cover;
  object-position: center 26%;
  background: var(--edge);
}

.mentor-name {
  font-size: clamp(.72rem, 3.2vw, .89rem);
  line-height: 1.15;
  font-weight: 600;
  text-wrap: balance;
}

.conversation {
  display: grid;
  justify-items: center;
  margin-top: clamp(24px, 5vh, 42px);
  text-align: center;
}

.orb {
  position: relative;
  display: grid;
  width: clamp(96px, 26vw, 122px);
  aspect-ratio: 1;
  margin: 0;
  place-items: center;
  border: 1px solid #dfeeca;
  border-radius: 50%;
  color: #23332b;
  background: radial-gradient(circle at 35% 22%, #e8f4d8, #b8d5a5 78%);
  box-shadow: 0 0 0 8px #cce4b416, 0 0 46px #a5c58730;
  cursor: pointer;
  transition: box-shadow .22s ease, transform .22s ease;
}

.orb:enabled:active {
  transform: scale(.96);
}

.orb:disabled {
  cursor: default;
  opacity: .58;
}

.orb[aria-pressed="true"] {
  border-color: #9eba96;
  color: #e8f4de;
  background: #354e3e;
}

.conversation[data-phase="speaking"] .orb {
  animation: speaking 2s ease-in-out infinite;
}

.conversation[data-phase="connecting"] .orb,
.conversation[data-phase="thinking"] .orb {
  animation: waiting 1.7s ease-in-out infinite;
}

@keyframes speaking {
  50% { box-shadow: 0 0 0 14px #cce4b421, 0 0 50px #a5c58746; }
}

@keyframes waiting {
  50% { box-shadow: 0 0 0 5px #cce4b414, 0 0 30px #a5c5871c; }
}

.orb-icon {
  position: relative;
  display: block;
  width: 36px;
  height: 36px;
}

.mic-head {
  position: absolute;
  top: 2px;
  left: 12px;
  width: 12px;
  height: 19px;
  border: 2px solid currentColor;
  border-radius: 7px;
}

.mic-bracket {
  position: absolute;
  top: 12px;
  left: 8px;
  width: 20px;
  height: 14px;
  border: 2px solid currentColor;
  border-top: 0;
  border-radius: 0 0 12px 12px;
}

.mic-base {
  position: absolute;
  top: 25px;
  left: 17px;
  width: 2px;
  height: 6px;
  background: currentColor;
}

.stop-icon {
  position: absolute;
  display: none;
  inset: 9px;
  border-radius: 5px;
  background: currentColor;
}

.orb[aria-pressed="true"] .stop-icon {
  display: block;
}

.orb[aria-pressed="true"] .mic-head,
.orb[aria-pressed="true"] .mic-bracket,
.orb[aria-pressed="true"] .mic-base {
  display: none;
}

.conversation-text {
  margin-top: 18px;
}

#action-label {
  margin: 0;
  font-size: .99rem;
  font-weight: 650;
}

.selected-mentor,
#status,
#error {
  margin: 6px 0 0;
  font-size: .83rem;
  line-height: 1.45;
}

.selected-mentor,
#status {
  color: var(--muted);
}

#status:empty {
  display: none;
}

#error {
  color: var(--danger);
}

.catalog-error {
  margin-top: 12px;
  color: var(--muted);
  font-size: .85rem;
  line-height: 1.4;
}

.catalog-error p {
  margin: 0;
}

.catalog-error button {
  min-height: 36px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
}

.portrait-credit {
  margin-top: clamp(24px, 5vh, 42px);
  color: var(--muted);
  font-size: .73rem;
  line-height: 1.45;
}

.portrait-credit summary {
  width: fit-content;
  cursor: pointer;
}

.portrait-credit p {
  margin: 7px 0 0;
}

.portrait-credit a {
  color: var(--accent);
}

@media (max-width: 340px) {
  .room { padding-right: 17px; padding-left: 17px; }
}

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