/* V14.6 — interface mobile complète */
:root {
  --mobile-nav-height: 68px;
  --mobile-safe-bottom: env(safe-area-inset-bottom, 0px);
}

.mobile-sidebar-overlay,
.mobile-bottom-nav {
  display: none;
}

button,
a,
input,
select,
textarea,
summary {
  -webkit-tap-highlight-color: transparent;
}

@media (max-width: 850px) {
  html,
  body {
    max-width: 100%;
    overflow-x: hidden;
  }

  body {
    padding-bottom: calc(var(--mobile-nav-height) + var(--mobile-safe-bottom));
  }

  .layout {
    display: block;
    min-height: 100vh;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 1002;
    width: min(86vw, 330px);
    max-width: 330px;
    height: 100dvh;
    padding-bottom: calc(24px + var(--mobile-safe-bottom));
    overflow-y: auto;
    overscroll-behavior: contain;
    transform: translateX(-105%);
    box-shadow: 24px 0 60px rgba(0, 0, 0, .45);
    transition: transform .22s ease;
  }

  body.menu-open {
    overflow: hidden;
  }

  body.menu-open .sidebar {
    transform: translateX(0);
  }

  .mobile-sidebar-overlay {
    position: fixed;
    inset: 0;
    z-index: 1001;
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: rgba(2, 6, 14, .72);
    backdrop-filter: blur(3px);
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
  }

  body.menu-open .mobile-sidebar-overlay {
    display: block;
    opacity: 1;
    pointer-events: auto;
  }

  .content {
    width: 100%;
    min-width: 0;
    padding: 12px 12px 20px;
  }

  .topbar {
    position: sticky;
    top: 0;
    z-index: 900;
    min-height: 62px;
    margin: -12px -12px 14px;
    padding: calc(10px + env(safe-area-inset-top, 0px)) 12px 10px;
    border-bottom: 1px solid var(--line);
    background: rgba(8, 13, 23, .94);
    backdrop-filter: blur(14px);
  }

  .topbar h1 {
    max-width: 70vw;
    margin: 0;
    font-size: clamp(1.1rem, 5vw, 1.45rem);
    line-height: 1.15;
  }

  .topbar p {
    max-width: 72vw;
    margin-top: 3px;
    overflow: hidden;
    color: var(--muted);
    font-size: .75rem;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .menu-button {
    display: inline-grid;
    place-items: center;
    flex: 0 0 42px;
    width: 42px;
    height: 42px;
    font-size: 1.2rem;
  }

  .bell {
    flex: 0 0 auto;
  }

  .mobile-bottom-nav {
    position: fixed;
    inset: auto 0 0;
    z-index: 1000;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    min-height: calc(var(--mobile-nav-height) + var(--mobile-safe-bottom));
    padding: 7px 5px var(--mobile-safe-bottom);
    border-top: 1px solid rgba(148, 163, 184, .2);
    background: rgba(8, 13, 23, .97);
    box-shadow: 0 -12px 34px rgba(0, 0, 0, .35);
    backdrop-filter: blur(16px);
  }

  .mobile-bottom-nav a,
  .mobile-bottom-nav button {
    display: grid;
    place-items: center;
    align-content: center;
    gap: 2px;
    min-width: 0;
    min-height: 52px;
    padding: 4px 2px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: #cbd5e1;
    text-decoration: none;
  }

  .mobile-bottom-nav a:active,
  .mobile-bottom-nav button:active,
  .mobile-bottom-nav a.is-active {
    background: rgba(112, 92, 255, .2);
    color: #fff;
  }

  .mobile-bottom-nav span {
    font-size: 1.25rem;
    line-height: 1;
  }

  .mobile-bottom-nav small {
    overflow: hidden;
    max-width: 100%;
    color: inherit;
    font-size: .64rem;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .panel {
    min-width: 0;
    padding: 14px;
    border-radius: 12px;
  }

  .panel + .panel,
  .panel + div,
  div + .panel {
    margin-top: 12px;
  }

  h1, h2, h3 {
    overflow-wrap: anywhere;
  }

  h2 {
    font-size: 1.15rem;
  }

  h3 {
    font-size: 1rem;
  }

  button,
  .action-button,
  .primary-link,
  .hero-button,
  .v14-primary-link,
  .v14-save-button {
    min-height: 44px;
  }

  input,
  select,
  textarea {
    min-height: 44px;
    font-size: 16px;
  }

  textarea {
    min-height: 110px;
  }

  .inline-actions,
  .inline-form,
  .button-grid,
  .filter-links,
  .availability-buttons,
  .v14-card-actions,
  .canvas-actions,
  .v144-header-actions,
  .v145-index-actions,
  .v145-review-actions {
    align-items: stretch;
  }

  .inline-actions > *,
  .button-grid > *,
  .availability-buttons > *,
  .v14-card-actions > *,
  .canvas-actions > *,
  .v144-header-actions > *,
  .v145-index-actions > *,
  .v145-review-actions > * {
    flex: 1 1 140px;
  }

  .inline-actions form,
  .inline-form {
    width: 100%;
  }

  .table-wrap,
  .responsive-table,
  .panel:has(> table) {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  table {
    min-width: 680px;
  }

  .dashboard-kpis,
  .dashboard-grid,
  .cards,
  .presence-grid,
  .member-cards,
  .action-grid,
  .v143-overview-grid,
  .v144-overview,
  .v145-defense-summary {
    grid-template-columns: 1fr;
  }

  .event-line,
  .presence-player,
  .panel-header,
  .status-banner {
    align-items: flex-start;
    flex-direction: column;
  }

  .presence-choice {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    width: 100%;
  }

  .presence-choice label {
    display: grid;
    place-items: center;
    min-height: 50px;
  }

  .progress-row {
    grid-template-columns: 1fr;
    gap: 5px;
  }

  .user-card {
    align-items: flex-start;
  }

  .sidebar nav a {
    min-height: 44px;
    padding: 11px 12px;
  }

  /* Base Designer mobile */
  .designer-toolbar,
  .base-designer-intro,
  .canvas-heading,
  .v14-library-header,
  .v14-editor-header,
  .v14-canvas-header,
  .v143-summary-header,
  .v144-header,
  .v145-intro,
  .v145-review-header,
  .v145-sections-header,
  .v145-defense-header {
    align-items: stretch;
    flex-direction: column;
  }

  .designer-layout,
  .v14-editor-layout {
    display: flex;
    flex-direction: column;
  }

  .tools-panel,
  .palette-panel,
  .v14-tool-panel,
  .v14-material-panel {
    position: static;
    width: 100%;
  }

  .tools-panel {
    order: 2;
  }

  .canvas-panel {
    order: 1;
  }

  .palette-panel {
    order: 3;
  }

  .tool-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .tool-grid .tool {
    min-width: 0;
    padding: 9px 5px;
    font-size: .78rem;
  }

  .claim-fields {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    width: 100%;
  }

  .claim-fields label {
    max-width: none;
  }

  .claim-fields button {
    grid-column: 1 / -1;
  }

  .claim-summary {
    display: grid;
    grid-template-columns: 1fr;
    gap: 4px;
  }

  #canvasScroller,
  #canvas3DScroller,
  #v14CanvasScroller {
    max-width: calc(100vw - 52px);
    max-height: 58dvh;
    overflow: auto;
    touch-action: pan-x pan-y;
  }

  #designCanvas,
  #v14Canvas {
    touch-action: none;
  }

  #design3DCanvas {
    min-width: 620px;
  }

  .v142-controls {
    grid-template-columns: 1fr 1fr;
  }

  #materialPalette,
  #v14MaterialPalette {
    max-height: 44dvh;
  }

  .material-palette-row {
    grid-template-columns: minmax(0, 1fr) 44px;
  }

  .material-button,
  .favorite-block {
    min-height: 48px;
  }

  .v143-resource-form,
  .v144-create-form,
  .v144-update-form,
  .v145-generator-form,
  .v145-section-controls,
  .v145-profile-selector {
    grid-template-columns: 1fr;
  }

  .v143-resource-card header,
  .v144-zone-card header {
    grid-template-columns: 34px minmax(0, 1fr);
  }

  .v143-resource-card header > strong {
    grid-column: 1 / -1;
  }

  .v144-zone-grid,
  .v145-review-grid,
  .v145-defense-columns {
    grid-template-columns: 1fr;
  }

  .v144-zone-info {
    grid-template-columns: 1fr;
  }

  .v145-section-canvas-wrap {
    max-width: calc(100vw - 52px);
  }

  .v145-section-canvas-wrap canvas {
    min-width: 560px;
  }

  .v145-profile-selector label {
    min-height: 92px;
  }

  details > summary {
    min-height: 44px;
    padding: 11px 0;
  }

  .mobile-scroll-hint {
    display: block;
    margin: 5px 0 0;
    color: var(--muted);
    font-size: .72rem;
  }
}

@media (max-width: 430px) {
  .content {
    padding-inline: 9px;
  }

  .topbar {
    margin-inline: -9px;
    padding-inline: 9px;
  }

  .panel {
    padding: 12px;
  }

  .mobile-bottom-nav small {
    font-size: .59rem;
  }

  .tool-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .claim-fields {
    grid-template-columns: 1fr;
  }

  .claim-fields button {
    grid-column: auto;
  }

  .v142-controls {
    grid-template-columns: 1fr;
  }

  #canvasScroller,
  #canvas3DScroller,
  #v14CanvasScroller,
  .v145-section-canvas-wrap {
    max-width: calc(100vw - 42px);
  }
}

@media (orientation: landscape) and (max-height: 560px) and (max-width: 950px) {
  :root {
    --mobile-nav-height: 58px;
  }

  .mobile-bottom-nav {
    grid-template-columns: repeat(5, minmax(72px, 1fr));
    overflow-x: auto;
  }

  .mobile-bottom-nav a,
  .mobile-bottom-nav button {
    min-height: 44px;
  }

  #canvasScroller,
  #canvas3DScroller,
  #v14CanvasScroller {
    max-height: 72dvh;
  }
}
