.graphing-shell {
  max-width: none;
  width: 100%;
  margin: 0 auto;
  padding: 0;
}

.graphing-shell .calc-card {
  background: #fcfcfc;
  border-radius: 12px;
  padding: 20px;
  border: 1px solid rgba(20, 24, 30, 0.08);
  box-shadow: 0 18px 34px -30px rgba(15, 23, 42, 0.7);
  max-width: 100%;
  overflow: hidden;
}

.graphing-shell .calc-breadcrumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #6b737c;
  margin-bottom: 8px;
}

.graphing-shell .calc-breadcrumbs a {
  color: #6b737c;
  text-decoration: none;
}

.graphing-shell .calc-breadcrumbs a:hover,
.graphing-shell .calc-breadcrumbs a:focus-visible {
  color: #2f6fdf;
  text-decoration: underline;
}

.graphing-shell .calc-page-title {
  font-size: 22px;
  font-weight: 600;
  margin: 0 0 8px;
  color: #151a1f;
}

.graphing-shell .calc-page-intro {
  margin: 0;
  max-width: 720px;
  color: #4b535d;
  font-size: 15px;
  line-height: 1.6;
}

.graphing-shell .calc-reference {
  margin-top: 16px;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  color: #1f2937;
}

.graphing-shell .calc-reference h2 {
  margin: 16px 0 8px;
  font-size: 1.45rem;
  font-weight: 600;
  line-height: 1.3;
  color: #151a1f;
}

.graphing-shell .calc-reference h2:first-child {
  margin-top: 0;
}

.graphing-shell .calc-reference p {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  color: #374151;
  font-size: 15px;
  line-height: 1.65;
  font-weight: 400;
}

.graphing-shell .calc-reference p + p {
  margin-top: 12px;
}

.graphing-shell .calc-reference ul,
.graphing-shell .calc-reference ol {
  margin: 10px 0 0;
  padding-left: 18px;
  color: #1f2937;
}

.graphing-shell .calc-reference li {
  margin: 2px 0;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.65;
  font-weight: 400;
  color: #374151;
}

.graphing-shell .calc-reference a {
  color: #0f172a;
  text-decoration: none;
  font-weight: 500;
}

.graphing-shell .calc-reference a:hover,
.graphing-shell .calc-reference a:focus-visible {
  color: #1f5cc9;
  text-decoration: none;
}

.graphing-shell a,
.graphing-shell button,
.graphing-shell [role='button'],
.graphing-shell [type='button'],
.graphing-shell [type='submit'] {
  cursor: pointer;
}

.graphing-layout {
  grid-template-columns: minmax(0, 1fr);
  gap: 0;
  align-items: stretch;
}

.graphing-layout .calc-main {
  display: grid;
  width: 100%;
  row-gap: 16px;
}

.graphing-layout .calc-sidebar {
  display: none;
}

.graphing-shell .graphing-card {
  padding: 0;
  overflow: hidden;
  border-radius: 0;
  border-left: 0;
  border-right: 0;
  border-top: 0;
}

