/* Phone bottom bar and help chat. Only shows on phones. */
.mbar, .chat, .chat-back { display: none; }
@media (max-width: 47.99rem) {
  body { padding-bottom: calc(4.9rem + env(safe-area-inset-bottom)); }
  html.chat-lock, html.chat-lock body { overflow: hidden; }
  .mbar {
    display: grid; grid-template-columns: 1fr 1fr 1fr; align-items: end;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 900;
    padding: .35rem .6rem calc(.35rem + env(safe-area-inset-bottom));
    background: rgba(13, 13, 18, .94); border-top: 1px solid var(--line);
    -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  }
  .mbar-item {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .15rem;
    min-height: 3.4rem; padding: .2rem; border: 0; background: none; cursor: pointer;
    color: var(--muted); font: 600 .72rem/1 var(--body); text-decoration: none; letter-spacing: .04em;
    -webkit-tap-highlight-color: transparent;
  }
  .mbar-item svg { width: 1.5rem; height: 1.5rem; }
  .mbar-item[aria-current="page"], .mbar-item:active, .mbar-item[aria-expanded="true"] { color: var(--gold); }
  .mbar-book {
    justify-self: center; width: 4.4rem; height: 4.4rem; min-height: 0; margin-top: -1.5rem; border-radius: 50%;
    background: var(--gold); color: var(--ink); box-shadow: 0 6px 22px rgba(227, 176, 75, .35), 0 0 0 5px rgba(13, 13, 18, .94);
  }
  .mbar-book[aria-current="page"], .mbar-book:active { color: var(--ink); background: var(--gold2); }

  .chat-back { display: block; position: fixed; inset: 0; z-index: 1000; background: rgba(0, 0, 0, .6); opacity: 0; transition: opacity .2s; }
  .chat-back.open { opacity: 1; }
  .chat {
    display: flex; flex-direction: column; position: fixed; left: 0; right: 0; bottom: 0; z-index: 1001;
    max-height: 86vh; max-height: 86dvh; min-height: 55vh;
    background: var(--bg2); border: 1px solid var(--line); border-bottom: 0; border-radius: 1.2rem 1.2rem 0 0;
    transform: translateY(100%); transition: transform .22s ease; padding-bottom: env(safe-area-inset-bottom);
  }
  .chat[hidden] { display: none !important; }
  .chat.open { transform: none; }
  .chat-head { display: flex; align-items: center; gap: .4rem; padding: .7rem .8rem; border-bottom: 1px solid var(--line); }
  .chat-head h2 { flex: 1; margin: 0; font: 400 1.15rem/1.2 var(--display); text-align: center; }
  .chat-nav, .chat-close { width: 2.6rem; height: 2.6rem; border: 0; border-radius: 50%; background: var(--card); color: var(--text); font-size: 1.4rem; line-height: 1; cursor: pointer; }
  .chat-nav[hidden] { display: block !important; visibility: hidden; }
  .chat-body { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 1rem; outline: 0; }
  .chat-msg, .chat-you { margin: 0 0 .9rem; padding: .8rem 1rem; border-radius: 1rem; max-width: 92%; font-size: .98rem; line-height: 1.55; }
  .chat-msg { background: var(--card); border: 1px solid var(--line); border-bottom-left-radius: .3rem; }
  .chat-you { background: var(--gold); color: var(--ink); font-weight: 600; margin-left: auto; border-bottom-right-radius: .3rem; }
  .chat-list { display: grid; gap: .5rem; margin-bottom: 1rem; }
  .chat-topic, .chat-q {
    display: block; width: 100%; text-align: left; padding: .85rem 1rem; min-height: 3rem; cursor: pointer;
    background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: .9rem; font: 500 .98rem/1.35 var(--body);
  }
  .chat-topic strong { display: block; font-weight: 700; }
  .chat-topic span { display: block; color: var(--muted); font-size: .85rem; margin-top: .15rem; }
  .chat-topic:active, .chat-q:active { border-color: var(--gold); }
  .chat-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1.2rem; }
  .chat-act { display: inline-flex; align-items: center; min-height: 2.8rem; padding: 0 1.1rem; border: 1px solid var(--gold); border-radius: 999px; color: var(--gold2); text-decoration: none; font: 600 .9rem var(--body); }
  .chat-act.primary { background: var(--gold); color: var(--ink); }
  .chat-more { margin: 0 0 .6rem; font: 700 .72rem var(--body); letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
  .chat-note { color: var(--muted); font-size: .9rem; display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
  .chat-note .chat-act { min-height: 2.4rem; }
}
@media (prefers-reduced-motion: reduce) { .chat, .chat-back { transition: none; } }
