.mh-chat__room {
  --mh-chat-reply-background: color-mix(in srgb, var(--mh-surface-raised) 88%, var(--mh-text));
  display: grid;
  min-width: 0;
  min-height: 0;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) auto;
}
.mh-chat__message :is(time, .mh-chat__read) { flex: none; color: var(--mh-text-subtle); font-size: calc(11px * var(--mh-ui-scale)); font-variant-numeric: tabular-nums; }
.mh-chat__avatar { position: relative; display: grid; flex: none; width: var(--mh-chat-avatar-size, 40px); aspect-ratio: 1; place-items: center; overflow: hidden; border-radius: 34%; background: var(--mh-accent-soft); color: var(--mh-accent-bright); }
button.mh-chat__avatar { padding: 0; border: 0; }
button.mh-chat__avatar:focus-visible { outline: 2px solid var(--mh-accent); outline-offset: 2px; }
.mh-chat__avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center 24%; }
.mh-chat__avatar .mh-icon { --mh-icon-size: 50%; }
.mh-chat__empty-room { grid-row: 1; display: grid; align-content: safe center; justify-items: center; gap: 8px; text-align: center; }
.mh-chat__empty-room > .mh-icon { --mh-icon-size: calc(26px * var(--mh-ui-scale)); margin-bottom: 8px; color: var(--mh-accent); }
.mh-chat__empty-room > .mh-chat__avatar { --mh-chat-avatar-size: 68px; margin-bottom: 6px; }
.mh-chat__empty-room h3 { font-size: calc(18px * var(--mh-ui-scale)); letter-spacing: -.035em; }
.mh-chat__empty-room p { max-width: 290px; color: var(--mh-text-muted); font-size: calc(13px * var(--mh-ui-scale)); }
.mh-chat__empty-room > :is(a, button) { margin-top: 6px; }

