/* Web chat message actions, inline controls, composer and bottom controls. */
.msg-inline-btn {
  width: 100%;
  min-height: 46px;
  padding: 12px 14px;
  border: 1px solid #b9d8ea;
  border-radius: 12px;
  background:
    linear-gradient(180deg, #f7fbff 0%, #ebf5fc 100%);
  color: #166089;
  font-weight: 600;
  line-height: 1.2;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.92),
    0 1px 2px rgba(21, 86, 124, 0.08);
  transition:
    background 0.16s ease,
    border-color 0.16s ease,
    transform 0.12s ease,
    box-shadow 0.16s ease;
  touch-action: pan-y;
}

.msg-inline-btn:hover {
  border-color: #9fcce6;
  background:
    linear-gradient(180deg, #ffffff 0%, #e6f2fb 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.98),
    0 4px 12px rgba(34, 114, 162, 0.12);
}

.msg-inline-btn:active {
  transform: translateY(1px);
  background:
    linear-gradient(180deg, #eaf4fb 0%, #deedf8 100%);
  box-shadow:
    inset 0 2px 4px rgba(26, 91, 130, 0.08);
}

.msg-inline-btn:focus-visible {
  outline: 2px solid rgba(34, 158, 217, 0.28);
  outline-offset: 2px;
}

.web-control-btn {
  position: relative;
}

.web-control-btn.is-control-disabled {
  cursor: wait;
  opacity: 0.72;
}

.web-control-btn.is-control-pending {
  border-color: #5baad4 !important;
  background:
    linear-gradient(180deg, #dff2ff 0%, #cfe8fb 100%) !important;
  color: #0f5076 !important;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.96),
    0 0 0 2px rgba(34, 158, 217, 0.12) !important;
}

.web-control-btn.is-control-pending::after {
  content: "";
  position: absolute;
  top: 8px;
  right: 8px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #229ed9;
  box-shadow: 0 0 0 0 rgba(34, 158, 217, 0.35);
  animation: control-pulse 1s ease infinite;
}

@keyframes control-pulse {
  0% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(34, 158, 217, 0.35);
  }
  70% {
    transform: scale(1);
    box-shadow: 0 0 0 8px rgba(34, 158, 217, 0);
  }
  100% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(34, 158, 217, 0);
  }
}

.chat-bottom {
  position: sticky;
  bottom: 0;
  display: grid;
  min-width: 0;
  background: #fff;
  z-index: 8;
}

.quick-keyboard {
  display: grid;
  gap: 6px;
  padding: 8px;
  border-top: 1px solid var(--tg-border);
  background: #f4f8fc;
  max-height: 180px;
  overflow-y: auto;
  opacity: 1;
  transform: translateY(0);
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  transition:
    max-height 0.18s ease,
    padding 0.18s ease,
    opacity 0.18s ease,
    transform 0.18s ease,
    border-color 0.18s ease;
}

.chat-bottom.reply-keyboard-open .quick-keyboard {
  max-height: min(40dvh, 360px);
  padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
}

.quick-keyboard.is-empty {
  display: none;
}

.quick-keyboard.is-collapsed {
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  border-top-color: transparent;
  opacity: 0;
  transform: translateY(6px);
  overflow: hidden;
}

.quick-row {
  --quick-row-columns: 1;
  display: grid;
  gap: 6px;
  grid-template-columns: repeat(var(--quick-row-columns), minmax(0, 1fr));
}

.quick-row[data-count="1"] {
  --quick-row-columns: 1;
}

.quick-row[data-count="2"] {
  --quick-row-columns: 2;
}

.quick-row[data-count="3"] {
  --quick-row-columns: 3;
}

.quick-row[data-count="4"] {
  --quick-row-columns: 2;
}

.quick-row[data-count="5"],
.quick-row[data-count="6"] {
  --quick-row-columns: 3;
}

.quick-keyboard button {
  width: 100%;
  min-width: 0;
  min-height: 48px;
  border: 1px solid #9fc8e2;
  background: #ffffff;
  color: #12507b;
  line-height: 1.15;
  text-align: center;
  touch-action: pan-y;
  transition:
    background 0.16s ease,
    border-color 0.16s ease,
    opacity 0.16s ease,
    box-shadow 0.16s ease;
}

.chat-footer {
  display: grid;
  grid-template-columns: 40px 1fr 40px;
  grid-template-areas:
    "reply reply reply"
    "files files files"
    "attach composer send";
  align-items: center;
  gap: 6px;
  padding-top: 4px;
  padding-right: calc(8px + env(safe-area-inset-right, 0px));
  padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  padding-left: calc(8px + env(safe-area-inset-left, 0px));
  border-top: 1px solid var(--tg-border);
  background: #fff;
}

.chat-bottom.reply-keyboard-open .chat-footer {
  padding-bottom: 6px;
}

.composer-reply-preview,
.composer-file-preview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid #d7e6f1;
  border-radius: 14px;
  background: #f7fbff;
  box-shadow: 0 8px 20px rgba(18, 62, 91, 0.05);
}

