.modal-route-dialog { display: flex; flex-direction: column; overflow: hidden; max-height: 90vh; max-height: 90dvh; }
.modal-route-scroll { overflow-y: auto; min-height: 0; overscroll-behavior: contain; }
.modal-route-toolbar, .article-modal-toolbar { display: flex; align-items: center; justify-content: flex-end; gap: .5rem; flex: 0 0 auto; padding: .5rem .75rem; background: var(--surface-white); border-bottom: 1px solid var(--border-light); position: relative; z-index: 15; }
.modal-route-toolbar .modal-close-btn { position: static; flex: 0 0 44px; width: 44px; height: 44px; background: var(--surface-alt); color: var(--text-dark); font-size: 1.75rem; }
.modal-copy-link { display: inline-flex; align-items: center; justify-content: center; gap: .5rem; min-height: 44px; padding: .6rem .8rem; border: 1px solid var(--border-light); border-radius: 10px; background: var(--surface-alt); color: var(--text-dark); cursor: pointer; font-size: .85rem; }
.modal-copy-link.is-copied { color: #10b981; }
.modal-copy-link:focus-visible, .modal-route-toolbar .modal-close-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.modal-share-status { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
#productModal .modal-content-inner { padding: 1.5rem; }
#productModalTitle { font-size: 1.5rem; line-height: 1.4; color: var(--text-dark); margin-bottom: 1rem; }
#productModalBody { display: grid; gap: 1.25rem; min-width: 0; color: var(--text-body); }
#productModalBody .product-img-box { min-height: 190px; }
#productModalBody .product-specs-table { width: 100%; }
#productModalBody .product-specs-table td { overflow-wrap: anywhere; }
[data-modal-route] { cursor: pointer; }
#projectModal .modal-specs-grid { min-width: 0; }
#projectModal .modal-spec-box { min-width: 0; overflow-wrap: anywhere; }
#projectModal h4 { color: var(--text-dark) !important; }
@media(max-width:640px) {
  .modal-route-scroll .modal-content-inner { padding: 1.25rem; }
  #productModal .modal-content-inner { padding: 1.25rem; }
  .modal-copy-link { font-size: .8rem; }
}

/* Temporary pause; set the body's data-project-modals-enabled to true to restore. */
body[data-project-modals-enabled="false"] .project-card { cursor: default; }

/* Compact toolbar remains outside the scrolling modal body. */
.modal-route-toolbar, #articleModal .article-modal-toolbar {
  gap: .35rem;
  padding: .2rem .6rem;
  min-height: 0;
}
.modal-route-toolbar .modal-copy-link, #articleModal .modal-copy-link {
  min-height: 40px;
  padding: .3rem .65rem;
  gap: .4rem;
  font-size: .8rem;
  line-height: 1.2;
  border-radius: 8px;
}
.modal-copy-link svg { width: 18px; height: 18px; flex-shrink: 0; }
.modal-route-toolbar .modal-close-btn, #articleModal #artModalCloseBtn {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  font-size: 1.5rem;
}
.modal-route-toolbar .modal-close-btn svg, #articleModal #artModalCloseBtn svg { width: 18px; height: 18px; }

/* Smaller desktop controls; retain comfortable touch targets on phones. */
@media (min-width: 641px) {
  .modal-route-toolbar .modal-copy-link, #articleModal .modal-copy-link {
    min-height: 32px;
    padding: .25rem .5rem;
    gap: .3rem;
    font-size: .72rem;
    border-radius: 7px;
  }
  .modal-route-toolbar .modal-close-btn, #articleModal #artModalCloseBtn {
    width: 32px;
    height: 32px;
    flex-basis: 32px;
    font-size: 1.2rem;
  }
  .modal-route-toolbar .modal-copy-link svg,
  .modal-route-toolbar .modal-close-btn svg,
  #articleModal .modal-copy-link svg,
  #articleModal #artModalCloseBtn svg { width: 16px; height: 16px; }
}

/* Consistent icon-only copy/share actions in every routed modal. */
.modal-route-toolbar .modal-icon-action, #articleModal .modal-icon-action {
  width: 32px;
  height: 32px;
  min-height: 32px;
  flex: 0 0 32px;
  padding: 0;
}
.modal-icon-action [data-copy-label] {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
@media(max-width:640px) {
  .modal-route-toolbar .modal-icon-action, #articleModal .modal-icon-action { width:40px; height:40px; min-height:40px; flex-basis:40px; }
}

.modal-share-status.is-visible {
  width: auto; height: auto; max-width: min(320px, 85vw); margin: 0;
  clip-path: none; white-space: normal; overflow: visible;
  top: 100%; right: .75rem; padding: .65rem .8rem;
  background: var(--surface-alt); color: var(--text-dark);
  border: 1px solid var(--border-light); border-radius: 8px;
  font-size: .8rem; line-height: 1.4; box-shadow: 0 4px 18px rgba(0,0,0,.2);
}

.modal-social-menu {
  position: absolute; z-index: 30; right: .6rem; top: calc(100% + .4rem);
  width: 290px; max-width: calc(100% - 1.2rem); box-sizing: border-box;
  padding: .85rem; border-radius: 14px; background: var(--surface-white);
  color: var(--text-dark); border: 1px solid var(--border-light);
  box-shadow: 0 12px 36px rgba(0,0,0,.3);
}
.modal-social-menu[hidden] { display: none; }
.modal-social-menu > strong { display: block; font-size: .85rem; margin-bottom: .7rem; }
.modal-social-options { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: .4rem; }
.modal-social-options > a, .modal-social-options > button, .modal-social-menu > button {
  display: flex; align-items: center; justify-content: center; gap: .4rem;
  min-width: 0; min-height: 44px; padding: .65rem .3rem;
  border: 1px solid var(--border-light); border-radius: 9px;
  background: var(--surface-alt); color: var(--text-dark); cursor: pointer;
  font: inherit; font-size: .7rem; text-decoration: none;
}
.modal-social-options > a, .modal-social-options > button { flex-direction: column; }
.modal-social-menu svg { width: 22px; height: 22px; flex-shrink: 0; }
.modal-social-menu [data-share-facebook] svg { color: #1877f2; }
.modal-social-menu [data-share-instagram] svg { color: #e34d8d; }
.modal-social-menu > button { width: 100%; margin-top: .5rem; font-size: .8rem; }
.modal-social-menu a:hover, .modal-social-menu button:hover { border-color: var(--primary); }
.modal-social-menu :focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
