/* -------------------------------------------------
   ORTEP editor layout
   ------------------------------------------------- */

.ortep-editor-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 400px);
  gap: 0.75rem;
  align-items: start;
  min-width: 0;
}

.ortep-svg-panel,
.ortep-controls-panel,
.ortep-override-panel {
  min-width: 0;
}

.ortep-side-column {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
  min-width: 0;
}

.ortep-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
}

.ortep-panel-header h2 {
  margin-bottom: 0.15rem;
}

.ortep-panel-header .hint {
  margin-top: 0;
}

/* -------------------------------------------------
   ORTEP collapsible sections
   ------------------------------------------------- */

.ortep-section {
  margin-top: 0.55rem;

  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-alt);
  overflow: hidden;
}

.ortep-section:first-of-type {
  margin-top: 0;
}

.ortep-section summary {
  cursor: pointer;
  padding: 0.48rem 0.6rem;

  color: var(--text);
  font-size: 0.82rem;
  font-weight: 650;

  user-select: none;
}

.ortep-section summary:hover {
  background: var(--accent-soft);
}

.ortep-section-body {
  padding: 0.55rem 0.6rem 0.65rem;
  border-top: 1px solid var(--border);
  overflow-x: auto;
}

.ortep-section-body label {
  display: block;
  margin: 0.45rem 0;
}

.ortep-section-body label:first-child {
  margin-top: 0;
}

.ortep-section-body label:last-child {
  margin-bottom: 0;
}

.ortep-section-body select,
.ortep-section-body input[type="text"] {
  display: block;
  width: 100%;
  margin-top: 0.18rem;
  padding: 0.28rem 0.35rem;

  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--input-bg);
  color: var(--text);

  font-size: 0.86rem;
}

/* -------------------------------------------------
   ORTEP slider controls
   Sidebar-friendly layout:
   label + value on top, slider below
   ------------------------------------------------- */

.ortep-slider-control {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.22rem;
  margin: 0.55rem 0;
}

.ortep-slider-control:first-child {
  margin-top: 0;
}

.ortep-slider-control:last-child {
  margin-bottom: 0;
}

.ortep-slider-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
}

.ortep-slider-meta label {
  margin: 0;
  min-width: 0;

  color: var(--muted);
  font-size: 0.82rem;
}

.ortep-slider-control input[type="range"] {
  width: 100%;
  min-width: 0;
  margin: 0;
}

.ortep-slider-value {
  flex-shrink: 0;

  color: var(--text);
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* -------------------------------------------------
   ORTEP checkbox controls
   ------------------------------------------------- */

.ortep-checkbox-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.22rem;
}

.ortep-checkbox-row {
  display: grid !important;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.42rem;
  align-items: start;

  margin: 0 !important;
  color: var(--text);
  line-height: 1.25;
}

.ortep-checkbox-row input {
  margin-top: 0.12rem;
}

/* -------------------------------------------------
   ORTEP SVG output
   ------------------------------------------------- */

.ortep-svg-box {
  min-height: 720px;

  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: auto;
}

.ortep-svg-box svg {
  display: block;
  width: 100%;
  height: auto;
  background: #ffffff;
}

.ortep-symmetry-notes {
  margin-top: 0.7rem;
}

.ortep-symmetry-notes h3 {
  margin: 0 0 0.25rem;

  color: var(--text);
  font-size: 0.85rem;
}

.ortep-symmetry-notes p {
  margin: 0;
}

/* -------------------------------------------------
   ORTEP figure in report preview
   ------------------------------------------------- */

.ortep-preview-figure {
  margin: 1.25rem 0 1rem;
  padding: 0.75rem;

  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
}

.ortep-preview-figure-svg {
  max-width: 100%;
  margin: 0 auto;

  background: #ffffff;
}

.ortep-preview-figure-svg svg {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto;

  background: #ffffff;
}

/* -------------------------------------------------
   ORTEP toolbars
   ------------------------------------------------- */

.ortep-figure-toolbar,
.ortep-download-toolbar,
.ortep-override-toolbar {
  margin-bottom: 0;
}

.ortep-figure-toolbar button,
.ortep-download-toolbar button,
.ortep-override-toolbar button {
  flex: 1 1 auto;
}

/* -------------------------------------------------
   ORTEP selected item / override controls
   ------------------------------------------------- */

.ortep-selected-actions {
  display: grid;
  gap: 0.35rem;
  margin-top: 0.45rem;
}

.ortep-selected-actions label {
  margin: 0;
}

.ortep-selected-actions select,
.ortep-section-body select[data-ortep-atom-show],
.ortep-section-body select[data-ortep-atom-label],
.ortep-section-body select[data-ortep-bond-show],
.ortep-section-body select[data-ortep-selected-atom-show],
.ortep-section-body select[data-ortep-selected-atom-label],
.ortep-section-body select[data-ortep-selected-bond-show],
.ortep-section-body select[data-ortep-selected-bond-style] {
  font-size: 0.78rem;
}

/* -------------------------------------------------
   ORTEP tables
   ------------------------------------------------- */

.ortep-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.35rem;

  font-size: 0.74rem;
}

.ortep-table th,
.ortep-table td {
  border: 1px solid var(--border);
  padding: 0.18rem 0.24rem;
  vertical-align: top;
}

.ortep-table th {
  background: var(--table-head);
  text-align: left;
  font-weight: 600;
}

.ortep-table select {
  min-width: 4.7rem;
}

.ortep-table .number {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* -------------------------------------------------
   ORTEP dark mode SVG handling
   ------------------------------------------------- */

@media (prefers-color-scheme: dark) {
  .ortep-svg-box {
    background: #020617;
  }

  .ortep-svg-box svg {
    filter: invert(1) hue-rotate(180deg) saturate(0.9) contrast(0.95);
  }
}

/* -------------------------------------------------
   ORTEP responsive layout
   ------------------------------------------------- */

@media (max-width: 1350px) {
  .ortep-editor-layout {
    grid-template-columns: minmax(0, 1fr) minmax(340px, 370px);
  }
}

@media (max-width: 1150px) {
  .ortep-editor-layout {
    grid-template-columns: 1fr;
  }

  .ortep-side-column {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .ortep-svg-box {
    min-height: 620px;
  }
}

@media (max-width: 800px) {
  .ortep-side-column {
    grid-template-columns: 1fr;
  }

  .ortep-svg-box {
    min-height: 460px;
  }
}