.nav-toggle {
  display: none;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid rgba(31, 36, 48, 0.15);
  background: var(--panel);
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
}

.nav-toggle span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--ink);
  border-radius: 999px;
}

.sidenav-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 20;
}

body.nav-open {
  overflow: hidden;
}

.migration-results {
  margin-top: var(--space-3);
  display: grid;
  gap: var(--space-3);
}

.migration-results__stats {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.migration-results__columns {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.migration-empty {
  color: var(--muted);
  font-size: 13px;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  box-shadow: none;
}

.settings-grid {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.settings-field {
  display: grid;
  gap: 6px;
}

.settings-field > span {
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
}

.settings-field input[type='text'],
.settings-field input[type='url'],
.settings-field select,
.settings-field textarea {
  width: 100%;
  border: 1px solid rgba(31, 36, 48, 0.2);
  border-radius: 10px;
  padding: 10px 12px;
  background: #fff;
  color: var(--ink);
  font-size: 14px;
}

.settings-field select[multiple] {
  min-height: 148px;
}

.settings-field textarea {
  resize: vertical;
  min-height: 72px;
}

.settings-help {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.settings-field--inline {
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 10px;
}

.actions--inline {
  display: flex;
  justify-content: flex-start;
  align-items: center;
}

.tag-page-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.tag-page-item {
  border: 1px solid rgba(31, 36, 48, 0.15);
  border-radius: 10px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.65);
  display: grid;
  gap: 6px;
}

.tag-page-item__name {
  font-size: 12px;
  color: var(--muted);
  font-weight: 700;
}

.tag-group-list {
  display: grid;
  gap: 10px;
}

.tag-page-library {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px;
  max-height: 180px;
  overflow: auto;
  padding-right: 4px;
}

.tag-page-library-item {
  border: 1px solid rgba(31, 36, 48, 0.12);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.7);
  padding: 8px 10px;
}

.tag-page-library-item .tag-group-item__head {
  gap: 6px;
}

.tag-page-library-item .tag-group-item__meta {
  font-size: 11px;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tag-group-item {
  border: 1px solid rgba(31, 36, 48, 0.15);
  border-radius: 10px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.7);
  display: grid;
  gap: 8px;
}

.tag-group-item__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.tag-group-item__meta {
  font-size: 12px;
  color: var(--muted);
}

@media (max-width: 960px) {
  .nav-toggle {
    display: flex; /* IMPORTANT: when visible */
    flex-direction: column; /* ✅ makes 3 lines vertical */
    align-items: center;
    justify-content: center;
    gap: 4px;
  }

  .app-shell {
    grid-template-columns: 1fr;
    overflow-x: hidden;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100%;
    width: 260px;
    max-width: 82%;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    z-index: 30;
    overflow-y: auto;
  }

  .app-shell.is-nav-open .sidebar {
    transform: translateX(0);
  }

  .sidenav-backdrop {
    display: block;
  }

  .app-shell.is-nav-open .sidenav-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

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

@media (max-width: 720px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-2);
  }

  .topbar h1 {
    font-size: 26px;
  }

  .card__row {
    flex-direction: column;
    align-items: flex-start;
    width: 100%;
    min-width: 0;
  }

  .topbar__actions {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
  }

  .topbar__actions > * {
    width: 100%;
    justify-content: center;
  }

  .actions {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
  }

  .actions > * {
    width: 100%;
  }

  .actions input,
  .actions select,
  .actions button {
    width: 100%;
    max-width: 100%;
  }
}

@media (max-width: 600px) {
  .sidebar {
    width: 280px;
    max-width: calc(100% - 16px);
    padding: var(--space-3);
  }

  .main {
    padding: var(--space-3);
  }

  .card {
    padding: var(--space-4);
  }

  .brand__mark {
    width: 38px;
    height: 38px;
    font-size: 18px;
  }

  .topbar__actions {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
  }

  .topbar__actions > * {
    width: 100%;
    justify-content: center;
  }

  .sidebar__footer {
    display: none;
  }
}

@media (max-width: 420px) {
  .topbar h1 {
    font-size: 22px;
  }

  .card {
    padding: var(--space-3);
  }

  .brand__text {
    display: none;
  }

  .btn {
    padding: 9px 14px;
  }

  .pill {
    font-size: 11px;
    padding: 4px 10px;
  }

  .nav-toggle {
    width: 36px;
    height: 36px;
    border-radius: 10px;
  }

  .nav-toggle span {
    width: 16px;
  }
}
