/* Milestone 8A — mobile Map / Search / Add / List information architecture. */
.command-surface {
  display: none;
}

@media (max-width: 899px) {
  body[data-view="detail"] .mobile-command-bar,
  body[data-view="detail"] .command-surface {
    display: none !important;
  }

  .map-toolbar .location-search {
    display: none;
  }

  .command-surface[hidden] {
    display: none !important;
  }

  .command-surface:not([hidden]) {
    position: fixed;
    z-index: 44;
    inset:
      calc(var(--header-height) + 27px)
      0
      calc(var(--mobile-command-height) + env(safe-area-inset-bottom, 0px))
      0;
    display: block;
    overflow-y: auto;
    overscroll-behavior: contain;
    background:
      linear-gradient(180deg, rgba(238, 243, 248, .7), transparent 130px),
      var(--cgb-warm-50);
    -webkit-overflow-scrolling: touch;
  }

  .command-surface__shell {
    width: min(100%, 34rem);
    min-height: 100%;
    margin: 0 auto;
    padding: 18px 16px calc(32px + env(safe-area-inset-bottom, 0px));
  }

  .command-surface__header {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr);
    align-items: center;
    gap: 12px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--cgb-neutral-200);
  }

  .command-surface__header h2 {
    margin: 2px 0 0;
    color: var(--cgb-navy-950);
    font-family: var(--font-display);
    font-size: clamp(1.65rem, 7vw, 2.15rem);
    line-height: 1;
  }

  .command-surface__back {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    padding: 0;
    color: var(--cgb-navy-950);
    background: var(--cgb-white);
    border: 1px solid var(--cgb-neutral-300);
    border-radius: var(--radius-sm);
    clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px);
    box-shadow: var(--shadow-xs);
  }

  .command-surface__intro {
    margin: 16px 0 18px;
    max-width: 38rem;
    color: var(--cgb-ink-700);
    font-size: .92rem;
    line-height: 1.45;
  }

  .command-intent {
    display: grid;
    gap: 3px;
    margin: -2px 0 14px;
    padding: 12px 14px 12px 17px;
    color: var(--cgb-navy-950);
    background: var(--cgb-gold-50);
    border-left: 4px solid var(--cgb-gold-400);
  }

  .command-intent strong {
    font-family: var(--font-condensed);
    font-size: .86rem;
    letter-spacing: .055em;
    text-transform: uppercase;
  }

  .command-intent span {
    color: var(--cgb-ink-700);
    font-size: .78rem;
    line-height: 1.35;
  }

  .search-surface__form-slot {
    min-height: 56px;
  }

  .command-surface .location-search {
    position: relative;
    width: 100%;
  }

  .command-surface .search-field {
    min-height: 54px;
    display: grid;
    grid-template-columns: 22px minmax(0, 1fr) auto;
    align-items: center;
    gap: 9px;
    padding: 5px 5px 5px 14px;
    background: var(--cgb-white);
    border: 1px solid var(--cgb-neutral-300);
    border-radius: var(--radius-sm);
    clip-path: polygon(10px 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%, 0 10px);
    box-shadow: var(--shadow-sm);
  }

  .command-surface .search-field:focus-within {
    border-color: var(--cgb-gold-400);
    box-shadow: var(--focus-ring), var(--shadow-sm);
  }

  .command-surface .search-field input {
    min-width: 0;
    padding: 12px 0;
    color: var(--cgb-ink-900);
    background: transparent;
    border: 0;
    outline: 0;
    font-size: 16px;
  }

  .command-surface .search-submit {
    min-height: 42px;
    padding: 0 15px;
    color: var(--cgb-white);
    background: var(--cgb-navy-950);
    border: 0;
    border-radius: var(--radius-sm);
    clip-path: polygon(7px 0, 100% 0, 100% calc(100% - 7px), calc(100% - 7px) 100%, 0 100%, 0 7px);
    font-family: var(--font-condensed);
    font-size: .78rem;
    font-weight: 800;
    letter-spacing: .055em;
    text-transform: uppercase;
  }

  .command-surface .search-suggestions {
    position: static;
    width: 100%;
    max-height: none;
    margin-top: 8px;
    overflow: visible;
    background: var(--cgb-white);
    border: 1px solid var(--cgb-neutral-200);
    border-radius: 0;
    box-shadow: var(--shadow-sm);
  }

  .command-surface .search-result-group {
    display: grid;
    border-bottom: 1px solid var(--cgb-neutral-200);
  }

  .command-surface .search-result-group:last-child {
    border-bottom: 0;
  }

  .command-surface .search-result-group__heading {
    padding: 11px 14px 5px;
    color: var(--cgb-ink-500);
    font-family: var(--font-condensed);
    font-size: .7rem;
    letter-spacing: .08em;
    text-transform: uppercase;
  }

  .command-surface .search-result-group__note,
  .command-surface .external-search-status {
    padding: 0 14px 10px;
    color: var(--cgb-ink-500);
    font-size: .72rem;
  }

  .command-surface .search-suggestions button,
  .command-surface .external-place-result {
    min-height: 58px;
    padding: 11px 14px;
    background: var(--cgb-white);
    border: 0;
    border-top: 1px solid var(--cgb-neutral-100);
    border-radius: 0;
  }

  .command-surface .search-suggestions button:hover,
  .command-surface .search-suggestions button:focus-visible,
  .command-surface .external-place-result:hover,
  .command-surface .external-place-result:focus-visible {
    background: var(--cgb-navy-50);
  }

  .command-surface .missing-location-link {
    margin: 6px 14px 14px;
  }

  .search-surface__legend {
    display: grid;
    gap: 0;
    margin-top: 18px;
    background: var(--cgb-white);
    border-top: 1px solid var(--cgb-neutral-200);
    border-bottom: 1px solid var(--cgb-neutral-200);
  }

  .search-surface__legend > div {
    min-height: 62px;
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    padding: 10px 2px;
    border-bottom: 1px solid var(--cgb-neutral-100);
  }

  .search-surface__legend > div:last-child {
    border-bottom: 0;
  }

  .search-surface__legend span:last-child {
    display: grid;
    gap: 2px;
  }

  .search-surface__legend strong {
    color: var(--cgb-navy-950);
    font-size: .82rem;
  }

  .search-surface__legend small {
    color: var(--cgb-ink-500);
    font-size: .7rem;
    line-height: 1.3;
  }

  .search-surface__marker {
    position: relative;
    width: 20px;
    height: 26px;
    display: block;
    margin-left: 3px;
    transform: rotate(45deg);
    border-radius: 50% 50% 50% 0;
  }

  .search-surface__marker::after {
    content: '';
    position: absolute;
    inset: 6px;
    background: var(--cgb-white);
    border-radius: 50%;
  }

  .search-surface__marker--cgb {
    background: var(--cgb-navy-950);
  }

  .search-surface__marker--place {
    background: var(--cgb-white);
    border: 2px solid var(--cgb-navy-950);
  }

  .search-surface__marker--place::after {
    background: var(--cgb-navy-950);
  }

  .add-context {
    display: grid;
    gap: 4px;
    margin-bottom: 15px;
    padding: 13px 15px;
    color: var(--cgb-white);
    background: var(--cgb-navy-950);
    clip-path: polygon(10px 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%, 0 10px);
  }

  .add-context .eyebrow {
    color: rgba(255, 255, 255, .68);
  }

  .add-context strong {
    font-family: var(--font-display);
    font-size: 1.08rem;
  }

  .add-context p {
    margin: 0;
    color: rgba(255, 255, 255, .76);
    font-size: .72rem;
    line-height: 1.35;
  }

  .add-actions {
    display: grid;
    background: var(--cgb-white);
    border-top: 1px solid var(--cgb-neutral-200);
    border-bottom: 1px solid var(--cgb-neutral-200);
  }

  .add-action {
    min-height: 78px;
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr) 20px;
    align-items: center;
    gap: 11px;
    padding: 13px 4px;
    text-align: left;
    color: var(--cgb-ink-900);
    background: var(--cgb-white);
    border: 0;
    border-bottom: 1px solid var(--cgb-neutral-100);
    border-radius: 0;
  }

  .add-action:last-of-type {
    border-bottom: 0;
  }

  .add-report-options {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1px;
    padding: 0 0 10px 45px;
    background: var(--cgb-navy-50);
    border-top: 1px solid var(--cgb-neutral-100);
  }

  .add-report-options[hidden] {
    display: none !important;
  }

  .add-report-options button {
    min-height: 42px;
    padding: 9px 12px;
    text-align: left;
    color: var(--cgb-navy-900);
    background: var(--cgb-white);
    border: 0;
    border-left: 3px solid var(--cgb-gold-400);
    border-radius: 0;
    font-size: .76rem;
    font-weight: 750;
  }

  .add-report-options button:hover,
  .add-report-options button:focus-visible {
    background: var(--cgb-gold-50);
  }

  .add-action:hover,
  .add-action:focus-visible {
    background: var(--cgb-navy-50);
  }

  .add-action > span:nth-child(2) {
    display: grid;
    gap: 4px;
  }

  .add-action strong {
    color: var(--cgb-navy-950);
    font-family: var(--font-display);
    font-size: 1rem;
    line-height: 1.05;
  }

  .add-action small {
    color: var(--cgb-ink-500);
    font-size: .7rem;
    line-height: 1.3;
  }

  .add-action__icon {
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    color: var(--cgb-navy-950);
    background: var(--cgb-navy-50);
    border: 1px solid var(--cgb-neutral-200);
    border-radius: 50%;
  }

  .add-action--primary .add-action__icon {
    color: var(--cgb-navy-950);
    background: var(--cgb-gold-400);
    border-color: var(--cgb-gold-400);
  }

  .add-missing-location {
    display: inline-flex;
    margin-top: 18px;
    color: var(--cgb-navy-900);
    font-size: .8rem;
    font-weight: 700;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
  }

  .mobile-command-bar {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .mobile-command {
    position: relative;
  }

  .mobile-command--add {
    overflow: visible;
  }

  .mobile-command__add-mark {
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    margin-top: -9px;
    color: var(--cgb-navy-950);
    background: var(--cgb-gold-400);
    border: 2px solid var(--cgb-white);
    border-radius: 50%;
    box-shadow: 0 2px 0 rgba(1, 1, 51, .16);
    font-size: 1.35rem;
    font-weight: 500;
    line-height: 1;
  }

  .mobile-command[aria-current="page"] {
    color: var(--cgb-navy-950);
  }

  .mobile-command[aria-current="page"]::after {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    width: 24px;
    height: 3px;
    transform: translateX(-50%);
    background: var(--cgb-gold-400);
  }

  .mobile-command--add[aria-current="page"]::after {
    display: none;
  }

  .tray--peek {
    height: 104px;
  }

  .tray-peek {
    padding-bottom: 9px;
  }

  .tray-summary strong {
    font-family: var(--font-display);
    font-size: 1rem;
  }

  .tray-summary small {
    max-width: 18rem;
    font-size: .68rem;
    line-height: 1.3;
  }
}