.mh-chat__timeline { position: relative; grid-row: 1; display: grid; min-height: 0; }
.mh-chat__older { display: flex; margin: 0 auto 10px; color: var(--mh-text-muted); }
.mh-chat__messages { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; }
.mh-chat__message { display: flex; align-items: end; gap: 8px; min-width: 0; }
.mh-chat__message--user { flex-direction: row-reverse; }
.mh-chat__message[data-day] { flex-wrap: wrap; }
.mh-chat__message[data-day]::before { flex-basis: 100%; margin-block: 8px 12px; color: var(--mh-text-subtle); font-size: calc(11px * var(--mh-ui-scale)); text-align: center; content: attr(data-day); }
.mh-chat__message .mh-chat__avatar, .mh-chat__typing .mh-chat__avatar { --mh-chat-avatar-size: 28px; }
.mh-chat__message > .mh-chat__bubble { max-width: 72%; padding: 9px 12px; border-radius: 13px 13px 13px 4px; background: var(--mh-chat-reply-background); color: var(--mh-text); white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.55; }
.mh-chat__message--user > .mh-chat__bubble { border-radius: 13px 13px 4px 13px; background: var(--mh-accent-fill); color: #fff; }
.mh-chat__message[data-failed] > .mh-chat__bubble { background: var(--mh-accent-soft); color: var(--mh-text-muted); }
.mh-chat__message :is(time, .mh-chat__read) { margin-bottom: 2px; }
.mh-chat__read { margin-inline-end: -4px; }
.mh-chat__failure { --mh-control-height: calc(27px * var(--mh-ui-scale)); flex: none; padding-inline: 6px; color: var(--mh-accent-bright); font-size: calc(11px * var(--mh-ui-scale)); }
.mh-chat__typing { display: flex; gap: 8px; align-items: end; margin-top: 12px; }
.mh-chat__typing-dots { display: flex; gap: 4px; align-items: center; height: 32px; padding-inline: 12px; border-radius: 12px 12px 12px 4px; background: var(--mh-chat-reply-background); }
.mh-chat__typing-dots i { width: 4px; height: 4px; border-radius: 50%; background: var(--mh-accent); animation: mh-chat-typing 1.2s ease-in-out infinite; }
.mh-chat__typing-dots i:nth-child(2) { animation-delay: .15s; }
.mh-chat__typing-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes mh-chat-typing { 0%, 60%, 100% { opacity: .35; } 30% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .mh-chat__typing-dots i { animation: none; } }
.mh-chat__latest { position: absolute; inset-inline-end: 20px; bottom: 12px; border-radius: 50%; background: var(--mh-surface-raised); box-shadow: 0 4px 14px #0005; }

.mh-chat__footer { grid-row: 2; }
#chat-footer { border-block-start: 0; }
.mh-chat__status { margin: 0 0 6px; color: var(--mh-text-muted); font-size: calc(12px * var(--mh-ui-scale)); }
.mh-chat__status:empty { display: none; }
.mh-chat__quota {
  display: flex;
  align-items: center;
  gap: clamp(6px, 2vw, 12px);
  margin: 0 2px 6px;
  color: var(--mh-text-muted);
  font-size: calc(11px * var(--mh-ui-scale));
  white-space: nowrap;
}
.mh-chat__quota-count { color: var(--mh-text); font-weight: 550; font-variant-numeric: tabular-nums; }
.mh-chat__quota[data-purchased] > .mh-chat__quota-count { color: var(--mh-accent); }

.mh-dialog--end:has(.model-call) .mh-dialog__surface { overflow: clip; }
.mh-dialog--end .mh-dialog__body:has(> .model-call) {
  flex: 1 1 0;
  min-height: 0;
  grid-template-rows: minmax(0, 1fr);
  align-content: stretch;
  padding: 0;
}
:is(.model-call, .mh-chat__room).mh-loading-dots {
  --mh-dots-start: 5% 8%;
  --mh-dots-end: 95% 92%;
  position: relative;
  isolation: isolate;
  background: var(--mh-bg);
}
.model-call {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  row-gap: clamp(14px, 2.4dvh, 20px);
  min-height: 0;
}
:is(.model-call, .mh-chat__room).mh-loading-dots::before {
  inset: 0;
  background-color: var(--mh-accent-soft);
  background-size: 93% 76%;
  mask: radial-gradient(circle, #000 .8px, transparent 1.15px) 0 0 / var(--mh-dot-step) var(--mh-dot-step) round;
  opacity: .68;
}
.model-call__content {
  display: grid;
  grid-template-rows: auto minmax(min-content, 1fr) auto;
  justify-items: center;
  gap: clamp(16px, 4dvh, 34px);
  padding: 18px var(--mh-dialog-padding) 0;
  overflow: auto;
  overscroll-behavior: contain;
  text-align: center;
}
.model-call__state { display: grid; justify-items: center; align-content: start; gap: 2px; min-height: 39px; }
.model-call__state .mh-audio-console__state { font-size: calc(13px * var(--mh-ui-scale)); }
.model-call__state .mh-audio-console__time { font-size: calc(15px * var(--mh-ui-scale)); }
.model-call__state:has(> .model-call__capacity:not([hidden])) { grid-auto-flow: row; gap: 15px; }
.model-call__capacity { margin: 0; color: var(--mh-accent-bright); font-size: calc(13px * var(--mh-ui-scale)); text-align: center; }
.model-call__identity { display: grid; align-self: center; justify-items: center; gap: 4px; min-width: 0; }
.model-call__identity h3 { font-size: calc(clamp(23px, 7vw, 32px) * var(--mh-ui-scale)); font-weight: 680; line-height: 1.2; overflow-wrap: anywhere; }
.model-call__identity h3:focus { outline: none; }
.model-call__handle { font-size: calc(13px * var(--mh-ui-scale)); overflow-wrap: anywhere; }
.model-call__avatar {
  position: relative;
  display: grid;
  width: clamp(86px, 24dvh, 144px);
  aspect-ratio: 1;
  place-items: center;
  margin-block: clamp(12px, 3.5dvh, 28px) 3px;
  overflow: hidden;
  border: 0;
  border-radius: 50%;
  padding: 0;
  background: var(--mh-surface-raised);
}
.model-call__avatar > .model-portrait { position: absolute; inset: 0; height: 100%; aspect-ratio: 1; }
.model-call__avatar img { object-position: center 56%; }
.model-call__avatar:is(:hover, :focus-visible) > .model-profile__cover-zoom { opacity: 1; }
.model-call__identity > .model-profile__waveform { width: 108px; height: 21px; }
.model-call__controls {
  display: grid;
  width: min(100%, 380px);
  padding: 22px 14px 24px;
  gap: clamp(16px, 4.5dvh, 34px);
  background: var(--mh-control-surface);
  border-radius: 26px;
}
.model-call__tools,
.model-call__actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: center;
  justify-items: center;
}
.model-call__controls :is(.model-call__tool, .model-call__shortcut) {
  width: 100%;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 6px;
  padding: 6px 3px;
  background: transparent;
  font-size: calc(11px * var(--mh-ui-scale));
  white-space: normal;
  --mh-icon-size: calc(23px * var(--mh-ui-scale));
}
.model-call__tool:is(:disabled, [aria-disabled="true"], [aria-pressed="false"]) { opacity: .36; }
.model-call__tool[aria-pressed="true"]:not(:disabled, [aria-disabled="true"]) { color: #fff; opacity: 1; }
.model-call__output-status { margin: -8px 0; font-size: calc(11px * var(--mh-ui-scale)); }
.model-call__output-status:empty { display: none; }
.model-call__actions > :is(.model-call__start, .model-call__hangup) { grid-column: 2; grid-row: 1; }
.model-call__shortcut:first-child { grid-column: 1; grid-row: 1; }
.model-call__shortcut:last-child { grid-column: 3; grid-row: 1; }
.model-call__actions > .mh-icon-button {
  --mh-icon-button-size: calc(64px * var(--mh-ui-scale));
  --mh-icon-size: calc(27px * var(--mh-ui-scale));
  border-radius: 50%;
  color: #fff;
}
.model-call__actions > .model-call__start { background: #217c57; }
.model-call__actions > .model-call__hangup { background: #b63c4e; }
.model-call__hangup .mh-icon { rotate: 135deg; }
.model-call__actions > :is(.model-call__start, .model-call__hangup):is(:hover, :focus-visible) { filter: brightness(1.18); }
.model-call-history { display: grid; align-content: start; gap: 16px; }
.model-call-history__day { display: grid; gap: 7px; }
.model-call-history__day h3 { padding-inline: 10px; color: var(--mh-text-muted); font-size: calc(12px * var(--mh-ui-scale)); font-weight: 550; }
.model-call-history__day ul {
  margin: 0;
  padding: 0 12px;
  border-radius: var(--mh-radius);
  background: var(--mh-control-surface-muted);
  list-style: none;
}
.model-call-history__day li {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 8px 2px;
}
.model-call-history__day li + li { border-block-start: 1px solid var(--mh-divider); }
.model-call-history__day li > .mh-icon { color: var(--mh-accent); --mh-icon-size: calc(17px * var(--mh-ui-scale)); }
.model-call-history__identity {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: flex-start;
  gap: 7px;
  padding: 0;
  text-align: start;
}
.model-call-history__identity .mh-chat__avatar { --mh-chat-avatar-size: 28px; border-radius: 50%; }
.model-call-history__identity strong { overflow: hidden; font-weight: 550; text-overflow: ellipsis; white-space: nowrap; }
.model-call-history__day li > div:not(.model-call-history__identity) { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px 8px; color: var(--mh-text-muted); font-size: calc(11px * var(--mh-ui-scale)); }
.model-call-history__timing { display: inline-flex; gap: 8px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.model-call-history__timing > :last-child { min-inline-size: 9ch; text-align: end; }
.model-call-history__delete { --mh-icon-button-size: calc(30px * var(--mh-ui-scale)); --mh-icon-size: calc(13px * var(--mh-ui-scale)); color: var(--mh-text-subtle); }
.model-call-history__delete:not([aria-disabled]):is(:hover, :focus-visible) { color: var(--mh-text); background: transparent; }
.model-call-history__error {
  position: sticky;
  bottom: 0;
  padding: 6px 10px;
  border-radius: var(--mh-radius-sm);
  background: var(--mh-dialog-surface);
  font-size: calc(12px * var(--mh-ui-scale));
}
.model-call-history__more { justify-self: center; --mh-control-height: calc(32px * var(--mh-ui-scale)); }

.model-call__footer { min-width: 0; border: 0; background: transparent; }
.model-call__footer .mh-chat__quota { margin-bottom: 0; }
@media (max-height: 660px) and (orientation: portrait) {
  .model-call__content { gap: 12px; padding-block-start: 10px; }
  .model-call__avatar { width: min(104px, 19dvh); margin-block: 10px 0; }
  .model-call__controls { gap: 14px; padding-block: 12px 16px; }
  .model-call__actions > .mh-icon-button { --mh-icon-button-size: calc(54px * var(--mh-ui-scale)); --mh-icon-size: calc(23px * var(--mh-ui-scale)); }
}
@media (max-width: 960px) and (max-height: 500px) and (orientation: landscape) {
  .model-call__content { grid-template: auto minmax(min-content, 1fr) / repeat(2, minmax(0, 1fr)); gap: 8px 20px; padding-block-start: 8px; }
  .model-call__state { grid-column: 1 / -1; min-height: 22px; grid-auto-flow: column; align-items: center; justify-content: center; gap: 8px; }
  .model-call__controls { align-self: center; padding-block: 10px 14px; gap: 10px; }
  .model-call__avatar { width: min(80px, 27dvh); margin-block: 7px 0; }
  .model-call__identity h3 { font-size: calc(21px * var(--mh-ui-scale)); }
  .model-call__actions > .mh-icon-button { --mh-icon-button-size: calc(49px * var(--mh-ui-scale)); --mh-icon-size: calc(22px * var(--mh-ui-scale)); }
  .model-call__footer { padding-block: 5px max(10px, env(safe-area-inset-bottom)); }
}
.mh-chat__quota progress {
  appearance: none;
  flex: 0 1 68px;
  min-width: 0;
  height: 4px;
  overflow: hidden;
  border: 0;
  border-radius: 999px;
  background: var(--mh-focus-surface);
}
.mh-chat__quota progress::-webkit-progress-bar { border-radius: 999px; background: var(--mh-focus-surface); }
.mh-chat__quota progress::-webkit-progress-value { border-radius: 999px; background: var(--mh-accent); }
.mh-chat__quota progress::-moz-progress-bar { border-radius: 999px; background: var(--mh-accent); }
.mh-chat__quota > .mh-button {
  --mh-control-height: calc(26px * var(--mh-ui-scale));
  --mh-control-size: calc(11px * var(--mh-ui-scale));
  --mh-icon-size: calc(12px * var(--mh-ui-scale));
  flex: none;
  margin-inline-start: auto;
  gap: 3px;
  padding-inline: 5px;
  color: var(--mh-accent-bright);
}
.mh-chat__status button { margin-inline-start: 8px; border: 0; background: none; color: var(--mh-accent-bright); }
.mh-chat__composer { padding: 6px; border-radius: 14px; background: var(--mh-field-surface); }
.mh-chat__room[data-file-drag] .mh-chat__composer,
#chat-form:has(#chat-input:focus) { background: var(--mh-field-focus-surface); }
#chat-form:has(#chat-input:focus-visible) { outline: 2px solid var(--mh-accent); outline-offset: 1px; }
.mh-chat__entry { display: flex; gap: 3px; align-items: end; }
.mh-chat__entry > textarea { flex: 1; min-height: 38px; max-height: 120px; padding: 8px 7px; resize: none; }
#chat-input { --mh-field-background: transparent; }
#chat-input:focus-visible { outline: none; }
.mh-chat__entry > button { --mh-control-height: calc(38px * var(--mh-ui-scale)); --mh-icon-button-size: calc(38px * var(--mh-ui-scale)); width: 38px; min-width: 38px; padding: 0; }
.mh-chat__attachment { display: flex; gap: 14px; align-items: start; width: fit-content; padding: 5px 8px 3px; }
.mh-chat__attachment img { width: 54px; height: 54px; border-radius: var(--mh-radius-sm); object-fit: cover; }
.mh-chat__attachment button { margin-block-start: 5px; }
.mh-chat__media { display: block; max-width: min(100%, 230px); margin-bottom: 6px; border-radius: var(--mh-radius-sm); overflow: hidden; }
.mh-chat__media:last-child { margin-bottom: 0; }
.mh-chat__media img { max-height: 210px; object-fit: contain; }
.mh-chat__send-icon { transform: rotate(90deg); }

@media (max-width: 760px), (max-height: 480px) and (orientation: landscape) {
  .mh-chat__entry > textarea { font-size: calc(16px * var(--mh-ui-scale)); }
}
