/* The regular website shares its mobile layout and data with desktop. */
.mobile-navigation { display: none; }
button, summary, a { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
input, textarea { max-width: 100%; }
.operation-icon, .modal-close { flex-shrink: 0; }
.operation-info b { white-space: nowrap; }
.operations, .wallet-list { grid-template-columns: minmax(0, 1fr); }
.operation { min-width: 0; }
.bank-open h2, .bank-preview b, .identity-copy, .budget-owner > div { overflow-wrap: anywhere; min-width: 0; }

@media (max-width: 1100px) and (min-width: 761px) {
  .overview-grid { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); }
  .account-card > strong { font-size: clamp(21px, 2.5vw, 29px); overflow-wrap: anywhere; }
}

@media (max-width: 760px) {
  :root { --mobile-bottom: calc(76px + env(safe-area-inset-bottom, 0px)); }
  .shell { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
  .site-header { position: relative; z-index: 20; }
  .site-header .top { min-height: 68px; gap: 10px; padding-top: max(12px, env(safe-area-inset-top)); padding-bottom: 12px; }
  .site-header.is-authenticated .top { display: grid; grid-template-columns: minmax(0, 1fr) auto; }
  .site-header.is-authenticated .top > .top-actions { grid-column: 2; grid-row: 1; gap: 6px; }
  .site-header.is-authenticated .top-actions > .link-btn { display: none; }
  .site-header .brand { font-size: 20px; padding: 0; justify-self: start; }
  .brand i { width: 32px; height: 32px; margin-right: 7px; }
  .chat-trigger { width: 44px; height: 44px; margin-left: 0; }
  .account-menu { margin-left: 0; padding-left: 10px; }
  .account-trigger { width: 44px; height: 44px; }
  .account-dropdown button { min-height: 44px; }
  .site-header .header-rates { grid-column: 1 / -1; grid-row: 2; order: initial; flex-basis: auto; justify-content: center; flex-wrap: wrap; gap: 8px 14px; padding: 4px 0 0; }
  .header-rates .cross-rate { display: none; }
  .header-rates b { font-size: 12px; }
  .mobile-navigation { position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); background: #ffffffed; backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-top: 1px solid var(--line); box-shadow: 0 -5px 22px #20342d08; padding: 8px max(12px, env(safe-area-inset-left)) calc(8px + env(safe-area-inset-bottom, 0px)); }
  .mobile-navigation button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 52px; padding: 7px; border-radius: 14px; background: transparent; color: #819080; font-size: 11px; font-weight: 700; }
  .mobile-navigation button svg { width: 22px; height: 22px; }
  .mobile-navigation button.active { background: #edf3e7; color: #294b37; }
  .mobile-navigation button:hover { background: #f0f4eb; }
  .site-header.is-authenticated ~ main { padding-bottom: calc(var(--mobile-bottom) + 24px); }
  .dashboard { padding-top: 22px; }
  .dash-head { margin-bottom: 20px; gap: 14px; }
  .dash-head h1 { font-size: 25px; letter-spacing: -.7px; }
  .dash-head > .top-actions { width: 100%; gap: 8px; flex-wrap: wrap; }
  .dash-head > .top-actions button { flex: 1; min-height: 44px; }
  .account-grid { gap: 14px; margin-bottom: 20px; }
  .account-card { border-radius: 20px; padding: 22px; }
  .account-top { margin-bottom: 18px; font-size: 13px; }
  .account-card > strong { font-size: clamp(28px, 7.8vw, 36px); overflow-wrap: anywhere; margin-bottom: 16px; }
  .account-card > small, .account-bottom { font-size: 11px; }
  .account-actions { margin-top: 18px; padding-top: 14px; gap: 10px; }
  .account-actions button { min-height: 44px; font-size: 12px; }
  .overview-grid { gap: 16px; }
  .panel { padding: 18px; border-radius: 18px; }
  .section-title h2 { font-size: 15px; }
  .section-title .link-btn { padding: 10px 0 10px 8px; flex-shrink: 0; font-size: 11px; }
  .operation { flex-wrap: wrap; gap: 9px; padding: 15px 0; }
  .operation .operation-info { flex-basis: calc(100% - 50px); }
  .operation > b { margin-left: 44px; font-size: 13px; }
  .operation > .icon-btn { margin-left: auto; }
  .operation .operation-info small { font-size: 11px; line-height: 1.6; }
  .icon-btn { width: 44px; height: 44px; flex-shrink: 0; }
  .primary, .outline, .choice { min-height: 44px; }
  .history-layout { gap: 16px; }
  .history-calendar-heading .icon-btn { width: 44px; height: 44px; }
  .calendar-weekdays { font-size: 11px; }
  .calendar-day { height: 44px; font-size: 13px; }
  .history-operation-open { display: grid; grid-template-columns: 35px minmax(0, 1fr); gap: 6px 10px; }
  .history-operation-open .operation-icon { grid-row: 1 / 3; align-self: start; }
  .history-operation-open strong { grid-column: 2; font-size: 13px; margin-top: 4px; }
  .history-operation-open small { display: block; font-size: 11px; color: var(--muted); margin-top: 5px; }
  .bank-grid { grid-template-columns: 1fr; gap: 14px; }
  .bank-open h2 { line-height: 1.5; }
  .bank-preview > div:first-child { gap: 12px; }
  .bank-preview span { flex-shrink: 0; }
  .profile-card { flex-wrap: nowrap; gap: 12px; align-items: flex-start; }
  .profile-card .identity-copy { flex: 1; }
  .profile-card h2 { font-size: 19px; line-height: 1.4; }
  .profile-card p { font-size: 12px; overflow-wrap: anywhere; }
  .profile-card > .profile-icon { width: 44px; height: 44px; padding: 10px; }
  .friends-panel .section-title { flex-wrap: nowrap; }
  .profile-budget-grid > .panel { padding: 18px; }
  .profile-budget-grid .budget-owner h2 { font-size: 19px; }
  .role-label { padding: 6px 8px; }
  .budget-currencies { flex-wrap: wrap; }
  .budget-context { padding: 12px 16px; line-height: 1.7; overflow-wrap: anywhere; }
  .budget-context button { margin-left: 0; }
  .budget-switches button { white-space: normal; text-align: left; overflow-wrap: anywhere; }
  .person-row > div { min-width: 0; flex-basis: calc(100% - 52px); overflow-wrap: anywhere; }
  .search-row { flex-wrap: wrap; }
  .search-row input { width: 100%; flex-basis: 100%; font-size: 16px; }
  .search-row button { width: 100%; }
  .operation-modal { position: fixed; inset: auto; top: calc(var(--visible-top, 0px) + 8px); left: max(8px, env(safe-area-inset-left)); margin: 0; width: calc(100% - 16px); max-width: none; max-height: calc(var(--visible-height, 100dvh) - 16px); padding: 20px 18px max(20px, env(safe-area-inset-bottom)); border-radius: 22px; overscroll-behavior: contain; scroll-padding: 20px; }
  .modal-heading { gap: 12px; }
  .modal-heading h2 { font-size: 21px; line-height: 1.4; overflow-wrap: anywhere; }
  .modal-close { width: 44px; height: 44px; }
  .field { margin: 18px 0; }
  .field input, .message-compose textarea { font-size: 16px; min-height: 46px; }
  .field input { min-width: 0; }
  .field label { line-height: 1.5; }
  .choice-row { gap: 8px; }
  .choice { flex-basis: calc(50% - 8px); white-space: normal; line-height: 1.4; padding: 10px; }
  .category-field .choice-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .category-field .choice { font-size: 12px; min-height: 44px; }
  .operation-detail-amount, .bank-summary strong { overflow-wrap: anywhere; }
  .operation-details > div { gap: 12px; }
  .operation-details dt { max-width: 45%; flex-shrink: 1; }
  .check-row { align-items: flex-start; line-height: 1.6; }
  .check-row input { flex-shrink: 0; }
  .bank-modal-actions .outline { width: 100%; }
  .plan-scroll { overscroll-behavior-x: contain; }
  .messages-modal { display: flex; flex-direction: column; height: calc(var(--visible-height, 100dvh) - 16px); overflow: hidden; padding: 14px 12px max(12px, env(safe-area-inset-bottom)); }
  .messages-modal:not([open]) { display: none; }
  .messages-modal .modal-heading { flex-shrink: 0; }
  .messages-modal .modal-heading{gap:10px}
  .messages-modal .modal-heading h2{flex:1;min-width:0}
  .messages-modal.chat-open .message-list-back{display:grid;place-items:center;width:40px;height:40px;margin-left:auto;flex-shrink:0;border:1px solid var(--control-line);border-radius:12px;background:#f0f4eb;color:var(--ink)}
  .message-layout { flex: 1; min-height: 0; height: auto; grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0,1fr); margin-top: 12px; border-radius: 14px; }
  .message-sidebar { display:block;min-width:0;overflow-x:hidden;overflow-y:auto;border:0;padding:6px;scroll-snap-type:none;overscroll-behavior:contain;scrollbar-width:thin }
  .messages-modal:not(.chat-open) .message-main{display:none}
  .conversation { position:relative;width:100%;min-height:76px;gap:14px;padding:14px 10px;border-radius:12px;scroll-snap-align:none;border-bottom:1px solid var(--line) }
  .conversation b{font-size:14px}
  .conversation small{font-size:12px;line-height:1.4;margin-top:6px}
  .conversation>.avatar,.conversation>.system-avatar{width:46px;height:46px;flex-shrink:0;border-radius:50%}
  .conversation.selected{background:#e7efdf}
  .conversation-count{min-width:20px;text-align:center;font-size:11px}
  .messages-modal.chat-open .message-layout{grid-template-columns:62px minmax(0,1fr)}
  .messages-modal.chat-open .message-sidebar{border-right:1px solid var(--line);padding:6px 4px;background:#f7f9f5}
  .messages-modal.chat-open .conversation{justify-content:center;gap:0;padding:10px 2px;min-height:62px;border-bottom:0;border-radius:12px}
  .messages-modal.chat-open .conversation>div{display:none}
  .messages-modal.chat-open .conversation>.avatar,.messages-modal.chat-open .conversation>.system-avatar{width:38px;height:38px}
  .messages-modal.chat-open .conversation-count{position:absolute;top:4px;right:0;padding:2px 4px;font-size:9px;min-width:16px;box-shadow:0 0 0 2px #f7f9f5}
  .messages-modal.chat-open .message-main{animation:message-slide-in .18s ease-out}
  .conversation b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .message-thread-heading { min-height: 54px; padding: 10px 12px; flex-shrink: 0; }
  .message-thread-heading > div, .message-thread-heading > b { min-width: 0; overflow-wrap: anywhere; }
  .ai-service-note { padding: 8px 12px; font-size: 10px; flex-shrink: 0; max-height: 76px; overflow-y: auto; }
  .message-error { max-height: 80px; overflow-y: auto; flex-shrink: 0; }
  .message-thread { padding: 12px; min-height: 0; overscroll-behavior: contain; }
  .message-compose { padding: 8px; gap: 6px; flex-wrap: wrap; flex-shrink: 0; }
  .message-compose textarea { flex-basis: 100%; width: 100%; max-height: 80px; }
  .message-compose button { width: 44px; height: 44px; padding: 10px; }
  .message-compose button[type=submit] { margin-left: auto; }
  .chat-bubble { max-width: 94%; }
  .ai-proposal { padding: 12px; }
  .ai-proposal dd { overflow-wrap: anywhere; }
  .access-line { flex-wrap: wrap; }
  .access-line > div { flex-basis: calc(100% - 50px); overflow-wrap: anywhere; }
  .hero { gap: 30px; padding: 34px 0; }
  .hero h1 { font-size: clamp(32px, 9vw, 44px); letter-spacing: -1.5px; }
  .hero-proof { flex-wrap: wrap; gap: 10px 16px; }
  .hero-visual { transform: none; padding: 18px; }
  .auth-wrap { min-height: calc(100dvh - 90px); padding: 24px 16px; }
  .auth-card { padding: 24px 20px; }
}

@media (max-width: 360px) {
  .site-header .brand { font-size: 18px; }
  .brand i { width: 28px; height: 28px; }
  .account-menu { padding-left: 6px; }
  .section-title h2 { font-size: 14px; }
  .account-card { padding: 18px; }
  .profile-card { flex-wrap: wrap; }
  .profile-card .identity-copy { flex-basis: calc(100% - 75px); }
}

@media (max-width: 760px) and (max-height: 500px) {
  .messages-modal .modal-heading h2 { font-size: 18px; }
  .conversation { padding: 6px 8px; }
  .messages-modal.chat-open .conversation small { display: none; }
  .message-thread-heading { min-height: 44px; padding: 5px 10px; }
  .message-compose textarea { flex-basis: 0; width: auto; min-height: 44px; max-height: 54px; }
  .message-compose { flex-wrap: nowrap; }
  .ai-service-note { max-height: 42px; padding: 5px 10px; }
}
@keyframes message-slide-in{from{opacity:0;transform:translateX(12px)}to{opacity:1;transform:translateX(0)}}
@media(prefers-reduced-motion:reduce){.messages-modal.chat-open .message-main{animation:none}}
