/* Twegese mobile app feel: install sheet + bottom tab navigation (phones/tablets). */

/* ---- install sheet ---- */
#twg-install {
  position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 1090;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: var(--bs-body-bg, #fff); color: var(--bs-body-color, #1f2937);
  border: 1px solid var(--bs-border-color, #e5e7eb); border-radius: 16px; padding: 14px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .18);
  transform: translateY(140%); transition: transform .25s ease; max-width: 520px; margin: 0 auto;
}
#twg-install.show { transform: translateY(0); }
.has-tabbar #twg-install { bottom: calc(78px + env(safe-area-inset-bottom)); }
.twg-install-icon img { width: 44px; height: 44px; border-radius: 10px; }
.twg-install-body { flex: 1 1 200px; display: flex; flex-direction: column; gap: 2px; font-size: 13.5px; line-height: 1.4; }
.twg-install-body strong { font-size: 15px; }
.twg-install-body span { color: var(--bs-secondary-color, #6b7280); }
.twg-install-actions { display: flex; gap: 8px; margin-left: auto; }
.twg-install-actions button { border-radius: 10px; padding: 8px 14px; font-weight: 600; font-size: 14px; border: 1px solid var(--bs-border-color, #d1d5db); background: transparent; color: inherit; }
.twg-install-actions .twg-install-yes { background: var(--bs-primary, #1a6b3a); border-color: var(--bs-primary, #1a6b3a); color: #fff; }

/* ---- bottom tab bar ---- */
.twg-tabbar { display: none; }
@media (max-width: 991.98px) {
  .twg-tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 1035;
    height: calc(62px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: var(--bs-body-bg, #fff); border-top: 1px solid var(--bs-border-color, #e5e7eb);
    box-shadow: 0 -4px 16px rgba(0, 0, 0, .06);
  }
  .twg-tab {
    flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    color: var(--bs-secondary-color, #6b7280); text-decoration: none; font-size: 11px; font-weight: 600;
    background: none; border: 0; padding: 6px 2px; position: relative; -webkit-tap-highlight-color: transparent;
  }
  .twg-tab i { font-size: 23px; line-height: 1; }
  .twg-tab span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .twg-tab.active { color: var(--bs-primary, #1a6b3a); }
  .twg-tab.active::before {
    content: ""; position: absolute; top: 0; left: 28%; right: 28%; height: 3px; border-radius: 0 0 3px 3px; background: currentColor;
  }
  .twg-tab:active { transform: scale(.94); }
  .twg-tab .twg-badge {
    position: absolute; top: 5px; left: calc(50% + 6px); min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px;
    background: #dc3545; color: #fff; font-size: 10px; line-height: 17px; text-align: center;
  }
  body.has-tabbar { padding-bottom: calc(62px + env(safe-area-inset-bottom)); }
  body.has-tabbar .footer { margin-bottom: calc(62px + env(safe-area-inset-bottom)); }
  body.has-tabbar #ai-fab { bottom: calc(76px + env(safe-area-inset-bottom)) !important; }
  body.has-tabbar #ai-panel { bottom: calc(70px + env(safe-area-inset-bottom)) !important; max-height: calc(100vh - 150px); }
}

/* Installed app: a little more app-like */
.twg-standalone body { overscroll-behavior-y: none; }
.twg-standalone #page-topbar { padding-top: env(safe-area-inset-top); }
