/**
 * Mobile shell (html[data-shell="mobile"]).
 * Header (Logo · Suche · Login), Bottom-Tab-Bar, Vollbild-Menü-Sheet,
 * Basis-Ergonomie (Touch-Größen, Formular-Typo, Toolbar, Command-Palette).
 * Breakpoint: max-width --bp-mobile (720px). See js/core/shell-boot.js.
 */

html[data-shell="mobile"] {
  --main-nav-height: 56px;
  --mobile-tabbar-h: 60px;
  --mobile-safe-bottom: env(safe-area-inset-bottom, 0px);
  --mobile-tabbar-total: calc(var(--mobile-tabbar-h) + var(--mobile-safe-bottom));
  --mobile-tap: 44px;
  overflow-x: clip;
}

html[data-shell="mobile"] body {
  overflow-x: clip;
  padding-bottom: var(--mobile-tabbar-total);
}

html[data-shell="mobile"] body.mobile-menu-open {
  overflow: hidden;
}

/* ---------- Header: Logo · Suche · Login (· Admin) ---------- */

html[data-shell="mobile"] .main-nav-inner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.5rem;
  padding: 0 max(0.6rem, env(safe-area-inset-right, 0px)) 0 max(0.85rem, env(safe-area-inset-left, 0px));
}

html[data-shell="mobile"] .nav-logo {
  grid-column: 1;
  min-width: 0;
  max-width: 10rem;
}

html[data-shell="mobile"] .nav-logo-img {
  height: 28px;
  width: auto;
  max-width: 100%;
  object-fit: contain;
  object-position: left center;
}

html[data-shell="mobile"] .nav-items,
html[data-shell="mobile"] .nav-items::before,
html[data-shell="mobile"] .nav-items::after,
html[data-shell="mobile"] .nav-theme-btn,
html[data-shell="mobile"] .nav-lang-wrap,
html[data-shell="mobile"] .nav-mobile-toggle {
  display: none;
}

html[data-shell="mobile"] .nav-actions {
  grid-column: 2;
}

html[data-shell="mobile"] .nav-actions,
html[data-shell="mobile"] .nav-actions-util,
html[data-shell="mobile"] .nav-actions-end {
  gap: 0.3rem;
}

