: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: 28px;
  padding: 30px 24px 20px;
  background: #fff;
  border-right: 1px solid #e0e6ef;
  box-shadow: 2px 0 12px rgba(21, 42, 76, 0.03);
  z-index: 1;

  overflow-y: auto;
  min-height: 0;

  font-family: "IBM Plex Sans", Arial, sans-serif;
}
.eyebrow {
  color: #3565a5;
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.14em;
}
.field-heading {
  margin: 18px 0 7px;
  font-size: 12px;
  font-weight: 650;
  color: #43536a;
}
h1 {
  margin: 8px 0 10px;
  font-size: 25px;
  letter-spacing: -0.04em;
}
.panel-header p,
.field-hint {
  color: #66748a;
  font-size: 13px;
  line-height: 1.5;
}
.panel-header p {
  margin: 0;
}
h2 {
  margin: 0 0 14px;
  font-size: 14px;
}
label {
  display: block;
  margin-bottom: 7px;
  font-size: 12px;
  font-weight: 650;
  color: #43536a;
}
input[type="text"] {
  width: 100%;
  min-width: 0;
  padding: 11px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #fff;
  color: #17243a;
  font: inherit;
  font-size: 14px;
}
input[type="text"]:focus {
  outline: 2px solid #8db5ef;
  outline-offset: 1px;
  border-color: #3972c3;
}
.field-hint {
  margin: 8px 0 0;
}
.bounds-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.panel-actions {
  display: grid;
  gap: 10px;
}
.divided-section,
.panel-actions {
  border-top: 1px solid #e0e6ef;
  padding-top: 14px;
}
button {
  padding: 12px 14px;
  border-radius: 8px;
  font: inherit;
  font-size: 14px;
  font-weight: 650;
  cursor: pointer;
}
.primary-button {
  background: #245bb0;
  border: 1px solid #245bb0;
  color: white;
}
.primary-button:hover {
  background: #1d4b93;
}
.secondary-button {
  background: #fff;
  border: 1px solid #cbd5e1;
  color: #28476e;
}
.secondary-button:hover {
  background: #f2f6fc;
}
.panel-footer {
  margin: auto 0 0;
  padding-top: 20px;
  font-size: 12px;
  color: #8995a6;
}
.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 rgba(25, 45, 75, 0.05);
  overflow: hidden;
}
#polarGraph {
  display: block;
  width: 100%;
  height: 100%;
}
.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;
}

.point-row {
  margin-bottom: 8px;
}

.point-row input {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.remove-point {
  border: none;
  background: transparent;
  color: #888;
  cursor: pointer;
  font-size: 1.2rem;
}

.remove-point:hover {
  color: #c33;
}
.draggable-label {
  cursor: grab;
  user-select: none;
  touch-action: none;
}

.draggable-label:active {
  cursor: grabbing;
}
#addPoint {
  margin-top: 6px;
  width: 100%;
}
#appearanceControls {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.style-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.style-row label {
  margin-bottom: 0;
}

.style-inputs {
  display: grid;
  grid-template-columns: 1fr 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;
}

#resetStyles {
  margin-top: 8px;
}

/* Color picker */

.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 {
  background: #f2f6fc;
}

.selected-color {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  border: 1px solid rgba(0, 0, 0, 0.2);
  border-radius: 4px;
}

.color-name {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.color-arrow {
  margin-left: auto;
  color: #66748a;
}

/* Color palette */

.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 rgba(0, 0, 0, 0.15);
}

.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;
}

/* Point-size slider */

.point-size-control {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

#pointSize,
#aspectRatio {
  width: 100%;
  min-width: 0;
  cursor: pointer;
  accent-color: #245bb0;
}

#pointSizeValue,
#aspectRatioValue {
  min-width: 36px;
  font-size: 12px;
  text-align: right;
  color: #43536a;
  font-variant-numeric: tabular-nums;
}
/* Font-size selector */

.font-size-buttons {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.font-size-button {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  padding: 0;
  background: white;
  color: #43536a;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  cursor: pointer;
}

.font-size-button:hover {
  background: #f2f6fc;
}

.font-size-button.selected {
  background: #eaf2ff;
  border: 2px solid #245bb0;
  color: #245bb0;
}

.font-size-button:focus-visible {
  outline: 2px solid #3972c3;
  outline-offset: 2px;
}

.font-preview {
  font-family: Georgia, serif;
  font-weight: 500;
  line-height: 1;
}

.font-preview-small {
  font-size: 15px;
}

.font-preview-normal {
  font-size: 22px;
}

.font-preview-large {
  font-size: 30px;
}

@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;
  }
  .panel-actions {
    grid-template-columns: 1fr 1fr;
  }
  .panel-footer {
    display: none;
  }
  .graph-area {
    padding: 12px;
  }
  .graph-frame {
    height: auto;
    min-height: 0;
    aspect-ratio: 6 / 5;
  }
}

/* Cohesive sidebar controls */
.controls-panel {
  gap: 22px;
}
.control-section {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.control-section h2 {
  margin: 0 0 10px;
  font-size: 14px;
}
.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: inherit;
  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;
}
.bounds-row {
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 8px;
  align-items: center;
}
.theta-inequality {
  font-size: 15px;
  font-weight: 500;
  white-space: nowrap;
}
#startTheta,
#stopTheta {
  text-align: center;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field label {
  margin: 0;
}
.details-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 14px 0 0;
}
.settings-details {
  border-top: 1px solid #e0e6ef;
  padding-top: 14px;
}
.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;
}
#appearanceControls {
  gap: 14px;
}
.point-headers {
  text-align: center;
}
.point-headers span {
  text-align: center;
}
.point-row input {
  padding: 9px 5px !important;
  text-align: center;
}
.remove-point {
  padding: 4px 0;
  border-radius: 6px;
}
.utility-button {
  font-size: 13px;
  padding: 9px 12px;
}
#copyGraph.copy-success {
  background: #e7f5eb;
  border-color: #8ac49a;
  color: #23683a;
}
.panel-actions {
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.panel-actions #sbutt {
  grid-column: 1 / -1;
}
.panel-actions button {
  padding: 11px 8px;
  font-size: 13px;
}
#resetStyles {
  margin-top: 0;
}
/* Mathematical expressions and numeric inputs */
#fname,
#startTheta,
#stopTheta,
.point-r,
.point-theta,
#maxR,
#majorRStep,
#minorSubdivisions {
  font-family: "IBM Plex Mono", monospace;
}
@media (max-width: 700px) {
  .panel-actions {
    grid-template-columns: 1fr 1fr;
  }
}

/* Semilog graph settings — outlined fieldsets */
.settings-group {
  min-width: 0;
  margin: 0;
  padding: 12px 14px 16px;
  border: 2px solid #a0a0a0;
  border-radius: 0;
}
.settings-group + .settings-group {
  margin-top: 8px;
}
.settings-group legend {
  padding: 0 5px;
  margin: 0;
  font-size: 16px;
  font-weight: 400;
  color: #17243a;
}
.settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
}
.settings-grid .field label {
  font-size: 12px;
  line-height: 1.35;
  min-height: 0;
}
.settings-checkbox {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin: 0;
  line-height: 1.4;
  cursor: pointer;
}
.settings-checkbox input {
  flex: 0 0 auto;
  margin: 2px 0 0;
  accent-color: #245bb0;
}
#fname, .point-x, .point-y,
#minX, #maxX, #xIncrement, #minY, #maxY, #yIncrement, #logBase, #xSubdivisions {
  font-family: "IBM Plex Mono", monospace;
}
