.turnup-math-graph-block {
  border: 1px solid #d7dde5;
  border-radius: 22px;
  padding: 24px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  box-shadow: 0 14px 36px rgba(15, 23, 42, 0.08);
  margin: 1.4rem 0;
  box-sizing: border-box;
}

.turnup-math-graph-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: #122033;
  margin-bottom: 16px;
}

.turnup-math-graph-editor-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 18px;
  align-items: start;
}

.turnup-math-graph-main,
.turnup-math-graph-side {
  min-width: 0;
}

.turnup-math-graph-side {
  position: relative;
  align-self: start;
}

.turnup-math-graph-panel {
  border: 1px solid #e2e8f0;
  border-radius: 20px;
  padding: 18px;
  background: #ffffff;
  margin-bottom: 16px;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.05);
}

.turnup-math-graph-preview-panel {
  padding: 18px 18px 16px;
}

.turnup-math-graph-subtitle {
  font-size: 1rem;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 10px;
}

.turnup-math-graph-controls,
.turnup-math-graph-item-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(165px, 1fr));
  gap: 14px;
}

.turnup-math-graph-controls {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.turnup-math-graph-item-grid-point {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.turnup-math-graph-field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.turnup-math-graph-field-wide {
  grid-column: span 2;
}

.turnup-math-graph-field-check {
  justify-content: flex-end;
}

.turnup-math-graph-field-check-wide {
  grid-column: span 2;
}

.turnup-math-graph-general {
  position: relative;
}

.turnup-math-graph-field-button {
  justify-content: flex-end;
}

.turnup-math-graph-field label {
  font-size: 0.88rem;
  font-weight: 700;
  color: #334155;
}

.turnup-math-graph-field input,
.turnup-math-graph-field select {
  width: 100%;
  box-sizing: border-box;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  background: #ffffff;
  color: #0f172a;
  font-size: 0.96rem;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}

.turnup-math-graph-field input:focus,
.turnup-math-graph-field select:focus {
  outline: none;
  border-color: #6d8cff;
  box-shadow: 0 0 0 4px rgba(109, 140, 255, 0.15);
}

.turnup-math-graph-readonly,
.turnup-math-graph-field input:disabled {
  background: linear-gradient(180deg, #f1f5f9 0%, #e2e8f0 100%);
  color: #64748b;
  border-color: #cbd5e1;
  box-shadow: inset 0 1px 3px rgba(15, 23, 42, 0.08);
  cursor: not-allowed;
}

.turnup-math-graph-field-check label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 4px;
}

.turnup-math-graph-field-check input[type="checkbox"] {
  width: 18px;
  height: 18px;
  min-height: 18px;
  padding: 0;
  accent-color: #4d8dff;
}

.turnup-math-graph-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

[data-template-buttons="1"] {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.turnup-math-graph-template-note {
  margin-top: 12px;
  color: #475569;
  font-size: 0.9rem;
  line-height: 1.65;
}

.turnup-math-graph-template-note p {
  margin: 0.35em 0;
}

.turnup-math-graph-tag {
  border: 1px solid #d7deea;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  color: #1e293b;
  padding: 9px 14px;
  cursor: pointer;
  font-weight: 700;
  letter-spacing: 0.01em;
  transition: transform 0.14s ease, background-color 0.14s ease, border-color 0.14s ease, box-shadow 0.14s ease;
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.05);
}

.turnup-math-graph-tag:hover {
  background: #eef2ff;
  border-color: #a5b4fc;
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(79, 70, 229, 0.12);
}


.turnup-math-graph-panel-head {
  margin-bottom: 0;
}

.turnup-math-graph-panel-body {
  margin-top: 12px;
}

.turnup-math-graph-general.is-collapsed .turnup-math-graph-panel-body,
.turnup-math-graph-template-panel.is-collapsed .turnup-math-graph-panel-body {
  display: none;
}

.turnup-math-graph-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.turnup-math-graph-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.turnup-math-graph-item {
  border: 1px solid #dbe4ee;
  border-radius: 16px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
  padding: 14px;
}

.turnup-math-graph-actions-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
}

.turnup-math-graph-inline-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid #d7deea;
  border-radius: 12px;
  background: #ffffff;
  color: #1e293b;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.05);
}

