:root {
  color-scheme: light;
  --bg: #f7f8f5;
  --surface: #ffffff;
  --ink: #17202a;
  --muted: #64707d;
  --line: #d9e0df;
  --line-strong: #80909c;
  --accent: #1f6feb;
  --accent-strong: #1454b8;
  --helper: #d43f3a;
  --warm: #f7b955;
  --green: #188764;
  --shadow: 0 18px 50px rgba(23, 32, 42, 0.12);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
}

button,
input {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

.page-shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 18px;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 4px 2px 18px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  background: var(--ink);
  color: white;
  font-size: 28px;
  font-weight: 800;
  font-style: italic;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 18px;
}

.brand small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 14px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 650;
}

.site-nav a:hover,
.site-nav a:focus-visible {
  color: var(--accent);
}

.tool-layout {
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
  gap: 18px;
  align-items: stretch;
}

.home-intro {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 360px);
  gap: 18px;
  align-items: stretch;
  margin-bottom: 18px;
}

.home-intro > div:first-child {
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.home-intro h1 {
  margin-bottom: 10px;
}

.home-intro p {
  width: min(760px, 100%);
  color: var(--muted);
  font-size: 17px;
  line-height: 1.55;
}

.search-box {
  display: grid;
  gap: 8px;
  margin-top: 20px;
  width: min(680px, 100%);
}

.search-box span {
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.search-box input {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  color: var(--ink);
  font-size: 15px;
  font-weight: 650;
  outline: none;
}

.search-box input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.14);
}

.home-ad {
  min-height: 120px;
}