html[data-shell="mobile"] .nav-search-btn {
  min-width: var(--mobile-tap);
  min-height: var(--mobile-tap);
  padding: 0.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

html[data-shell="mobile"] .nav-search-btn svg {
  width: 22px;
  height: 22px;
}

html[data-shell="mobile"] .nav-login-btn {
  min-height: var(--mobile-tap);
  max-width: 7.5rem;
  font-size: 0.74rem;
  padding: 0.4rem 0.7rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

html[data-shell="mobile"] .nav-admin-btn {
  min-width: var(--mobile-tap);
  min-height: var(--mobile-tap);
  padding: 0.4rem 0.5rem;
  justify-content: center;
}

html[data-shell="mobile"] .nav-admin-btn span {
  display: none;
}

/* Legacy Tools mega-menu (nur noch per Tastatur erreichbar) – 1-spaltig */
html[data-shell="mobile"] .mega-menu-inner {
  grid-template-columns: 1fr;
  padding: 0.85rem 1rem 1.1rem;
}

html[data-shell="mobile"] .mega-menu-item {
  min-height: 3rem;
  padding: 0.7rem 0.75rem;
}

html[data-shell="mobile"] .nav-search-wrap.is-open .nav-search-panel {
  width: auto;
  left: max(0.75rem, env(safe-area-inset-left, 0px)) !important;
  right: max(0.75rem, env(safe-area-inset-right, 0px)) !important;
  top: calc(var(--main-nav-height) + 0.5rem) !important;
  animation: searchRevealMobile 0.18s ease;
}

/* ---------- Bottom Tab-Bar ---------- */

html[data-shell="mobile"] .mobile-tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2100;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  height: var(--mobile-tabbar-total);
  padding: 0 max(0.25rem, env(safe-area-inset-right, 0px)) var(--mobile-safe-bottom) max(0.25rem, env(safe-area-inset-left, 0px));
  background: color-mix(in srgb, var(--bg-secondary) 94%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
  view-transition-name: mobile-tabbar;
}

html[data-shell="mobile"] .mobile-tab {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.22rem;
  min-width: 0;
  min-height: var(--mobile-tabbar-h);
  padding: 0.35rem 0.15rem 0.3rem;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.15s;
}

html[data-shell="mobile"] .mobile-tab svg {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  opacity: 0.85;
  transition: opacity 0.15s, transform 0.15s;
}

html[data-shell="mobile"] .mobile-tab-label {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

html[data-shell="mobile"] .mobile-tab.active {
  color: var(--accent);
}

html[data-shell="mobile"] .mobile-tab.active svg {
  opacity: 1;
}

html[data-shell="mobile"] .mobile-tab.active::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  width: 1.75rem;
  height: 3px;
  transform: translateX(-50%);
  border-radius: 0 0 3px 3px;
  background: var(--accent);
}

html[data-shell="mobile"] .mobile-tab:active svg {
  transform: scale(0.92);
}

/* ---------- Vollbild-Menü (Sheet) ---------- */

html[data-shell="mobile"] .mobile-menu-sheet {
  position: fixed;
  inset: 0;
  z-index: 2200;
  display: block;
}

html[data-shell="mobile"] .mobile-menu-sheet[hidden] {
  display: none;
}

html[data-shell="mobile"] .mobile-menu-backdrop {
  position: absolute;
  inset: 0;
  background: var(--mega-backdrop, rgba(0, 0, 0, 0.55));
  opacity: 0;
  transition: opacity 0.18s ease;
}

html[data-shell="mobile"] .mobile-menu-panel {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: var(--mobile-tabbar-total);
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
  transform: translateY(6%);
  opacity: 0;
  transition: transform 0.2s ease, opacity 0.18s ease;
}

html[data-shell="mobile"] .mobile-menu-sheet.is-open .mobile-menu-backdrop,
html[data-shell="mobile"] .mobile-menu-sheet.is-open .mobile-menu-panel {
  opacity: 1;
  transform: none;
}

html[data-shell="mobile"] .mobile-menu-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 0 0 auto;
  min-height: var(--main-nav-height);
  padding: env(safe-area-inset-top, 0px) max(0.5rem, env(safe-area-inset-right, 0px)) 0 max(1rem, env(safe-area-inset-left, 0px));
  background: var(--nav-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

html[data-shell="mobile"] .mobile-menu-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
}

html[data-shell="mobile"] .mobile-menu-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--mobile-tap);
  height: var(--mobile-tap);
  border: none;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
}

html[data-shell="mobile"] .mobile-menu-close svg {
  width: 24px;
  height: 24px;
}

html[data-shell="mobile"] .mobile-menu-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 0.75rem max(0.85rem, env(safe-area-inset-right, 0px)) 1.25rem max(0.85rem, env(safe-area-inset-left, 0px));
}

html[data-shell="mobile"] .mobile-menu-search {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  min-height: 3rem;
  padding: 0.6rem 0.9rem;
  margin-bottom: 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  color: var(--text-secondary);
  font: inherit;
  font-size: 0.95rem;
  text-align: left;
  cursor: pointer;
}

html[data-shell="mobile"] .mobile-menu-search svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

