.auth-view {
  position: relative;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: clamp(32px, 7vh, 72px) 20px max(56px, calc(24px + env(safe-area-inset-bottom)));
  background: var(--bg);
}

.auth-footer {
  position: absolute;
  right: 20px;
  bottom: max(18px, env(safe-area-inset-bottom));
  left: 20px;
  text-align: center;
}

.auth-footer a {
  color: var(--muted);
  font-size: 12px;
}

.auth-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-bottom: 44px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 800;
  letter-spacing: .14em;
}

.auth-brand img {
  width: 88px;
  height: 88px;
  object-fit: contain;
}

.auth-content {
  width: min(100%, 400px);
}

.auth-content h1 {
  margin: 0;
  font-size: 26px;
  line-height: 1.2;
  letter-spacing: 0;
}

.auth-heading {
  margin-bottom: 30px;
  text-align: center;
}

.auth-heading p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.auth-form .field > label {
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
}

.field-error {
  min-height: 16px;
  margin: 0;
  color: var(--warning);
  font-size: 12px;
  line-height: 16px;
}

.password-control {
  position: relative;
}

.password-control.has-value .text-input {
  padding-right: 48px;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 6px;
  width: 32px;
  height: 32px;
  transform: translateY(-50%);
  color: var(--muted);
  background: transparent;
  border-radius: 6px;
}

.password-toggle svg {
  width: 18px;
  height: 18px;
  display: block;
  margin: auto;
  stroke-width: 1.8;
}

.auth-message {
  min-height: 0;
  margin: 0;
  padding: 0 12px;
  overflow: hidden;
  color: var(--warning);
  border: 0 solid var(--warning-border);
  border-radius: var(--radius);
  background: var(--warning-surface);
  font-size: 12px;
  line-height: 18px;
  opacity: 0;
  transition: margin 150ms ease, min-height 150ms ease, padding 150ms ease, opacity 150ms ease;
}

.auth-message.is-visible {
  min-height: 42px;
  margin: 2px 0 14px;
  padding: 11px 12px;
  border-width: 1px;
  opacity: 1;
}

.auth-submit {
  margin-top: 3px;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0 5px;
  color: var(--faint);
  font-size: 11px;
}

.auth-divider::before,
.auth-divider::after {
  height: .5px;
  flex: 1;
  background: var(--line);
  content: "";
}

.auth-switch {
  width: fit-content;
  display: block;
  min-height: 40px;
  margin: 0 auto;
  padding: 8px;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
}

.auth-switch strong {
  color: var(--accent);
}

.search-toolbar {
  padding: 12px 13px;
  border-bottom: .5px solid var(--line);
  background: var(--surface);
}

.search-box {
  height: 42px;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 12px;
  color: var(--muted);
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--surface-raised);
  cursor: text;
  transition: border-color .18s, background .18s, box-shadow .18s;
}

.search-box:focus-within,
.search-box.focused {
  border-color: var(--accent);
}

.search-box:focus-within svg,
.search-box.focused svg {
  color: var(--accent);
  stroke: var(--accent);
}

.search-box input {
  min-width: 0;
  width: 100%;
  border: 0;
  outline: 0;
  caret-color: var(--accent);
  caret-shape: bar;
  color: var(--ink);
  background: transparent;
  cursor: text;
  font-size: 16px;
  line-height: 1.5;
  appearance: none;
}

.search-box input::placeholder {
  color: #65706b;
}

.search-box svg {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  stroke-width: 2.2;
  pointer-events: none;
  transition: color .18s;
}

.search-box input::-webkit-search-cancel-button {
  appearance: none;
}

.contact-list {
  display: flex;
  flex-direction: column;
}

.contact {
  --contact-divider-inset: 85px;
  width: 100%;
  min-height: 88px;
  position: relative;
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 16px 22px;
  color: var(--ink);
  text-align: left;
  background: transparent;
  transition: background .18s;
}

.contact + .contact::before {
  content: "";
  height: 0;
  position: absolute;
  top: 0;
  right: 0;
  left: var(--contact-divider-inset);
  border-top: .5px solid rgb(42 50 48 / 76%);
  pointer-events: none;
}

