/**
 * TuAPI Chat — Chat shell (WhatsApp-style)
 */

/* Altura y shell móvil se resuelven en pwa-mobile.css (page-chat).
   Aquí: estructura base reutilizable y densidad de escritorio. */
.page-chat .app-main {
    max-width: 720px;
    padding: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.page-chat .app-footer { display: none; }

.chat-shell {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    height: 100%;
    background: var(--color-surface);
}

.chat-shell__header {
    flex: 0 0 auto;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--color-border);
    background: var(--color-surface);
}

.chat-shell__header-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
}

.chat-shell__header h1 {
    margin: 0;
    font-size: 1.05rem;
}

.chat-shell__header p {
    margin: 0.15rem 0 0;
    font-size: 0.82rem;
    color: var(--color-muted);
}

.chat-shell__dev {
    margin: 0.35rem 0 0;
    font-size: 0.78rem;
}

.chat-shell__ai-status {
    font-weight: 600;
}

.chat-shell__ai-status--active {
    color: #1f7a3f;
}

.chat-shell__ai-status--unavailable {
    color: #a15c00;
}

.chat-shell__ai-status--disabled {
    color: var(--color-muted);
}

.chat-bubble__ai-tag {
    display: inline-block;
    margin-right: 0.35rem;
    padding: 0.05rem 0.35rem;
    border-radius: 0.25rem;
    border: 1px solid var(--color-border);
    font-size: 0.68rem;
    letter-spacing: 0.02em;
    color: var(--color-muted);
    background: transparent;
}

.chat-messages {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.75rem 0.85rem 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    -webkit-overflow-scrolling: touch;
    position: relative;
    isolation: isolate;
    background-color: #e5ddd5;
}

.chat-messages::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 0;
    pointer-events: none;
    min-height: 100%;
    height: var(--chat-pattern-height, 100%);
    background-image: var(--chat-pattern-url, url('../images/chat/chat-pattern.png'));
    background-repeat: repeat;
    background-size: 360px auto;
    background-position: 0 0;
    mix-blend-mode: screen;
    opacity: 0.44;
}

.chat-messages > * {
    position: relative;
    z-index: 1;
}

.chat-composer {
    flex: 0 0 auto;
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
    padding-bottom: env(safe-area-inset-bottom);
}

.chat-bubble {
    display: inline-flex;
    flex-direction: column;
    max-width: var(--chat-bubble-max, min(82%, 420px));
    width: fit-content;
    padding: 0.45rem 0.65rem 0.35rem;
    border-radius: 12px;
    font-size: var(--chat-font-size, 0.92rem);
    line-height: var(--chat-line-height, 1.35);
    box-shadow: 0 1px 1px rgba(0,0,0,.06);
    animation: chatBubbleIn .18s ease-out;
}

@keyframes chatBubbleIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

.chat-bubble__text {
    white-space: pre-wrap;
    word-break: break-word;
}

.chat-bubble__action {
    display: inline-block;
    margin-top: 0.65rem;
    text-decoration: none;
}

.chat-quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.65rem;
}

.chat-quick-replies__btn {
    border: 1px solid #cfe8d6;
    background: #f3faf5;
    color: #0f5132;
    border-radius: 999px;
    padding: 0.35rem 0.75rem;
    font-size: 0.82rem;
    line-height: 1.2;
    cursor: pointer;
    min-height: 2rem;
}

.chat-quick-replies__btn:hover:not([disabled]) {
    background: #e3f5ea;
}

.chat-quick-replies__btn[disabled],
.chat-quick-replies__btn.is-used {
    opacity: 0.45;
    cursor: default;
}

.chat-delivery-card {
    max-width: min(100%, 34rem);
}

.chat-delivery-card__title {
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.chat-delivery-card__textarea {
    width: 100%;
    min-height: 14rem;
    max-height: 20rem;
    height: auto;
    resize: vertical;
    border: 1px solid #d7e3ef;
    border-radius: 8px;
    padding: 0.75rem 0.85rem;
    font-family: inherit;
    font-size: 0.95rem;
    line-height: 1.5;
    background: #f8fafc;
    color: #111b21;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    white-space: pre-wrap;
    word-break: break-word;
}

@media (max-width: 640px) {
    .chat-delivery-card__textarea {
        min-height: 9rem;
        max-height: 14rem;
        font-size: 16px;
    }
}

.chat-delivery-card__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.65rem;
}

.chat-delivery-card__btn {
    flex: 1 1 auto;
    text-align: center;
    min-width: 8.5rem;
}

.chat-bubble__meta {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.35rem;
    margin-top: 0.15rem;
    font-size: 0.68rem;
    color: rgba(15, 23, 42, 0.55);
}

.chat-bubble__status {
    font-style: italic;
    opacity: 0.85;
}

.chat-bubble--bot {
    align-self: flex-start;
    background: #fff;
    border-bottom-left-radius: 4px;
}

.chat-bubble--user {
    align-self: flex-end;
    background: #d9fdd3;
    color: #111b21;
    border-bottom-right-radius: 4px;
}

.chat-bubble--typing {
    align-self: flex-start;
    background: #fff;
    padding: 0.55rem 0.75rem;
}

.chat-bubble--typing .chat-typing-dots span {
    display: inline-block;
    width: 6px;
    height: 6px;
    margin: 0 2px;
    border-radius: 50%;
    background: #94a3b8;
    animation: chatTyping 1.2s infinite ease-in-out;
}

.chat-bubble--typing .chat-typing-dots span:nth-child(2) { animation-delay: .15s; }
.chat-bubble--typing .chat-typing-dots span:nth-child(3) { animation-delay: .3s; }