.graphing-app {
  --graph-bg: #f7f8fb;
  --graph-panel: #ffffff;
  --graph-border: #dbe1ea;
  --graph-text: #111827;
  --graph-muted: #5f6774;
  --graph-btn: #eef2f7;
  --graph-btn-text: #152238;
  --graph-danger: #ef4444;
  color: var(--graph-text);
  background: radial-gradient(circle at top right, #eef4ff 0%, #f8fafc 45%, #ffffff 100%);
  display: grid;
  grid-template-columns: minmax(320px, 390px) minmax(0, 1fr);
  grid-template-areas: 'panel stage';
  gap: 0;
  height: var(--graphing-app-height, 620px);
  min-height: var(--graphing-app-height, 620px);
}

.graphing-app[data-theme='dark'] {
  --graph-bg: #11151d;
  --graph-panel: #161b24;
  --graph-border: #2a3343;
  --graph-text: #e7ecf5;
  --graph-muted: #a5afbf;
  --graph-btn: #1d2531;
  --graph-btn-text: #e7ecf5;
  --graph-danger: #f87171;
  background: radial-gradient(circle at top right, #1f2734 0%, #121722 55%, #0f141d 100%);
}

.graphing-app[data-theme='dark'] .graph-function-panel,
.graphing-app[data-theme='dark'] .graph-btn {
  background: #161b24;
}

.graphing-app[data-theme='dark'] .graph-row-block {
  background: #1a202b;
}

.graphing-app[data-theme='dark'] .graph-row-block:focus-within {
  box-shadow: 0 18px 34px -30px rgba(15, 23, 42, 0.7);
  background: #1e2531;
}

.graphing-app[data-theme='dark'] .graph-row-block.is-selected {
  box-shadow: 0 18px 34px -30px rgba(15, 23, 42, 0.7);
  background: #202938;
}

.graphing-app[data-theme='dark'] .graph-row-block.is-selected::before {
  background: rgba(96, 165, 250, 0.5);
}

.graphing-app[data-theme='dark'] .graph-remove {
  color: #7f8897;
}

.graphing-app[data-theme='dark'] .graph-visibility,
.graphing-app[data-theme='dark'] .graph-visibility.is-hidden,
.graphing-app[data-theme='dark'] .graph-visibility:hover {
  color: #7f8897;
  background: transparent;
}

.graphing-app[data-theme='dark'] .graph-row-index {
  color: #8d96a5;
}

.graphing-app[data-theme='dark'] .graph-swatch-point {
  box-shadow: 0 18px 34px -30px rgba(15, 23, 42, 0.7);
}

.graphing-app[data-theme='dark'] .graph-point-label-toggle {
  color: #a5afbf;
}

.graphing-app[data-theme='dark'] .graph-point-label-input {
  background: #11151d;
  border-color: #2a3343;
  color: #e7ecf5;
}

.graphing-app[data-theme='dark'] .graph-point-label-input:focus-visible {
  border-color: #5b89d7;
  box-shadow: 0 18px 34px -30px rgba(15, 23, 42, 0.7);
}

.graphing-app[data-theme='dark'] .graph-point-label-input:disabled {
  background: #1b2330;
  color: #8d96a5;
}

.graphing-app[data-theme='dark'] .graph-functions {
  scrollbar-color: #5c6a7f #1c2330;
}

.graphing-app[data-theme='dark'] .graph-functions::-webkit-scrollbar-track {
  background: #1c2330;
  border-left-color: #2a3343;
}

.graphing-app[data-theme='dark'] .graph-functions::-webkit-scrollbar-thumb {
  background: #5c6a7f;
  border-color: #1c2330;
}

.graphing-app[data-theme='dark'] .graph-functions::-webkit-scrollbar-thumb:hover {
  background: #6f7f98;
}

.graph-function-panel {
  grid-area: panel;
  background: #f1f3f6;
  border-right: 1px solid var(--graph-border);
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.graph-toolbar {
  display: grid;
  gap: 0;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-bottom: 1px solid var(--graph-border);
}

.graph-btn {
  border: 0;
  border-right: 1px solid var(--graph-border);
  background: #f1f3f6;
  color: var(--graph-btn-text);
  border-radius: 0;
  font-size: 0.88rem;
  line-height: 1.2;
  min-height: 52px;
  padding: 0 12px;
  font-weight: 600;
}

.graph-btn:last-child {
  border-right: 0;
}

.graph-btn:focus-visible,
.graph-remove:focus-visible,
.graph-visibility:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

.graph-functions {
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1 1 auto;
  min-height: 0;
  padding-right: 0;
  border-bottom: 1px solid var(--graph-border);
  overscroll-behavior-y: contain;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: #9eabbd #e8edf4;
}

.graph-functions::-webkit-scrollbar {
  width: 12px;
}

.graph-functions::-webkit-scrollbar-track {
  background: #e8edf4;
  border-left: 1px solid #d4dce8;
}

.graph-functions::-webkit-scrollbar-thumb {
  background: #9eabbd;
  border-radius: 999px;
  border: 2px solid #e8edf4;
}

.graph-functions::-webkit-scrollbar-thumb:hover {
  background: #8695aa;
}

.graph-row-block {
  border-bottom: 1px solid var(--graph-border);
  background: #f8f9fb;
  position: relative;
  transition: background-color 0.16s ease, box-shadow 0.16s ease;
}

.graph-row-block:focus-within {
  box-shadow: 0 18px 34px -30px rgba(15, 23, 42, 0.7);
  background: #f6f8fc;
}

.graph-row-block.is-selected {
  box-shadow: 0 18px 34px -30px rgba(15, 23, 42, 0.7);
  background: #f5f8fd;
}

.graph-row-block.is-selected::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 2px;
  background: rgba(37, 99, 235, 0.45);
}

.graph-row-block.is-hidden .graph-swatch,
.graph-row-block.is-hidden .graph-row-index,
.graph-row-block.is-hidden .graph-input,
.graph-row-block.is-hidden .graph-point-label-controls {
  opacity: 0.55;
}

.graph-input:focus-visible {
  outline: none;
}

.graph-point-label-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px 10px 52px;
}

.graph-point-label-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #5f6774;
  font-size: 0.88rem;
  line-height: 1;
  user-select: none;
}

