:root {
  color: #17243a;
  background: #f4f6fa;
}
* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  min-height: 100%;
}
button,
input,
select {
  font-family: inherit;
}
.app-layout {
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr);
  height: 100dvh;
  overflow: hidden;
}
.controls-panel {
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 30px 24px 20px;
  background: #fff;
  border-right: 1px solid #e0e6ef;
  box-shadow: 2px 0 12px #152a4c08;
  z-index: 1;
  overflow-y: auto;
  min-height: 0;
  font-family: "IBM Plex Sans", Arial, sans-serif;
}
.details-body > .secondary-button {
  width: 100%;
}
h2 {
  margin: 0 0 10px;
  font-size: 14px;
}
label {
  display: block;
  margin-bottom: 7px;
  font-size: 12px;
  font-weight: 650;
  color: #43536a;
}
.control-section {
  display: flex;
  flex-direction: column;
}
.divided-section,
.settings-details {
  border-top: 1px solid #c5d0df;
  padding-top: 14px;
}

.preference-actions {
  display: grid;
  gap: 9px;
  border-top: 1px solid #c5d0df;
  padding-top: 20px;
}

.panel-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: -8px;
}

.panel-actions button {
  padding: 11px 8px;
  font-size: 13px;
}

.controls-panel input[type="text"],
.controls-panel input[type="number"] {
  display: block;
  width: 100%;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #fff;
  color: #17243a;
  font-size: 14px;
}
.controls-panel input[type="text"]:focus,
.controls-panel input[type="number"]:focus {
  outline: 2px solid #8db5ef;
  outline-offset: 1px;
  border-color: #3972c3;
}
#fname,
#domainLower,
#domainUpper,
.point-x,
.point-y,
.settings-grid input {
  font-family: "IBM Plex Mono", monospace;
}
.domain-controls {
  margin-top: 12px;
}
.bounds-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.field label,
.style-row label {
  margin: 0;
}
.point-headers,
.point-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1.4fr 28px;
  gap: 6px;
  align-items: center;
}
.point-headers {
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 6px;
  text-align: center;
}
.point-row {
  margin-bottom: 8px;
}
.point-row input {
  padding: 9px 5px !important;
  text-align: center;
}
.remove-point {
  border: none;
  background: transparent;
  color: #888;
  cursor: pointer;
  font-size: 1.2rem;
  padding: 4px 0;
  border-radius: 6px;
}
.remove-point:hover {
  color: #c33;
}
#addPoint {
  margin-top: 6px;
  width: 100%;
}
.utility-button {
  font-size: 13px;
  padding: 9px 12px;
}
.settings-details summary {
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  color: #17243a;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.settings-details summary::-webkit-details-marker {
  display: none;
}
.settings-details summary::after {
  content: "▸";
  color: #66748a;
  font-size: 16px;
}
.settings-details[open] summary::after {
  content: "▾";
}
.settings-details summary:focus-visible {
  outline: 2px solid #3972c3;
  outline-offset: 4px;
  border-radius: 3px;
}
.details-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 14px 0 0;
}
.settings-group {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  margin: 0;
  padding: 14px 12px 16px;
  border: 1px solid #cbd5e1;
  border-radius: 0px;
}

.settings-group legend {
  padding: 0 6px;
  font-size: 13px;
  font-weight: 650;
  color: #43536a;
}
.settings-group + .settings-group {
  margin-top: 8px;
}

.settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
}
.settings-grid .field label {
  font-size: 12px;
  line-height: 1.35;
}
.settings-checkbox {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0;
  line-height: 1.4;
  cursor: pointer;
}
.settings-checkbox input {
  flex: 0 0 auto;
  margin: 0;
  accent-color: #245bb0;
}
.color-swatch.no-color,
.selected-color.no-color {
  position: relative;
  background-color: #ffffff;
  overflow: hidden;
}

.color-swatch.no-color::after,
.selected-color.no-color::after {
  content: "";
  position: absolute;
  top: 50%;
  left: -20%;
  width: 140%;
  height: 2px;
  background: #d32f2f;
  transform: translateY(-50%) rotate(-45deg);
}
.marker-style-buttons {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.marker-style-button,
.angle-label-button {
  width: 100%;
  min-width: 0;
  padding: 10px 2px;
  text-align: center;
}
.marker-style-button {
  padding: 9px 4px;
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  background: white;
  color: #43536a;
  font-size: 12px;
  cursor: pointer;
}

.marker-style-button:hover {
  background: #f1f5f9;
}

.marker-style-button.selected {
  background: #e8f0fc;
  border-color: #3972c3;
  color: #245bb0;
  font-weight: 600;
}

#graph .draggable-label {
  cursor: grab;
  user-select: none;
  touch-action: none;
}

#graph .draggable-label:active {
  cursor: grabbing;
}
.slider-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
}

.slider-row label {
  margin: 0;
}

.slider-row input[type="range"] {
  width: 100%;
  min-width: 0;
}
.style-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.style-inputs {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
}
.style-inputs select {
  width: 100%;
  min-width: 0;
  padding: 9px 6px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: white;
  font-size: 12px;
}
.color-picker {
  position: relative;
  min-width: 0;
}
.color-trigger {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  height: 38px;
  padding: 6px 8px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: white;
  color: #17243a;
  font-size: 12px;
  font-weight: 400;
  cursor: pointer;
}
.color-trigger:hover,
.secondary-button:hover {
  background: #f2f6fc;
}
.selected-color {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  border: 1px solid #0003;
  border-radius: 4px;
}
.color-name {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.color-arrow {
  margin-left: auto;
  color: #66748a;
}
.color-palette {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(5, 28px);
  gap: 7px;
  width: max-content;
  padding: 10px;
  background: white;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  box-shadow: 0 6px 20px #0002;
}
.color-palette[hidden] {
  display: none;
}
.color-swatch {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  transition: transform 0.12s;
}
.color-swatch:hover {
  transform: scale(1.12);
  border-color: #555;
}
.color-swatch[aria-pressed="true"] {
  outline: 2px solid #245bb0;
  outline-offset: 2px;
  border-color: white;
}
.color-trigger:focus-visible,
.color-swatch:focus-visible {
  outline: 2px solid #3972c3;
  outline-offset: 2px;
}

#fontSize {
  width: 100%;
  min-width: 0;
  cursor: pointer;
  accent-color: #245bb0;
}

