/* chatOAME – Real Data Explorer
 * The toolbar button reuses the toolbar's own classes (.chatoame-teacher-attachment-item,
 * .chatoame-camera-button), so it inherits the Camera / Screenshot / Ink look exactly.
 * The modal follows the camera/editor modal conventions in Unified Tools.
 */

.chatoame-rde-icon { width: 25px !important; height: 25px !important; }

/* Selection chip, first row of the toolbar shell. */
#chatOAME .chatoame-rde-chip,
.chatoame-rde-chip {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px;
  margin: 0 0 8px; padding: 6px 10px; border-radius: 10px;
  border: 1px solid var(--co-line-strong, #c7d2da);
  background: var(--co-surface-soft, #f4f8fb); color: var(--co-ink, #14232d);
  font-size: 0.8rem; line-height: 1.3;
}
.chatoame-rde-chip-label { font-weight: 700; }
.chatoame-rde-chip-title { flex: 1 1 220px; min-width: 0; overflow-wrap: anywhere; }
.chatoame-rde-chip-btn {
  appearance: none; border: 1px solid var(--co-line-strong, #c7d2da); background: #fff; color: inherit;
  border-radius: 999px; padding: 3px 10px; font: inherit; font-weight: 650; cursor: pointer;
}
.chatoame-rde-chip-btn:hover { background: rgba(15, 23, 42, 0.06); }

/* Why a selection was removed: shown where the chip was, until dismissed or a new selection is made. */
#chatOAME .chatoame-rde-notice,
.chatoame-rde-notice {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px;
  margin: 0 0 8px; padding: 6px 10px; border-radius: 10px;
  border: 1px solid #d9b45a; background: #fff8e6; color: #3a2a00; /* fixed pair: readable whatever the theme ink is */
  font-size: 0.8rem; line-height: 1.3;
}
.chatoame-rde-notice-text { flex: 1 1 220px; min-width: 0; overflow-wrap: anywhere; }
.chatoame-rde-more-note { list-style: none; font-style: italic; }

/* Modal (mirrors .chatoame-camera-modal). */
.chatoame-rde-modal[hidden] { display: none !important; }
.chatoame-rde-modal {
  position: fixed; inset: 0; z-index: 2147483600; /* above the chatOAME side rail (2147483002), below its own pop-up panels */ display: flex; align-items: center; justify-content: center;
  padding: 20px; background: rgba(0, 0, 0, 0.72);
}
html.chatoame-rde-open { overflow: hidden; }
.chatoame-rde-dialog {
  --rde-ink: var(--co-ink, #14232d); --rde-soft: var(--co-ink-soft, #334956); --rde-line: var(--co-line-strong, #c7d2da);
  --rde-accent: var(--co-shipyard-800, #1e394b); --rde-bar: #3c7da6; --rde-fit: #b4462b; --rde-bg: var(--co-surface, #ffffff);
  width: min(1100px, 96vw); max-height: min(88vh, 900px); display: flex; flex-direction: column;
  background: var(--rde-bg); color: var(--rde-ink); border-radius: 16px; box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  overflow: hidden; font-size: 0.95rem;
}
.chatoame-rde-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; padding: 16px 20px 12px; border-bottom: 1px solid var(--rde-line); }
.chatoame-rde-title { margin: 0; font-size: 1.3rem; line-height: 1.2; }
.chatoame-rde-intro { margin: 4px 0 0; color: var(--rde-soft); }
.chatoame-rde-close {
  appearance: none; border: 1px solid var(--rde-line); background: #fff; color: var(--rde-ink);
  width: 40px; height: 40px; border-radius: 999px; font-size: 1.5rem; line-height: 1; cursor: pointer; flex: 0 0 40px;
}
.chatoame-rde-body { display: grid; grid-template-columns: minmax(250px, 300px) 1fr; min-height: 0; flex: 1 1 auto; }
.chatoame-rde-filters { overflow-y: auto; padding: 14px 16px; border-right: 1px solid var(--rde-line); background: var(--co-surface-soft, #f7fafc); }
.chatoame-rde-main { overflow-y: auto; padding: 16px 20px 24px; min-width: 0; }
.chatoame-rde-main:focus { outline: none; }

.chatoame-rde-activities { border: 0; margin: 0 0 10px; padding: 0; }
.chatoame-rde-activities legend { font-weight: 750; padding: 0; margin-bottom: 4px; }
.chatoame-rde-group { margin: 10px 0 4px; font-size: 0.78rem; font-weight: 750; text-transform: uppercase; letter-spacing: 0.04em; color: var(--rde-soft); }
.chatoame-rde-activity { display: flex; gap: 8px; align-items: flex-start; padding: 5px 4px; border-radius: 8px; }
.chatoame-rde-activity:has(input:checked) { background: rgba(60, 125, 166, 0.12); }
.chatoame-rde-activity input { margin-top: 3px; flex: 0 0 auto; }
.chatoame-rde-activity label { cursor: pointer; display: flex; flex-direction: column; }
.chatoame-rde-activity-name { font-weight: 650; }
.chatoame-rde-activity-desc { font-size: 0.8rem; color: var(--rde-soft); }

.chatoame-rde-more { border-top: 1px solid var(--rde-line); padding-top: 8px; }
.chatoame-rde-more > summary { font-weight: 750; cursor: pointer; padding: 4px 0; }
.chatoame-rde-field { display: flex; flex-direction: column; gap: 3px; margin: 8px 0; }
.chatoame-rde-field label { font-size: 0.82rem; font-weight: 650; }
.chatoame-rde-check { flex-direction: row; align-items: center; gap: 8px; }
.chatoame-rde-preview .chatoame-rde-field { max-width: 360px; }
.chatoame-rde-select, .chatoame-rde-input {
  font: inherit; padding: 6px 8px; border: 1px solid var(--rde-line); border-radius: 8px; background: #fff; color: var(--rde-ink); min-width: 0; width: 100%;
}

.chatoame-rde-empty { color: var(--rde-soft); padding: 12px 0; }
.chatoame-rde-empty.is-error, .chatoame-rde-inline-error { color: #9b2c1f; }
.chatoame-rde-count { margin: 0 0 10px; font-size: 1rem; }
.chatoame-rde-results { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.chatoame-rde-card { border: 1px solid var(--rde-line); border-radius: 12px; padding: 12px 14px; background: #fff; }
.chatoame-rde-card-title { margin: 0 0 4px; font-size: 1rem; }
.chatoame-rde-card-open {
  appearance: none; border: 0; background: none; padding: 0; text-align: left; font: inherit; font-weight: 700;
  color: var(--rde-accent); text-decoration: underline; text-underline-offset: 2px; cursor: pointer;
}
.chatoame-rde-card-why { margin: 0 0 8px; color: var(--rde-soft); font-size: 0.88rem; }
.chatoame-rde-meta { display: grid; grid-template-columns: max-content 1fr; gap: 2px 12px; margin: 0; font-size: 0.85rem; }
.chatoame-rde-meta dt { font-weight: 650; color: var(--rde-soft); }
.chatoame-rde-meta dd { margin: 0; overflow-wrap: anywhere; }
.chatoame-rde-pager { display: flex; align-items: center; justify-content: center; gap: 12px; margin: 14px 0 0; }
.chatoame-rde-pager button, .chatoame-rde-back, .chatoame-rde-secondary {
  appearance: none; border: 1px solid var(--rde-line); background: #fff; color: var(--rde-ink); border-radius: 999px;
  padding: 6px 14px; font: inherit; font-weight: 650; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center;
}
.chatoame-rde-pager button[disabled], .chatoame-rde-primary[disabled], .chatoame-rde-secondary[disabled] { opacity: 0.5; cursor: not-allowed; }
.chatoame-rde-back { margin-bottom: 8px; }
.chatoame-rde-detail-title { margin: 4px 0 10px; font-size: 1.15rem; }
.chatoame-rde-detail-title:focus { outline: none; }
.chatoame-rde-ident { margin-bottom: 12px; }
.chatoame-rde-why h4, .chatoame-rde-limits h4, .chatoame-rde-preview h4, .chatoame-rde-table-wrap h4 { margin: 16px 0 6px; font-size: 1rem; }
.chatoame-rde-why p { margin: 0; }
.chatoame-rde-note { font-size: 0.85rem; color: var(--rde-soft); margin: 6px 0; }
.chatoame-rde-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 4px; }
.chatoame-rde-primary {
  appearance: none; border: 0; border-radius: 999px; padding: 9px 18px; font: inherit; font-weight: 750; cursor: pointer;
  background: var(--rde-accent); color: #fff;
}
.chatoame-rde-primary:hover { filter: brightness(1.1); }

.chatoame-rde-chart { width: 100%; height: auto; max-height: 360px; display: block; background: #fff; border: 1px solid var(--rde-line); border-radius: 10px; }
.chatoame-rde-axes line { stroke: var(--rde-soft); stroke-width: 1; }
.chatoame-rde-axes line.grid { stroke: var(--rde-line); stroke-dasharray: 3 3; }
.chatoame-rde-axes text { font-size: 11px; fill: var(--rde-soft); }
.chatoame-rde-axes text.label { font-size: 12px; font-weight: 650; fill: var(--rde-ink); }
.chatoame-rde-chart .bar { fill: var(--rde-bar); fill-opacity: 0.78; stroke: #fff; stroke-width: 1; }
.chatoame-rde-box line { stroke: var(--rde-ink); stroke-width: 2; }
.chatoame-rde-box .median { stroke: var(--rde-fit); stroke-width: 3; }
.chatoame-rde-chart .pt { fill: var(--rde-accent); fill-opacity: 0.75; }
.chatoame-rde-chart .fit { stroke: var(--rde-fit); stroke-width: 2.5; fill: none; }
.chatoame-rde-five { grid-template-columns: repeat(auto-fill, minmax(90px, max-content) minmax(70px, 1fr)); margin-top: 8px; }

.chatoame-rde-table-scroll { max-height: 340px; overflow: auto; border: 1px solid var(--rde-line); border-radius: 10px; margin: 6px 0; }
.chatoame-rde-table { border-collapse: collapse; width: 100%; font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.chatoame-rde-table th, .chatoame-rde-table td { padding: 4px 10px; border-bottom: 1px solid var(--rde-line); text-align: left; }
.chatoame-rde-table thead th { position: sticky; top: 0; background: var(--co-surface-soft, #f4f8fb); }
.chatoame-rde-table td { text-align: right; }
.chatoame-rde-limits ul, .chatoame-rde-prov ul { margin: 0; padding-left: 1.2em; font-size: 0.88rem; }
.chatoame-rde-sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.chatoame-rde-dialog :is(button, a, input, select, summary, [tabindex]):focus-visible {
  outline: 3px solid var(--chatoame-tanzanite, #4b3fb5); outline-offset: 2px;
}

@media (max-width: 900px) {
  .chatoame-rde-body { grid-template-columns: 1fr; overflow-y: auto; }
  .chatoame-rde-filters { border-right: 0; border-bottom: 1px solid var(--rde-line); overflow: visible; }
  .chatoame-rde-main { overflow: visible; }
}
@media (max-width: 620px) {
  .chatoame-rde-modal { padding: 0; align-items: stretch; }
  .chatoame-rde-dialog { width: 100vw; max-height: none; height: 100%; border-radius: 0; }
  .chatoame-rde-header { padding: 12px 14px; }
  .chatoame-rde-main { padding: 12px 14px 20px; }
  .chatoame-rde-actions > * { flex: 1 1 100%; justify-content: center; }
}
@media (prefers-reduced-motion: reduce) { .chatoame-rde-dialog * { transition: none !important; } }
@media (forced-colors: active) {
  .chatoame-rde-dialog, .chatoame-rde-card, .chatoame-rde-chip, .chatoame-rde-notice { border: 1px solid CanvasText; }
  .chatoame-rde-chart .bar { fill: Highlight; }
  .chatoame-rde-chart .pt { fill: CanvasText; }
  .chatoame-rde-chart .fit { stroke: LinkText; }
}