.turnup-math-graph-inline-check input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: #4d8dff;
}

.turnup-math-graph-actions-row .button,
.turnup-math-graph-section-head .button,
.turnup-math-graph-field-button .button {
  min-height: 40px;
  border-radius: 12px;
}

.turnup-math-graph-status {
  font-size: 0.93rem;
  color: #334155;
  margin-bottom: 12px;
  min-height: 1.4em;
}

.turnup-math-graph-toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%) translateY(18px);
  padding: 12px 18px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.92);
  color: #ffffff;
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  box-shadow: 0 16px 30px rgba(15, 23, 42, 0.26);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s ease, transform 0.28s ease;
  z-index: 99999;
}

.turnup-math-graph-toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.turnup-math-graph-status.is-error {
  color: #b91c1c;
  font-weight: 700;
}

.turnup-math-graph-canvas-wrap {
  max-width: 100%;
  overflow-x: auto;
  padding-bottom: 6px;
}

.turnup-math-graph-plot-surface {
  display: inline-block;
  padding: 14px;
  border-radius: 20px;
  background: #2B3516;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.04), 0 12px 28px rgba(0,0,0,0.18);
}

.turnup-math-graph-canvas {
  display: block;
  background: transparent;
  max-width: none;
}

@media (max-width: 980px) {
  .turnup-math-graph-editor-layout {
    grid-template-columns: 1fr;
  }

  .turnup-math-graph-side {
    position: static;
  }
}

@media (max-width: 860px) {
  .turnup-math-graph-field-wide,
  .turnup-math-graph-field-check-wide {
    grid-column: span 1;
  }

  .turnup-math-graph-section-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .turnup-math-graph-block {
    padding: 16px;
    border-radius: 18px;
  }
}

.turnup-math-graph-subtitle-secondary {
  margin-top: 18px;
}

.turnup-math-graph-help {
  margin: 10px 0 0;
  color: #475569;
  font-size: 0.9rem;
  line-height: 1.65;
}

.turnup-math-graph-block.is-pseudo-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 999999;
  margin: 0;
  border-radius: 0;
  padding: 16px;
  max-width: none;
  overflow-y: auto;
  overflow-x: hidden;
}

body.tpe-graph-pseudo-fullscreen {
  overflow: hidden;
}

.turnup-math-graph-block.is-pseudo-fullscreen .turnup-math-graph-editor-layout {
  grid-template-columns: minmax(0, 4fr) minmax(280px, 1fr) !important;
  gap: 16px;
  min-height: calc(100vh - 32px);
  align-items: start;
}

.turnup-math-graph-block.is-pseudo-fullscreen .turnup-math-graph-main,
.turnup-math-graph-block.is-pseudo-fullscreen .turnup-math-graph-side {
  min-height: 0;
}

.turnup-math-graph-block.is-pseudo-fullscreen .turnup-math-graph-main {
  display: flex;
  flex-direction: column;
}

.turnup-math-graph-block.is-pseudo-fullscreen .turnup-math-graph-side {
  overflow: auto;
  max-height: calc(100vh - 32px);
  padding-right: 8px;
}

.turnup-math-graph-block.is-pseudo-fullscreen .turnup-math-graph-preview-panel {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 64px);
  margin-bottom: 0;
}

.turnup-math-graph-block.is-pseudo-fullscreen .turnup-math-graph-canvas-wrap {
  flex: 1;
  min-height: 420px;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

.turnup-math-graph-block.is-pseudo-fullscreen .turnup-math-graph-plot-surface {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.turnup-math-graph-block.is-pseudo-fullscreen .turnup-math-graph-canvas {
  width: 100% !important;
  max-width: 100%;
  height: auto !important;
}


/* Standalone plugin wrapper. */
.tgm-graph-pane { width: 100%; }

.tgm-graph-export-options {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  background: #f8fafc;
}

.tgm-graph-export-field {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  font-weight: 700;
  color: #334155;
}

.tgm-graph-export-field input {
  width: 96px;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  background: #ffffff;
  color: #0f172a;
  box-sizing: border-box;
}

.tgm-graph-export-help {
  color: #64748b;
  font-size: 0.84rem;
  line-height: 1.6;
}

.tgm-graph-save-note { margin-top: 8px; font-size: 12px; color: #4b5563; }
