li,
section > form {
  display: flex;
  justify-content: space-between;
  align-items: center;

  > * + * {
    margin-left: 1rem;
  }

  > :first-child {
    width: 100%;
  }

  /* Override simple.css on smaller screens */
  > :last-child {
    width: unset;
  }
}
ul {
  display: flex;
  flex-direction: column;
}

li.right-aligned-item {
  align-self: flex-center; /* Aligns this specific item to the end of the cross axis */
  flex-grow: 4;
}

ul {
  padding: 0;
}

/* DataTable fixed-width cells — 3-line clamp via inner div */
table.dataTable td { max-width: 200px; }
table.dataTable td .cell-clamp {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  white-space: normal;
  word-break: break-word;
}

/* ── Chat message bubbles ────────────────────── */
#chat > li {
  display: block !important;
  padding: 0 !important;
  margin: 0 0 0.75rem 0 !important;
  border: none !important;
  align-items: unset !important;
}

.msg-alg {
  background: #105257;
  border-left: 3px solid #2dd4bf;
  border-radius: 0 6px 6px 0;
  padding: 0.75rem 1rem;
  max-width: 90%;
  color: #e0e8f0;
  font-size: 0.9rem;
  position: relative;
}

.msg-cancel-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.6rem;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  border: 1px solid #f87171;
  background: transparent;
  color: #f87171;
  font-size: 0.72rem;
  cursor: pointer;
  opacity: 0.85;
  transition: opacity 0.15s, background 0.15s;
}
.msg-cancel-btn:hover { background: #f87171; color: #0a2a2e; opacity: 1; }

.msg-you {
  background: #2d2d2d;
  border-right: 3px solid #666;
  border-radius: 6px 0 0 6px;
  padding: 0.75rem 1rem;
  max-width: 65%;
  margin-left: auto;
  color: #e0e0e0;
  font-size: 0.9rem;
}

.msg-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 0.4rem;
}

.msg-name {
  color: #2dd4bf;
  font-weight: 700;
  font-size: 0.75rem;
  font-family: monospace;
  letter-spacing: 0.05em;
}

.msg-name.you-name { color: #aaa; }

.msg-timestamp {
  color: #555;
  font-size: 0.68rem;
  font-family: monospace;
  margin-left: auto;
}

.msg-body { line-height: 1.6; }

/* ── Markdown content inside message bodies ─────── */

/* Paragraphs */
.msg-body p { margin: 0 0 0.5rem 0; }
.msg-body p:last-child { margin-bottom: 0; }

/* Headers — scaled down; full h1/h2 sizes are jarring in a chat bubble */
.msg-body h1, .msg-body h2, .msg-body h3, .msg-body h4 {
  font-size: 0.9rem;
  font-weight: 700;
  margin: 0.85rem 0 0.25rem 0;
  color: #2dd4bf;
  border: none;
  padding: 0;
}
.msg-body h3, .msg-body h4 { color: #a8dbd7; }

/* Fix: global `li { display: flex }` breaks markdown list items.
   Reset to list-item inside message bodies. */
.msg-body ul, .msg-body ol {
  display: block;
  padding-left: 1.4rem;
  margin: 0.35rem 0 0.5rem 0;
}
.msg-body li {
  display: list-item;
  padding: 0;
  margin: 0.15rem 0;
  align-items: unset;
  width: unset;
}
.msg-body ul > li::marker { color: #2dd4bf; }

/* Bold */
.msg-body strong { color: #e8f4f3; font-weight: 600; }

/* Blockquote */
.msg-body blockquote {
  border-left: 3px solid #2dd4bf44;
  padding-left: 0.75rem;
  margin: 0.5rem 0;
  color: #9ab8b6;
  font-style: italic;
}

/* Horizontal rule */
.msg-body hr {
  border: none;
  border-top: 1px solid #1a5a5e;
  margin: 0.75rem 0;
}

.msg-body code {
  font-family: monospace;
  background: #0c3d40;
  padding: 0.1em 0.3em;
  border-radius: 3px;
  font-size: 0.85em;
  color: #2dd4bf;
}

.msg-body pre {
  background: #0a3235;
  border: 1px solid #1a5a5e;
  border-radius: 4px;
  padding: 0.75rem;
  overflow-x: auto;
  font-size: 0.8rem;
}

.suggested-questions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.75rem;
  padding-top: 0.5rem;
  border-top: 1px solid #1a5a5e;
}

.sq-btn {
  background: none;
  border: 1px solid #1a6a6e;
  border-radius: 12px;
  color: #2dd4bf;
  font-size: 0.72rem;
  padding: 0.2rem 0.6rem;
  cursor: pointer;
  font-family: monospace;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.sq-btn:hover {
  background: #0c3d40;
  border-color: #2dd4bf;
}

/* Striped DataTables */
table.dataTable tbody tr.odd  { background-color: #f9f9f9; }
table.dataTable tbody tr.even { background-color: #ffffff; }
table.dataTable tbody tr:hover { background-color: #d4f0ee; color: #111; }
table.dataTable tbody tr.row-selected { background-color: #2dd4bf55 !important; color: #111; }
table.dataTable thead th {
  background-color: #2d2d2d;
  color: #ffffff;
  border-bottom: 2px solid #444;
}

/* DataTable CSV button */
.dt-csv-btn {
  background: #1a1a1a !important;
  border: 1px solid #444 !important;
  color: #2dd4bf !important;
  border-radius: 999px !important;
  padding: 0.2rem 0.75rem !important;
  font-size: 0.75rem !important;
  cursor: pointer;
}
.dt-csv-btn:hover { border-color: #2dd4bf !important; }

/* Chart */
.chart-wrapper {
  margin-top: 1rem;
  background: #0c3d40;
  border: 1px solid #2dd4bf33;
  border-radius: 8px;
  padding: 1rem;
  max-width: 600px;
}

/* Map */
.map-wrapper {
  max-width: 100%;
  padding: 0.5rem;
}
.map-wrapper .leaflet-container {
  border-radius: 6px;
}