.td-notebook-widget {
  --td-widget-ink: #211a1c;
  --td-widget-muted: #72686b;
  --td-widget-paper: #fffdf8;
  --td-widget-line: rgba(68, 48, 53, 0.11);
  --td-widget-rose: #ad2f4d;
  --td-widget-blue: #2467a8;
  --td-widget-green: #277552;
  --td-widget-amber: #b36a17;
  --td-widget-shadow: 0 24px 60px rgba(54, 31, 37, 0.13);
  display: grid;
  gap: 14px;
  width: 100%;
  padding: clamp(16px, 2.5vw, 26px);
  overflow: hidden;
  color: var(--td-widget-ink);
  background:
    radial-gradient(circle at 92% 8%, rgba(214, 164, 100, 0.17), transparent 28%),
    linear-gradient(145deg, #fffdfa 0%, #f8f1eb 100%);
  border: 1px solid rgba(82, 50, 58, 0.16);
  border-radius: 24px;
  box-shadow: var(--td-widget-shadow);
  box-sizing: border-box;
}

.td-notebook-widget-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.td-notebook-widget-header > div {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.td-notebook-widget-header-actions {
  display: flex !important;
  grid-template-columns: none !important;
  flex: 0 0 auto;
  align-items: center;
  gap: 7px !important;
}

.td-notebook-widget-kicker {
  color: var(--td-widget-rose);
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.td-notebook-widget-header h4 {
  margin: 0;
  color: var(--td-widget-ink);
  font-size: clamp(1.1rem, 2.4vw, 1.52rem);
  font-weight: 900;
  letter-spacing: -0.035em;
}

.td-notebook-widget-header p {
  max-width: 720px;
  margin: 0;
  color: var(--td-widget-muted);
  font-size: 0.87rem;
  line-height: 1.5;
}

.td-notebook-widget-badge {
  flex: 0 0 auto;
  padding: 7px 10px;
  color: #754353;
  background: rgba(173, 47, 77, 0.09);
  border: 1px solid rgba(173, 47, 77, 0.16);
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 800;
  white-space: nowrap;
}

.td-notebook-widget-focus {
  width: 34px;
  height: 34px;
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid rgba(181, 45, 79, 0.2);
  border-radius: 11px;
  color: #7b2941;
  background: rgba(181, 45, 79, 0.075);
  font: inherit;
  font-size: 1rem;
  font-weight: 950;
  cursor: pointer;
}

.td-notebook-widget-focus:hover,
.td-notebook-widget-focus:focus-visible {
  border-color: rgba(181, 45, 79, 0.42);
  background: rgba(181, 45, 79, 0.14);
}

.td-notebook-widget-focus-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1090;
  border: 0;
  background: rgba(20, 14, 17, 0.78);
  backdrop-filter: blur(12px);
}

.td-notebook-widget.is-focus-mode {
  position: fixed;
  inset: clamp(12px, 4vw, 52px);
  z-index: 1100;
  display: grid;
  align-content: start;
  width: auto;
  max-width: 1400px;
  max-height: calc(100dvh - clamp(24px, 8vw, 104px));
  margin: auto;
  overflow: auto;
  border-radius: 24px;
  box-shadow: 0 36px 110px rgba(0, 0, 0, 0.5);
}

.td-notebook-widget.is-focus-mode .td-notebook-widget-frame-shell,
.td-notebook-widget.is-focus-mode .td-notebook-widget-frame {
  min-height: min(74dvh, 940px);
}

body.has-notebook-widget-focus {
  overflow: hidden;
}

.td-notebook-widget-graph-shell {
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(rgba(255, 255, 255, 0.82), rgba(255, 255, 255, 0.82)),
    repeating-linear-gradient(0deg, transparent 0 23px, rgba(62, 86, 112, 0.09) 23px 24px),
    repeating-linear-gradient(90deg, transparent 0 23px, rgba(62, 86, 112, 0.09) 23px 24px);
  border: 1px solid rgba(57, 43, 47, 0.12);
  border-radius: 18px;
}

.td-notebook-widget-graph {
  display: block;
  width: 100%;
  min-height: 220px;
  max-height: 440px;
}

.td-widget-grid line {
  stroke: var(--td-widget-line);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.td-widget-grid text {
  fill: #8a7e81;
  font-family: "Manrope", sans-serif;
  font-size: 11px;
  font-weight: 700;
}

.td-widget-axes line {
  stroke: rgba(33, 26, 28, 0.55);
  stroke-width: 1.4;
  vector-effect: non-scaling-stroke;
}

.td-widget-series-path {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 3.8;
  vector-effect: non-scaling-stroke;
  filter: drop-shadow(0 3px 3px rgba(33, 26, 28, 0.12));
}

.td-widget-series-path.is-rose {
  stroke: var(--td-widget-rose);
}

.td-widget-series-path.is-blue {
  stroke: var(--td-widget-blue);
}

.td-widget-series-path.is-green {
  stroke: var(--td-widget-green);
}

.td-widget-series-path.is-amber {
  stroke: var(--td-widget-amber);
}

.td-widget-series-path.is-ink {
  stroke: var(--td-widget-ink);
}

.td-notebook-widget-legend {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
  max-width: calc(100% - 24px);
}

.td-notebook-widget-legend > span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 9px;
  color: var(--td-widget-ink);
  background: rgba(255, 253, 248, 0.92);
  border: 1px solid rgba(57, 43, 47, 0.1);
  border-radius: 999px;
  box-shadow: 0 5px 15px rgba(45, 31, 35, 0.07);
  backdrop-filter: blur(8px);
}

.td-notebook-widget-legend i {
  width: 9px;
  height: 9px;
  background: currentColor;
  border-radius: 50%;
}

.td-notebook-widget-legend b {
  font-size: 0.69rem;
  font-weight: 800;
}

.td-notebook-widget-legend .is-rose {
  color: var(--td-widget-rose);
}

.td-notebook-widget-legend .is-blue {
  color: var(--td-widget-blue);
}

.td-notebook-widget-legend .is-green {
  color: var(--td-widget-green);
}

.td-notebook-widget-legend .is-amber {
  color: var(--td-widget-amber);
}

.td-notebook-widget-legend .is-ink {
  color: var(--td-widget-ink);
}

.td-notebook-widget-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, 0.32fr);
  gap: 12px;
}