.contact:focus-visible,
.profile-link:focus-visible,
.new-conversation-button:focus-visible,
.conversation-options-button:focus-visible,
.conversation-menu button:focus-visible,
.conversation-edit button:focus-visible,
.message-action:focus-visible,
.speak-button:focus-visible,
.composer-edit-cancel:focus-visible,
.call-control:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.avatar {
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  display: grid;
  place-items: center;
  position: relative;
  overflow: hidden;
  color: #101412;
  background: linear-gradient(145deg, #b6c1bc, #45524f);
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 800;
}

.avatar.small {
  width: 40px;
  height: 40px;
  flex-basis: 40px;
  font-size: 11px;
}

.avatar img,
.avatar-field-preview img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.avatar-field {
  margin-bottom: 24px;
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
}

#create-form .avatar-field {
  margin-bottom: 16px;
}

#create-form > .section {
  padding: 16px;
  border-top: 0;
}

#create-form > .form-actions {
  padding: 11px 16px calc(11px + env(safe-area-inset-bottom));
  border-top: 0;
  background: transparent;
}

.dialog-actions.character-form-actions,
#create-form > .character-form-actions {
  padding: 11px 16px calc(11px + env(safe-area-inset-bottom));
}

.view:has(.main-page-body) {
  height: 100dvh;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding-bottom: 64px;
  overflow: hidden;
}

.view:has(.main-page-body) > .page-heading {
  flex: 0 0 auto;
}

.main-page-body {
  min-height: 0;
  flex: 1;
  overflow-y: auto;
}

.avatar-field-preview {
  width: 58px;
  height: 58px;
  overflow: hidden;
  display: grid;
  place-items: center;
  color: var(--muted);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface-raised);
}

.avatar-placeholder {
  font: 300 24px var(--font-ui);
}

.avatar-field-copy {
  min-width: 0;
  display: grid;
  gap: 5px;
}

.avatar-field-copy strong {
  font-size: 12px;
}

.avatar-field-copy span {
  color: var(--muted);
  font-size: 10px;
}

.avatar-choose {
  width: 84px;
  min-width: 84px;
  min-height: 38px;
  padding-inline: 12px;
  cursor: pointer;
}

.crop-dialog {
  width: min(92vw, 480px);
}

.crop-dialog-body {
  display: grid;
  justify-items: center;
  gap: 20px;
}

