.app {
  display: flex;
  height: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  background: var(--color-bg);
}

.app__sidebar {
  width: var(--sidebar-width);
  height: 100%;
  min-height: 0;
  background: var(--color-bg-elevated);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.app__brand {
  padding: 20px;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

.app__brand-logo {
  display: block;
  height: 32px;
  width: auto;
  max-width: 100%;
  object-fit: contain;
}

.app__brand-text {
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.03em;
  color: var(--color-text);
}

.app__brand-text span {
  color: var(--color-primary);
}

.app__brand-sub {
  font-size: 11px;
  color: var(--color-text-muted);
}

.app__sidebar-nav {
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.app__main {
  flex: 1;
  display: flex;
  overflow: hidden;
  min-width: 0;
  min-height: 0;
  height: 100%;
}

.app__left {
  width: 40%;
  height: 100%;
  display: flex;
  flex-direction: column;
  min-width: 360px;
  min-height: 0;
  background: var(--color-bg-elevated);
  border-right: 1px solid var(--color-border);
  overflow: hidden;
}

.app__right {
  width: 60%;
  height: 100%;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--color-bg-elevated);
  overflow: visible;
  position: relative;
}

.app__right-top {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
  min-height: 0;
  height: 100%;
}

.app__right-bottom {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  height: 320px;
  border-top: 2px solid var(--color-border);
  background: var(--color-bg-elevated);
  box-shadow: 0 -8px 24px rgba(17, 24, 39, 0.12);
  overflow: hidden;
  pointer-events: auto;
}

.app__right-bottom > .inspector-panel {
  flex: 1;
  min-height: 0;
}

.app__right--inspector-closed .app__right-bottom {
  display: none;
}

.app__toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-accent-lavender);
}

.app__toolbar-spacer {
  flex: 1;
}

/* Tablette : panneaux empilés (chat au-dessus de l'aperçu) */
@media (min-width: 769px) and (max-width: 1024px) {
  .app__main {
    flex-direction: column;
  }

  .app__left,
  .app__right {
    width: 100%;
    min-width: 0;
    height: 50%;
  }

  .app__left {
    border-right: none;
    border-bottom: 1px solid var(--color-border);
  }

  .app__sidebar {
    width: 220px;
  }
}

/* ===== Mobile : navigation par onglets plein écran (style iPhone) ===== */
.app__mobile-nav {
  display: none;
}

@media (max-width: 768px) {
  .app {
    flex-direction: column;
    overflow: hidden;
    padding-top: env(safe-area-inset-top, 0);
  }

  .app__sidebar,
  .app__main {
    display: none;
    width: 100%;
    min-width: 0;
    min-height: 0;
    height: auto;
    max-height: none;
    flex: 1 1 auto;
    border-right: none;
  }

  .app__sidebar {
    border-bottom: none;
  }

  .app[data-mobile-view="conversations"] .app__sidebar {
    display: flex;
  }

  .app[data-mobile-view="chat"] .app__main,
  .app[data-mobile-view="preview"] .app__main {
    display: flex;
    flex-direction: column;
  }

  .app__left,
  .app__right {
    width: 100%;
    min-width: 0;
    height: 100%;
    border-right: none;
    border-bottom: none;
  }

  .app[data-mobile-view="preview"] .app__left {
    display: none;
  }

  .app[data-mobile-view="chat"] .app__right {
    display: none;
  }

  .app__toolbar {
    padding: 8px 10px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .app__toolbar::-webkit-scrollbar {
    display: none;
  }

  .app__toolbar .btn {
    min-height: 38px;
    flex-shrink: 0;
  }

  .app__mobile-nav {
    display: flex;
    flex-shrink: 0;
    align-items: stretch;
    background: var(--color-bg-elevated);
    border-top: 1px solid var(--color-border);
    box-shadow: 0 -4px 16px rgba(17, 24, 39, 0.06);
    padding-bottom: env(safe-area-inset-bottom, 0);
  }

  .app__mobile-nav-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-height: 54px;
    padding: 8px 4px;
    font-size: 11px;
    font-weight: 500;
    color: var(--color-text-muted);
    transition: color var(--transition), background var(--transition);
  }

  .app__mobile-nav-btn:active {
    background: var(--color-bg-hover);
  }

  .app__mobile-nav-btn--active {
    color: var(--color-primary);
  }

  .app__mobile-nav-icon {
    display: flex;
    line-height: 1;
  }
}

@media (min-width: 1600px) {
  .app__left {
    width: 40%;
  }

  .app__right {
    width: 60%;
  }
}