.td-notebook-widget-slider,
.td-notebook-widget-analysis {
  min-width: 0;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(57, 43, 47, 0.11);
  border-radius: 16px;
}

.td-notebook-widget-slider {
  display: grid;
  gap: 12px;
}

.td-notebook-widget-slider > span {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.td-notebook-widget-slider small {
  color: var(--td-widget-muted);
  font-size: 0.75rem;
  font-weight: 800;
}

.td-notebook-widget-slider output {
  color: var(--td-widget-rose);
  font-size: 1.05rem;
  font-weight: 900;
}

.td-notebook-widget-slider input {
  width: 100%;
  height: 22px;
  margin: 0;
  accent-color: var(--td-widget-rose);
  cursor: ew-resize;
}

.td-notebook-widget-analysis {
  display: grid;
  align-content: center;
  gap: 3px;
}

.td-notebook-widget-analysis strong {
  color: var(--td-widget-rose);
  font-size: 1.08rem;
  font-weight: 900;
}

.td-notebook-widget-analysis span {
  color: var(--td-widget-ink);
  font-size: 0.77rem;
  font-weight: 800;
}

.td-notebook-widget-analysis small {
  min-height: 1.2em;
  color: var(--td-widget-muted);
  font-size: 0.7rem;
  font-weight: 700;
}

.notebook-curator-widget-preview {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.notebook-curator-visual-preview {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.notebook-curator-visual-preview.hidden {
  display: none;
}

.notebook-curator-visual-status {
  margin: 0;
  padding: 10px 12px;
  border: 1px dashed rgba(120, 186, 213, 0.28);
  border-radius: 12px;
  color: #b9adb1;
  background: rgba(120, 186, 213, 0.06);
  font-size: 0.7rem;
  font-weight: 720;
  line-height: 1.45;
}

.notebook-curator-visual-status:empty {
  display: none;
}

.notebook-curator-visual-preview-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
  gap: 14px;
}

.notebook-curator-visual-build {
  display: grid;
  align-content: start;
  gap: 12px;
  min-width: 0;
  padding: 14px;
  border: 1px solid rgba(67, 48, 54, 0.12);
  border-radius: 24px;
  background: rgba(255, 252, 248, 0.92);
  box-shadow: 0 18px 44px rgba(54, 31, 37, 0.09);
}

.notebook-curator-visual-build > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.notebook-curator-visual-build > header > div {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.notebook-curator-visual-build > header span {
  color: #a83451;
  font-size: 0.64rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.notebook-curator-visual-build > header strong {
  overflow: hidden;
  color: #241a1d;
  font-size: 0.95rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.notebook-curator-visual-build > header small {
  flex: 0 0 auto;
  padding: 7px 10px;
  border-radius: 999px;
  color: #6f5e64;
  font-size: 0.7rem;
  font-weight: 800;
  background: #f0e8e3;
}

.notebook-curator-visual-build.is-ready_for_review > header small {
  color: #7c3a00;
  background: #fff0cd;
}

.notebook-curator-visual-build.is-published > header small {
  color: #176139;
  background: #dff4e7;
}

.notebook-curator-visual-build > figure {
  display: grid;
  gap: 8px;
  margin: 0;
}

.notebook-curator-visual-build > figure img {
  display: block;
  width: 100%;
  height: min(340px, 34vh);
  border: 1px solid rgba(67, 48, 54, 0.1);
  border-radius: 18px;
  object-fit: contain;
  background: #fff;
}

.notebook-curator-visual-build > figure figcaption,
.notebook-curator-visual-provenance {
  margin: 0;
  color: #776b6e;
  font-size: 0.72rem;
  line-height: 1.45;
}

.notebook-curator-visual-provenance a {
  color: #94334d;
  font-weight: 800;
}

.notebook-curator-widget-preview.hidden {
  display: none;
}

.notebook-curator-widget-preview-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 14px;
}

.notebook-curator-widget-preview-head > div {
  display: grid;
  gap: 3px;
}

.notebook-curator-widget-preview-head span {
  color: #a83451;
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.notebook-curator-widget-preview-head strong {
  color: #241a1d;
  font-size: 1rem;
}

.notebook-curator-widget-preview-head small {
  max-width: 340px;
  color: #776b6e;
  font-size: 0.74rem;
  line-height: 1.35;
  text-align: right;
}

.notebook-curator-widget-preview-list {
  display: grid;
  gap: 14px;
}

.notebook-curator-widget-preview .td-notebook-widget {
  box-shadow: 0 16px 40px rgba(54, 31, 37, 0.11);
}

.notebook-curator-widget-build {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid rgba(67, 48, 54, 0.12);
  border-radius: 24px;
  background: rgba(255, 252, 248, 0.9);
  box-shadow: 0 18px 44px rgba(54, 31, 37, 0.09);
}

.notebook-curator-widget-build > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.notebook-curator-widget-build > header > div {
  display: grid;
  gap: 3px;
}

.notebook-curator-widget-build > header span {
  color: #a83451;
  font-size: 0.64rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.notebook-curator-widget-build > header strong {
  color: #241a1d;
  font-size: 0.95rem;
}

.notebook-curator-widget-build > header small {
  padding: 7px 10px;
  border-radius: 999px;
  color: #6f5e64;
  font-size: 0.7rem;
  font-weight: 800;
  background: #f0e8e3;
}

.notebook-curator-widget-build.is-ready_for_review > header small {
  color: #7c3a00;
  background: #fff0cd;
}

.notebook-curator-widget-build.is-published > header small {
  color: #176139;
  background: #dff4e7;
}

.notebook-curator-widget-build-message {
  margin: 0;
  padding: 22px;
  border-radius: 18px;
  color: #776b6e;
  text-align: center;
  background: #f6f0ec;
}

.notebook-curator-widget-build-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.student-notebook-block-content > .td-notebook-widget {
  margin-top: 8px;
}

.td-notebook-widget-sandbox {
  overflow: hidden;
}

.td-notebook-widget-frame-shell {
  position: relative;
  min-height: 280px;
  overflow: hidden;
  border: 1px solid rgba(68, 51, 57, 0.12);
  border-radius: 20px;
  background: #faf5ef;
}

.td-notebook-widget-frame {
  display: block;
  width: 100%;
  height: 420px;
  border: 0;
  opacity: 0;
  transition: opacity 180ms ease;
}

.td-notebook-widget-frame.is-loaded {
  opacity: 1;
}

.td-notebook-widget-frame-loading {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: grid;
  place-items: center;
  padding: 20px;
  color: #7d6870;
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  background:
    radial-gradient(circle at 50% 42%, rgba(196, 54, 91, 0.14), transparent 28%),
    #faf5ef;
}

.td-notebook-widget-frame-loading::before {
  position: absolute;
  width: 34px;
  height: 34px;
  margin-top: -48px;
  border: 3px solid rgba(168, 52, 81, 0.16);
  border-top-color: #a83451;
  border-radius: 50%;
  content: "";
  animation: td-widget-frame-spin 700ms linear infinite;
}

.td-notebook-widget-frame-loading.hidden {
  display: none;
}

.td-notebook-widget-sandbox.has-runtime-error .td-notebook-widget-frame-shell {
  border-color: rgba(174, 42, 72, 0.38);
}

@keyframes td-widget-frame-spin {
  to {
    transform: rotate(360deg);
  }
}

.student-notebook-blocks.is-paper .td-notebook-widget-graph {
  min-height: clamp(280px, 34vw, 420px);
}

@media (max-width: 720px) {
  .td-notebook-widget {
    gap: 11px;
    padding: 14px;
    border-radius: 18px;
  }

  .td-notebook-widget-header {
    align-items: flex-start;
  }

  .td-notebook-widget-badge {
    display: none;
  }

  .td-notebook-widget.is-focus-mode {
    inset: 6px;
    max-height: calc(100dvh - 12px);
    border-radius: 18px;
  }

  .td-notebook-widget-graph {
    min-height: 230px;
  }

  .td-notebook-widget-controls {
    grid-template-columns: 1fr;
  }

  .td-notebook-widget-frame-shell {
    min-height: 250px;
    border-radius: 15px;
  }

  .td-notebook-widget-legend {
    position: static;
    justify-content: flex-start;
    max-width: none;
    padding: 0 10px 10px;
  }

  .td-notebook-widget-legend > span {
    padding: 5px 8px;
    box-shadow: none;
  }

  .notebook-curator-widget-preview-head {
    display: grid;
  }

  .notebook-curator-widget-preview-head small {
    text-align: left;
  }
}