.function-section {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.function-section h2 {
  padding-left: 2px;
  color: var(--ink);
  font-size: 18px;
  text-transform: none;
}

.function-grid {
  display: grid;
  gap: 18px;
}

.function-grid-featured {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.function-grid-compact {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.function-card {
  display: grid;
  gap: 10px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  transition:
    border-color 160ms ease,
    transform 160ms ease,
    box-shadow 160ms ease;
}

.function-card[hidden] {
  display: none;
}

.function-card-large {
  min-height: 430px;
}

.function-card-small {
  min-height: 270px;
  padding: 14px;
  gap: 8px;
  box-shadow: 0 12px 34px rgba(23, 32, 42, 0.09);
}

.function-card:hover,
.function-card:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 20px 55px rgba(31, 111, 235, 0.15);
  transform: translateY(-2px);
  outline: none;
}

.card-topline {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.function-card strong {
  font-size: 23px;
  line-height: 1.1;
}

.function-card strong math,
.detail-heading [data-expression] math {
  color: inherit;
  font-family: "Cambria Math", "STIX Two Math", "Times New Roman", serif;
  font-size: inherit;
  font-weight: inherit;
}

.function-card-small strong {
  font-size: 19px;
}

.function-description {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.function-card-small .function-description {
  font-size: 12px;
  line-height: 1.35;
}

.function-card svg {
  width: 100%;
  aspect-ratio: 13 / 7.5;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  touch-action: none;
}

.function-card-small svg {
  aspect-ratio: 13 / 6.4;
}

.hover-readout {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  width: fit-content;
  max-width: 100%;
  padding: 6px 10px;
  border-radius: 8px;
  background: #edf5ff;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 800;
}

.function-card-small .hover-readout {
  min-height: 30px;
  padding: 5px 8px;
  font-size: 12px;
}

.empty-search {
  margin: 18px 0 0;
  padding: 22px;
  border: 1px dashed #a9b5bd;
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: 16px;
  font-weight: 800;
  text-align: center;
}

.control-panel,
.graph-area,
.teaching-notes {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.detail-page {
  display: grid;
  gap: 18px;
}

.detail-heading,
.detail-controls,
.detail-graph-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.detail-heading {
  display: grid;
  gap: 8px;
  padding: 24px;
}

.detail-heading a {
  color: var(--accent);
  font-size: 14px;
  font-weight: 800;
}

.detail-heading p {
  color: var(--muted);
  font-size: 22px;
  font-weight: 800;
}

.detail-controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  padding: 18px;
}

.detail-graph-card {
  overflow: hidden;
}

.detail-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.detail-toolbar .icon-controls {
  width: min(300px, 100%);
}

.detail-svg {
  display: block;
  min-height: 560px;
}

.control-panel {
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 22px;
}

.control-group {
  display: grid;
  gap: 12px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 31px;
  line-height: 1.05;
}

h2 {
  font-size: 13px;
  letter-spacing: 0;
  text-transform: uppercase;
  color: var(--muted);
}

h3 {
  font-size: 18px;
}

.lede {
  color: var(--muted);
  font-size: 15px;
  line-height: 1.5;
}

.preset-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.preset-button,
.icon-controls button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.preset-button {
  padding: 0 12px;
  text-align: left;
}

.preset-button:hover,
.icon-controls button:hover {
  border-color: var(--accent);
}

.preset-button.is-active {
  border-color: var(--accent);
  background: #eaf2ff;
  color: var(--accent-strong);
}

.parameter-panel[hidden] {
  display: none;
}

.slider-row {
  display: grid;
  gap: 7px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 750;
}

.slider-row span {
  display: flex;
  justify-content: space-between;
}

.slider-row input {
  accent-color: var(--accent);
}

.toggle-list {
  display: grid;
  gap: 9px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 650;
}

.toggle-list label {
  display: flex;
  align-items: center;
  gap: 9px;
}

.toggle-list input {
  width: 18px;
  height: 18px;
  accent-color: var(--green);
}

.icon-controls {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.icon-controls button {
  padding: 0 10px;
  text-align: center;
}

.graph-area {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(360px, 1fr);
  min-height: 640px;
  overflow: hidden;
}

.graph-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.expression {
  color: var(--ink);
  font-size: 20px;
  font-weight: 800;
}

.hint {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.graph-svg {
  width: 100%;
  min-height: 360px;
  height: 100%;
  touch-action: none;
  cursor: grab;
  background: #ffffff;
}

.graph-svg:active {
  cursor: grabbing;
}

.grid-line {
  stroke: #e8eeee;
  stroke-width: 1;
}

.axis-grid-line {
  stroke: #c5d0d5;
  stroke-width: 1.4;
}

.axis-line {
  stroke: var(--line-strong);
  stroke-width: 2.2;
}

.function-path {
  stroke: var(--accent);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.helper-dot {
  fill: var(--helper);
  stroke: #ffffff;
  stroke-width: 3;
}

.helper-label {
  fill: var(--helper);
  font-size: 16px;
  font-weight: 800;
  paint-order: stroke;
  stroke: #ffffff;
  stroke-width: 4px;
  stroke-linejoin: round;
}

.hover-guide {
  stroke: rgba(212, 63, 58, 0.38);
  stroke-width: 2;
  stroke-dasharray: 6 6;
}

.hover-dot {
  fill: var(--helper);
  stroke: #ffffff;
  stroke-width: 3;
}

.hover-label {
  fill: var(--helper);
  font-size: 16px;
  font-weight: 800;
  paint-order: stroke;
  stroke: #ffffff;
  stroke-width: 4px;
  stroke-linejoin: round;
}

.ad-slot {
  display: grid;
  min-height: 72px;
  place-items: center;
  border: 1px dashed #a9b5bd;
  border-radius: 8px;
  background: #fbfaf5;
  color: #727b83;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.tool-ad {
  position: absolute;
  right: 18px;
  bottom: 18px;
  width: min(320px, calc(100% - 36px));
  opacity: 0.92;
}

.teaching-notes {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr;
  gap: 24px;
  margin-top: 18px;
  padding: 26px;
  box-shadow: none;
}

.teaching-notes h2 {
  margin-bottom: 10px;
  color: var(--ink);
  font-size: 24px;
  line-height: 1.1;
  text-transform: none;
}

.teaching-notes h3 {
  margin-bottom: 10px;
}

.teaching-notes p,
.teaching-notes li {
  color: var(--muted);
  font-size: 15px;
  line-height: 1.55;
}

.teaching-notes ul {
  display: grid;
  gap: 7px;
  margin: 0;
  padding-left: 20px;
}

.content-ad {
  grid-column: 1 / -1;
}

.content-page {
  width: min(760px, 100%);
  margin: 32px auto;
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.content-page h1 {
  margin-bottom: 18px;
}

.content-page p {
  margin-top: 14px;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.65;
}

@media (max-width: 860px) {
  .page-shell {
    padding: 14px;
  }

  .site-header,
  .graph-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .site-nav {
    justify-content: flex-start;
  }

  .tool-layout,
  .home-intro,
  .function-grid-featured,
  .function-grid-compact,
  .teaching-notes {
    grid-template-columns: 1fr;
  }

  .control-panel {
    gap: 18px;
    padding: 18px;
  }

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

  .preset-button {
    min-height: 48px;
    text-align: center;
  }

  .graph-area {
    min-height: 520px;
  }

  .detail-controls {
    grid-template-columns: 1fr;
  }

  .detail-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .detail-svg {
    min-height: 420px;
  }

  .tool-ad {
    position: static;
    width: auto;
    margin: 0 14px 14px;
  }
}

@media (max-width: 520px) {
  h1 {
    font-size: 26px;
  }

  .preset-grid,
  .icon-controls {
    grid-template-columns: 1fr;
  }

  .graph-area {
    grid-template-rows: auto 360px auto;
    min-height: auto;
  }

  .graph-svg {
    height: 360px;
  }

  .home-intro > div:first-child,
  .function-card,
  .detail-heading,
  .detail-controls {
    padding: 18px;
  }

  .function-card {
    min-height: 300px;
  }

  .function-card-large {
    min-height: 360px;
  }

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

  .icon-controls {
    grid-template-columns: repeat(3, 1fr);
  }
}