.graph-point-label-toggle input {
  width: 14px;
  height: 14px;
  margin: 0;
}

.graph-point-label-title {
  line-height: 1;
}

.graph-point-label-input {
  flex: 1 1 auto;
  min-width: 0;
  height: 30px;
  border: 1px solid #cfd7e3;
  border-radius: 4px;
  background: #ffffff;
  color: #1f2937;
  font-size: 0.88rem;
  padding: 0 8px;
}

.graph-point-label-input:focus-visible {
  outline: none;
  border-color: #7da4eb;
  box-shadow: 0 18px 34px -30px rgba(15, 23, 42, 0.7);
}

.graph-point-label-input:disabled {
  background: #eef2f7;
  color: #8b93a1;
}

.graph-function-row {
  display: grid;
  grid-template-columns: 28px 20px minmax(0, 1fr) 32px 32px;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 8px;
}

.graph-swatch {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  display: inline-block;
  justify-self: center;
}

.graph-swatch-line {
  background: currentColor;
  box-shadow: 0 18px 34px -30px rgba(15, 23, 42, 0.7);
}

.graph-swatch-point {
  box-sizing: border-box;
  background: transparent;
  border: 2px solid currentColor;
  box-shadow: 0 18px 34px -30px rgba(15, 23, 42, 0.7);
}

.graph-row-index {
  font-size: 0.72rem;
  color: #8b93a1;
  justify-self: center;
  line-height: 1;
}

.graph-equals {
  font-weight: 600;
  color: var(--graph-muted);
}

.graph-input {
  min-height: 42px;
  height: 42px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--graph-text);
  padding: 0 4px;
  font-size: 1.45rem;
  font-family: "Times New Roman", Times, serif;
  font-weight: 400;
  letter-spacing: 0;
}

.graph-visibility {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #b0b7c3;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-self: center;
  justify-self: center;
  transition: color 0.16s ease, background-color 0.16s ease;
}

.graph-visibility.is-hidden {
  color: #b0b7c3;
}

.graph-visibility:hover {
  color: #b0b7c3;
  background: transparent;
}