button {
  padding: 12px 14px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 650;
  cursor: pointer;
}
.primary-button {
  background: #24518a;
  border: 1px solid #24518a;
  color: white;
}

.primary-button:hover {
  background: #1b406f;
}
.secondary-button {
  background: white;
  border: 1px solid #cbd5e1;
  color: #28476e;
}
.gold-button {
  background: #f8dc91;
  border: 1px solid #e6ba57;
  color: #253b57;
}

.gold-button:hover {
  background: #f3cd70;
}
#rememberStyles,
#resetStyles {
  width: 100%;
}
#resetStyles {
  margin-top: 0;
}
.panel-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.panel-actions {
  padding-top: 20px;
}
.panel-actions button {
  padding: 11px 8px;
  font-size: 13px;
}
.controls-panel input[type="range"] {
  width: 100%;
  accent-color: #245bb0;
}
.controls-panel .field > select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: white;
  color: #17243a;
  font-size: 13px;
}
#copyGraph.copy-success,
#rememberStyles.copy-success {
  background: #e7f5eb;
  border-color: #8ac49a;
  color: #23683a;
}
.graph-area {
  min-width: 0;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #f4f6fa;
  overflow: hidden;
}
.graph-frame {
  width: 100%;
  height: calc(100dvh - 48px);
  min-height: 360px;
  display: grid;
  place-items: center;
  background: white;
  border: 1px solid #e0e6ef;
  border-radius: 14px;
  box-shadow: 0 4px 24px #192d4b0d;
  overflow: hidden;
}
#graph {
  display: block;
  width: 100%;
  height: 100%;
}

@media (max-width: 700px) {
  .app-layout {
    grid-template-columns: minmax(0, 1fr);
    height: auto;
    min-height: 100dvh;
    overflow: visible;
  }
  .controls-panel {
    gap: 20px;
    padding: 20px;
    border-right: 0;
    border-bottom: 1px solid #e0e6ef;
    overflow-y: visible;
  }
  .graph-area {
    padding: 12px;
  }
  .graph-frame {
    height: auto;
    min-height: 0;
    aspect-ratio: 6 / 5;
  }
}

/* STIX Two Text — Regular Latin */
@font-face {
  font-family: "STIX Two Text";
  src: url("../../resources/fonts/STIX2RegularLatin.woff2") format("woff2");
  font-style: normal;
  font-weight: 400 700;
  unicode-range:
    U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+0304,
    U+2000-206F, U+2212, U+2215;
}

/* STIX Two Text — Regular Greek */
@font-face {
  font-family: "STIX Two Text";
  src: url("../../resources/fonts/STIX2RegularGreek.woff2") format("woff2");
  font-style: normal;
  font-weight: 400 700;
  unicode-range: U+0370-03FF;
}

/* STIX Two Text — Italic Latin */
@font-face {
  font-family: "STIX Two Text";
  src: url("../../resources/fonts/STIX2ItalicLatin.woff2") format("woff2");
  font-style: italic;
  font-weight: 400 700;
  unicode-range:
    U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+0304,
    U+2000-206F, U+2212, U+2215;
}

/* STIX Two Text — Italic Greek */
@font-face {
  font-family: "STIX Two Text";
  src: url("../../resources/fonts/STIX2ItalicGreek.woff2") format("woff2");
  font-style: italic;
  font-weight: 400 700;
  unicode-range: U+0370-03FF;
}

/* Terminal-ray figure settings */
#theta,
#radiusValue,
#incrementLabel {
  font-family: "IBM Plex Mono", monospace;
}

/* Flag an invalid angle expression without interrupting typing. */
.controls-panel input.invalid-input {
  border-color: #c33;
}

/* Additional draggable text labels */
.angle-label-button {
  padding: 9px 4px;
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  background: white;
  color: #43536a;
  font-size: 12px;
  cursor: pointer;
}
.angle-label-button.selected {
  background: #e8f0fc;
  border-color: #3972c3;
  color: #245bb0;
  font-weight: 600;
}
#customAngleLabel[hidden] {
  display: none;
}
.free-label-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 28px;
  gap: 6px;
  align-items: center;
  margin-bottom: 8px;
}
.free-label-row input {
  min-width: 0;
}
.remove-label {
  border: none;
  background: transparent;
  color: #888;
  cursor: pointer;
  font-size: 1.2rem;
}
.remove-label:hover {
  color: #c33;
}

/* Reorganized collapsible control groups */
.controls-panel > .field {
  margin-bottom: 0;
}
.controls-panel > .settings-details {
  flex-shrink: 0;
}
.controls-panel .style-row {
  min-width: 0;
}
.controls-panel .details-body .field[hidden] {
  display: none;
}

.controls-panel .details-body > .style-row > label {
  margin-bottom: 6px;
}
#graph .special-label {
  cursor: grab;
  user-select: none;
}

.intersection-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.intersection-controls > button {
  width: 100%;
}

#intersectionLabelField {
  gap: 4px;
}

#intersectionLabelField label {
  font-size: 11px;
  color: #66748a;
}
#pointsSection .point-headers {
  margin-bottom: -10px;
}
