:root {
  color-scheme: light;
  --telegram: #2aabee;
  --telegram-deep: #168ac2;
  --ink: #17212b;
  --muted: #71808d;
  --line: rgba(23, 33, 43, 0.11);
  --page: #dce4e8;
  --paper: #ffffff;
  --assistant: #ffffff;
  --user: #2aabee;
  --shadow: 0 18px 70px rgba(36, 55, 68, 0.18);
  --font: "SF Pro Text", "SF Pro Display", "PingFang SC", "Microsoft YaHei", sans-serif;
  --app-height: 100dvh;
  --app-top: 0px;
  --composer-height: 62px;
  --header-height: 66px;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  background: #cfd9df;
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

button,
textarea {
  font: inherit;
}

button {
  margin: 0;
  padding: 0;
  appearance: none;
  -webkit-appearance: none;
  -webkit-tap-highlight-color: transparent;
}

[hidden] {
  display: none !important;
}

.app-shell {
  position: relative;
  top: var(--app-top);
  width: min(100%, 840px);
  height: 100vh;
  height: var(--app-height);
  margin: 0 auto;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  overflow: hidden;
  background: var(--page);
  box-shadow: var(--shadow);
  isolation: isolate;
}

.game-dock {
  grid-row: 2;
  position: relative;
  z-index: 42;
  width: min(calc(100% - 24px), 736px);
  min-height: 54px;
  margin: 10px auto 0;
  padding: 8px 10px;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto 16px;
  align-items: center;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.96);
  color: var(--ink);
  text-align: left;
  box-shadow: 0 5px 18px rgba(41, 57, 68, 0.1);
  cursor: pointer;
}

.game-dock-die {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: var(--telegram);
  color: white;
  font-size: 25px;
  line-height: 1;
}

.game-dock-copy {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.game-dock-copy strong {
  font-size: 13px;
  font-weight: 650;
}

.game-dock-copy span {
  overflow: hidden;
  color: var(--muted);
  font-size: 10.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.game-dock-turn {
  padding: 5px 8px;
  border-radius: 999px;
  background: rgba(42, 171, 238, 0.11);
  color: var(--telegram-deep);
  font-size: 11px;
  font-weight: 650;
  white-space: nowrap;
}

.game-dock-chevron {
  color: var(--muted);
  font-size: 25px;
  line-height: 1;
}

.game-panel {
  position: absolute;
  top: var(--header-height);
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 48;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  background: var(--page);
}

body.game-open .composer {
  visibility: hidden;
  pointer-events: none;
}

.game-panel-head {
  min-height: 58px;
  padding: 8px 12px;
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr) 56px;
  align-items: center;
  gap: 6px;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}

.game-back,
.game-more {
  min-height: 38px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--telegram-deep);
  font-size: 13px;
  cursor: pointer;
}

.game-back { text-align: left; }
.game-more { text-align: right; }

.game-round-copy {
  min-width: 0;
  display: grid;
  gap: 2px;
  text-align: center;
}

.game-round-copy strong {
  font-size: 14px;
  font-weight: 650;
}