@keyframes chatTyping {
    0%, 80%, 100% { transform: translateY(0); opacity: .5; }
    40% { transform: translateY(-3px); opacity: 1; }
}

.chat-chips {
    display: flex;
    gap: 0.45rem;
    overflow-x: auto;
    padding: 0.45rem 0.75rem 0.25rem;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.chat-chips::-webkit-scrollbar { display: none; }

.chip {
    flex: 0 0 auto;
    border: 1px solid var(--color-border);
    background: #f8fafc;
    border-radius: 999px;
    padding: 0.35rem 0.7rem;
    font-size: 0.8rem;
    cursor: pointer;
    white-space: nowrap;
}

.chip:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.chip:hover:not(:disabled) { border-color: var(--color-primary); color: var(--color-primary-dark); }

.chip--link {
    text-decoration: none;
    display: inline-flex;
    align-items: center;
}

.chat-form {
    display: flex;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem 0.65rem;
    align-items: flex-end;
}

.chat-composer-menu {
    position: relative;
    flex: 0 0 auto;
    align-self: flex-end;
}
.chat-composer-menu.is-empty,
.chat-composer-menu[hidden] {
    display: none !important;
}
.chat-composer-menu__toggle {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    border-radius: 50%;
    border: 1px solid var(--color-border, #d8dee6);
    background: var(--color-surface, #fff);
    color: var(--color-text, #0f172a);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}
.chat-composer-menu__toggle:hover:not(:disabled) {
    border-color: var(--color-primary);
    color: var(--color-primary-dark, var(--color-primary));
}
.chat-composer-menu__toggle:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}
.chat-composer-menu__icon {
    font-size: 1.45rem;
    font-weight: 500;
    transform: translateY(-1px);
}
.chat-composer-menu[data-open="1"] .chat-composer-menu__toggle {
    background: color-mix(in srgb, var(--color-primary) 12%, var(--color-surface));
    border-color: var(--color-primary);
}
.chat-composer-menu[data-open="1"] .chat-composer-menu__icon {
    transform: rotate(45deg) translateY(-1px);
}
.chat-composer-menu__panel {
    position: absolute;
    left: 0;
    bottom: calc(100% + 0.45rem);
    z-index: 40;
    width: min(22rem, calc(100vw - 1.5rem));
    max-height: min(55vh, 22rem);
    border: 1px solid var(--color-border, #d8dee6);
    border-radius: 14px;
    background: var(--color-surface, #fff);
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.14);
    overflow: hidden;
    padding-bottom: env(safe-area-inset-bottom, 0);
}
.chat-composer-menu__scroll {
    max-height: min(55vh, 22rem);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0.45rem 0.35rem 0.55rem;
}
.chat-composer-menu__section + .chat-composer-menu__section {
    margin-top: 0.35rem;
    padding-top: 0.35rem;
    border-top: 1px solid var(--color-border, #e5e7eb);
}
.chat-composer-menu__section-title {
    margin: 0.15rem 0.55rem 0.25rem;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--color-muted, #64748b);
}
.chat-composer-menu__list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.chat-composer-menu__item {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.1rem;
    min-height: 44px;
    padding: 0.55rem 0.7rem;
    border: 0;
    border-radius: 10px;
    background: transparent;
    text-align: left;
    cursor: pointer;
    color: inherit;
}
.chat-composer-menu__item:hover,
.chat-composer-menu__item:focus-visible {
    background: color-mix(in srgb, var(--color-primary) 10%, var(--color-surface));
    outline: none;
}
.chat-composer-menu__item-label {
    font-size: 0.92rem;
    font-weight: 600;
    line-height: 1.25;
}
.chat-composer-menu__item-example {
    font-size: 0.78rem;
    color: var(--color-muted, #64748b);
    line-height: 1.25;
}
@media (max-width: 430px) {
    .chat-composer-menu__panel {
        position: fixed;
        left: 0.5rem;
        right: 0.5rem;
        bottom: calc(var(--app-height, 100dvh) - env(safe-area-inset-bottom, 0px) - 4.75rem);
        width: auto;
        max-height: 52vh;
    }
    .chat-composer-menu__scroll {
        max-height: 52vh;
    }
}

.chat-form__textarea,
.chat-form__secure {
    flex: 1;
    min-width: 0;
    border: 1px solid var(--color-border);
    border-radius: 18px;
    padding: 0.55rem 0.85rem;
    font-size: 16px;
    font-family: inherit;
    line-height: 1.35;
    background: #f8fafc;
    color: inherit;
    box-sizing: border-box;
}

.chat-form__textarea:focus,
.chat-form__secure:focus {
    outline: 2px solid color-mix(in srgb, var(--color-primary, #0d9488) 40%, transparent);
    border-color: var(--color-primary, #0d9488);
    background: #fff;
}

.chat-form__textarea {
    resize: none;
    min-height: 2.6rem;
    max-height: 8.5rem;
    overflow-y: auto;
    field-sizing: content;
}

.chat-form__secure {
    border-radius: 24px;
    min-height: 2.6rem;
}

.chat-form__textarea.is-hidden,
.chat-form__secure.is-hidden {
    display: none !important;
}

.chat-form .btn {
    flex-shrink: 0;
    border-radius: 999px;
    min-width: 4.5rem;
    align-self: flex-end;
}

.chat-shell .btn--sm {
    padding: 0.45rem 0.75rem;
    font-size: 0.85rem;
    min-height: 40px;
}

.chat-shell__header-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
  justify-content: flex-end;
  max-width: 55%;
}

.chat-shell__header-actions.is-empty {
  display: none;
}

.chat-shell__icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 44px;
  min-width: 44px;
}

.chat-shell__icon-btn .tuapi-icon {
  flex-shrink: 0;
}

.chat-shell__easy-read-btn[aria-pressed="true"] {
  background: #eef2ff;
  border-color: #c7d2fe;
  box-shadow: inset 0 0 0 1px #a5b4fc;
}

.chat-shell__easy-read-btn:focus-visible {
  outline: 2px solid var(--color-primary, #4f46e5);
  outline-offset: 2px;
}

@media (max-width: 480px) {
  .chat-shell__easy-read-btn .chat-shell__icon-btn-label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  .chat-shell__easy-read-btn {
    position: relative;
    justify-content: center;
    padding-left: 0.55rem;
    padding-right: 0.55rem;
  }

  .chat-shell__header-actions {
    max-width: 40%;
  }
}

/* .btn / .chat-shell__icon-btn set display:inline-flex and override UA [hidden]. */
.chat-shell__header-actions .is-hidden,
.chat-shell__header-actions [hidden] {
  display: none !important;
}

.chat-history-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-top: 0.55rem;
    padding: 0.55rem 0.65rem;
    border-radius: 10px;
    background: #f3f0ea;
    border: 1px solid var(--color-border);
}

.chat-history-banner__text {
    font-size: 0.85rem;
    min-width: 0;
}

.chat-history-banner__text strong {
    display: inline-block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: bottom;
}

.chat-shell--readonly .chat-composer {
    display: none !important;
}

.chat-history-panel {
    position: fixed;
    inset: 0;
    z-index: 55;
    display: none;
}

.chat-history-panel.is-open,
.chat-history-panel:not([hidden]) {
    display: block;
}

.chat-history-panel[hidden] {
    display: none !important;
}

.chat-history-panel__backdrop {
    position: absolute;
    inset: 0;
    background: var(--panel-backdrop);
}

.chat-history-panel__sheet {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    background: var(--panel-bg);
    color: var(--color-text);
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
}

@media (min-width: 768px) {
    .chat-history-panel__sheet {
        inset: 0;
        width: 100%;
        max-width: 720px;
        margin: 0 auto;
        border-right: none;
        box-shadow: none;
    }
}

.chat-history-panel__header {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 0.75rem;
    border-bottom: 1px solid var(--color-border);
    background: var(--panel-surface);
    color: var(--color-text);
    padding-top: calc(0.55rem + env(safe-area-inset-top));
}

.chat-history-panel__back {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    border: 0;
    background: transparent;
    color: var(--color-primary-dark, #0f766e);
    font: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    min-height: 40px;
    padding: 0.25rem 0.35rem;
    cursor: pointer;
    border-radius: 8px;
}
.chat-history-panel__back:hover,
.chat-history-panel__back:focus-visible {
    background: color-mix(in srgb, var(--color-primary) 12%, var(--panel-surface));
    outline: none;
}
.chat-history-panel__back .tuapi-icon {
    width: 22px;
    height: 22px;
}

.chat-history-panel__titles {
    text-align: center;
    min-width: 0;
}
.chat-history-panel__titles h2 {
    margin: 0;
    font-size: 1.05rem;
    color: var(--panel-text-strong);
    font-weight: 700;
}
.chat-history-panel__biz {
    margin: 0.1rem 0 0;
    font-size: 0.75rem;
    color: var(--color-muted, #64748b);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-history-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    text-align: left;
    border: 0;
    border-bottom: 1px solid var(--panel-border-soft);
    background: transparent;
    padding: 0.62rem 0.9rem;
    cursor: pointer;
    font: inherit;
    color: inherit;
}

.chat-history-item:hover,
.chat-history-item:focus-visible {
    background: var(--panel-hover);
    outline: none;
}

.chat-history-item--wa {
    /* misma composición horizontal; evita que reglas posteriores rompan el flex */
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.chat-history-item__avatar {
    flex: 0 0 auto;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: var(--panel-avatar-bg);
    color: var(--color-primary-dark);
    font-weight: 700;
    font-size: 1rem;
    letter-spacing: 0.02em;
}
.chat-history-item--tuapi .chat-history-item__avatar {
    background: var(--panel-avatar-tuapi-bg);
    color: var(--color-primary-dark);
}
.chat-history-item__meta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    align-items: center;
    margin-top: 0.15rem;
}

.chat-history-panel__spacer {
    width: 3.5rem;
}

.chat-history-panel__list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    background: var(--panel-surface);
}

.chat-history-panel__empty {
    margin: 1.25rem 1rem;
    font-size: 0.9rem;
    color: var(--color-muted);
}

.chat-history-panel__footer {
    padding: 0.5rem 0.75rem calc(0.65rem + env(safe-area-inset-bottom));
    border-top: 1px solid var(--color-border);
    text-align: center;
    background: var(--panel-surface);
}

.chat-history-day {
    position: sticky;
    top: 0;
    z-index: 1;
    padding: 0.35rem 1rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--color-muted);
    background: var(--panel-sticky-day);
    border-bottom: 1px solid var(--color-border);
}

.chat-history-item__row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
}

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

.chat-history-item__title-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.65rem;
    margin-bottom: 0.12rem;
}

.chat-history-item__title-block {
    min-width: 0;
    flex: 1;
}

.chat-history-item__title {
    font-size: 0.98rem;
    font-weight: 650;
    color: var(--panel-text-strong);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-history-item__phone {
    margin-top: 0.05rem;
    font-size: 0.75rem;
    color: var(--panel-text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-history-item__preview {
    font-size: 0.82rem;
    color: var(--panel-text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.3;
}

.chat-history-item__time {
    flex: 0 0 auto;
    font-size: 0.72rem;
    color: var(--color-muted);
    padding-top: 0.15rem;
}

.chat-history-item__hint {
    margin-top: 0.12rem;
    font-size: 0.74rem;
    color: var(--panel-warn);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.25;
}

.chat-history-detail__titles {
    min-width: 0;
}

.chat-history-detail__titles h3 {
    margin: 0;
}

.chat-history-detail__phone {
    margin: 0.1rem 0 0;
    font-size: 0.8rem;
}

.chat-history-item__meta {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.75rem;
    min-width: 0;
}

.chat-history-item__side {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.25rem;
}

.chat-history-item__ro {
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--panel-badge-ro-text);
    background: var(--panel-badge-ro-bg);
    border-radius: 999px;
    padding: 0.1rem 0.45rem;
}

.chat-history-item__count {
    margin-top: 0.25rem;
    font-size: 0.75rem;
    color: var(--color-muted);
}

.chat-reminders-notice {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-top: 0.55rem;
    padding: 0.55rem 0.65rem;
    border-radius: 10px;
    background: #eef6ff;
    border: 1px solid #c9def5;
    font-size: 0.85rem;
}

.chat-reminders-notice__chip {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    padding: 0.2rem 0.65rem;
    border-radius: 999px;
    background: #0f766e;
    color: #fff;
    text-decoration: none;
    font-size: 0.78rem;
    font-weight: 600;
}


.chat-chips.is-empty,
.chat-chips[hidden] {
  display: none !important;
}

.chat-attach-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  border-radius: 50%;
  border: 1px solid var(--color-border, #d8dee6);
  background: var(--color-surface, #fff);
  color: var(--color-muted, #64748b);
  cursor: pointer;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
.chat-attach-btn.is-hidden,
.chat-attach-btn[hidden] {
  display: none !important;
}
.chat-attach-btn__face {
  display: inline-flex;
  pointer-events: none;
}
/* iOS Safari: el input debe recibir el tap directo (sin label/sr-only/async). */
.chat-attach-btn__input {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  opacity: 0.01;
  border: 0;
  cursor: pointer;
  font-size: 16px; /* evita zoom iOS; mantiene área clickeable */
}
.chat-composer__send {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  border-radius: 50%;
  padding: 0 !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.chat-composer__send:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.chat-attach-card[hidden],
.chat-attach-card.is-hidden {
  display: none !important;
}
.chat-attach-card {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: 0.35rem 0.65rem;
  align-items: center;
  margin: 0 0.65rem 0.35rem;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--color-border, #e5e7eb);
  border-radius: 12px;
  background: #f8fafc;
}
.chat-attach-card__img {
  width: 56px;
  height: 56px;
  border-radius: 10px;
  object-fit: cover;
  grid-row: 1 / span 2;
}
.chat-attach-card__meta {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}
.chat-attach-card__meta strong { font-size: 0.88rem; }
.chat-attach-card__remove {
  width: 36px;
  height: 36px;
  border: 0;
  background: transparent;
  color: var(--color-muted);
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.chat-attach-card #chatAttachSend {
  grid-column: 2 / span 2;
  justify-self: start;
}
.chat-attach-status[hidden],
.chat-attach-status.is-hidden { display: none !important; }
.chat-attach-status {
  margin: 0 0.75rem 0.25rem;
  font-size: 0.82rem;
}
.chat-sketch {
  margin: 0.45rem 0 0;
  max-width: min(280px, 78vw);
}
.chat-sketch__media {
  display: block;
}
.chat-sketch img {
  display: block;
  width: 100%;
  max-height: 220px;
  border-radius: 12px;
  object-fit: cover;
}
.chat-sketch__unavailable {
  display: none;
  margin-top: 0.35rem;
  padding: 0.55rem 0.65rem;
  border-radius: 10px;
  background: #f8fafc;
  border: 1px dashed var(--color-border, #cbd5e1);
  color: var(--color-muted, #64748b);
  font-size: 0.86rem;
}
.chat-sketch.is-unavailable .chat-sketch__media {
  display: none;
}
.chat-sketch.is-unavailable .chat-sketch__unavailable,
.chat-sketch.is-unavailable .chat-sketch__unavailable[hidden] {
  display: block !important;
}
.chat-sketch.is-unavailable .chat-sketch__open {
  pointer-events: none;
  opacity: 0.55;
  text-decoration: none;
}
.chat-sketch__caption {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.65rem;
  margin-top: 0.35rem;
  font-size: 0.86rem;
  line-height: 1.35;
}
.chat-sketch__name {
  font-weight: 600;
}
.chat-sketch__open {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.chat-new-messages {
  position: absolute;
  left: 50%;
  bottom: calc(4.5rem + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 5;
  pointer-events: none;
}
.chat-new-messages[hidden] {
  display: none !important;
}
.chat-new-messages__btn {
  pointer-events: auto;
  min-height: 44px;
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--color-border, #cbd5e1);
  background: #fff;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.12);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-primary-dark, #0f766e);
}
.chat-shell {
  position: relative;
}

#chatEasyReadBtn.is-active {
  background: #ede9fe;
  border-color: #ddd6fe;
  color: #5b21b6;
  box-shadow: inset 0 0 0 1px #c4b5fd;
}
#chatEasyReadBtn:focus-visible {
  outline: 2px solid #7c3aed;
  outline-offset: 2px;
}
#chatEasyReadBtn {
  min-width: 44px;
  min-height: 44px;
}

/*
 * Lectura fácil — variables en .chat-shell; selectores con body.page-chat para
 * ganar a body.page-chat .chat-bubble (especificidad 0,2,1) de pwa-mobile.css.
 */
.chat-shell {
  --chat-font-size: 0.95rem;
  --chat-line-height: 1.35;
  --chat-bubble-gap: 0.35rem;
  --chat-bubble-max: min(88%, 22rem);
  --chat-meta-size: 0.72rem;
  --chat-header-size: 1.05rem;
  --chat-composer-size: 1rem;
  --chat-control-size: 0.85rem;
  --chat-control-min-h: 40px;
  --chat-sketch-caption-size: 0.86rem;
  --chat-sketch-max: min(280px, 78vw);
}

body.page-chat .chat-shell--easy-read,
body.page-chat.chat-easy-read .chat-shell,
html.chat-easy-read-boot body.page-chat .chat-shell {
  --chat-font-size: 1.28rem;
  --chat-line-height: 1.6;
  --chat-bubble-gap: 0.85rem;
  --chat-bubble-max: min(96%, 36rem);
  --chat-meta-size: 0.95rem;
  --chat-header-size: 1.3rem;
  --chat-composer-size: 1.18rem;
  --chat-control-size: 1.05rem;
  --chat-control-min-h: 48px;
  --chat-sketch-caption-size: 1.05rem;
  --chat-sketch-max: min(340px, 92vw);
}

body.page-chat .chat-shell--easy-read .chat-shell__header h1,
body.page-chat.chat-easy-read .chat-shell__header h1,
html.chat-easy-read-boot body.page-chat .chat-shell__header h1 {
  font-size: var(--chat-header-size);
}

body.page-chat .chat-shell--easy-read .chat-shell__header p,
body.page-chat .chat-shell--easy-read .chat-bubble__meta,
body.page-chat .chat-shell--easy-read .chat-attach-status,
body.page-chat .chat-shell--easy-read .chat-reminders-notice,
body.page-chat .chat-shell--easy-read .chat-history-banner,
body.page-chat.chat-easy-read .chat-shell__header p,
body.page-chat.chat-easy-read .chat-bubble__meta,
html.chat-easy-read-boot body.page-chat .chat-shell__header p,
html.chat-easy-read-boot body.page-chat .chat-bubble__meta {
  font-size: var(--chat-meta-size);
  line-height: 1.45;
  white-space: normal;
  overflow: visible;
  text-overflow: unset;
  max-width: none;
}

body.page-chat .chat-shell--easy-read .chat-messages,
body.page-chat.chat-easy-read .chat-messages,
html.chat-easy-read-boot body.page-chat .chat-messages {
  gap: var(--chat-bubble-gap);
}

body.page-chat .chat-shell--easy-read .chat-bubble,
body.page-chat.chat-easy-read .chat-bubble,
html.chat-easy-read-boot body.page-chat .chat-bubble {
  max-width: var(--chat-bubble-max);
  font-size: var(--chat-font-size);
  line-height: var(--chat-line-height);
  padding: 0.7rem 0.85rem 0.5rem;
}

body.page-chat .chat-shell--easy-read .chat-bubble__text,
body.page-chat.chat-easy-read .chat-bubble__text,
html.chat-easy-read-boot body.page-chat .chat-bubble__text {
  overflow-wrap: anywhere;
  word-break: break-word;
  font-size: inherit;
  line-height: inherit;
}

body.page-chat .chat-shell--easy-read .chat-form__textarea,
body.page-chat .chat-shell--easy-read .chat-form__secure,
body.page-chat.chat-easy-read .chat-form__textarea,
body.page-chat.chat-easy-read .chat-form__secure,
html.chat-easy-read-boot body.page-chat .chat-form__textarea,
html.chat-easy-read-boot body.page-chat .chat-form__secure {
  font-size: var(--chat-composer-size);
  line-height: 1.45;
  min-height: 48px;
}

body.page-chat .chat-shell--easy-read .chip,
body.page-chat .chat-shell--easy-read .chat-quick-replies__btn,
body.page-chat .chat-shell--easy-read .btn--sm,
body.page-chat .chat-shell--easy-read .chat-composer__send,
body.page-chat .chat-shell--easy-read .chat-shell__icon-btn,
body.page-chat.chat-easy-read .chip,
body.page-chat.chat-easy-read .chat-quick-replies__btn,
body.page-chat.chat-easy-read .btn--sm,
body.page-chat.chat-easy-read .chat-composer__send,
body.page-chat.chat-easy-read .chat-shell__icon-btn,
html.chat-easy-read-boot body.page-chat .chip,
html.chat-easy-read-boot body.page-chat .chat-quick-replies__btn,
html.chat-easy-read-boot body.page-chat .btn--sm,
html.chat-easy-read-boot body.page-chat .chat-composer__send,
html.chat-easy-read-boot body.page-chat .chat-shell__icon-btn {
  font-size: var(--chat-control-size);
  min-height: var(--chat-control-min-h);
  line-height: 1.3;
}

body.page-chat .chat-shell--easy-read .chat-sketch,
body.page-chat.chat-easy-read .chat-sketch,
html.chat-easy-read-boot body.page-chat .chat-sketch {
  max-width: var(--chat-sketch-max);
}

body.page-chat .chat-shell--easy-read .chat-sketch__caption,
body.page-chat .chat-shell--easy-read .chat-sketch__name,
body.page-chat .chat-shell--easy-read .chat-sketch__open,
body.page-chat .chat-shell--easy-read .chat-sketch__unavailable,
body.page-chat.chat-easy-read .chat-sketch__caption,
body.page-chat.chat-easy-read .chat-sketch__name,
body.page-chat.chat-easy-read .chat-sketch__open,
html.chat-easy-read-boot body.page-chat .chat-sketch__caption,
html.chat-easy-read-boot body.page-chat .chat-sketch__open {
  font-size: var(--chat-sketch-caption-size);
  line-height: 1.45;
}

body.page-chat .chat-shell--easy-read .chat-sketch img,
body.page-chat.chat-easy-read .chat-sketch img,
html.chat-easy-read-boot body.page-chat .chat-sketch img {
  max-height: 280px;
}

body.page-chat .chat-shell--easy-read .chat-delivery-card__title,
body.page-chat .chat-shell--easy-read .chat-delivery-card__textarea,
body.page-chat.chat-easy-read .chat-delivery-card__title,
body.page-chat.chat-easy-read .chat-delivery-card__textarea {
  font-size: var(--chat-font-size);
  line-height: var(--chat-line-height);
}

/* Lectura fácil también en bandeja Clientes + timeline (mismo estado body/html) */
body.page-chat.chat-easy-read .chat-history-panel,
html.chat-easy-read-boot body.page-chat .chat-history-panel {
  --chat-font-size: 1.18rem;
  --chat-line-height: 1.55;
  --chat-meta-size: 0.92rem;
  --chat-header-size: 1.2rem;
  --chat-control-size: 1rem;
  --chat-control-min-h: 46px;
}

body.page-chat.chat-easy-read .chat-history-panel__titles h2,
body.page-chat.chat-easy-read .chat-history-detail__header h3,
html.chat-easy-read-boot body.page-chat .chat-history-panel__titles h2,
html.chat-easy-read-boot body.page-chat .chat-history-detail__header h3 {
  font-size: var(--chat-header-size);
}

body.page-chat.chat-easy-read .chat-history-item__title,
html.chat-easy-read-boot body.page-chat .chat-history-item__title {
  font-size: 1.08rem;
  font-weight: 700;
}

body.page-chat.chat-easy-read .chat-history-item__preview,
body.page-chat.chat-easy-read .chat-history-item__hint,
body.page-chat.chat-easy-read .chat-history-item__phone,
body.page-chat.chat-easy-read .chat-history-item__time,
html.chat-easy-read-boot body.page-chat .chat-history-item__preview,
html.chat-easy-read-boot body.page-chat .chat-history-item__hint,
html.chat-easy-read-boot body.page-chat .chat-history-item__phone,
html.chat-easy-read-boot body.page-chat .chat-history-item__time {
  font-size: var(--chat-meta-size);
  line-height: 1.45;
}

body.page-chat.chat-easy-read .chat-history-item,
html.chat-easy-read-boot body.page-chat .chat-history-item {
  padding: 0.78rem 0.9rem;
  gap: 0.85rem;
}

body.page-chat.chat-easy-read .chat-history-item__avatar,
html.chat-easy-read-boot body.page-chat .chat-history-item__avatar {
  width: 54px;
  height: 54px;
  font-size: 1.05rem;
}

body.page-chat.chat-easy-read .chat-timeline-event,
html.chat-easy-read-boot body.page-chat .chat-timeline-event {
  padding: 0.9rem 1rem;
}

body.page-chat.chat-easy-read .chat-timeline-event__title,
html.chat-easy-read-boot body.page-chat .chat-timeline-event__title {
  font-size: 1.08rem;
}

body.page-chat.chat-easy-read .chat-timeline-event__body,
body.page-chat.chat-easy-read .chat-client-summary__line,
body.page-chat.chat-easy-read .chat-client-summary__next,
html.chat-easy-read-boot body.page-chat .chat-timeline-event__body,
html.chat-easy-read-boot body.page-chat .chat-client-summary__line,
html.chat-easy-read-boot body.page-chat .chat-client-summary__next {
  font-size: var(--chat-font-size);
  line-height: var(--chat-line-height);
}

body.page-chat.chat-easy-read .chat-timeline-event__time,
html.chat-easy-read-boot body.page-chat .chat-timeline-event__time {
  font-size: var(--chat-meta-size);
}

body.page-chat.chat-easy-read .chat-timeline-event__actions .btn,
body.page-chat.chat-easy-read .chat-history-detail__header .btn,
body.page-chat.chat-easy-read .chat-history-panel__footer .btn,
html.chat-easy-read-boot body.page-chat .chat-timeline-event__actions .btn,
html.chat-easy-read-boot body.page-chat .chat-history-detail__header .btn,
html.chat-easy-read-boot body.page-chat .chat-history-panel__footer .btn {
  font-size: var(--chat-control-size);
  min-height: var(--chat-control-min-h);
  max-width: 100%;
  white-space: normal;
}

.chat-client-summary {
  margin: 0 0 0.75rem;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  background: var(--panel-summary-bg);
  border: 1px solid var(--panel-summary-border);
}

.chat-client-summary__line {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 650;
  color: var(--panel-text-strong);
}

.chat-client-summary__next {
  margin: 0.25rem 0 0;
  font-size: 0.82rem;
  color: var(--panel-warn);
}

.chat-timeline-event--account {
  border-color: color-mix(in srgb, var(--color-primary) 22%, var(--color-border));
}

.chat-timeline-event--expiration_alert {
  background: var(--panel-expiration-bg);
  border-color: var(--panel-expiration-border);
}

.chat-timeline-event__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.55rem;
}

@media (prefers-reduced-motion: reduce) {
  body.page-chat .chat-shell--easy-read *,
  body.page-chat.chat-easy-read *,
  html.chat-easy-read-boot body.page-chat * {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
.chat-bubble--bot .chat-quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.55rem 0 0.15rem;
}
.chat-quick-replies__btn {
  border: 1px solid color-mix(in srgb, var(--color-primary, #0d9488) 35%, #fff);
  background: #fff;
  color: var(--color-primary-dark, #0f766e);
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  font-size: 0.82rem;
  min-height: 36px;
  cursor: pointer;
}
.chat-quick-replies__btn:disabled,
.chat-quick-replies__btn.is-used {
  opacity: 0.55;
  cursor: default;
}
.chat-bubble__text {
  white-space: pre-wrap;
}

/* Historial: detalle timeline + filtro TuAPI */
.chat-history-panel__detail {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 0.5rem 0.75rem 1rem;
  -webkit-overflow-scrolling: touch;
  background: var(--panel-surface);
}

.chat-history-detail__header {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 0.75rem;
}

.chat-history-detail__header h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 650;
}

.chat-history-detail__timeline {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.chat-timeline-event {
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 0.7rem 0.8rem;
  background: var(--panel-surface-muted);
}

.chat-timeline-event__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.chat-timeline-event__title {
  font-size: 0.9rem;
  font-weight: 650;
}

.chat-timeline-event__time {
  flex: 0 0 auto;
  font-size: 0.72rem;
  color: var(--color-muted);
}

.chat-timeline-event__body {
  white-space: pre-wrap;
  font-size: 0.88rem;
  line-height: 1.45;
  color: var(--color-text);
}

.chat-timeline-event__actions {
  margin-top: 0.5rem;
}

.chat-history-day-sep {
  text-align: center;
  font-size: 0.78rem;
  color: var(--color-muted);
  margin: 0.75rem 0 0.35rem;
  font-weight: 600;
}

.chat-tuapi-filter {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: none;
}

.chat-tuapi-filter.is-open {
  display: block;
}

.chat-tuapi-filter__backdrop {
  position: absolute;
  inset: 0;
  background: var(--panel-backdrop);
}

.chat-tuapi-filter__sheet {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(22rem, calc(100vw - 1.5rem));
  background: var(--panel-surface);
  color: var(--color-text);
  border-radius: 14px;
  padding: 1rem 1.1rem 1.15rem;
  box-shadow: var(--shadow);
}

.chat-tuapi-filter__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.chat-tuapi-filter__header h2 {
  margin: 0;
  font-size: 1.05rem;
}

.chat-tuapi-filter__hint {
  margin: 0 0 0.85rem;
  font-size: 0.85rem;
}

.chat-tuapi-filter__field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 0.65rem;
  font-size: 0.85rem;
}

.chat-tuapi-filter__input {
  border: 1px solid var(--color-border, #e2e8f0);
  border-radius: 8px;
  padding: 0.45rem 0.55rem;
  min-height: 2.5rem;
}

.chat-tuapi-filter__actions {
  margin-top: 0.35rem;
}

.chat-tuapi-filter__error {
  margin: 0.55rem 0 0;
  color: #b91c1c;
  font-size: 0.85rem;
}

@media (min-width: 768px) {
  .chat-timeline-event {
    padding: 0.85rem 1rem;
  }
}

html.gym-pay-open,
body.gym-pay-open {
  overflow: hidden !important;
  overscroll-behavior: none;
}

body.page-chat.gym-pay-open .chat-messages {
  overflow: hidden;
}

.gym-pay-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0.85rem;
  padding-bottom: calc(0.85rem + env(safe-area-inset-bottom, 0px));
  box-sizing: border-box;
  overflow: hidden;
}

.gym-pay-modal.is-open {
  display: flex;
}

.gym-pay-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
}

.gym-pay-modal__sheet {
  position: relative;
  z-index: 1;
  width: min(50rem, calc(100% - 1.5rem));
  max-height: min(90vh, 34rem);
  margin: 0;
  padding: 1.25rem 1.35rem 1.3rem;
  overflow: hidden;
  border-radius: 24px;
  border: 1px solid var(--color-border, #e2e8f0);
  background: var(--color-surface, #fff);
  box-shadow: 0 24px 52px rgba(15, 23, 42, 0.22);
  box-sizing: border-box;
}

.gym-pay-modal__panel {
  display: grid;
  grid-template-columns: minmax(16.5rem, 0.95fr) minmax(16rem, 1.05fr);
  gap: 1.15rem 1.5rem;
  align-items: center;
}

.gym-pay-modal.is-no-qr .gym-pay-modal__panel {
  grid-template-columns: 1fr;
}

.gym-pay-modal.is-no-qr .gym-pay-modal__visual {
  display: none;
}

.gym-pay-modal__visual {
  display: grid;
  place-items: center;
  min-width: 0;
}

.gym-pay-modal__copy {
  display: grid;
  gap: 0.75rem;
  min-width: 0;
  align-content: center;
}

.gym-pay-modal__header {
  text-align: left;
}

.gym-pay-modal__header h2 {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--color-muted, #64748b);
}

.gym-pay-modal__amount {
  margin: 0.4rem 0 0;
  color: var(--color-text, #0f172a);
  font-size: 1.85rem;
  font-weight: 800;
  letter-spacing: -0.045em;
  line-height: 1.1;
}

.gym-pay-modal__plan {
  margin: 0.28rem 0 0;
  color: var(--color-muted, #64748b);
  font-size: 1rem;
  font-weight: 650;
}

.gym-pay-modal__qr {
  width: min(22rem, 100%);
  margin: 0;
  overflow: hidden;
  border-radius: 20px;
  border: 1px solid var(--color-border, #e2e8f0);
  background: #fff;
  box-shadow: inset 0 0 0 8px #fff;
}

.gym-pay-modal__qr img {
  display: block;
  width: 100%;
  height: auto;
  min-height: 16.5rem;
  aspect-ratio: 1 / 1;
  object-fit: contain;
}

.gym-pay-modal__meta {
  display: grid;
  gap: 0.55rem;
  margin: 0;
}

.gym-pay-modal__row dt {
  margin: 0;
  color: var(--color-muted, #64748b);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.gym-pay-modal__row dd {
  margin: 0.12rem 0 0;
  font-size: 1.02rem;
  font-weight: 650;
  overflow-wrap: anywhere;
}

.gym-pay-modal__hint {
  margin: 0;
  color: var(--color-muted, #64748b);
  font-size: 0.88rem;
  line-height: 1.4;
}

.gym-pay-modal__actions {
  display: grid;
  gap: 0.5rem;
}

.gym-pay-modal__actions .btn {
  min-height: 48px;
  justify-content: center;
}

.gym-pay-modal__actions .btn--primary {
  background: #0d9488;
  border-color: #0d9488;
  color: #fff;
}

.gym-pay-modal__success {
  display: none;
  place-items: center;
  gap: 0.75rem;
  min-height: 18rem;
  padding: 1.5rem 0.5rem;
  text-align: center;
}

.gym-pay-modal.is-success .gym-pay-modal__success {
  display: grid;
}

.gym-pay-modal__check {
  display: grid;
  place-items: center;
  width: 6.25rem;
  height: 6.25rem;
  animation: gym-pay-check-pop 0.75s ease-out;
}

.gym-pay-modal__check svg {
  display: block;
}

.gym-pay-modal__check circle {
  fill: color-mix(in srgb, #0d9488 14%, #fff);
  stroke: #0d9488;
  stroke-width: 3.5;
}

.gym-pay-modal__check path {
  fill: none;
  stroke: #0d9488;
  stroke-width: 5.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 64;
  stroke-dashoffset: 64;
  animation: gym-pay-check-draw 0.6s 0.12s ease-out forwards;
}

.gym-pay-modal__success-title {
  margin: 0;
  color: var(--color-text, #0f172a);
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.gym-pay-modal__success-sub {
  margin: 0;
  color: var(--color-muted, #64748b);
  font-size: 1rem;
  line-height: 1.4;
}

.gym-pay-modal__row.is-hidden,
.gym-pay-modal__qr.is-hidden,
.gym-pay-modal__amount.is-hidden,
.gym-pay-modal__plan.is-hidden,
.gym-pay-modal__panel.is-hidden,
.gym-pay-modal__success.is-hidden {
  display: none;
}

@keyframes gym-pay-check-pop {
  0% {
    transform: scale(0.72);
    opacity: 0;
  }
  70% {
    transform: scale(1.06);
    opacity: 1;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes gym-pay-check-draw {
  to {
    stroke-dashoffset: 0;
  }
}

@media (max-width: 767px) {
  .gym-pay-modal {
    z-index: 110;
    align-items: flex-end;
    padding: 0.4rem 0.5rem;
    padding-bottom: calc(0.35rem + 56px + env(safe-area-inset-bottom, 0px));
    overflow: hidden;
  }

  .gym-pay-modal__sheet {
    width: min(100%, 26.5rem);
    max-width: 100%;
    max-height: min(78dvh, calc(100dvh - 56px - 0.75rem - env(safe-area-inset-bottom, 0px)));
    display: flex;
    flex-direction: column;
    overflow: hidden;
    overflow-x: hidden;
    overscroll-behavior: contain;
    padding: 0.75rem 0.8rem 0.65rem;
    border-radius: 20px 20px 14px 14px;
  }

  .gym-pay-modal__panel,
  .gym-pay-modal.is-no-qr .gym-pay-modal__panel {
    display: flex;
    flex-direction: column;
    grid-template-columns: 1fr;
    align-items: stretch;
    gap: 0.45rem;
    min-height: 0;
    flex: 1 1 auto;
    overflow: hidden;
  }

  .gym-pay-modal__copy {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    min-width: 0;
    min-height: 0;
    flex: 1 1 auto;
    overflow: hidden;
  }

  .gym-pay-modal__header,
  .gym-pay-modal__hint {
    text-align: center;
  }

  .gym-pay-modal__header h2 {
    font-size: 0.7rem;
  }

  .gym-pay-modal__amount {
    margin-top: 0.22rem;
    font-size: 1.35rem;
  }

  .gym-pay-modal__plan {
    font-size: 0.9rem;
  }

  .gym-pay-modal__qr {
    width: min(11.25rem, 42vw);
    margin: 0 auto;
    border-radius: 14px;
    box-shadow: inset 0 0 0 5px #fff;
  }

  .gym-pay-modal__qr img {
    min-height: 0;
    max-height: 11.25rem;
  }

  .gym-pay-modal__meta {
    gap: 0.35rem;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }

  .gym-pay-modal__row dt {
    font-size: 0.66rem;
  }

  .gym-pay-modal__row dd {
    font-size: 0.92rem;
  }

  .gym-pay-modal__hint {
    font-size: 0.8rem;
    line-height: 1.35;
  }

  .gym-pay-modal__actions {
    flex: 0 0 auto;
    gap: 0.4rem;
    margin-top: auto;
    position: sticky;
    bottom: 0;
    z-index: 1;
    padding-top: 0.2rem;
    background: var(--color-surface, #fff);
  }

  .gym-pay-modal__actions .btn {
    min-height: 48px;
    width: 100%;
  }

  .gym-pay-modal__success {
    min-height: 0;
    padding: 0.85rem 0.35rem;
    gap: 0.5rem;
  }

  .gym-pay-modal__check {
    width: 4.5rem;
    height: 4.5rem;
  }

  .gym-pay-modal__success-title {
    font-size: 1.15rem;
  }

  .gym-pay-modal__success-sub {
    font-size: 0.88rem;
  }
}