html[data-shell="mobile"] .mobile-menu-search span {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

html[data-shell="mobile"] .mobile-menu-group {
  margin-bottom: 1rem;
}

html[data-shell="mobile"] .mobile-menu-group-title {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0 0.25rem 0.4rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

html[data-shell="mobile"] .mobile-menu-group-title svg {
  width: 16px;
  height: 16px;
  opacity: 0.8;
}

html[data-shell="mobile"] .mobile-menu-list,
html[data-shell="mobile"] .mobile-menu-settings {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  overflow: hidden;
}

html[data-shell="mobile"] .mobile-menu-list:empty {
  display: none;
}

html[data-shell="mobile"] .mobile-menu-link,
html[data-shell="mobile"] .mobile-menu-theme,
html[data-shell="mobile"] .mobile-menu-lang-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  min-height: 3.25rem;
  padding: 0.65rem 0.9rem;
  border: none;
  border-bottom: 1px solid var(--border);
  background: transparent;
  color: var(--text-primary);
  font: inherit;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

html[data-shell="mobile"] .mobile-menu-list > :last-child,
html[data-shell="mobile"] .mobile-menu-settings > :last-child {
  border-bottom: none;
}

html[data-shell="mobile"] .mobile-menu-link:active,
html[data-shell="mobile"] .mobile-menu-theme:active {
  background: var(--bg-hover);
}

html[data-shell="mobile"] .mobile-menu-link.active {
  color: var(--accent);
}

html[data-shell="mobile"] .mobile-menu-link > svg,
html[data-shell="mobile"] .mobile-menu-theme-icon {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  color: var(--text-secondary);
  opacity: 0.9;
}

html[data-shell="mobile"] .mobile-menu-link.active > svg {
  color: var(--accent);
}

html[data-shell="mobile"] .mobile-menu-theme-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

html[data-shell="mobile"] .mobile-menu-theme-icon svg {
  width: 22px;
  height: 22px;
}

html[data-shell="mobile"] .mobile-menu-link-text {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  flex: 1 1 auto;
  min-width: 0;
}

html[data-shell="mobile"] .mobile-menu-link-label {
  font-size: 0.98rem;
  font-weight: 600;
  line-height: 1.25;
}

html[data-shell="mobile"] .mobile-menu-link-desc {
  font-size: 0.78rem;
  line-height: 1.3;
  color: var(--text-secondary);
}

html[data-shell="mobile"] .mobile-menu-chevron {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: var(--text-muted);
  opacity: 0.7;
}

html[data-shell="mobile"] .mobile-menu-link .nav-live-badge {
  flex-shrink: 0;
}

html[data-shell="mobile"] .mobile-menu-admin--owner .mobile-menu-link-label,
html[data-shell="mobile"] .mobile-menu-admin--admin .mobile-menu-link-label {
  color: var(--accent);
}

/* Settings: Theme + Sprache */
html[data-shell="mobile"] .mobile-menu-lang-row {
  cursor: default;
  justify-content: space-between;
  flex-wrap: wrap;
  row-gap: 0.5rem;
}

html[data-shell="mobile"] .mobile-menu-lang-segments {
  display: inline-flex;
  gap: 0.25rem;
  padding: 0.2rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-primary);
}

html[data-shell="mobile"] .mobile-menu-lang {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 2.5rem;
  padding: 0.35rem 0.8rem;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}

html[data-shell="mobile"] .mobile-menu-lang svg,
html[data-shell="mobile"] .mobile-menu-lang img {
  width: 18px;
  height: 13px;
  border-radius: 2px;
}

html[data-shell="mobile"] .mobile-menu-lang.is-active {
  background: var(--accent);
  color: #1a1408;
}

html[data-shell="mobile"] .mobile-menu-foot {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.75rem 0.5rem 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

html[data-shell="mobile"] .mobile-menu-foot a,
html[data-shell="mobile"] .mobile-menu-foot-btn {
  display: inline-flex;
  align-items: center;
  min-height: 2.5rem;
  padding: 0 0.4rem;
  color: var(--text-secondary);
  text-decoration: none;
}

html[data-shell="mobile"] .mobile-menu-foot-btn {
  appearance: none;
  border: 0;
  background: none;
  font: inherit;
  font-size: inherit;
  cursor: pointer;
}

/* ---------- Fixe Legal-Bar aus (Links stehen im Menü-Footer) ---------- */

html[data-shell="mobile"] .site-legal-bar {
  display: none;
}

html[data-shell="mobile"] body.has-site-legal-bar .home-credits {
  display: flex;
}

html[data-shell="mobile"] body.has-site-legal-bar .page-content.home-page {
  padding-bottom: 1.5rem;
}

/* ---------- Seiteninhalt, Toolbar, Formulare, Touch-Basis ---------- */

html[data-shell="mobile"] .page-content {
  padding: 1rem max(0.9rem, env(safe-area-inset-right, 0px)) 1.5rem max(0.9rem, env(safe-area-inset-left, 0px));
}

html[data-shell="mobile"] .page-toolbar {
  flex-direction: column;
  align-items: stretch;
  gap: 0.65rem;
  margin-bottom: 1rem;
}

html[data-shell="mobile"] .page-toolbar-title {
  font-size: 1.2rem;
}

html[data-shell="mobile"] .page-toolbar-actions {
  width: 100%;
  flex-wrap: wrap;
}

html[data-shell="mobile"] .page-toolbar-actions .btn {
  min-height: var(--mobile-tap);
}

html[data-shell="mobile"] .btn,
html[data-shell="mobile"] .btn-sm,
html[data-shell="mobile"] .btn-secondary,
html[data-shell="mobile"] .btn-primary,
html[data-shell="mobile"] .vote-btn,
html[data-shell="mobile"] .icon-btn,
html[data-shell="mobile"] .toggle-btn,
html[data-shell="mobile"] .chip-btn {
  min-height: var(--mobile-tap);
}

html[data-shell="mobile"] .btn-sm {
  padding-block: 0.5rem;
}

html[data-shell="mobile"] .page-content input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]),
html[data-shell="mobile"] .page-content select,
html[data-shell="mobile"] .page-content textarea,
html[data-shell="mobile"] .map-filters input,
html[data-shell="mobile"] .map-filters select {
  font-size: 1rem; /* verhindert iOS-Zoom */
  min-height: var(--mobile-tap);
}