.game-round-copy span {
  overflow: hidden;
  color: var(--muted);
  font-size: 10.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.game-panel-scroll {
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 12px max(12px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
}

.game-setup {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
}

.game-setup-progress {
  padding: 12px 18px 4px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.game-setup-progress span {
  height: 3px;
  border-radius: 99px;
  background: var(--line);
  transition: background 160ms ease;
}

.game-setup-progress span.current { background: var(--telegram); }

.game-setup-scroll {
  min-height: 0;
  padding: 12px max(14px, env(safe-area-inset-right)) 18px max(14px, env(safe-area-inset-left));
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.game-setup-step {
  width: min(100%, 560px);
  margin: 0 auto;
}

.game-setup-intro,
.game-setup-title {
  margin: 2px 2px 16px;
}

.game-setup-intro {
  display: flex;
  align-items: center;
  gap: 12px;
}

.game-setup-die {
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  display: grid;
  place-items: center;
  border-radius: 15px;
  background: linear-gradient(145deg, #b9627c, #77364b);
  color: white;
  font-size: 28px;
  box-shadow: 0 8px 22px rgba(119, 54, 75, 0.2);
}

.game-setup-intro strong,
.game-setup-title strong {
  font-size: 18px;
  font-weight: 680;
}

.game-setup-intro p,
.game-setup-title p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.game-setup-card {
  min-width: 0;
  margin: 0 0 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--paper);
}

.game-setup-card legend {
  padding: 0 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
}

.game-text-field {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.game-text-field input {
  min-width: 0;
  height: 38px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
  background: var(--page);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
}

.game-text-field input:focus { border-color: var(--telegram); }

.game-choice-row {
  margin-top: 10px;
  display: grid;
  grid-template-columns: 46px repeat(2, minmax(0, 1fr));
  align-items: center;
  gap: 7px;
}

.game-choice-row > span {
  color: var(--muted);
  font-size: 12px;
}

.game-choice-row.wide {
  margin-top: 0;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.game-choice-row.wide.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.game-choice-row label,
.game-chip-grid label {
  position: relative;
  min-width: 0;
}

.game-choice-row input,
.game-option-stack input,
.game-check-list input,
.game-chip-grid input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.game-choice-row label span {
  min-height: 36px;
  padding: 7px 6px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.game-choice-row input:checked + span,
.game-chip-grid input:checked + span {
  border-color: rgba(169, 78, 104, 0.5);
  background: rgba(169, 78, 104, 0.11);
  color: var(--telegram-deep);
}

.game-option-stack,
.game-check-list {
  display: grid;
  gap: 7px;
}

.game-option-stack label,
.game-check-list label {
  position: relative;
  display: block;
}

.game-option-stack label > span,
.game-check-list label > span {
  min-height: 48px;
  padding: 9px 11px 9px 38px;
  display: grid;
  align-content: center;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: 11px;
  font-size: 12px;
}

.game-option-stack label > span::before,
.game-check-list label > span::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 13px;
  width: 15px;
  height: 15px;
  border: 1.5px solid var(--muted);
  border-radius: 50%;
  transform: translateY(-50%);
}

.game-check-list label > span::before { border-radius: 4px; }

.game-option-stack input:checked + span,
.game-check-list input:checked + span {
  border-color: rgba(169, 78, 104, 0.5);
  background: rgba(169, 78, 104, 0.08);
}

.game-option-stack input:checked + span::before,
.game-check-list input:checked + span::before {
  border-color: var(--telegram-deep);
  background: var(--telegram-deep);
  box-shadow: inset 0 0 0 3px var(--paper);
}

.game-option-stack small,
.game-safety-confirm small {
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.4;
}

.game-chip-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.game-chip-grid label span {
  min-height: 34px;
  padding: 7px 3px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

.game-safety-confirm {
  position: relative;
  min-height: 66px;
  padding: 12px 12px 12px 44px;
  display: grid;
  align-content: center;
  gap: 3px;
  border: 1px solid rgba(169, 78, 104, 0.38);
  border-radius: 15px;
  background: rgba(169, 78, 104, 0.08);
}

.game-safety-confirm input {
  position: absolute;
  top: 22px;
  left: 15px;
  width: 18px;
  height: 18px;
  accent-color: var(--telegram-deep);
}

.game-safety-confirm strong { font-size: 13px; }

.game-setup-footer {
  padding: 10px max(14px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.4fr);
  gap: 8px;
  border-top: 1px solid var(--line);
  background: var(--paper);
}

.game-setup-primary,
.game-setup-secondary {
  min-height: 46px;
  border: 0;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 650;
}

.game-setup-primary {
  grid-column: 2;
  background: var(--telegram);
  color: white;
}

.game-setup-secondary {
  grid-column: 1;
  background: var(--page);
  color: var(--muted);
}

.game-setup-primary:only-child { grid-column: 1 / -1; }

body.room-mode .game-setup-card,
body.room-mode .game-setup-footer,
body.room-mode .game-safety-confirm {
  background: #211b22;
}

body.room-mode .game-text-field input,
body.room-mode .game-setup-secondary { background: #171219; }

.game-players {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.game-player {
  min-width: 0;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--paper);
}

.game-player-head {
  display: flex;
  align-items: center;
  gap: 7px;
}

.game-token,
.game-piece {
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: white;
  font-weight: 700;
}

.game-token {
  width: 25px;
  height: 25px;
  flex: 0 0 25px;
  font-size: 10px;
}

.game-token.human,
.game-piece.human { background: #2aabee; }
.game-token.claude,
.game-piece.claude { background: #a94e68; }

.game-player strong {
  overflow: hidden;
  font-size: 13px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.game-player-detail,
.game-player-identity {
  display: block;
  overflow: hidden;
  margin-top: 5px;
  color: var(--muted);
  font-size: 10.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.game-player-identity { margin-top: 2px; }

.game-board {
  position: relative;
  width: min(100%, 520px);
  margin: 12px auto;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  grid-template-rows: repeat(6, 58px);
  gap: 3px;
}

.game-cell {
  position: relative;
  min-width: 0;
  padding: 3px 2px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--paper);
}

.game-cell.has-player {
  background: rgba(42, 171, 238, 0.08);
}

.game-cell-icon {
  font-size: 17px;
  line-height: 1;
}

.game-cell-label {
  color: var(--muted);
  font-size: 9px;
  line-height: 1;
  white-space: nowrap;
}

.game-pieces {
  position: absolute;
  right: 2px;
  bottom: 2px;
  display: flex;
}

.game-piece {
  width: 15px;
  height: 15px;
  margin-left: -2px;
  font-size: 8px;
  box-shadow: 0 0 0 1px var(--paper);
}

.game-board-center {
  grid-column: 2 / 6;
  grid-row: 2 / 6;
  padding: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  text-align: center;
}

.game-big-die {
  font-size: 42px;
  line-height: 1;
}

.game-board-center strong {
  font-size: 15px;
  font-weight: 650;
}

.game-board-center span:last-child {
  max-width: 240px;
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.4;
}

.game-task {
  width: min(100%, 560px);
  margin: 0 auto;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--paper);
}

.game-task-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.game-task-head strong {
  font-size: 14px;
  font-weight: 650;
}

.game-task-head span {
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(169, 78, 104, 0.12);
  color: var(--telegram-deep);
  font-size: 10.5px;
  white-space: nowrap;
}

.game-task p {
  margin: 9px 0 0;
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.game-actions {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.game-action {
  min-height: 42px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: transparent;
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.game-action.primary {
  border-color: transparent;
  background: var(--telegram);
  color: white;
}

.game-action:disabled {
  cursor: default;
  opacity: 0.48;
}

.game-history-wrap {
  width: min(100%, 560px);
  margin: 11px auto 0;
  color: var(--muted);
  font-size: 11px;
}

.game-history-wrap summary {
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  list-style: none;
}

.game-history-wrap summary::-webkit-details-marker { display: none; }

.game-history {
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--line);
}

.game-history li {
  padding: 8px 2px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid var(--line);
}

.game-history li span:last-child {
  flex: 0 0 auto;
  white-space: nowrap;
}

.balance-panel {
  position: absolute;
  inset: 0;
  z-index: 58;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  background: #eef3f5;
  animation: panel-in 160ms ease-out both;
}

body.balance-open .composer {
  visibility: hidden;
  pointer-events: none;
}

.balance-panel-head {
  min-height: 66px;
  padding: max(8px, env(safe-area-inset-top)) 12px 8px;
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr) 76px;
  align-items: center;
  gap: 6px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(18px);
}

.balance-back,
.balance-refresh {
  min-height: 38px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--telegram-deep);
  font-size: 13px;
  cursor: pointer;
}

.balance-back { text-align: left; }
.balance-refresh { text-align: right; }
.balance-refresh:disabled { color: var(--muted); }

.balance-panel-title {
  min-width: 0;
  display: grid;
  gap: 2px;
  text-align: center;
}

.balance-panel-title strong {
  font-size: 15px;
  font-weight: 680;
}

.balance-panel-title span {
  overflow: hidden;
  color: var(--muted);
  font-size: 10.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.balance-panel-scroll {
  min-height: 0;
  padding: 16px max(14px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.balance-list {
  width: min(100%, 680px);
  margin: 0 auto;
  display: grid;
  gap: 10px;
}

.balance-loading {
  padding: 38px 16px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.balance-card {
  min-width: 0;
  min-height: 82px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  overflow: hidden;
  border: 1px solid rgba(23, 33, 43, 0.08);
  border-radius: 17px;
  background: white;
  box-shadow: 0 5px 18px rgba(45, 65, 76, 0.07);
}

.balance-card.low {
  border-color: rgba(224, 114, 55, 0.34);
  background: #fffaf6;
}

.balance-card.error {
  border-color: rgba(196, 89, 89, 0.24);
}

.balance-card-link {
  min-width: 0;
  padding: 14px 12px 14px 14px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

.balance-card-link:focus-visible {
  outline: 2px solid rgba(42, 171, 238, 0.45);
  outline-offset: -2px;
}

.balance-card-identity {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 11px;
}

.balance-card-identity > span:last-child {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.balance-card-identity strong {
  overflow: hidden;
  font-size: 14px;
  font-weight: 680;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.balance-card-identity small {
  overflow: hidden;
  color: var(--muted);
  font-size: 10.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.balance-site-mark {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  display: grid !important;
  place-items: center;
  border-radius: 13px;
  background: rgba(42, 171, 238, 0.12);
  color: var(--telegram-deep);
  font-size: 16px;
  font-weight: 720;
}

.balance-card.low .balance-site-mark {
  background: rgba(224, 114, 55, 0.12);
  color: #bf612e;
}

.balance-card-amount {
  min-width: 74px;
  display: grid;
  justify-items: end;
  gap: 5px;
}

.balance-card-amount strong {
  font-size: 19px;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.balance-card-amount span {
  padding: 3px 7px;
  border-radius: 999px;
  background: rgba(83, 184, 106, 0.1);
  color: #39834b;
  font-size: 9.5px;
  white-space: nowrap;
}

.balance-card.low .balance-card-amount span {
  background: rgba(224, 114, 55, 0.12);
  color: #b95829;
}

.balance-card.error .balance-card-amount span,
.balance-card.missing .balance-card-amount span {
  background: rgba(113, 128, 141, 0.1);
  color: var(--muted);
}

.balance-card-settings {
  width: 58px;
  border: 0;
  border-left: 1px solid var(--line);
  background: rgba(247, 249, 250, 0.76);
  color: var(--telegram-deep);
  font-size: 12px;
  cursor: pointer;
}

.balance-card-settings:active {
  background: rgba(42, 171, 238, 0.11);
}

.balance-safety-note {
  width: min(100%, 620px);
  margin: 18px auto 0;
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.55;
  text-align: center;
}

.balance-editor {
  position: absolute;
  inset: 0;
  z-index: 4;
  padding: max(18px, env(safe-area-inset-top)) 14px max(18px, env(safe-area-inset-bottom));
  display: grid;
  place-items: center;
  overflow-y: auto;
  background: rgba(20, 31, 39, 0.34);
  backdrop-filter: blur(5px);
}

.balance-editor-card {
  width: min(100%, 440px);
  padding: 18px;
  display: grid;
  gap: 14px;
  border-radius: 20px;
  background: white;
  box-shadow: 0 24px 70px rgba(24, 38, 47, 0.26);
  animation: panel-in 160ms ease-out both;
}

.balance-editor-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.balance-editor-head > div {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.balance-editor-head strong { font-size: 16px; }
.balance-editor-head span { color: var(--muted); font-size: 11px; }

.balance-editor-head button {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  border: 0;
  border-radius: 50%;
  background: #eef2f4;
  color: var(--muted);
  font-size: 22px;
  cursor: pointer;
}

.balance-editor-card label {
  display: grid;
  gap: 6px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 620;
}

.balance-editor-card input {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid rgba(23, 33, 43, 0.14);
  border-radius: 11px;
  outline: none;
  background: #f8fafb;
  color: var(--ink);
  font: inherit;
  font-weight: 450;
}

.balance-editor-card input:focus {
  border-color: rgba(42, 171, 238, 0.72);
  background: white;
  box-shadow: 0 0 0 3px rgba(42, 171, 238, 0.1);
}

.balance-editor-card small {
  color: var(--muted);
  font-size: 10px;
  font-weight: 450;
  line-height: 1.45;
}

.balance-editor-warning {
  margin: 0;
  padding: 10px 11px;
  border-radius: 10px;
  background: #fff8eb;
  color: #896029;
  font-size: 10.5px;
  line-height: 1.5;
}

.balance-editor-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
}

.balance-editor-actions button {
  min-height: 42px;
  padding: 0 16px;
  border-radius: 11px;
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
}

.balance-disconnect {
  border: 1px solid rgba(196, 89, 89, 0.2);
  background: white;
  color: #b34c4c;
}

.balance-save {
  border: 0;
  background: var(--telegram);
  color: white;
}

.balance-editor-actions button:disabled {
  cursor: wait;
  opacity: 0.62;
}

@media (max-width: 460px) {
  .balance-card-link { gap: 8px; padding-left: 11px; }
  .balance-site-mark { width: 38px; height: 38px; flex-basis: 38px; }
  .balance-card-identity { gap: 9px; }
  .balance-card-identity small { max-width: 136px; }
  .balance-card-amount { min-width: 66px; }
  .balance-card-amount strong { font-size: 17px; }
  .balance-card-settings { width: 52px; }
}

.chat-header {
  position: relative;
  z-index: 50;
  min-height: 66px;
  padding: max(8px, env(safe-area-inset-top)) 16px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

.identity {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 11px;
}

.avatar {
  position: relative;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #17212b;
  color: white;
  font-family: Georgia, serif;
  font-size: 23px;
  font-style: italic;
  line-height: 1;
}

.online-dot {
  position: absolute;
  right: -1px;
  bottom: 1px;
  width: 11px;
  height: 11px;
  border: 2px solid white;
  border-radius: 50%;
  background: #53b86a;
}

.identity-copy {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.identity-copy strong {
  overflow: hidden;
  font-size: 15px;
  font-weight: 650;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.identity-copy span {
  color: var(--telegram-deep);
  font-size: 12px;
  line-height: 1.2;
}

.identity-copy span.offline {
  color: var(--muted);
}

.route-area {
  position: relative;
  flex: 0 0 auto;
}

.route-trigger {
  min-height: 38px;
  padding: 0 11px 0 13px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--telegram-deep);
  font-size: 14px;
  font-weight: 650;
  cursor: pointer;
}

.route-trigger:hover,
.route-trigger:focus-visible {
  background: rgba(42, 171, 238, 0.09);
  outline: none;
}

.route-trigger[aria-expanded="true"] .chevron {
  transform: rotate(225deg) translate(-1px, -1px);
}

.chevron {
  width: 7px;
  height: 7px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg) translate(-1px, -1px);
  transition: transform 160ms ease;
}

.route-menu {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 55;
  max-height: min(72dvh, 620px);
  padding: 7px 0 max(10px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(77, 96, 108, 0.14);
  border-bottom: 0;
  border-radius: 22px 22px 0 0;
  background: #fff;
  box-shadow: 0 -14px 42px rgba(33, 48, 59, 0.2);
  animation: route-sheet-in 180ms cubic-bezier(.2, .78, .22, 1) both;
}

.route-sheet-handle {
  width: 38px;
  height: 4px;
  flex: 0 0 auto;
  margin: 0 auto 5px;
  border-radius: 999px;
  background: #d4dce1;
}

.route-sheet-header {
  min-height: 57px;
  padding: 5px 17px 9px 19px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex: 0 0 auto;
  border-bottom: 1px solid var(--line);
}

.route-sheet-heading {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.route-sheet-heading strong {
  color: var(--ink);
  font-size: 17px;
  line-height: 1.2;
}

.route-sheet-heading span {
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.route-sheet-close {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: #f1f5f7;
  color: #677983;
  font-size: 25px;
  font-weight: 300;
  line-height: 1;
  cursor: pointer;
}

.route-sheet-scroll {
  min-height: 0;
  padding: 7px 9px 2px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-color: rgba(92, 112, 125, 0.32) transparent;
}

.route-option {
  width: 100%;
  min-height: 50px;
  padding: 7px 11px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font-size: 14px;
  text-align: left;
  cursor: pointer;
}

.route-option:hover,
.route-option:focus-visible {
  background: #f1f5f7;
  outline: none;
}

.route-option.current {
  color: var(--telegram-deep);
  font-weight: 650;
  background: rgba(42, 171, 238, 0.08);
}

.route-check {
  width: 18px;
  margin-left: auto;
  color: var(--telegram);
  font-size: 17px;
  text-align: center;
}

.route-option-copy {
  min-width: 0;
  flex: 1 1 auto;
  display: grid;
  gap: 2px;
}

.route-option-copy strong {
  overflow: hidden;
  font-size: 14px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.route-option-copy span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 400;
}

.route-status-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #9aa8b0;
  box-shadow: 0 0 0 3px rgba(154, 168, 176, 0.12);
}

.route-status-dot.available {
  background: #44b972;
  box-shadow: 0 0 0 3px rgba(68, 185, 114, 0.12);
}

.route-status-dot.cooling {
  background: #d79a39;
  box-shadow: 0 0 0 3px rgba(215, 154, 57, 0.12);
}

.route-option.cooling:not(.current) {
  color: #7d858b;
}

.route-divider {
  height: 1px;
  margin: 5px 7px;
  background: var(--line);
}

.route-trigger.room-active,
.route-option.room-leave {
  color: #a84f68;
}

.message-scroller {
  grid-row: 3;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-color: rgba(92, 112, 125, 0.36) transparent;
}

.messages {
  width: min(100%, 760px);
  min-height: 100%;
  margin: 0 auto;
  padding: 18px 18px 20px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 7px;
}

.history-loading {
  align-self: center;
  padding: 7px 12px;
  color: var(--muted);
  font-size: 12px;
}

.date-divider {
  align-self: center;
  margin: 8px 0 4px;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(83, 103, 116, 0.5);
  color: white;
  font-size: 11px;
  line-height: 1;
  backdrop-filter: blur(8px);
}

.conversation-divider {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 13px 0 9px;
  color: rgba(72, 91, 104, 0.72);
  font-size: 11px;
  line-height: 1;
}

.conversation-divider::before,
.conversation-divider::after {
  content: "";
  height: 1px;
  flex: 1;
  background: rgba(84, 105, 119, 0.2);
}

.conversation-divider span {
  flex: none;
}

.failure-notice {
  width: min(100%, 560px);
  align-self: center;
  margin: 8px 0 2px;
  padding: 11px 12px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border: 1px solid rgba(190, 77, 77, 0.2);
  border-radius: 14px;
  background: #fff4f2;
  color: #8c3434;
  box-shadow: 0 4px 18px rgba(115, 45, 45, 0.08);
}

.failure-notice > div {
  min-width: 0;
  flex: 1;
  display: grid;
  gap: 4px;
}

.failure-notice strong {
  font-size: 13px;
}

.failure-notice p {
  margin: 0;
  color: #663f3f;
  font-size: 13px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.failure-notice button {
  width: 28px;
  height: 28px;
  flex: none;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #9b6464;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.failure-notice button:hover,
.failure-notice button:focus-visible {
  background: rgba(140, 52, 52, 0.08);
  outline: none;
}

.message-row {
  width: 100%;
  display: flex;
}

.message-row[data-reply-ts] {
  -webkit-touch-callout: default;
  touch-action: pan-y;
}

.bubble-text,
.voice-transcript,
.voice-translation,
.image-caption {
  -webkit-touch-callout: default;
  -webkit-user-select: text;
  user-select: text;
}

.sticker-message,
.image-message img,
.voice-play,
.voice-waveform {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.message-action-menu {
  position: fixed;
  z-index: 65;
  width: 154px;
  padding: 5px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  border: 0;
  border-radius: 13px;
  background: rgba(36, 38, 41, 0.97);
  box-shadow: 0 12px 34px rgba(15, 20, 24, 0.3);
  animation: menu-in 130ms ease-out both;
}

.message-action-menu::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -6px;
  width: 12px;
  height: 12px;
  background: rgba(36, 38, 41, 0.97);
  transform: translateX(-50%) rotate(45deg);
}

.message-action-menu.below::after {
  top: -6px;
  bottom: auto;
}

.message-action-menu button {
  min-height: 40px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: #ffffff;
  font-size: 14px;
  cursor: pointer;
}

.message-action-menu button:hover,
.message-action-menu button:focus-visible {
  background: rgba(42, 171, 238, 0.1);
  color: #ffffff;
  outline: none;
}

.message-row.user {
  justify-content: flex-end;
}

.message-row.assistant {
  justify-content: flex-start;
}

.message-stack {
  max-width: min(76%, 560px);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.message-row.user .message-stack {
  align-items: flex-end;
}

.bubble {
  position: relative;
  max-width: 100%;
  min-width: 58px;
  padding: 8px 10px 6px;
  border-radius: 17px;
  box-shadow: 0 1px 1px rgba(41, 57, 68, 0.09);
}

.message-row.assistant .bubble {
  background: var(--assistant);
  border-bottom-left-radius: 5px;
}

.message-row.user .bubble {
  background: var(--user);
  color: white;
  border-bottom-right-radius: 5px;
}

.tool-event-row {
  padding-left: 4px;
}

.tool-event {
  max-width: min(82%, 600px);
  min-width: 260px;
  padding: 9px 11px;
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  border: 1px solid rgba(82, 98, 110, 0.16);
  border-radius: 12px;
  background: rgba(244, 247, 249, 0.94);
  color: #33424d;
}

.tool-event-icon {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(54, 134, 178, 0.12);
  color: #24779f;
  font-size: 13px;
  font-weight: 700;
}

.tool-event.running .tool-event-icon {
  width: 18px;
  height: 18px;
  margin: 2px;
  border: 2px solid rgba(54, 134, 178, 0.2);
  border-top-color: #2a8ab7;
  background: transparent;
  animation: tool-event-spin 750ms linear infinite;
}

.tool-event.error .tool-event-icon {
  background: rgba(180, 67, 67, 0.12);
  color: #a23c3c;
}

.tool-event-copy {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.tool-event-copy strong,
.tool-event-copy span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tool-event-copy strong {
  font-size: 13px;
}

.tool-event-copy span,
.tool-event-state {
  color: #74838d;
  font-size: 11px;
}

.tool-event-state {
  white-space: nowrap;
}

.route-polling-event-row {
  padding-left: 0;
  justify-content: center;
}

.route-polling-event-row + .route-polling-event-row {
  margin-top: 16px;
}

.route-polling-event {
  width: auto;
  min-width: 0;
  max-width: min(calc(100% - 80px), 480px);
  padding: 2px 14px;
  grid-template-columns: 16px minmax(0, 1fr);
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: #f2f2f2;
  color: rgba(0, 0, 0, 0.5);
  box-shadow: none;
}

.route-polling-event.success {
  border-color: #d8ecdf;
  background: #dbf8e5;
  color: rgba(0, 0, 0, 0.72);
}

.route-polling-event .tool-event-icon {
  width: 16px;
  height: 16px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(54, 134, 178, 0.12);
  color: #24779f;
  font-size: 10px;
  font-weight: 700;
}

.route-polling-event.running .tool-event-icon {
  margin: 0;
  border: 2px solid rgba(54, 134, 178, 0.2);
  border-top-color: #2a8ab7;
  background: transparent;
  animation: tool-event-spin 750ms linear infinite;
}

.route-polling-event.error .tool-event-icon {
  background: rgba(180, 67, 67, 0.12);
  color: #a23c3c;
}

.route-polling-event .tool-event-copy {
  display: block;
}

.route-polling-event .tool-event-copy strong {
  color: inherit;
  font-size: 12px;
  font-weight: 500;
}

.route-polling-event .tool-event-copy span {
  display: none;
}

.route-polling-event .tool-event-state {
  display: none;
}

.bubble-text {
  margin: 0;
  font-size: 15px;
  line-height: 1.48;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.message-reply-quote {
  min-width: 0;
  margin: 0 0 6px;
  padding: 5px 8px;
  display: grid;
  gap: 1px;
  border-left: 3px solid var(--telegram);
  border-radius: 7px;
  background: rgba(42, 171, 238, 0.08);
}

.message-reply-quote strong,
.message-reply-quote span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-reply-quote strong {
  color: var(--telegram-deep);
  font-size: 11px;
}

.message-reply-quote span {
  color: var(--muted);
  font-size: 11px;
}

.message-row.user .message-reply-quote {
  border-left-color: rgba(255, 255, 255, 0.9);
  background: rgba(255, 255, 255, 0.13);
}

.message-row.user .message-reply-quote strong,
.message-row.user .message-reply-quote span {
  color: rgba(255, 255, 255, 0.9);
}

.bubble-meta {
  margin: 3px 0 0 9px;
  float: right;
  position: relative;
  top: 3px;
  color: rgba(75, 92, 104, 0.68);
  font-size: 10px;
  line-height: 1;
  white-space: nowrap;
}

.message-row.user .bubble-meta {
  color: rgba(255, 255, 255, 0.75);
}

.usage-line {
  margin: 4px 8px 1px;
  color: #6e7d87;
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
  line-height: 1.25;
  white-space: nowrap;
}

.sticker-message {
  position: relative;
  width: min(42vw, 190px);
  min-width: 116px;
  min-height: 116px;
  display: grid;
  place-items: center;
}

.image-stack {
  max-width: min(78%, 420px);
}

.image-message {
  width: min(68vw, 360px);
  max-width: 100%;
  padding: 3px;
  overflow: hidden;
  border-radius: 18px 18px 6px 18px;
  background: var(--user);
  box-shadow: 0 1px 1px rgba(41, 57, 68, 0.09);
}

.image-message-visual {
  position: relative;
  min-height: 110px;
  overflow: hidden;
  border-radius: 15px;
  background: rgba(23, 33, 43, 0.08);
}

.image-message img {
  width: 100%;
  max-height: 430px;
  display: block;
  object-fit: contain;
}

.image-time {
  position: absolute;
  right: 6px;
  bottom: 6px;
  padding: 3px 6px;
  border-radius: 999px;
  background: rgba(25, 37, 46, 0.52);
  color: white;
  font-size: 10px;
  line-height: 1;
}

.image-caption {
  margin: 0;
  padding: 7px 8px 6px;
  color: white;
  font-size: 15px;
  line-height: 1.42;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.voice-stack {
  max-width: min(82%, 420px);
}

.voice-message {
  width: min(395px, 100%);
  max-width: 100%;
  padding: 12px 16px;
  border: 0;
  border-radius: 21px;
  background: var(--assistant);
  box-shadow: 0 0 1px rgba(0, 0, 0, 0.12);
}

.message-row.assistant .voice-message {
  border-radius: 8px 21px 21px 21px;
}

.message-row.user .voice-message {
  border-radius: 21px 8px 21px 21px;
  background: var(--user);
  color: white;
}

.voice-player {
  display: flex;
  align-items: center;
  gap: 8px;
}

.voice-play {
  position: relative;
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.voice-play::before {
  position: absolute;
  inset: -14px;
  content: "";
}

.voice-message.playing .voice-play {
  background: transparent;
}

.voice-play img {
  width: 20px;
  height: 20px;
  display: block;
}

.voice-waveform {
  --voice-progress: 0%;
  position: relative;
  width: 34px;
  height: 20px;
  flex: 0 0 34px;
  cursor: pointer;
  touch-action: none;
}

.voice-waveform img {
  width: 34px;
  height: 20px;
  display: block;
}

.voice-waveform::after {
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--voice-progress);
  background: #00c78b;
  content: "";
  -webkit-mask: url("/assets/figma-chat/icon-voice-waveform.svg") left center / 34px 20px no-repeat;
  mask: url("/assets/figma-chat/icon-voice-waveform.svg") left center / 34px 20px no-repeat;
}

.voice-duration {
  color: #1a284f;
  font-size: 16px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  line-height: 20px;
  white-space: nowrap;
}

.voice-transcript,
.voice-translation {
  margin: 8px 0 0;
  padding-top: 8px;
  border-top: 0.5px solid rgba(0, 0, 0, 0.06);
  font-size: 12px;
  line-height: 18px;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.voice-translation {
  margin-top: 6px;
  padding-top: 0;
  border-top: 0;
  color: var(--muted);
  font-size: 14px;
}

.message-row.user .voice-waveform i {
  background: rgba(255, 255, 255, 0.43);
}

.message-row.user .voice-waveform i.played {
  background: white;
}

.message-row.user .voice-meta,
.message-row.user .voice-translation {
  color: rgba(255, 255, 255, 0.76);
}

.message-row.user .voice-transcript {
  border-top-color: rgba(0, 0, 0, 0.06);
}

.sticker-message img {
  display: block;
  width: 100%;
  max-height: 190px;
  object-fit: contain;
  filter: drop-shadow(0 2px 2px rgba(24, 36, 44, 0.12));
}

.sticker-fallback {
  font-size: 76px;
  line-height: 1;
}

.sticker-time {
  position: absolute;
  right: 2px;
  bottom: 2px;
  padding: 3px 6px;
  border-radius: 999px;
  background: rgba(28, 41, 51, 0.48);
  color: white;
  font-size: 10px;
  line-height: 1;
}

.empty-state {
  margin: auto;
  max-width: 260px;
  padding: 16px 18px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  text-align: center;
  box-shadow: 0 1px 1px rgba(41, 57, 68, 0.06);
}

.empty-state strong {
  display: block;
  margin-bottom: 4px;
  color: var(--ink);
  font-size: 14px;
}

.empty-state span {
  font-size: 12px;
  line-height: 1.5;
}

.typing-bubble {
  width: 58px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border-radius: 17px 17px 17px 5px;
  background: white;
  box-shadow: 0 1px 1px rgba(41, 57, 68, 0.09);
}

.typing-bubble i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #8c9aa4;
  animation: typing 1.1s ease-in-out infinite;
}

.typing-bubble i:nth-child(2) {
  animation-delay: 120ms;
}

.typing-bubble i:nth-child(3) {
  animation-delay: 240ms;
}

.composer {
  grid-row: 4;
  position: relative;
  z-index: 50;
  min-height: 62px;
  padding: 8px 12px max(8px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: 42px 42px minmax(0, 1fr) 42px;
  align-items: end;
  gap: 4px;
  background: rgba(255, 255, 255, 0.98);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

/* 主屏幕 App 的可用视口已经避开了 Home Indicator，不再重复垫安全区。 */
html.standalone-app .composer {
  padding-bottom: 0;
}

.icon-button,
.send-button {
  width: 42px;
  height: 42px;
  align-self: end;
  display: grid;
  place-items: center;
  border: 0;
  cursor: pointer;
}

.composer .icon-button {
  width: 42px;
}

.icon-button {
  border-radius: 10px;
  background: transparent;
  color: #6d7b86;
  font-size: 25px;
  line-height: 1;
}

.icon-button:hover,
.icon-button:focus-visible {
  color: var(--telegram-deep);
  background: rgba(42, 171, 238, 0.08);
  outline: none;
}

.icon-button[aria-expanded="true"] {
  color: var(--telegram-deep);
}

.image-trigger svg {
  display: block;
  width: 23px;
  height: 23px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.65;
}

.sticker-trigger svg {
  display: block;
  width: 25px;
  height: 25px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.65;
}

.visually-hidden {
  position: fixed !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.image-preview {
  grid-column: 1 / -1;
  min-width: 0;
  margin: 0 2px 4px;
  padding: 7px 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid rgba(23, 33, 43, 0.1);
  border-radius: 14px;
  background: #f2f6f8;
}

.reply-preview {
  grid-column: 1 / -1;
  min-width: 0;
  margin: 0 2px 4px;
  padding: 5px 7px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-radius: 10px;
  background: #f2f6f8;
}

.reply-preview-accent {
  width: 3px;
  height: 34px;
  flex: 0 0 3px;
  border-radius: 999px;
  background: var(--telegram);
}

.reply-preview-copy {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.reply-preview-copy strong,
.reply-preview-copy span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reply-preview-copy strong {
  color: var(--telegram-deep);
  font-size: 12px;
}

.reply-preview-copy span {
  color: var(--muted);
  font-size: 11px;
}

.reply-cancel {
  width: 32px;
  height: 32px;
  margin-left: auto;
  flex: 0 0 32px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #71808d;
  font-size: 23px;
  line-height: 1;
}

.reply-cancel:hover,
.reply-cancel:focus-visible {
  background: rgba(23, 33, 43, 0.07);
  outline: none;
}

.image-preview img {
  width: 54px;
  height: 54px;
  flex: 0 0 54px;
  display: block;
  object-fit: cover;
  border-radius: 10px;
  background: #dce5ea;
}

.image-preview-copy {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.image-preview-copy strong {
  font-size: 13px;
  font-weight: 650;
}

.image-preview-copy span {
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.image-remove {
  width: 34px;
  height: 34px;
  margin-left: auto;
  flex: 0 0 34px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #71808d;
  font-size: 25px;
  line-height: 1;
}

.image-remove:hover,
.image-remove:focus-visible {
  background: rgba(23, 33, 43, 0.07);
  outline: none;
}

.input-wrap {
  min-height: 42px;
  align-self: end;
  padding: 9px 13px;
  display: flex;
  align-items: center;
  border: 1px solid rgba(23, 33, 43, 0.13);
  border-radius: 21px;
  background: #f5f7f8;
}

.input-wrap:focus-within {
  border-color: rgba(42, 171, 238, 0.55);
  background: white;
}

textarea {
  display: block;
  width: 100%;
  min-height: 21px;
  max-height: 110px;
  padding: 0;
  resize: none;
  overflow-y: auto;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  /* iPhone 会自动放大字号小于 16px 的输入框。 */
  font-size: 16px;
  line-height: 21px;
}

textarea::placeholder {
  color: #8d9aa3;
}

.send-button {
  border-radius: 50%;
  background: var(--telegram);
  color: white;
  font-size: 25px;
  font-weight: 500;
  line-height: 1;
  transition: transform 120ms ease, background 120ms ease;
}

.send-button svg {
  display: block;
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.send-button .mic-glyph {
  position: relative;
  display: none;
  width: 12px;
  height: 18px;
  margin-bottom: 4px;
  border: 2px solid currentColor;
  border-radius: 8px;
}

.send-button .mic-glyph::before {
  position: absolute;
  left: 50%;
  bottom: -7px;
  width: 18px;
  height: 10px;
  border: 2px solid currentColor;
  border-top: 0;
  border-radius: 0 0 10px 10px;
  content: "";
  transform: translateX(-50%);
}

.send-button .mic-glyph::after {
  position: absolute;
  left: 50%;
  bottom: -11px;
  width: 2px;
  height: 5px;
  border-radius: 2px;
  background: currentColor;
  content: "";
  transform: translateX(-50%);
}

.send-button.voice-mode {
  background: transparent;
  color: #6d7b86;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.send-button.voice-mode .send-glyph {
  display: none;
}

.send-button.voice-mode .mic-glyph {
  display: block;
}

.send-button.voice-mode:hover,
.send-button.voice-mode:focus-visible {
  background: rgba(42, 171, 238, 0.08);
  color: var(--telegram-deep);
}

.voice-recording {
  grid-column: 1 / -1;
  min-height: 42px;
  padding: 0 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-radius: 20px;
  background: #f3f6f8;
  color: #52636f;
}

.voice-recording[hidden] {
  display: none;
}

.voice-recording strong {
  min-width: 0;
  flex: 1;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
}

.voice-recording-dot {
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #e84d5b;
  box-shadow: 0 0 0 4px rgba(232, 77, 91, 0.12);
  animation: voice-recording-pulse 1.1s ease-in-out infinite;
}

.voice-recording.cancel {
  background: #fff0f1;
  color: #d43f50;
}

@keyframes voice-recording-pulse {
  50% { opacity: 0.45; transform: scale(0.78); }
}

.send-button:hover,
.send-button:focus-visible {
  background: var(--telegram-deep);
  outline: none;
}

.send-button:active {
  transform: scale(0.94);
}

.send-button:disabled,
.icon-button:disabled {
  cursor: default;
  opacity: 0.45;
}

.sticker-panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: var(--composer-height);
  z-index: 45;
  height: min(43%, 390px);
  padding: 13px 14px 18px;
  background: rgba(255, 255, 255, 0.98);
  border-top: 1px solid var(--line);
  box-shadow: 0 -12px 34px rgba(35, 51, 62, 0.12);
  backdrop-filter: blur(18px);
  animation: panel-in 180ms ease-out both;
}

.sticker-panel-head {
  height: 28px;
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.sticker-panel-head strong {
  font-size: 14px;
  font-weight: 650;
}

.sticker-panel-head span {
  color: var(--muted);
  font-size: 11px;
}

.sticker-grid {
  height: calc(100% - 28px);
  padding-top: 6px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
  grid-auto-rows: 84px;
  align-content: start;
  gap: 7px;
  overflow-y: auto;
}

.sticker-item {
  position: relative;
  min-width: 0;
  min-height: 0;
  padding: 4px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 0;
  border-radius: 12px;
  background: transparent;
  cursor: pointer;
}

.sticker-item:hover,
.sticker-item:focus-visible {
  background: #eef3f5;
  outline: none;
}

.sticker-art {
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.sticker-item img,
.sticker-art img {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.sticker-item .sticker-fallback {
  font-size: 36px;
}

.page-backdrop {
  position: absolute;
  inset: 0;
  z-index: 35;
  padding: 0;
  border: 0;
  background: rgba(18, 29, 37, 0.12);
}

.toast {
  position: absolute;
  left: 50%;
  bottom: calc(74px + env(safe-area-inset-bottom));
  z-index: 60;
  max-width: calc(100% - 40px);
  padding: 9px 13px;
  border-radius: 10px;
  background: rgba(27, 39, 48, 0.88);
  color: white;
  font-size: 12px;
  line-height: 1.35;
  text-align: center;
  transform: translateX(-50%);
  box-shadow: 0 8px 24px rgba(27, 39, 48, 0.2);
}

@keyframes typing {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-3px); opacity: 1; }
}

@keyframes menu-in {
  from { opacity: 0; transform: translateY(-4px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes route-sheet-in {
  from { opacity: 0.7; transform: translateY(24px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes panel-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

body.room-mode {
  color-scheme: dark;
  --telegram: #a94e68;
  --telegram-deep: #d18198;
  --ink: #f2edf1;
  --muted: #a89ca5;
  --line: rgba(255, 255, 255, 0.09);
  --page: #111015;
  --paper: #1c1920;
  --assistant: #262229;
  --user: #92445b;
  --shadow: 0 18px 70px rgba(0, 0, 0, 0.46);
  background: #09080b;
}

body.room-mode .app-shell {
  background: var(--page);
}

body.room-mode .game-dock,
body.room-mode .game-panel-head,
body.room-mode .game-player,
body.room-mode .game-cell,
body.room-mode .game-task {
  border-color: rgba(255, 255, 255, 0.09);
  background: rgba(38, 34, 41, 0.98);
}

body.room-mode .game-dock {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
}

body.room-mode .game-dock-turn {
  background: rgba(209, 129, 152, 0.12);
}

body.room-mode .game-cell.has-player {
  background: rgba(209, 129, 152, 0.13);
}

body.room-mode .game-piece {
  box-shadow: 0 0 0 1px #262229;
}

body.room-mode .chat-header,
body.room-mode .composer,
body.room-mode .sticker-panel,
body.room-mode .message-action-menu {
  background: rgba(24, 21, 27, 0.97);
}

body.room-mode .reply-preview,
body.room-mode .image-preview,
body.room-mode .voice-recording {
  background: rgba(255, 255, 255, 0.055);
}

body.room-mode .send-button.voice-mode {
  color: #b9adb6;
}

body.room-mode .voice-recording.cancel {
  background: rgba(169, 78, 104, 0.18);
  color: #ec9db3;
}

body.room-mode .message-reply-quote {
  background: rgba(209, 129, 152, 0.09);
}

body.room-mode .voice-waveform i {
  background: #766b74;
}

body.room-mode .voice-waveform i.played {
  background: #d18198;
}

body.room-mode .voice-play {
  background: #b35873;
}

body.room-mode .voice-message.playing .voice-play {
  background: #d18198;
}

body.room-mode .voice-transcript {
  border-top-color: rgba(255, 255, 255, 0.1);
}

body.room-mode .voice-meta,
body.room-mode .voice-translation {
  color: #a89ca5;
}

body.room-mode .chat-header {
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.16);
}

body.room-mode .avatar {
  background: #702f43;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

body.room-mode .online-dot {
  border-color: #18151b;
}

body.room-mode .message-scroller {
  background:
    radial-gradient(circle at 18% 12%, rgba(114, 47, 69, 0.12), transparent 34%),
    radial-gradient(circle at 82% 82%, rgba(79, 48, 86, 0.1), transparent 38%),
    #111015;
  scrollbar-color: rgba(205, 155, 174, 0.28) transparent;
}

body.room-mode .route-menu {
  border-color: rgba(255, 255, 255, 0.09);
  background: #1f1b22;
  box-shadow: 0 -16px 42px rgba(0, 0, 0, 0.42);
}

body.room-mode .route-sheet-handle {
  background: rgba(255, 255, 255, 0.22);
}

body.room-mode .route-sheet-close {
  background: rgba(255, 255, 255, 0.07);
  color: #c9bcc4;
}

body.room-mode .route-option {
  color: var(--ink);
}

body.room-mode .route-option:hover,
body.room-mode .route-option:focus-visible,
body.room-mode .sticker-item:hover,
body.room-mode .sticker-item:focus-visible {
  background: rgba(255, 255, 255, 0.065);
}

body.room-mode .route-option.room-leave {
  color: #e09aaf;
}

body.room-mode .route-trigger:hover,
body.room-mode .route-trigger:focus-visible,
body.room-mode .icon-button:hover,
body.room-mode .icon-button:focus-visible {
  background: rgba(205, 108, 139, 0.1);
}

body.room-mode .empty-state {
  background: rgba(39, 34, 42, 0.8);
  color: var(--muted);
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.24);
}

body.room-mode .typing-bubble {
  background: var(--assistant);
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.26);
}

body.room-mode .typing-bubble i {
  background: #b9a9b3;
}

body.room-mode .tool-event {
  border-color: rgba(234, 196, 209, 0.14);
  background: rgba(255, 255, 255, 0.055);
  color: #f0e7ec;
}

body.room-mode .tool-event-icon {
  background: rgba(203, 113, 137, 0.16);
  color: #e7a8b9;
}

body.room-mode .tool-event.running .tool-event-icon {
  border-color: rgba(203, 113, 137, 0.22);
  border-top-color: #df8fa6;
  background: transparent;
}

body.room-mode .tool-event-copy span,
body.room-mode .tool-event-state {
  color: rgba(238, 220, 229, 0.62);
}

body.room-mode .route-polling-event {
  background: #302a32;
}

@keyframes tool-event-spin {
  to { transform: rotate(360deg); }
}

body.room-mode .input-wrap {
  border-color: rgba(255, 255, 255, 0.1);
  background: #242128;
}

body.room-mode .input-wrap:focus-within {
  border-color: rgba(209, 129, 152, 0.5);
  background: #2a252d;
}

body.room-mode .image-preview {
  border-color: rgba(255, 255, 255, 0.09);
  background: #242128;
}

body.room-mode .page-backdrop {
  background: rgba(0, 0, 0, 0.36);
}

body.room-mode .usage-line {
  color: #a89ca5;
}

body.room-mode .date-divider {
  background: rgba(108, 81, 96, 0.68);
}

body.room-mode .conversation-divider {
  color: rgba(198, 168, 181, 0.76);
}

body.room-mode .conversation-divider::before,
body.room-mode .conversation-divider::after {
  background: rgba(201, 142, 166, 0.2);
}

body.room-mode .failure-notice {
  border-color: rgba(224, 116, 144, 0.22);
  background: rgba(91, 40, 56, 0.58);
  color: #f0a9bb;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.16);
}

body.room-mode .failure-notice p {
  color: #e8cbd3;
}

body.room-mode .failure-notice button {
  color: #cc8fa1;
}

@media (max-width: 620px) {
  html,
  body {
    background: #ffffff;
  }

  body.room-mode {
    background: #18151b;
  }

  .app-shell {
    width: 100%;
    box-shadow: none;
  }

  .chat-header {
    padding-left: 12px;
    padding-right: 10px;
    isolation: isolate;
    transform: translateZ(0);
  }

  .message-scroller {
    position: relative;
    z-index: 1;
    isolation: isolate;
    contain: paint;
  }

  .messages {
    padding: 14px max(12px, env(safe-area-inset-left)) 16px max(12px, env(safe-area-inset-right));
  }

  .game-dock {
    width: calc(100% - 20px);
    margin-top: 8px;
  }

  .game-panel-scroll {
    padding-top: 10px;
  }

  .game-board {
    grid-template-rows: repeat(6, 48px);
  }

  .game-cell-icon {
    font-size: 15px;
  }

  .game-cell-label {
    font-size: 8.5px;
  }

  .bubble {
    max-width: 100%;
  }

  .message-stack {
    max-width: 84%;
  }

  .voice-stack {
    max-width: 88%;
  }

  .voice-message {
    width: min(74vw, 340px);
  }

  .route-area {
    position: relative;
  }

  .route-menu {
    max-height: 74dvh;
    border-radius: 20px 20px 0 0;
  }

  .route-option {
    min-height: 52px;
    padding: 7px 12px;
  }

  .sticker-grid {
    grid-template-columns: repeat(4, minmax(58px, 1fr));
    grid-auto-rows: 78px;
  }

  .composer {
    padding-left: max(8px, env(safe-area-inset-left));
    padding-right: max(8px, env(safe-area-inset-right));
    gap: 3px;
  }
}

@media (max-width: 360px) {
  .game-players {
    grid-template-columns: 1fr;
  }

  .game-player {
    padding: 8px 10px;
  }

  .game-board {
    grid-template-rows: repeat(6, 43px);
  }

  .game-board-center {
    padding: 8px;
  }

  .game-big-die {
    font-size: 34px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
/* 手机局域网访问登录页 */
.login-page {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(160deg, #eef4f7 0%, #dbe6eb 100%);
}

.login-card {
  width: min(100%, 360px);
  padding: 34px 28px 30px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 18px 50px rgba(45, 70, 82, 0.16);
  text-align: center;
}

.login-avatar {
  width: 66px;
  height: 66px;
  margin: 0 auto 16px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #2aabee;
  color: #fff;
  font-size: 30px;
  font-weight: 700;
}

.login-card h1 {
  margin: 0;
  font-size: 24px;
}

.login-card p {
  margin: 8px 0 24px;
  color: #7c8b92;
  font-size: 14px;
}

.login-card form {
  display: grid;
  gap: 12px;
}

.login-card input,
.login-card button {
  width: 100%;
  height: 48px;
  border-radius: 14px;
  font: inherit;
}

.login-card input {
  border: 1px solid #d9e1e5;
  padding: 0 16px;
  color: #253238;
  background: #ffffff;
  outline: none;
}

.login-card input:focus {
  border-color: #2aabee;
  box-shadow: 0 0 0 3px rgba(42, 171, 238, 0.13);
}

.login-card button {
  border: 0;
  background: #2aabee;
  color: #fff;
  font-weight: 650;
}

.login-card button:disabled {
  opacity: 0.6;
}

.login-error {
  margin-top: 14px;
  color: #c94c5d;
  font-size: 13px;
}

.secure-setup-page {
  min-height: 100vh;
  min-height: 100dvh;
  overflow-y: auto;
  padding: max(24px, env(safe-area-inset-top)) 18px max(30px, env(safe-area-inset-bottom));
  background: linear-gradient(160deg, #eef4f7 0%, #dbe6eb 100%);
}

.secure-setup-card {
  width: min(100%, 430px);
  margin: 0 auto;
  padding: 28px 22px 24px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 18px 50px rgba(45, 70, 82, 0.16);
}

.secure-setup-card .login-avatar {
  margin-bottom: 12px;
}

.secure-setup-kicker {
  margin: 0 0 5px;
  color: var(--telegram-deep);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

.secure-setup-card h1 {
  margin: 0;
  font-size: 25px;
  text-align: center;
}

.secure-setup-intro {
  margin: 10px auto 22px;
  color: #71808d;
  font-size: 14px;
  line-height: 1.6;
  text-align: center;
}

.secure-setup-steps {
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
  list-style: none;
}

.secure-setup-steps li {
  min-height: 58px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 11px;
  border: 1px solid #e1e8eb;
  border-radius: 16px;
  background: #f8fafb;
}

.secure-setup-steps li > span {
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(42, 171, 238, 0.13);
  color: var(--telegram-deep);
  font-size: 13px;
  font-weight: 750;
}

.secure-setup-steps div {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.secure-setup-steps strong {
  font-size: 14px;
}

.secure-setup-steps small {
  color: #71808d;
  font-size: 12px;
  line-height: 1.45;
}

.secure-setup-actions {
  margin-top: 18px;
  display: grid;
  gap: 10px;
}

.secure-setup-actions a {
  min-height: 48px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 700;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

.secure-setup-primary {
  background: var(--telegram);
  color: white;
}

.secure-setup-secondary {
  border: 1px solid #d7e0e4;
  background: white;
  color: var(--telegram-deep);
}

.secure-setup-note {
  margin: 14px 0 0;
  overflow-wrap: anywhere;
  color: #8a969d;
  font-size: 11px;
  line-height: 1.45;
  text-align: center;
}

/* 2026-08 Figma 聊天界面 */
:root {
  --figma-blue: #9de7f8;
  --figma-blue-strong: #73d4ec;
  --figma-panel: #fafafa;
  --figma-page: #f9f9f9;
  --header-height: calc(45px + env(safe-area-inset-top));
  --composer-height: 66px;
  --active-composer-panel-height: 162px;
}

html,
body {
  background: #f9f9f9;
}

body {
  color: #151515;
}

.app-shell {
  width: min(100%, 640px);
  grid-template-rows: var(--header-height) auto minmax(0, 1fr) auto;
  background: var(--figma-page);
  box-shadow: 0 0 40px rgba(32, 43, 50, 0.08);
}

.chat-header {
  grid-row: 1;
  min-height: var(--header-height);
  height: var(--header-height);
  padding: env(safe-area-inset-top) 20px 0;
  display: grid;
  grid-template-columns: 24px 35px minmax(0, 1fr) 24px;
  align-items: center;
  justify-content: initial;
  gap: 12px;
  border: 0;
  background: #ffffff;
  box-shadow: none;
  backdrop-filter: none;
}

.header-back,
.header-more {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}

.header-back img {
  display: block;
  width: 8.591px;
  height: 15.061px;
}

.header-more img {
  display: block;
  width: 16px;
  height: 4px;
}

.header-avatar {
  width: 35px;
  height: 35px;
  display: block;
  object-fit: cover;
  border-radius: 50%;
}

.identity-copy {
  gap: 1px;
  align-content: center;
}

.identity-copy strong {
  color: #111;
  font-size: 15px;
  font-weight: 590;
  line-height: 19px;
}

.route-status-line {
  min-width: 0;
  display: flex !important;
  align-items: center;
  gap: 4px;
  width: fit-content;
  padding: 0;
  overflow: hidden;
  border: 0;
  background: transparent;
  color: #00c78b !important;
  font-size: 12px !important;
  line-height: 14px !important;
  text-align: left;
  cursor: pointer;
}

.route-status-line > span {
  overflow: hidden;
  color: inherit !important;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.route-status-line.offline {
  color: #808080 !important;
}

.online-dot {
  position: static;
  width: 5px;
  height: 5px;
  flex: 0 0 5px;
  border: 0;
  border-radius: 50%;
  background: #00c78b;
}

.online-dot.offline {
  background: #b7b7b7;
}

.message-scroller {
  grid-row: 3;
  background: var(--figma-page);
  scrollbar-width: none;
}

.message-scroller::-webkit-scrollbar {
  display: none;
}

.messages {
  width: min(100%, 520px);
  padding: 20px 20px 18px;
  gap: 0;
}

.date-divider,
.message-clock {
  align-self: center;
  margin: 2px 0 8px;
  padding: 0;
  background: transparent;
  color: #a2a2a2;
  font-size: 12px;
  line-height: 15px;
  backdrop-filter: none;
}

.date-divider:not(:first-child) {
  margin-top: 16px;
}

.message-clock {
  margin: 16px 0 0;
}

.conversation-divider {
  margin: 10px 0;
  color: #a2a2a2;
  font-size: 10px;
}

.message-row {
  align-items: flex-start;
  gap: 12px;
  margin-top: 16px;
}

.message-row.user {
  flex-direction: row;
}

.message-row.assistant + .message-row.assistant,
.message-row.user + .message-row.user,
.message-row.continuation {
  margin-top: 10px;
}

.message-row.assistant.route-polling-event-row,
.message-row.assistant.route-polling-event-row + .message-row.assistant.route-polling-event-row {
  justify-content: center;
  margin-top: 16px;
}

.message-avatar,
.message-avatar-spacer {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
}

.message-avatar {
  display: block;
  border-radius: 50%;
  object-fit: cover;
}

.message-avatar-spacer {
  display: block;
}

.message-stack {
  max-width: min(calc(100% - 96px), 390px);
  gap: 10px;
}

.message-row.continuation {
  margin-top: 10px;
}

.bubble {
  min-width: 0;
  padding: 9px 16px;
  border-radius: 21px;
  box-shadow: 0 0 1px rgba(0, 0, 0, 0.12);
}

.message-row.assistant .bubble {
  border-top-left-radius: 8px;
  border-bottom-left-radius: 21px;
  background: #ffffff;
  color: #151515;
}

.message-row.user .bubble {
  border-top-right-radius: 8px;
  border-bottom-right-radius: 21px;
  background: var(--figma-blue);
  color: #151515;
}

.bubble-text {
  color: inherit;
  font-size: 16px;
  line-height: 24px;
}

.bubble-meta {
  display: none;
}

.usage-line {
  order: -1;
  margin: 0 3px;
  color: #9c9c9c;
  font-size: 10px;
  line-height: 13px;
  white-space: nowrap;
}

.message-row.user .usage-line {
  text-align: right;
}

.message-reply-quote {
  margin: 0 0 6px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.42);
}

.sticker-message {
  width: 120px;
  height: 120px;
  padding: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.sticker-message img,
.sticker-message video,
.sticker-message canvas {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.image-message,
.image-message img {
  max-width: 220px;
  border-radius: 18px;
}

.voice-message {
  width: min(395px, 100%);
  min-height: 0;
  border: 0;
  border-radius: 21px;
  box-shadow: 0 0 1px rgba(0, 0, 0, 0.12);
}

.message-row.assistant .voice-message {
  border-radius: 8px 21px 21px 21px;
  background: #ffffff;
}

.message-row.user .voice-message {
  border-radius: 21px 8px 21px 21px;
  background: var(--figma-blue);
  color: #151515;
}

.typing-bubble {
  width: 58px;
  min-width: 58px;
  height: 42px;
  padding: 9px 16px;
  border-radius: 8px 21px 21px 21px;
  border-top-left-radius: 8px;
  background: #ffffff;
  box-shadow: 0 0 1px rgba(0, 0, 0, 0.12);
}

.failure-notice {
  box-shadow: none;
}

.composer {
  min-height: var(--composer-height);
  padding: 11px 12px;
  grid-template-columns: 32px minmax(0, 1fr) 32px 32px;
  align-items: center;
  gap: 8px;
  border-top: 0;
  background: #ffffff;
  backdrop-filter: none;
}

html.standalone-app .composer {
  padding-bottom: 0;
}

html.standalone-app body.more-panel-open .composer {
  padding-bottom: 11px;
}

html.standalone-app,
html.standalone-app body:not(.room-mode) {
  background: #ffffff;
}

.composer-round {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--figma-panel);
  cursor: pointer;
}

.composer-round > img,
.voice-mode-icon,
.voice-mode-icon img {
  display: block;
}

.sticker-trigger img {
  width: 13px;
  height: 15px;
}

.more-trigger img {
  width: 24px;
  height: 24px;
}

.voice-mode-toggle {
  position: relative;
  grid-column: 1;
}

.voice-mode-icon {
  position: relative;
  width: 24px;
  height: 24px;
}

.voice-wave-icon {
  position: absolute;
  inset: 0;
  width: 24px;
  height: 24px;
}

.keyboard-icon {
  display: none !important;
  width: 18px;
  height: 18px;
}

.voice-mode-toggle.text-mode .voice-mode-icon {
  display: none;
}

.voice-mode-toggle.text-mode .keyboard-icon {
  display: block !important;
}

.input-wrap,
.voice-hold-button {
  grid-column: 2;
  min-height: 44px;
  width: 100%;
  align-self: center;
  border: 0;
  border-radius: 22px;
}

.input-wrap {
  position: relative;
  padding: 11px 48px 11px 16px;
  background: #fafafa;
}

.input-wrap:focus-within {
  border: 0;
  background: #fafafa;
}

textarea {
  min-height: 22px;
  max-height: 88px;
  color: #181818;
  font-size: 16px;
  line-height: 22px;
}

textarea::placeholder {
  color: #a0a0a0;
}

.send-button {
  position: absolute;
  right: 6px;
  bottom: 6px;
  width: 32px;
  height: 32px;
  background: var(--figma-blue-strong);
}

.send-button svg {
  width: 20px;
  height: 20px;
}

.voice-hold-button {
  background: #f2f2f2;
  padding: 0 16px;
  border: 0;
  color: #202020;
  font-size: 14px;
  font-weight: 500;
  line-height: 44px;
  text-align: center;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.composer.voice-input-mode .input-wrap {
  display: none;
}

.sticker-trigger {
  grid-column: 3;
}

.more-trigger {
  grid-column: 4;
}

.header-back:focus-visible,
.header-more:focus-visible,
.composer-round:focus-visible,
.voice-hold-button:focus-visible,
.more-action:focus-visible,
.route-sheet-cancel:focus-visible,
.route-sheet-done:focus-visible,
.route-option:focus-visible,
.route-balance-link:focus-visible,
.sticker-item:focus-visible {
  outline: none;
}

.composer-round:disabled,
.voice-hold-button:disabled {
  opacity: 0.46;
}

.reply-preview,
.image-preview {
  grid-column: 1 / -1;
  margin: 0 0 2px;
  border: 0;
  background: var(--figma-panel);
}

body.composer-panel-open .composer {
  position: absolute;
  right: 0;
  bottom: var(--active-composer-panel-height);
  left: 0;
}

body.sticker-panel-open {
  --active-composer-panel-height: calc(282px + env(safe-area-inset-bottom));
}

body.more-panel-open {
  --active-composer-panel-height: calc(162px + env(safe-area-inset-bottom));
}

body.room-page.more-panel-open {
  --active-composer-panel-height: calc(260px + env(safe-area-inset-bottom));
}

.sticker-panel,
.more-panel {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 45;
  border-top: 0;
  background: var(--figma-panel);
  box-shadow: none;
  backdrop-filter: none;
  animation: panel-in 160ms ease-out both;
}

.sticker-panel {
  height: calc(282px + env(safe-area-inset-bottom));
  padding: 20px 20px max(18px, env(safe-area-inset-bottom));
}

.sticker-grid {
  height: 100%;
  padding: 0;
  grid-template-columns: repeat(4, minmax(0, 60px));
  grid-auto-rows: 60px;
  justify-content: space-between;
  align-content: start;
  gap: 10px;
}

.sticker-item {
  width: 60px;
  height: 60px;
  padding: 0;
  border-radius: 12px;
  background: transparent;
}

.sticker-item:hover,
.sticker-item:focus-visible {
  background: rgba(0, 0, 0, 0.035);
  outline: none;
}

.sticker-art,
.sticker-art img,
.sticker-art video,
.sticker-art canvas {
  width: 58px;
  height: 58px;
  object-fit: contain;
}

.more-panel {
  height: calc(162px + env(safe-area-inset-bottom));
  padding: 20px 20px max(14px, env(safe-area-inset-bottom));
  border-top: 1px solid #f0f0f0;
  background: #ffffff;
}

.room-page .more-panel {
  height: calc(260px + env(safe-area-inset-bottom));
}

.more-actions {
  display: grid;
  grid-template-columns: repeat(3, 68px);
  justify-content: start;
  align-content: start;
  column-gap: 21px;
  row-gap: 18px;
}

.room-page .more-actions {
  grid-template-columns: repeat(4, minmax(0, 68px));
  justify-content: space-between;
  gap: 18px 14px;
}

.more-action {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  border: 0;
  background: transparent;
  color: #393939;
  font-size: 11px;
  line-height: 14px;
  cursor: pointer;
}

.more-action-icon {
  position: relative;
  width: 68px;
  height: 68px;
  display: grid;
  place-items: center;
  border-radius: 20px;
  background: #fafafa;
}

.more-action-icon > img {
  width: 24px;
  height: 24px;
}

.more-action-symbol {
  color: #595959;
  font-size: 22px;
  font-weight: 560;
}

.room-page .more-action {
  gap: 7px;
}

.room-only {
  display: none;
}

.room-page .room-only {
  display: flex;
}

.room-page .main-only {
  display: none;
}

.page-backdrop {
  position: absolute;
  inset: 0;
  z-index: 40;
  border: 0;
  background: rgba(0, 0, 0, 0.22);
  cursor: default;
}

body:not(.composer-panel-open) .page-backdrop {
  z-index: 54;
}

.route-menu {
  z-index: 55;
  max-height: min(72dvh, 610px);
  padding: 0 0 max(18px, env(safe-area-inset-bottom));
  border: 0;
  border-radius: 20px 20px 0 0;
  background: #fff;
  box-shadow: none;
}

.route-sheet-header {
  min-height: 54px;
  padding: 8px 20px 4px;
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) 64px;
  align-items: center;
  gap: 0;
  border-bottom: 0;
}

.route-sheet-cancel,
.route-sheet-done {
  min-height: 38px;
  border: 0;
  background: transparent;
  color: #777;
  font-size: 14px;
  cursor: pointer;
}

.route-sheet-cancel {
  text-align: left;
}

.route-sheet-done {
  color: #58bfd8;
  text-align: right;
}

.route-sheet-title {
  color: #171717;
  font-size: 16px;
  font-weight: 590;
  text-align: center;
}

.route-sheet-scroll {
  padding: 10px 20px 18px;
  overflow-y: auto;
}

.route-group + .route-group {
  margin-top: 24px;
}

.route-group-title {
  display: block;
  margin-bottom: 10px;
  color: #919191;
  font-size: 11px;
  font-weight: 450;
  line-height: 14px;
}

.route-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px 8px;
}

.route-option {
  min-height: 46px;
  padding: 5px 8px;
  justify-content: center;
  border: 0;
  border-radius: 14px;
  background: var(--figma-panel);
  color: #5e5e5e;
  font-size: 12px;
  line-height: 15px;
  text-align: center;
}

.route-option.current {
  background: var(--figma-blue);
  color: #171717;
  box-shadow: none;
}

.route-option.cooling {
  opacity: 0.42;
}

.route-balance-link {
  width: 100%;
  min-height: 42px;
  margin-top: 18px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: #58bfd8;
  font-size: 13px;
}

.voice-recording {
  position: fixed;
  inset: 0;
  z-index: 90;
  min-height: 0;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 0;
  background: rgba(0, 0, 0, 0.26);
  color: #1e1e1e;
  pointer-events: none;
}

.voice-recording-card {
  width: 174px;
  height: 160px;
  margin-top: -30px;
  padding: 30px 14px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  border-radius: 20px;
  background: #a7eaf9;
  box-shadow: 0 12px 30px rgba(31, 68, 77, 0.12);
}

.voice-recording-mic {
  width: 28px;
  height: 34px;
}

.voice-recording-wave {
  width: 92px;
  height: 20px;
  margin-top: 10px;
}

.voice-recording strong {
  margin-top: 10px;
  color: #343434;
  font-size: 11px;
  font-weight: 450;
  line-height: 14px;
}

.voice-recording-card > span {
  margin-top: 4px;
  color: #646464;
  font-size: 10px;
}

.voice-recording-release {
  position: absolute;
  bottom: max(26px, calc(env(safe-area-inset-bottom) + 17px));
  left: 50%;
  width: min(220px, calc(100% - 124px));
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 22px;
  background: var(--figma-panel);
  color: #202020;
  font-size: 14px;
  font-weight: 500;
  transform: translateX(-50%);
}

.voice-recording.cancel .voice-recording-card {
  background: #f3b7c0;
}

body.room-mode {
  --figma-page: #111015;
  --figma-panel: #262229;
}

body.room-mode .chat-header,
body.room-mode .composer {
  background: #18151b;
  box-shadow: none;
}

body.room-mode .header-back img,
body.room-mode .header-more img,
body.room-mode .composer-round img {
  filter: brightness(0) invert(1);
  opacity: 0.82;
}

body.room-mode .identity-copy strong,
body.room-mode .bubble-text,
body.room-mode .voice-hold-button,
body.room-mode textarea {
  color: #f3edf1;
}

body.room-mode .message-row.assistant .bubble,
body.room-mode .message-row.assistant .voice-message {
  background: #262229;
}

body.room-mode .message-row.user .bubble,
body.room-mode .message-row.user .voice-message {
  background: #8f4c61;
  color: #fff;
}

body.room-mode .sticker-panel,
body.room-mode .more-panel {
  background: #1e1a20;
}

body.room-mode .more-action {
  color: #d9cfd6;
}

body.room-mode .more-action-icon {
  background: #2b252d;
}

body.room-mode .more-action-icon > img {
  filter: brightness(0) invert(1);
  opacity: 0.82;
}

body.room-mode .more-action-symbol {
  color: #d9cfd6;
}

body.room-mode .route-sheet-title,
body.room-mode .route-option {
  color: #eee7ec;
}

body.room-mode .route-option {
  background: #2b252d;
}

body.room-mode .route-option.current {
  background: #a95b73;
}

@media (max-width: 430px) {
  .app-shell {
    width: 100%;
    box-shadow: none;
  }

  .messages {
    width: 100%;
  }
}

@media (max-width: 350px) {
  .more-actions {
    grid-template-columns: repeat(3, 68px);
    column-gap: 21px;
  }

  .room-page .more-actions {
    grid-template-columns: repeat(4, minmax(0, 62px));
    gap: 16px 8px;
  }

  .room-page .more-action-icon {
    width: 62px;
    height: 62px;
  }

  .composer {
    padding-right: 8px;
    padding-left: 8px;
    gap: 6px;
  }
}