@media (min-width: 900px) {
  .mobile-command-bar {
    position: fixed;
    z-index: 46;
    top: calc(var(--header-height) + 22px);
    right: 24px;
    bottom: auto;
    left: auto;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(12px, .5fr) auto;
    align-items: center;
    column-gap: 0;
    width: min(390px, 34vw);
    height: 52px;
    min-height: 52px;
    padding: 5px 6px;
    border: 0;
    border-bottom: 1px solid rgba(1, 1, 51, .12);
    border-radius: var(--radius-lg, 18px) var(--radius-lg, 18px) 0 0;
    background: rgba(255, 255, 255, .98);
    box-shadow: none;
    backdrop-filter: blur(12px);
  }

  .mobile-command {
    display: flex;
    min-width: 0;
    min-height: 40px;
    flex-direction: row;
    gap: 6px;
    padding: 7px 10px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--cgb-navy-800, #0b2856);
    font-size: .72rem;
    letter-spacing: .01em;
  }

  #mobile-search-button {
    display: none;
  }

  #mobile-list-button {
    grid-row: 1;
    grid-column: 1;
    width: 100%;
    justify-content: center;
    border: 1px solid rgba(1, 1, 51, .18);
    border-radius: 9px 0 0 9px;
  }

  #mobile-map-button {
    grid-row: 1;
    grid-column: 2;
    width: 100%;
    justify-content: center;
    border: 1px solid rgba(1, 1, 51, .18);
    border-left: 0;
    border-radius: 0 9px 9px 0;
  }

  .mobile-command:hover:not(:disabled),
  .mobile-command:focus-visible {
    background: var(--cgb-neutral-100, #f2f2f2);
  }

  .mobile-command[aria-current="page"] {
    background: var(--cgb-navy-950, #010133);
    color: var(--cgb-white, #fff);
  }

  #mobile-map-button:disabled {
    opacity: .42;
    cursor: default;
  }

  .mobile-command--add,
  .mobile-command--add[aria-current="page"] {
    grid-row: 1;
    grid-column: 4;
    min-height: 34px;
    margin: 0 0 0 12px;
    padding: 5px 9px;
    border: 1px solid var(--cgb-gold-400, #fdb515);
    background: var(--cgb-gold-50, #fff7dc);
    color: var(--cgb-navy-950, #010133);
  }

  .mobile-command--add:hover:not(:disabled),
  .mobile-command--add:focus-visible {
    background: rgba(253, 181, 21, .18);
  }

  .mobile-command__add-mark {
    width: 15px;
    height: 15px;
    margin-top: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    font-size: .9rem;
  }

  .command-surface[hidden] {
    display: none !important;
  }

  .command-surface:not([hidden]) {
    position: fixed;
    z-index: 90;
    inset: var(--header-height) 0 var(--footer-height);
    display: grid !important;
    place-items: start center;
    overflow: auto;
    padding: 28px;
    background: rgba(1, 1, 51, .38);
    backdrop-filter: blur(6px);
  }

  .command-surface__shell {
    width: min(100%, 680px);
    max-height: calc(100dvh - var(--header-height) - var(--footer-height) - 56px);
    overflow: auto;
    padding: 24px;
    border: 1px solid rgba(1, 1, 51, .12);
    border-radius: 22px;
    background: var(--cgb-white, #fff);
    box-shadow: 0 24px 64px rgba(1, 1, 51, .26);
  }

  .command-surface__header {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    margin-bottom: 10px;
  }

  .command-surface__header h2 {
    margin: 2px 0 0;
    color: var(--cgb-navy-950, #010133);
    font-family: var(--font-display);
    font-size: 1.75rem;
  }

  .command-surface__back {
    display: grid;
    flex: 0 0 auto;
    width: 42px;
    height: 42px;
    place-items: center;
    border: 1px solid var(--cgb-neutral-200, #dfe3e8);
    border-radius: 12px;
    background: white;
    color: var(--cgb-navy-800, #0b2856);
    cursor: pointer;
  }

  .command-surface__intro {
    margin: 0 0 18px 56px;
    color: var(--cgb-ink-500, #657083);
  }

  .command-surface--search .command-surface__shell {
    width: min(100%, 760px);
  }

  .command-surface .location-search,
  .command-surface .search-surface__form-slot {
    width: 100%;
  }

  .command-surface .search-field {
    width: 100%;
  }

  .command-surface .search-suggestions:not([hidden]) {
    position: static;
    display: grid;
    width: 100%;
    max-height: min(50vh, 430px);
    margin-top: 10px;
    overflow: auto;
  }

  .command-intent:not([hidden]),
  .add-context:not([hidden]) {
    display: grid;
    gap: 4px;
    margin-bottom: 12px;
    padding: 13px 15px;
    border: 1px solid var(--cgb-neutral-200, #dfe3e8);
    border-radius: 14px;
    background: var(--cgb-neutral-100, #f2f4f7);
  }

  .add-context strong {
    color: var(--cgb-navy-950, #010133);
    font-size: 1rem;
  }

  .add-context p {
    margin: 0;
    color: var(--cgb-ink-500, #657083);
    line-height: 1.4;
  }

  .add-actions {
    display: grid;
    gap: 10px;
  }

  .add-action {
    display: grid;
    grid-template-columns: 36px minmax(0, 1fr) 20px;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-height: 68px;
    padding: 12px 14px;
    border: 1px solid var(--cgb-neutral-200, #dfe3e8);
    border-radius: 14px;
    background: white;
    color: var(--cgb-navy-950, #010133);
    text-align: left;
    cursor: pointer;
  }

  .add-action:hover,
  .add-action:focus-visible {
    border-color: var(--cgb-navy-700, #153f75);
    background: var(--cgb-neutral-100, #f2f4f7);
  }

  .add-action > span:not(.add-action__icon) {
    display: grid;
    gap: 3px;
  }

  .add-action small {
    color: var(--cgb-ink-500, #657083);
  }

  .add-missing-location:not([hidden]) {
    display: inline-flex;
    margin-top: 16px;
  }
}