html[data-shell="mobile"] .page-content input[type="checkbox"],
html[data-shell="mobile"] .page-content input[type="radio"],
html[data-shell="mobile"] .tracker-shell input[type="checkbox"],
html[data-shell="mobile"] .tracker-shell input[type="radio"] {
  width: 1.25rem;
  height: 1.25rem;
}

html[data-shell="mobile"] .page-content label:has(> input[type="checkbox"]),
html[data-shell="mobile"] .page-content label:has(> input[type="radio"]),
html[data-shell="mobile"] .tracker-shell label:has(> input[type="checkbox"]),
html[data-shell="mobile"] .tracker-shell label:has(> input[type="radio"]) {
  min-height: 2.5rem;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

html[data-shell="mobile"] table {
  font-size: 0.88rem;
}

/* ---------- Command-Palette vollflächig ---------- */

html[data-shell="mobile"] .cmdk {
  padding: max(0.75rem, env(safe-area-inset-top, 0px)) 0.6rem calc(var(--mobile-tabbar-total) + 0.75rem);
  align-items: stretch;
}

html[data-shell="mobile"] .cmdk-panel {
  width: 100%;
  max-height: 100%;
}

html[data-shell="mobile"] .cmdk-input,
html[data-shell="mobile"] #cmdk-input {
  font-size: 1rem;
  min-height: var(--mobile-tap);
}

/* ---------- Login-Modal ---------- */

html[data-shell="mobile"] .login-modal-backdrop {
  align-items: end;
  padding: 0.5rem 0.5rem calc(var(--mobile-tabbar-total) + 0.5rem);
}

html[data-shell="mobile"] .login-modal {
  width: 100%;
  max-height: calc(100dvh - var(--mobile-tabbar-total) - 1rem);
  overflow-y: auto;
}

html[data-shell="mobile"] .login-modal .btn,
html[data-shell="mobile"] .login-modal input {
  min-height: var(--mobile-tap);
  font-size: 1rem;
}

html[data-shell="mobile"] .login-modal-actions {
  flex-wrap: wrap;
}

html[data-shell="mobile"] .login-modal-actions .btn {
  flex: 1 1 calc(50% - 0.35rem);
}

/* Fixed/toast-Elemente über der Tab-Bar halten */
html[data-shell="mobile"] .toast,
html[data-shell="mobile"] .toast-stack,
html[data-shell="mobile"] .snackbar {
  bottom: calc(var(--mobile-tabbar-total) + 0.75rem);
}

html[data-shell="mobile"] .dev-auth-preview {
  right: 0.75rem;
  bottom: calc(var(--mobile-tabbar-total) + 0.75rem);
}

html[data-shell="mobile"] .dev-auth-preview-label {
  display: none;
}