.graph-visibility-icon {
  width: 20px;
  height: 20px;
  display: block;
  background: currentColor;
  transform: translateY(0.5px);
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M2 12s3.9-6.5 10-6.5S22 12 22 12s-3.9 6.5-10 6.5S2 12 2 12z' fill='none' stroke='%23000' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3Ccircle cx='12' cy='12' r='3.4' fill='none' stroke='%23000' stroke-width='2.6'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M2 12s3.9-6.5 10-6.5S22 12 22 12s-3.9 6.5-10 6.5S2 12 2 12z' fill='none' stroke='%23000' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3Ccircle cx='12' cy='12' r='3.4' fill='none' stroke='%23000' stroke-width='2.6'/%3E%3C/svg%3E");
}

.graph-visibility.is-hidden .graph-visibility-icon {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M2 12s3.9-6.5 10-6.5S22 12 22 12s-3.9 6.5-10 6.5S2 12 2 12z' fill='none' stroke='%23000' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3Ccircle cx='12' cy='12' r='3.4' fill='none' stroke='%23000' stroke-width='2.6'/%3E%3Cpath d='M3 21L21 3' fill='none' stroke='%23000' stroke-width='2.8' stroke-linecap='round'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M2 12s3.9-6.5 10-6.5S22 12 22 12s-3.9 6.5-10 6.5S2 12 2 12z' fill='none' stroke='%23000' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3Ccircle cx='12' cy='12' r='3.4' fill='none' stroke='%23000' stroke-width='2.6'/%3E%3Cpath d='M3 21L21 3' fill='none' stroke='%23000' stroke-width='2.8' stroke-linecap='round'/%3E%3C/svg%3E");
}

.graph-remove {
  width: 30px;
  height: 30px;
  min-height: 30px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #b0b7c3;
  font-size: 2rem;
  font-weight: 400;
  padding: 0;
  line-height: 1;
  align-self: center;
  justify-self: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.graph-row-action-hidden {
  opacity: 0;
  pointer-events: none;
}

.graph-row-error,
.graph-global-error {
  color: #dc2626;
  font-size: 0.8rem;
  margin: 0 0 6px 64px;
  line-height: 1.2;
}

.graph-row-error:empty {
  display: none;
}

.graph-empty {
  color: var(--graph-muted);
}

.graph-stage {
  grid-area: stage;
  position: relative;
  background: var(--graph-bg);
  min-height: 0;
  overflow: hidden;
}

.graphing-reference-stack {
  width: min(1020px, calc(100% - 32px));
  margin: 0 auto;
  display: grid;
  gap: 16px;
}

.graphing-reference-stack > .calc-card {
  margin: 0;
}

.graphing-shell .graphing-reference-stack > .graphing-breadcrumbs {
  margin: 0;
}

.graphing-page-info,
.graphing-content {
  margin-top: 0;
}

.graphing-example-table-wrap {
  overflow-x: auto;
}

#graph {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

@media (max-width: 1024px) {
  .graphing-app {
    grid-template-columns: 1fr;
    grid-template-areas:
      'stage'
      'panel';
  }

  .graph-function-panel {
    border-right: 0;
    border-top: 1px solid var(--graph-border);
    max-height: none;
  }

  .graph-stage {
    min-height: 0;
  }

  .graph-functions {
    max-height: 100%;
  }
}

@media (max-width: 760px) {
  .graphing-shell .calc-card {
    padding: 16px;
  }

  .graphing-shell .graphing-card {
    padding: 0;
    border-radius: 0;
  }

  .graphing-app {
    grid-template-areas:
      'stage'
      'panel';
    grid-template-rows: minmax(220px, 46%) minmax(0, 1fr);
  }

  .graph-stage {
    min-height: 0;
  }

  .graph-function-panel {
    position: static;
    border-top: 1px solid var(--graph-border);
    box-shadow: 0 18px 34px -30px rgba(15, 23, 42, 0.7);
    max-height: none;
    padding-bottom: 12px;
  }

  .graph-toolbar {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .graph-functions {
    max-height: 100%;
  }
}

@media (max-width: 680px) {
  .graphing-reference-stack {
    width: calc(100% - 20px);
  }
}