.composer-reply-preview[hidden],
.composer-file-preview[hidden] {
  display: none;
}

.composer-reply-preview {
  grid-area: reply;
}

.composer-file-preview {
  grid-area: files;
}

.composer-reply-copy {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.composer-reply-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #176896;
}

.composer-reply-copy strong {
  min-width: 0;
  font-size: 13px;
  font-weight: 600;
  color: #31485c;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.composer-file-list {
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.composer-file-chip {
  max-width: 100%;
  padding: 5px 8px;
  border-radius: 999px;
  background: #e7f1f9;
  color: #235d84;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.composer-clear-btn {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 10px;
  background: #e8f0f6;
  color: #537189;
  font-size: 20px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.composer-clear-btn:hover {
  background: #dceaf4;
  color: #1f628e;
}

.composer-input {
  grid-area: composer;
  position: relative;
  display: flex;
  align-items: center;
  min-height: 38px;
}

.chat-footer textarea {
  min-height: 38px;
  max-height: 120px;
  padding-top: 8px;
  padding-bottom: 8px;
  resize: none;
  padding-right: 46px;
}

.restart-btn,
.attach-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 38px;
  width: 38px;
  padding: 0;
  box-sizing: border-box;
}

.restart-btn {
  grid-area: restart;
  border: 1px solid #c9d8e6;
  border-radius: 12px;
  background: linear-gradient(180deg, #ffffff, #edf6fd);
  color: #1c628f;
  box-shadow: 0 6px 16px rgba(34, 158, 217, 0.12);
}

.restart-btn:hover {
  background: linear-gradient(180deg, #f7fcff, #e4f1fb);
}

.restart-btn svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.attach-btn {
  grid-area: attach;
  background: #eef4fb;
  border: 1px solid var(--tg-border);
  color: #2b5f86;
  border-radius: 12px;
  font-size: 20px;
  line-height: 1;
  text-align: center;
}

.attach-btn input { display: none; }

.keyboard-toggle-btn {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 9px;
  background: #eef5fb;
  color: #4b6a82;
  cursor: pointer;
  transition:
    background 0.16s ease,
    color 0.16s ease,
    transform 0.16s ease,
    opacity 0.16s ease;
}

.keyboard-toggle-btn svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.keyboard-toggle-btn:hover {
  background: #e3eef8;
  color: #245d84;
}

.keyboard-toggle-btn.is-collapsed {
  background: #dcecf8;
  color: #1874aa;
  transform: translateY(-50%) rotate(180deg);
}

.keyboard-toggle-btn.is-hidden {
  opacity: 0;
  pointer-events: none;
}

.send-btn {
  grid-area: send;
  height: 38px;
  border-radius: 10px;
}

.send-btn.is-busy {
  background: #6ca5c3;
}

.settings-form { display: grid; gap: 8px; }

@media (min-width: 900px) {
  .menu-drawer {
    padding: 18px;
  }

  .menu-panel {
    width: min(390px, calc(100vw - 36px));
    height: min(100dvh - 36px, 860px);
    border: 1px solid #d9e6f1;
    border-radius: 28px;
  }

  .install-prompt {
    align-items: center;
    padding: 24px;
  }

  .install-prompt-card {
    max-height: min(82dvh, 720px);
    border-radius: 30px;
  }
}

@media (min-width: 1000px) {
  .chat-shell {
    width: min(900px, 100vw);
    margin: 0 auto;
    border-left: 1px solid var(--tg-border);
    border-right: 1px solid var(--tg-border);
    background: var(--surface-0);
  }
}

:root[data-theme="dark"] .web-index-kicker,
:root[data-theme="dark"] .web-site-pill,
:root[data-theme="dark"] .msg-reply-author,
:root[data-theme="dark"] .doc-view-content a,
:root[data-theme="dark"] .msg-text a {
  color: #7fc7f0;
}

:root[data-theme="dark"] .web-index-hero,
:root[data-theme="dark"] .web-site-card,
:root[data-theme="dark"] .auth-card,
:root[data-theme="dark"] .menu-panel,
:root[data-theme="dark"] .menu-user-chip,
:root[data-theme="dark"] .menu-section,
:root[data-theme="dark"] .menu-action-btn,
:root[data-theme="dark"] .menu-secondary-btn,
:root[data-theme="dark"] .settings-form input,
:root[data-theme="dark"] .chat-footer textarea,
:root[data-theme="dark"] .msg-reply-btn,
:root[data-theme="dark"] .msg-inline-btn,
:root[data-theme="dark"] .keyboard-toggle-btn,
:root[data-theme="dark"] .quick-keyboard button,
:root[data-theme="dark"] .attach-btn,
:root[data-theme="dark"] .doc-view-head,
:root[data-theme="dark"] .doc-view-card,
:root[data-theme="dark"] .doc-view-btn,
:root[data-theme="dark"] .theme-floating-btn {
  background: var(--surface-1);
  border-color: var(--tg-border);
  color: var(--tg-text);
}

:root[data-theme="dark"] .web-site-card,
:root[data-theme="dark"] .web-index-hero,
:root[data-theme="dark"] .auth-card,
:root[data-theme="dark"] .doc-view-head,
:root[data-theme="dark"] .doc-view-card {
  box-shadow: 0 18px 38px rgba(0, 0, 0, 0.28);
}

:root[data-theme="dark"] .web-site-card p,
:root[data-theme="dark"] .web-index-copy,
:root[data-theme="dark"] .auth-brand p,
:root[data-theme="dark"] .auth-help,
:root[data-theme="dark"] .menu-user-label,
:root[data-theme="dark"] .menu-action-meta,
:root[data-theme="dark"] .menu-section-note,
:root[data-theme="dark"] .menu-section-title,
:root[data-theme="dark"] .msg time,
:root[data-theme="dark"] .msg-reply-text,
:root[data-theme="dark"] .doc-view-brand p,
:root[data-theme="dark"] .doc-view-content {
  color: var(--text-muted);
}

:root[data-theme="dark"] .site-logo,
:root[data-theme="dark"] .web-site-card-logo,
:root[data-theme="dark"] .auth-logo,
:root[data-theme="dark"] .doc-view-logo {
  background: rgba(232, 238, 243, 0.78);
  border-color: rgba(120, 138, 154, 0.24);
}

:root[data-theme="dark"] .menu-drawer {
  background: rgba(4, 10, 17, 0.54);
}

:root[data-theme="dark"] .messages {
  background:
    radial-gradient(circle at top right, rgba(120, 188, 226, 0.08), rgba(120, 188, 226, 0) 36%),
    linear-gradient(180deg, #1e2731 0%, #1a2129 100%);
}

