.shell {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  min-height: 100vh;
}

.menu-toggle,
.menu-overlay {
  display: none;
}

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  padding: 16px;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(16, 19, 26, 0.96);
  box-shadow: var(--shadow);
  z-index: 10;
  overflow-y: auto;
}

.sidebar-title {
  margin: 0 0 14px;
  color: var(--text);
  font-size: 18px;
  font-weight: 900;
  letter-spacing: -0.03em;
}

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.nav-group {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  overflow: hidden;
}

.nav-group summary {
  position: relative;
  padding: 12px 14px;
  color: var(--text);
  font-size: 14px;
  font-weight: 850;
  cursor: pointer;
  user-select: none;
  list-style: none;
}

.nav-group summary::-webkit-details-marker {
  display: none;
}

.nav-group summary::after {
  content: "▾";
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  transition: transform 120ms ease;
}

.nav-group:not([open]) summary::after {
  transform: translateY(-50%) rotate(-90deg);
}

.nav-group-items {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0 10px 10px;
}

.nav-help {
  margin: 4px 4px 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.nav-btn {
  width: 100%;
  margin: 0;
  text-align: left;
}

.nav-btn.active {
  background: linear-gradient(180deg, var(--primary), var(--primary-strong));
  border-color: transparent;
  color: #06101f;
  font-weight: 900;
}

.main-content {
  min-width: 0;
}

.tool-view {
  display: none;
}

.tool-view.active {
  display: block;
}

.converter-layout {
  display: grid;
  grid-template-columns: minmax(280px, 420px) minmax(320px, 1fr);
  gap: 16px;
  padding: 16px;
}

.media-preview,
.media-canvas {
  width: 100%;
  max-height: 64vh;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #0f131b;
  object-fit: contain;
}

.media-canvas {
  image-rendering: pixelated;
}

.download-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 10px 12px;
  border-radius: 10px;
  background: linear-gradient(180deg, var(--primary), var(--primary-strong));
  color: #06101f;
  font-weight: 900;
  text-decoration: none;
}

progress {
  width: 100%;
  height: 14px;
}

@media (max-width: 900px) {
  .shell {
    display: block;
    min-height: 100vh;
  }

  .main-content {
    width: 100%;
    min-width: 0;
  }

  .menu-toggle {
    display: inline-flex;
    position: fixed;
    left: 10px;
    top: 10px;
    z-index: 80;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 9px 12px;
    border-radius: 999px;
    background: linear-gradient(180deg, var(--primary), var(--primary-strong));
    color: #06101f;
    border-color: transparent;
    font-weight: 900;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  }

  .menu-overlay {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 60;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity 160ms ease;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 70;
    width: min(82vw, 300px);
    max-width: 300px;
    height: 100dvh;
    padding: 16px 12px;
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    border-bottom: 0;
    transform: translateX(-105%);
    transition: transform 180ms ease;
    will-change: transform;
  }

  body.menu-open {
    overflow: hidden;
  }

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

  body.menu-open .menu-overlay {
    opacity: 1;
    pointer-events: auto;
  }

  .app-header {
    padding-top: 64px;
  }

  .sidebar-title {
    margin-bottom: 12px;
    font-size: 16px;
  }

  .side-nav {
    gap: 10px;
  }

  .nav-group summary {
    padding: 11px 32px 11px 12px;
    font-size: 14px;
  }

  .nav-group summary::after {
    right: 12px;
  }

  .nav-group-items {
    gap: 6px;
    padding: 0 8px 8px;
  }

  .nav-help {
    display: block;
    font-size: 11px;
  }

  .nav-btn {
    padding: 10px 9px;
    text-align: left;
    font-size: 13px;
    line-height: 1.25;
    white-space: normal;
  }

  .converter-layout {
    grid-template-columns: 1fr;
    padding: 10px;
    gap: 10px;
  }
}
