/* Final spacing and control hierarchy pass. Loaded last on purpose. */
header {
  gap: 24px;
  padding-inline: clamp(18px, 4vw, 56px);
}

.head-right {
  flex: 0 1 auto;
  gap: 10px;
  margin-left: auto;
}

.local {
  max-width: 160px;
  line-height: 1.25;
}

#lang {
  width: 72px;
  min-height: 42px;
  flex: 0 0 72px;
  padding: 8px 10px;
}

.icon-btn {
  width: 42px;
  min-width: 42px;
  height: 42px;
  min-height: 42px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: 1px solid transparent;
  transition: background-color .16s ease, border-color .16s ease, transform .16s ease;
}

header .icon-btn {
  border-color: var(--ref-border, var(--line));
  background: #fff;
  font-size: 1.18rem;
}

header .icon-btn:hover {
  border-color: #c9c6df;
  background: #f3f2fa;
}

header .icon-btn:active,
.mobile-nav button:active,
.share-channel:active {
  transform: scale(.97);
}

.install-button {
  min-height: 42px;
  border-radius: 11px;
}

.shared-actions,
.pending-actions,
.collab-buttons,
.dialog-actions,
.quick-confirm-actions {
  gap: 10px;
}

.shared-actions button,
.pending-actions button,
.collab-buttons button,
.dialog-actions button,
.quick-confirm-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.pending-item {
  gap: 18px;
  padding: 16px;
}

.pending-actions button {
  min-width: 92px;
}

.board-toolbar {
  gap: 12px;
}

.filters {
  gap: 6px;
}

.filters button {
  min-height: 40px;
  padding-inline: 13px;
}

.share-channel {
  transition: background-color .16s ease, border-color .16s ease, transform .16s ease;
}

.mobile-nav button {
  -webkit-tap-highlight-color: transparent;
}

@media (max-width: 1100px) and (min-width: 691px) {
  .local { display: none; }
  .head-right { gap: 8px; }
}

@media (max-width: 690px) {
  body {
    padding-bottom: calc(84px + env(safe-area-inset-bottom));
  }

  header {
    height: 66px;
    gap: 8px;
    padding-inline: 12px;
  }

  .brand {
    min-width: 0;
    gap: 7px;
    font-size: 1.26rem;
  }

  .brand-icon {
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
  }

  .head-right {
    min-width: 0;
    gap: 6px;
  }

  .head-right .header-feedback,
  .head-right .header-share {
    display: none !important;
  }

  .install-button,
  .head-right .icon-btn,
  #lang {
    width: 40px !important;
    min-width: 40px;
    height: 40px;
    min-height: 40px;
    flex: 0 0 40px;
    border-radius: 11px;
  }

  #lang {
    padding: 5px 4px !important;
    text-align: center;
  }

  main {
    padding: 12px 12px 8px;
  }

  .shared-bar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    min-height: 62px;
    padding: 10px 11px;
  }

  .shared-copy {
    gap: 9px;
  }

  .shared-copy span:last-child {
    max-width: 150px;
  }

  .shared-actions .primary.compact {
    min-height: 44px;
    max-width: 116px;
    padding: 8px 10px;
  }

  .startup-guide {
    gap: 9px;
  }

  .startup-step {
    gap: 11px;
    min-height: 66px;
    padding: 10px 11px;
  }

  .task-inbox {
    margin-bottom: 14px;
  }

  .pending-item {
    gap: 12px;
    padding: 14px;
  }

  .pending-actions {
    gap: 8px;
  }

  .pending-actions button {
    min-width: 0;
    min-height: 52px;
  }

  .quick-add {
    padding: 18px 14px 16px;
  }

  .quick-flow {
    gap: 10px;
  }

  .quick-add-member,
  .quick-submit,
  .quick-location {
    border-radius: 12px;
  }

  .board-heading {
    gap: 12px;
  }

  .board-toolbar {
    gap: 10px;
  }

  .filters {
    gap: 4px;
    padding: 4px;
  }

  .filters button {
    min-height: 44px;
    padding: 8px 5px;
  }

  .task {
    gap: 11px;
    padding: 16px 14px 14px;
  }

  .card-edit {
    width: auto;
    min-width: 48px;
    min-height: 42px;
    border-radius: 10px;
    background: #f2f1f8;
  }

  .collab-row {
    gap: 11px;
    padding-top: 12px;
  }

  .collab-buttons {
    gap: 8px;
  }

  .collab-buttons button {
    min-height: 50px;
    border-radius: 12px;
  }

  .share-grid,
  .social-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .share-channel {
    min-height: 84px;
    padding: 11px 8px;
    border-radius: 14px;
  }

  .share-channel span {
    width: 40px;
    height: 40px;
  }

  .dialog-top {
    gap: 12px;
    margin-bottom: 16px;
  }

  .dialog-actions,
  .quick-confirm-actions {
    gap: 10px;
  }

  .mobile-nav {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px;
    min-height: 74px;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  }

  .mobile-nav button {
    min-width: 0;
    min-height: 58px;
    gap: 5px;
    padding: 5px 2px;
    border-radius: 12px;
  }

  .mobile-nav span {
    width: 32px;
    height: 28px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    font-size: 1.08rem;
  }

  .mobile-nav b {
    max-width: 100%;
    overflow: hidden;
    font-size: .7rem;
    line-height: 1.1;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-nav .mobile-add span {
    width: 40px;
    height: 32px;
    border-radius: 11px;
    font-size: 1.35rem;
  }
}

@media (max-width: 370px) {
  header { padding-inline: 9px; }
  .brand { font-size: 1.14rem; }
  .brand-icon { width: 36px; height: 36px; flex-basis: 36px; }
  .head-right { gap: 4px; }
  .install-button,
  .head-right .icon-btn,
  #lang {
    width: 38px !important;
    min-width: 38px;
    flex-basis: 38px;
  }
  .shared-copy span:last-child { max-width: 118px; }
  .mobile-nav b { font-size: .66rem; }
}
