/* some overrides */
:root {
  --pico-line-height: 1.0; 
  --pico-font-size: 1rem;
}

/* Layout */
.container { display:flex; flex-direction:column; gap:1rem; }
.grid { display:grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap:.75rem; }
fieldset { border:1px solid gray; padding:.4rem; border-radius:.3rem; }
.cats { display:flex; gap:2rem; flex-wrap:wrap; }
.range { display:inline-block; vertical-align: middle; align-items:center; gap:.5rem; }
.actions { display:flex; gap:3.0rem; }
.post-query-filters {
  display: flex;
  flex-direction: column;
  gap: .35rem;
}
.post-query-filters fieldset {
  padding: .3rem .45rem;
}
.post-query-filters legend {
  margin-bottom: .15rem;
}
.post-query-filters label {
  display: flex;
  flex-direction: column;
  gap: .2rem;
  margin-bottom: 0;
}
/* .post-query-filters input:not([type="checkbox"]) {
  margin-bottom: 10px;
} */

.post-query-filters > .filter-row {
  display: block;
  width: 100%;
}
.post-query-filters > .filter-row:nth-of-type(1),
.post-query-filters > .filter-row:nth-of-type(2) {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .5rem .6rem;
  align-items: start;
}
.post-query-filters > .filter-row:nth-of-type(1) > div,
.post-query-filters > .filter-row:nth-of-type(2) > div {
  min-width: 0;
}
.post-query-filters > .filter-row:nth-of-type(2) > .range {
  display: block;
}
.post-query-filters > .filter-row:nth-of-type(1) .filter-ctl,
.post-query-filters > .filter-row:nth-of-type(2) .filter-ctl {
  width: 100%;
  box-sizing: border-box;
}
.post-query-filters > .filter-row.actions-row {
  display: inline-flex;
  gap: .5rem .6rem;
}
.post-query-filters .classes-fieldset {
  min-width: 0;
}
.post-query-filters .filter-actions {
  display: flex;
  justify-content: flex-end;
}
.end-of-results td { color: var(--muted-color); }

/* top localization banner */
.locbar {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 1rem;
  padding: .6rem .8rem;
  border: 1px solid gray;
  border-radius: .35rem;
  cursor: pointer;
}
.legend {
  padding: 0 .35rem;
  font-weight: 600;
}

.locbar-top {
  width: 100%;
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  gap: .5rem;
}
.locbar-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: .6rem .3rem;
}
.locbar-item {
  min-width: 0;
}
.locbar-title {
  display: block;
  font-size: 1.05rem;
  line-height: 1.15;
  margin-bottom: .08rem;
}
.locbar-detail {
  display: block;
  line-height: 1.15;
  white-space: normal;
  overflow-wrap: anywhere;
}
.locbar-ai {
  display: flex;
  align-items: flex-start;
  gap: .4rem;
  font-size: .95rem;
  line-height: 1.2;
}
.locbar-ai-text {
  white-space: normal;
  overflow-wrap: anywhere;
}

/* buttons in fieldset to line up across the page using flex grid */
fieldset .actions { display: flex; flex-wrap: wrap }

/* for the sortable headers */
button.linklike {
  background: none; border: 0; padding: 0; margin: 0;
  font: inherit; color: var(--link-color, #0a58ca);
  /* text-decoration: underline; */
  cursor: pointer;
}
button.linklike:hover { text-decoration: none; }

/* Table */
table.striped { width:100%; table-layout:auto; border-collapse:collapse; }
th, td { padding:.375rem .5rem; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
table.striped tbody tr:nth-child(odd){ background:rgba(127,127,127,.05); }

/* need more experiments with this - applies to TH with multi-line headers */
.nowrap { white-space:nowrap; }
.wrap { white-space:normal; }

table.striped tbody td, th {
  border: 1px solid #eee;      /* faint gray lines */
  padding: 6px;
}

/* Dialog sizing & position */

dialog.modal {
  width: clamp(320px, 92vw, 1100px) !important; /* cap width */
  max-height: min(85dvh, 820px);
  margin: auto;                 /* center */
  padding: 0;
  align-items: stretch;
  border: 2px solid red;
  border-radius: .75rem;
  box-shadow: 0 30px 80px rgba(0,0,0,.35);
  overflow: hidden;
}

/* Override pico's dialog display without forcing it open */
#loc-dialog {
  display: none !important;
}
#loc-dialog[open] {
  display: block !important;
  align-items: stretch;
  justify-items: stretch;
  height: min(85dvh, 820px);
}

dialog.modal::backdrop { background: rgba(21, 7, 91, 0.45); }

/* Prevent background page scroll while dialog is open */
body:has(#loc-dialog[open]) {
  overflow: hidden;
}
dialog.modal[open] {
  overscroll-behavior: contain;
}

/* Inner layout: header / scrollable body / footer */
dialog.modal .layout {
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: .75rem;
  padding: 1rem;
  min-height: 0;
  height: 100%;
}
dialog.modal .layout .body {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* Two-column form grid (collapses on small screens) */
dialog.modal .grid2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .75rem 1rem;
}
dialog.modal .loc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: .85rem 1rem;
}
dialog.modal .loc-section {
  min-width: 0;
}
dialog.modal .loc-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .6rem .9rem;
}

dialog.modal .loc-fields:has(> :nth-child(2):last-child) {
  grid-template-columns: 1fr;
}
dialog.modal .loc-ai {
  grid-column: 1 / -1;
}
dialog.modal .ai-managed input[readonly],
dialog.modal .ai-managed select[disabled] {
  background: #a4afb9;
  color: #3f4a52;
  cursor: not-allowed;
}
dialog.modal .ai-managed .loc-note {
  grid-column: 1 / -1;
  color: #5f6a72;
  font-size: 0.82rem;
}
dialog.modal label {
  display: flex;
  flex-direction: column;
  gap: .25rem;
}