.crop-stage {
  width: min(360px, calc(100vw - 72px));
  aspect-ratio: 1;
  position: relative;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
  background:
    linear-gradient(45deg, #202625 25%, transparent 25%, transparent 75%, #202625 75%),
    linear-gradient(45deg, #202625 25%, #171b1b 25%, #171b1b 75%, #202625 75%);
  background-position: 0 0, 8px 8px;
  background-size: 16px 16px;
}

.crop-stage.dragging {
  cursor: grabbing;
}

.crop-stage > img {
  position: absolute;
  max-width: none;
  user-select: none;
}

.crop-box {
  width: 180px;
  height: 180px;
  position: absolute;
  z-index: 1;
  pointer-events: none;
  touch-action: none;
  border: 2px solid var(--accent);
  box-shadow: 0 0 0 999px rgb(5 7 7 / 55%);
}

.crop-box i {
  width: 12px;
  height: 12px;
  position: absolute;
  border-color: var(--ink);
  border-style: solid;
}

.crop-box i:nth-child(1) { top: -2px; left: -2px; border-width: 2px 0 0 2px; }
.crop-box i:nth-child(2) { top: -2px; right: -2px; border-width: 2px 2px 0 0; }
.crop-box i:nth-child(3) { right: -2px; bottom: -2px; border-width: 0 2px 2px 0; }
.crop-box i:nth-child(4) { bottom: -2px; left: -2px; border-width: 0 0 2px 2px; }

.contact-main {
  min-width: 0;
  flex: 1;
}

.contact-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.contact-name {
  font-size: var(--text-md);
  font-weight: 700;
}

.contact-time {
  color: var(--faint);
  font: var(--text-xs) var(--font-mono);
}

.contact-preview {
  margin-top: 6px;
  overflow: hidden;
  color: var(--muted);
  font-size: var(--text-sm);
  line-height: 1.5;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.empty-state {
  margin: 22px;
  padding: 34px 20px;
  color: var(--muted);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  text-align: center;
  font-size: 12px;
  line-height: 1.7;
}

.app-dialog {
  width: min(92vw, 540px);
  max-height: min(88dvh, 720px);
  overflow: hidden;
  padding: 0;
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.app-dialog::backdrop {
  background: rgb(0 0 0 / 72%);
  backdrop-filter: blur(5px);
}

.dialog-panel {
  max-height: inherit;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.dialog-header,
.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 17px 18px;
  border-bottom: .5px solid var(--line);
}

.dialog-header h2 {
  margin: 5px 0 0;
  font-size: 18px;
}

.dialog-header > .icon-button {
  flex: 0 0 auto;
}

.dialog-body {
  min-height: 0;
  flex: 1;
  overflow-y: auto;
  padding: 18px;
}

.dialog-actions {
  justify-content: flex-end;
  border-top: .5px solid var(--line);
  border-bottom: 0;
}

.dialog-actions .primary-button,
.dialog-actions .secondary-button,
.dialog-actions .danger-button {
  min-width: 100px;
}

.confirm-dialog {
  width: min(92vw, 380px);
}

.confirm-dialog .dialog-header h2 {
  margin: 0;
}

.confirm-dialog-message {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
}

.confirm-dialog-message strong {
  overflow-wrap: anywhere;
  color: var(--ink);
  font-weight: 800;
}

.confirm-dialog .dialog-actions button {
  min-width: 96px;
}

.history-dialog {
  width: min(100% - 24px, 520px);
  max-height: min(78dvh, 620px);
  overflow: hidden;
  margin: auto auto 12px;
}

.history-dialog .dialog-panel {
  max-height: inherit;
}

.history-body {
  overflow-x: hidden;
  overflow-y: auto;
  padding: 12px;
}

.new-conversation-button {
  min-height: 46px;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 13px 14px;
  color: var(--accent-ink);
  border-radius: var(--radius);
  border: 1px solid var(--accent);
  background: var(--accent);
  font-size: 12px;
  font-weight: 800;
  text-align: left;
}

.new-conversation-button svg { width: 16px; height: 16px; }

.conversation-list {
  display: grid;
  gap: 5px;
  padding: 11px 0 0;
  margin: 0;
  list-style: none;
}

.conversation-row.active {
  border-color: var(--line);
  background: var(--surface-raised);
}

.conversation-row {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 38px;
  align-items: center;
  border: 1px solid transparent;
  border-radius: var(--radius);
}

.conversation-row.active { border-color: var(--line); background: var(--surface-raised); }

.conversation-open {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 4px 11px 12px;
  color: var(--ink);
  background: transparent;
  text-align: left;
}

.conversation-copy {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.conversation-copy strong,
.conversation-copy small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conversation-copy strong { font-size: 12px; }
.conversation-copy small,
.conversation-open time { color: var(--muted); font: 10px var(--font-mono); }
.conversation-open time { flex: 0 0 auto; align-self: flex-start; padding-top: 2px; }

.conversation-options {
  position: relative;
}

.conversation-options-button {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  color: var(--muted);
  background: transparent;
  border-radius: var(--radius);
}

.conversation-options-button svg { width: 16px; height: 16px; }

.conversation-menu {
  min-width: 148px;
  position: fixed;
  z-index: 3;
  top: 0;
  left: 0;
  display: none;
  gap: 2px;
  padding: 6px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface-raised);
  box-shadow: 0 18px 48px rgb(0 0 0 / 48%), 0 1px 0 rgb(255 255 255 / 5%) inset;
}

.conversation-menu.open { display: grid; }

.conversation-menu button {
  min-height: 38px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 11px;
  color: var(--ink);
  background: transparent;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 650;
  text-align: left;
  white-space: nowrap;
}

.conversation-menu button.danger { color: var(--danger); }
.conversation-menu svg { width: 14px; height: 14px; }

.conversation-edit {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px;
}

.conversation-edit .text-input { min-width: 0; height: 32px; padding: 6px 8px; }
.conversation-edit button { width: 30px; height: 30px; display: grid; place-items: center; color: var(--muted); background: transparent; border-radius: var(--radius); }
.conversation-edit svg { width: 15px; height: 15px; }

.history-empty { padding: 24px 10px; color: var(--muted); font-size: 12px; text-align: center; }

.form-actions {
  padding: 18px 22px calc(20px + env(safe-area-inset-bottom));
  border-top: .5px solid var(--line);
  background: var(--surface);
}

.form-actions p {
  margin: 8px 0 0;
  color: var(--faint);
  text-align: center;
  font-size: 9px;
}

.profile-card {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  min-height: calc(124px + env(safe-area-inset-top));
  display: flex;
  align-items: center;
  gap: 16px;
  padding: calc(20px + env(safe-area-inset-top)) 20px 20px;
  border: 0;
  border-bottom: .5px solid var(--line);
  background: var(--surface);
}

.profile-card > div:last-child,
.profile-link > strong {
  min-width: 0;
}

.profile-card .avatar {
  width: 52px;
  height: 52px;
  flex-basis: 52px;
  font-size: 16px;
}

.profile-label {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 500;
}

.profile-module {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 0 20px;
  border: 0;
  border-top: .5px solid var(--line);
  border-radius: 0;
  background: var(--surface);
}

.profile-module-group > :last-child {
  border-bottom: .5px solid var(--line);
}

.profile-setting-group,
.admin-profile-links {
  margin-top: 18px;
}

.profile-setting,
.profile-link {
  color: var(--ink);
  text-align: left;
}

.profile-setting strong {
  display: block;
  flex: 0 0 auto;
  white-space: nowrap;
}

.profile-setting .select-control {
  min-width: 0;
  width: min(48%, 190px);
  max-width: 190px;
  margin-left: auto;
  flex: 0 1 190px;
}

.profile-setting .select-trigger {
  height: 42px;
  font-size: 12px;
}

.profile-model-menu .select-option {
  font-size: 12px;
}

.profile-link-icon {
  color: var(--muted);
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  opacity: .62;
}

.profile-section {
  min-height: 100%;
}

.profile-logout {
  width: calc(100% - 32px);
  min-height: 46px;
  margin-top: 18px;
  margin-right: 16px;
  margin-left: 16px;
}

.admin-manager-dialog {
  width: min(94vw, 920px);
  height: fit-content;
  max-height: min(88dvh, 720px);
}

.admin-manager-dialog > .dialog-panel {
  height: fit-content;
  max-height: inherit;
}

.admin-manager-body {
  min-height: 0;
  max-height: calc(min(88dvh, 720px) - 75px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.admin-manager-controls {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 14px;
  align-items: end;
  padding: 16px 20px;
  border-bottom: .5px solid var(--line);
  background: var(--surface-raised);
}

.admin-create-button {
  min-height: 46px;
  padding-inline: 18px;
}

.admin-create-button span {
  font-size: 18px;
  line-height: 1;
}

.admin-manager-select {
  margin: 0;
}

.admin-manager-select .select-trigger {
  background: var(--surface);
}

.admin-voice-editor {
  min-width: 0;
  min-height: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.voice-admin-form,
.role-admin-form {
  width: 100%;
  max-height: 100%;
  min-height: 0;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
}

.admin-editor-scroll {
  min-height: 0;
  flex: 1;
  overflow-y: auto;
  padding: 28px;
}

.voice-admin-fields {
  display: grid;
  grid-template-columns: 1fr;
  column-gap: 18px;
  align-items: start;
}

.voice-admin-form .field {
  margin-bottom: 18px;
}

.mono-input {
  font-family: var(--font-mono);
}

.admin-role-editor {
  min-width: 0;
  min-height: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.admin-role-editor .admin-editor-scroll {
  padding: 16px;
}

.character-prompt {
  min-height: 96px;
}

.character-fields {
  padding: 16px;
}

.character-fields > .field {
  margin-bottom: 10px;
}

.character-fields > .avatar-field {
  margin-bottom: 16px;
}

.admin-editor-actions {
  flex: 0 0 auto;
}

.admin-manager-dialog .primary-button,
.admin-manager-dialog .secondary-button,
.admin-manager-dialog .danger-button,
.admin-editor-actions .primary-button,
.admin-editor-actions .danger-button {
  min-width: 112px;
  min-height: 46px;
  padding-inline: 16px;
}

.admin-manager-dialog .avatar-choose {
  width: 84px;
  min-width: 84px;
  min-height: 38px;
  padding-inline: 12px;
}

.user-manager-dialog {
  width: min(92vw, 560px);
}

.user-create-form {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 10px;
  align-items: end;
  padding-bottom: 20px;
  border-bottom: .5px solid var(--line);
}

.user-create-form .field {
  margin-bottom: 0;
}

.user-list-head {
  margin: 22px 0 8px;
}

.user-admin-list {
  display: grid;
  gap: 7px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.user-admin-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 58px;
  padding: 9px 10px 9px 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-raised);
}

.user-admin-identity {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.user-admin-identity strong {
  overflow: hidden;
  font-size: var(--text-sm);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-admin-identity span,
.current-user-tag {
  color: var(--muted);
  font: var(--text-xs) var(--font-mono);
}

.user-admin-actions {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex: 0 0 auto;
  flex-wrap: nowrap;
}

.user-admin-actions .compact-button {
  min-width: 112px;
  min-height: 46px;
}

.user-password-form {
  width: 100%;
}

.user-password-form > div {
  display: flex;
  gap: 7px;
  align-items: center;
}

.user-password-form .text-input {
  min-width: 0;
  flex: 1;
  height: 38px;
}

.user-bubble {
  width: 100%;
  display: block;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.profile-card h2 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
}

.profile-card p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
}

.chat-view {
  position: fixed;
  top: var(--chat-viewport-offset, 0);
  left: 50%;
  width: min(100%, 580px);
  height: var(--chat-viewport-height, 100dvh);
  display: flex;
  flex-direction: column;
  transform: translateX(-50%);
  background: var(--bg);
}

.chat-header {
  min-height: calc(60px + env(safe-area-inset-top));
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 8px 8px;
  border-bottom: .5px solid var(--line);
  background: rgb(16 19 19 / 90%);
  backdrop-filter: blur(16px);
}

.chat-meta {
  min-width: 0;
  flex: 1;
}

.chat-meta strong {
  display: block;
  overflow: hidden;
  font-size: var(--text-md);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-tool {
  width: 46px;
  height: 46px;
  flex: 0 0 46px;
}

.chat-tool svg {
  width: 18px;
  height: 18px;
  stroke-width: 2.2;
}

.chat-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

.messages {
  flex: 1;
  overflow-y: auto;
  overflow-anchor: none;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 24px 16px;
}

.chat-scroll-bottom {
  position: absolute;
  right: 18px;
  bottom: calc(72px + env(safe-area-inset-bottom));
  z-index: 4;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  padding: 0;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface-raised);
  box-shadow: var(--shadow);
}

.chat-scroll-bottom[hidden] { display: none; }
.chat-scroll-bottom svg { width: 16px; height: 16px; }
.chat-scroll-bottom.generating::before {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  background: conic-gradient(from 0deg, transparent 0 55%, var(--accent) 78%, transparent 100%);
  padding: 1px;
  pointer-events: none;
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  animation: chat-scroll-glow 1.25s linear infinite;
}

@keyframes chat-scroll-glow { to { transform: rotate(1turn); } }

.message {
  min-width: 0;
  max-width: min(84%, 540px);
  display: flex;
  align-items: end;
  gap: 8px;
}

.message-content {
  min-width: 0;
  max-width: 100%;
}

.message.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.bubble {
  max-width: 100%;
  padding: 11px 14px;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-raised);
  font-size: var(--text-md);
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.message.user .bubble {
  color: var(--accent-ink);
  border-color: var(--accent);
  background: var(--accent);
}

.message.user .message-content {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.message.pending .bubble {
  color: var(--muted);
  animation: pulse 1.2s ease-in-out infinite;
}

.message.is-rewriting .bubble {
  border-color: var(--line-strong);
}

.message.user.is-rewriting .bubble {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgb(216 243 93 / 12%);
}

.message.failed .bubble {
  color: var(--warning);
  border-color: rgb(255 138 101 / 40%);
}

.stamp {
  min-height: 19px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-top: 5px;
  color: var(--faint);
  font: 8px var(--font-mono);
}

.message-actions {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin-left: 6px;
}

.deepseek-chat .message:not(.user) .bubble {
  background: transparent;
  border: 0;
  box-shadow: none;
  padding-left: 0;
  padding-right: 0;
}

.deepseek-chat .message:not(.user),
.deepseek-chat .message:not(.user) .message-content {
  width: 100%;
  max-width: none;
}

.deepseek-chat .message:not(.user) .stamp {
  display: flex;
  width: 100%;
  justify-content: flex-start;
}

.deepseek-chat .message:not(.user) .message-actions {
  margin-left: 0;
}

.markdown-body {
  min-width: 0;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: normal;
}

.markdown-body > :first-child { margin-top: 0; }
.markdown-body > :last-child { margin-bottom: 0; }
.markdown-body p { margin: 0 0 .8em; }
.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
  margin: 1.25em 0 .55em;
  color: var(--ink);
  font-size: 1em;
  line-height: 1.35;
}
.markdown-body h1 { font-size: 1.35em; }
.markdown-body h2 { font-size: 1.22em; }
.markdown-body h3 { font-size: 1.1em; }
.markdown-body ul,
.markdown-body ol { margin: .6em 0 .85em; padding-left: 1.45em; }
.markdown-body li + li { margin-top: .28em; }
.markdown-body li > p { margin: .25em 0; }
.markdown-body input[type="checkbox"] { margin: 0 .45em 0 0; accent-color: var(--accent); }
.markdown-body blockquote {
  margin: .85em 0;
  padding: .1em 0 .1em .85em;
  color: var(--muted);
  border-left: 3px solid var(--line-strong);
}
.markdown-body a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.markdown-body hr { height: 1px; margin: 1.1em 0; border: 0; background: var(--line); }
.markdown-body code {
  padding: .12em .35em;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface-raised);
  font: .88em/1.55 var(--font-mono);
}
.markdown-body pre {
  max-width: 100%;
  margin: .85em 0;
  padding: 12px 14px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-raised);
  -webkit-overflow-scrolling: touch;
}
.markdown-body pre code { padding: 0; border: 0; background: transparent; white-space: pre; overflow-wrap: normal; }
.markdown-body table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  font-size: .92em;
}
.markdown-table-container {
  max-width: 100%;
  margin: .85em 0;
}
.markdown-table-scroll {
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.markdown-table-scroll::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}
.markdown-body thead { background: var(--surface-raised); }
.markdown-body th,
.markdown-body td { max-width: min(52vw, 320px); padding: 7px 10px; border: 1px solid var(--line); text-align: left; vertical-align: top; overflow-wrap: anywhere; }
.markdown-body img { max-width: 100%; height: auto; border-radius: var(--radius); }

.reasoning-panel {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.88rem;
}

.reasoning-panel summary {
  cursor: pointer;
  color: var(--muted);
  font-weight: 600;
}

.reasoning-panel > div {
  margin-top: 8px;
  padding-left: 12px;
  border-left: 2px solid var(--line-strong);
  white-space: normal;
}

.message-action {
  width: 23px;
  height: 19px;
  display: inline-grid;
  place-items: center;
  padding: 2px 5px;
  color: var(--muted);
  background: transparent;
}

.message-action:disabled,
.speak-button:disabled { opacity: .45; }
.message-action svg,
.speak-button svg {
  width: 13px;
  height: 13px;
  stroke-width: 2.2;
}
.message-action.active { color: var(--accent); }

.speak-button {
  width: 23px;
  height: 19px;
  display: inline-grid;
  place-items: center;
  padding: 2px 5px;
  color: var(--muted);
  background: transparent;
}

.speak-button.playing {
  color: var(--accent);
  animation: sound-pulse 1s ease-in-out infinite;
}

.composer-button svg {
  width: 16px;
  height: 16px;
  stroke-width: 2.2;
}

.composer {
  position: relative;
  display: grid;
  grid-template-columns: 50px minmax(0, 1fr) 50px;
  align-items: center;
  gap: 8px;
  padding: 7px 13px calc(7px + env(safe-area-inset-bottom));
  border-top: .5px solid var(--line);
  background: var(--surface);
  transition: grid-template-columns 180ms ease;
}

.composer-edit-header {
  display: none;
}

.composer.send-hidden {
  grid-template-columns: 50px minmax(0, 1fr) 0;
}

.chat-view.editing-message .message:not(.editing-target) {
  opacity: .42;
  transition: opacity 180ms ease;
}

.message.editing-target .bubble {
  box-shadow: 0 0 0 2px rgb(216 243 93 / 18%);
}

.composer.editing-message {
  grid-template-columns: minmax(0, 1fr) 50px;
  padding-top: 38px;
  border-top-color: var(--line-strong);
  background: var(--bg);
}

.composer.editing-message .composer-edit-header {
  position: absolute;
  inset: 0 0 auto;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 13px 0;
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 600;
}

.composer-edit-cancel {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  color: var(--muted);
  border-radius: var(--radius);
  background: transparent;
}

.composer-edit-cancel svg {
  width: 15px;
  height: 15px;
}

.composer.editing-message #dictate {
  display: none;
}

.composer.editing-message textarea.text-area:focus {
  border-color: var(--accent);
}

.composer.editing-message.is-updating textarea {
  opacity: .55;
  pointer-events: none;
}

.composer.editing-message.send-hidden {
  grid-template-columns: minmax(0, 1fr) 0;
}

.composer textarea {
  height: 42px;
  min-height: 42px;
  max-height: 110px;
  overflow-y: hidden;
  padding: 10px 12px;
  resize: none;
}

.composer textarea::placeholder {
  font-size: var(--text-md);
}

.composer-button {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  color: var(--ink);
  border-radius: var(--radius);
  background: var(--surface-soft);
  font-size: 16px;
}

.composer-button.send {
  justify-self: end;
  color: var(--accent-ink);
  background: var(--accent);
  opacity: 1;
  visibility: visible;
  transition: opacity 120ms ease, visibility 0s linear;
}

.composer.send-hidden .composer-button.send {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 100ms ease, visibility 0s linear 180ms;
}

.composer.restore-composer-state .composer-button.send {
  transition: none;
}

.composer-button.recording {
  color: var(--accent-ink);
  background: var(--warning);
  animation: mic-pulse 1.1s ease-in-out infinite;
}

.phone-overlay {
  position: absolute;
  z-index: 20;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 58px;
  padding: 32px 24px;
  text-align: center;
  background: var(--bg);
}

.phone-header {
  width: min(100%, 580px);
  min-height: calc(68px + env(safe-area-inset-top));
  position: absolute;
  z-index: 1;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: max(12px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
  backdrop-filter: blur(16px);
}

@media (hover: none) and (pointer: coarse) {
  .auth-switch:active,
  .contact:active,
  .conversation-open:active,
  .conversation-options-button:active,
  .conversation-menu button:active,
  .conversation-edit button:active,
  .profile-link:active,
  .message-action:active:not(:disabled),
  .speak-button:active:not(:disabled),
  .composer-edit-cancel:active,
  .user-bubble:active,
  .call-control:active:not(:disabled) {
    background: var(--surface-soft);
  }

  .contact:active,
  .profile-link:active,
  .conversation-row:has(.conversation-open:active) {
    background: var(--surface-raised);
  }
}

.phone-history-button {
  width: 56px;
  height: 56px;
  flex: 0 0 56px;
}

.phone-history-button svg {
  width: 22px;
  height: 22px;
  stroke-width: 2.2;
}

.phone-controls {
  width: min(100%, 380px);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 48px;
}

.phone-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.voice-orbit {
  width: 144px;
  height: 144px;
  display: grid;
  place-items: center;
  position: relative;
}

.voice-orbit::before,
.voice-orbit::after {
  content: "";
  position: absolute;
  inset: 8px;
  border: 1px solid rgb(216 243 93 / 28%);
  border-radius: 50%;
  animation: orbit-pulse 2s ease-out infinite;
}

.voice-orbit::after {
  inset: -8px;
  animation-delay: .7s;
}

.phone-overlay .avatar {
  width: 100px;
  height: 100px;
  margin: 0 auto;
  background: transparent;
  font-size: 23px;
  box-shadow: 0 0 0 10px rgb(216 243 93 / 5%);
  z-index: 1;
}

.phone-overlay h1 {
  margin: 23px 0 6px;
  font-size: 27px;
  line-height: 1.25;
  letter-spacing: 0;
}

.phone-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 22px;
  color: var(--accent);
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.4;
  letter-spacing: 0;
}

.status-signal {
  width: 7px;
  height: 7px;
  display: inline-block;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 12px currentColor;
}

.voice-bars {
  height: 30px;
  display: flex;
  align-items: center;
  gap: 3px;
  position: absolute;
  bottom: -5px;
  z-index: 2;
}

.voice-bars i {
  width: 3px;
  height: max(7px, calc(7px + (var(--voice-level, 0) * 25px)));
  display: block;
  background: var(--accent);
  transform-origin: center;
  animation: voice-bar 1s ease-in-out infinite;
}

.voice-bars i:nth-child(2) { animation-delay: .12s; }
.voice-bars i:nth-child(3) { animation-delay: .24s; }
.voice-bars i:nth-child(4) { animation-delay: .36s; }
.voice-bars i:nth-child(5) { animation-delay: .48s; }

.phone-overlay.connecting .voice-bars i { animation-play-state: paused; opacity: .4; }
.phone-overlay.listening .voice-bars i { animation-duration: 1.35s; }
.phone-overlay.speaking .voice-bars i { animation-duration: .55s; }
.phone-overlay.call-error { --accent: var(--danger); }

.phone-subtitles {
  width: min(100%, 340px);
  min-height: 150px;
  display: grid;
  align-content: start;
  gap: 8px;
  margin-top: 10px;
}

.phone-subtitle-stack {
  min-height: 136px;
  max-height: min(38dvh, 390px);
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: hidden;
}

.phone-subtitle {
  min-height: 64px;
  flex: 0 1 auto;
  display: flex;
  flex-direction: column;
  padding: 10px 10px 9px;
  border: 1px solid var(--line);
  background: rgb(255 255 255 / 3%);
  max-width: 330px;
  color: #dce2de;
  font-size: 14px;
  line-height: 1.65;
  letter-spacing: 0;
  overflow: hidden;
}

.phone-subtitle-title {
  flex: 0 0 auto;
  margin-bottom: 5px;
  color: var(--faint);
  font: 600 11px var(--font-mono);
}

.phone-subtitle-text {
  min-height: 0;
  overflow-y: auto;
  overflow-wrap: anywhere;
  scrollbar-width: none;
}

.phone-subtitle-text::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

.user-subtitle { color: var(--muted); }
.assistant-subtitle .phone-subtitle-title { color: var(--accent); }
.user-subtitle.interim { opacity: .65; }

.phone-live-actions {
  min-height: 22px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 2px;
}

.voice-history-page {
  width: min(100%, 580px);
  height: var(--chat-viewport-height, 100dvh);
  min-height: 0;
  position: fixed;
  z-index: 22;
  top: var(--chat-viewport-offset, 0);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

.voice-history-page .page-heading {
  flex: 0 0 auto;
  position: relative;
  justify-content: center;
  padding-right: 56px;
  padding-left: 56px;
}

.voice-history-page .page-heading h1 {
  min-width: 0;
  overflow: hidden;
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.voice-history-page .voice-history-back,
.voice-history-page .video-transcription-back {
  position: absolute;
  left: 8px;
  top: calc(env(safe-area-inset-top) + 24px);
  transform: translateY(-50%);
}

.voice-history-page .messages {
  min-height: 0;
  width: 100%;
}

.video-transcription-body {
  width: min(100%, 580px);
  min-height: 0;
  margin: 0 auto;
  padding: 40px 22px calc(32px + env(safe-area-inset-bottom));
  overflow-y: auto;
  scrollbar-width: none;
}

.video-transcription-body::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

.video-transcription-intro {
  display: grid;
  justify-items: center;
  gap: 10px;
  margin: 20px 0 34px;
  text-align: center;
}

.video-transcription-intro svg { width: 30px; height: 30px; color: var(--accent); }
.video-transcription-intro strong { font-size: 18px; }
.video-transcription-intro p { margin: 0; color: var(--muted); font-size: var(--text-sm); }
.video-upload-control { min-height: 54px; display: flex; align-items: center; justify-content: center; gap: 8px; border: 1px dashed var(--line-strong); border-radius: var(--radius); color: var(--ink); background: var(--surface-raised); cursor: pointer; }
.video-upload-control input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.video-progress { margin-top: 24px; }
.video-progress-track { height: 5px; overflow: hidden; border-radius: 5px; background: var(--surface-raised); }
.video-progress-track span { display: block; width: 0; height: 100%; background: var(--accent); transition: width .25s ease; }
.video-progress-meta { display: flex; justify-content: space-between; margin-top: 8px; color: var(--muted); font-size: var(--text-xs); }
.video-result { margin-top: 28px; }
.video-result-text { min-height: 180px; padding: 0; border: 0; background: transparent; font-size: var(--text-md); line-height: 1.7; }
.video-result-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.video-result-actions button { display: inline-flex; align-items: center; gap: 6px; min-height: 42px; padding: 0 14px; border-radius: var(--radius); }
.video-result-actions svg { width: 16px; height: 16px; }

.end-call {
  width: 60px;
  height: 60px;
  color: white;
  border-radius: 50%;
  background: var(--danger);
  font-size: 18px;
  box-shadow: 0 0 0 0 rgb(240 104 98 / 45%);
  animation: end-call-pulse 2s ease-out infinite;
}

@keyframes sound-pulse {
  50% { transform: scale(1.15); }
}

@keyframes mic-pulse {
  50% { box-shadow: 0 0 0 5px rgb(255 138 101 / 20%); }
}

@keyframes orbit-pulse {
  0% { opacity: .75; transform: scale(.86); }
  100% { opacity: 0; transform: scale(1.08); }
}

@keyframes voice-bar {
  0%, 100% { transform: scaleY(.88); }
  50% { transform: scaleY(1.12); }
}

@keyframes end-call-pulse {
  70% { box-shadow: 0 0 0 12px rgb(240 104 98 / 0%); }
  100% { box-shadow: 0 0 0 0 rgb(240 104 98 / 0%); }
}

.call-control {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: var(--surface-raised);
}

.call-control svg { width: 20px; height: 20px; }

.mic-control.muted { color: var(--warning); }

.mic-control:disabled { opacity: .45; }