/* Inputs should fill their cell but not explode */
dialog.modal input,
dialog.modal select,
dialog.modal textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 8px;
  font-size: 0.9rem;
}

/* Footer buttons */
dialog.modal .footer {
  display: flex;
  gap: .5rem;
  justify-content: flex-end;
}

/* table update spinner overlay */
.table-spinner {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .75rem;
  background: rgba(255, 255, 255, 0.65);
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s ease-in-out;
  z-index: 9999;
}
.table-spinner.is-active {
  opacity: 1;
  pointer-events: all;
}
.table-spinner .spinner {
  width: 44px;
  height: 44px;
  border: 4px solid #c9c9c9;
  border-top-color: #333333;
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
.table-spinner .spinner-text {
  font-size: 0.95rem;
  color: #333333;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Mobile: stack the form fields */
@media (max-width: 640px) {
  .post-query-filters > .filter-row:nth-of-type(1),
  .post-query-filters > .filter-row:nth-of-type(2) {
    grid-template-columns: 1fr;
  }
  dialog.modal { width: 100vw !important; max-width: 100vw; border-radius: 0; }
  dialog.modal .grid2 { grid-template-columns: 1fr; }
  dialog.modal .loc-grid { grid-template-columns: 1fr; }
  dialog.modal .loc-fields { grid-template-columns: 1fr; }
  .locbar-top {
    flex-direction: column;
    align-items: stretch;
  }
  .locbar-grid {
    grid-template-columns: 1fr;
  }

  .ai-info-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .ai-info-body {
    padding: .95rem 1rem 1rem;
  }
}

/* AI detail summary panel */
.ai-info-panel {
  border: 1px solid #2d4758;
  border-left: 5px solid #7cb2cf;
  border-radius: .7rem;
  background: linear-gradient(180deg, #142330 0%, #0e1b26 100%);
  overflow: hidden;
}

.ai-info-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: .9rem 1.1rem .55rem;
  background: rgba(124, 178, 207, 0.08);
  border-bottom: 1px solid rgba(124, 178, 207, 0.18);
}

.ai-info-title {
  margin: 0;
  font-size: 1.05rem;
  color: #eef6fb;
}

.ai-info-kicker {
  margin: 0;
  color: #9cc2d7;
  font-size: .82rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  white-space: nowrap;
}

.ai-info-body {
  padding: 1rem 1.25rem 1.15rem;
}

.ai-info-body > * {
  max-width: 72ch;
}

.ai-info-body p {
  margin: 0 0 .8rem;
  line-height: 1.45;
  color: #d7e7f1;
}

.ai-info-body p:last-child {
  margin-bottom: 0;
}

.ai-info-markdown {
  max-width: 72ch;
}

.ai-info-markdown > :first-child {
  margin-top: 0;
}

.ai-info-markdown > :last-child {
  margin-bottom: 0;
}

.ai-info-markdown p,
.ai-info-markdown li,
.ai-info-markdown blockquote {
  color: #d7e7f1;
  line-height: 1.5;
}

.ai-info-markdown h1,
.ai-info-markdown h2,
.ai-info-markdown h3,
.ai-info-markdown h4 {
  color: #eef6fb;
  margin: 0 0 .7rem;
}

.ai-info-markdown ul,
.ai-info-markdown ol {
  margin: 0 0 .9rem 1.2rem;
}

.ai-info-markdown code {
  color: #f3fbff;
  background: rgba(156, 194, 215, 0.14);
  padding: .1rem .3rem;
  border-radius: .25rem;
}

.ai-info-loading {
  display: flex;
  align-items: center;
  gap: .85rem;
  color: #d7e7f1;
}

.ai-info-loading .spinner {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  border: 3px solid rgba(156, 194, 215, 0.24);
  border-top-color: #9cc2d7;
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

.ai-info-status-text {
  font-weight: 600;
  color: #eef6fb;
}

.ai-info-status-note {
  color: #a8c3d3;
  font-size: .94rem;
}

.ai-info-error {
  margin-top: .85rem;
  padding: .8rem .95rem;
  border: 1px solid #d8b38a;
  border-radius: .55rem;
  background: #fff6eb;
  color: #7c4d1f;
}

.ai-info-image-slot {
  display: flex;
  align-items: center;
  gap: .7rem;
  margin-top: 1rem;
  padding-top: .9rem;
  border-top: 1px solid rgba(156, 194, 215, 0.18);
  color: #a8c3d3;
}

.ai-info-image-slot .spinner {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  border: 3px solid rgba(156, 194, 215, 0.2);
  border-top-color: #9cc2d7;
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

.ai-info-image-status {
  margin: 0;
  color: #a8c3d3;
}

.ai-info-image-block {
  margin-top: 1rem;
  padding-top: .95rem;
  border-top: 1px solid rgba(156, 194, 215, 0.18);
}

.ai-info-image-title {
  margin: 0 0 .7rem;
  color: #eef6fb;
  font-size: .98rem;
}

.ai-info-image-figure {
  margin: 0;
}

.ai-info-image {
  display: block;
  width: 100%;
  max-width: 720px;
  max-height: 420px;
  object-fit: cover;
  border-radius: .55rem;
  border: 1px solid rgba(156, 194, 215, 0.22);
  background: #0a141c;
}

.ai-info-image-links {
  margin-top: .55rem;
  color: #a8c3d3;
  font-size: .92rem;
}

.ai-info-image-links a {
  color: #9cc2d7;
}

/* dso alitude graph and moon illum charts */
.chart-container {
  width: 100%;
  height: auto;
}
