.magnet-page {
  background:
    radial-gradient(circle at 15% 18%, rgba(37, 99, 235, .14), transparent 26%),
    radial-gradient(circle at 84% 18%, rgba(239, 68, 68, .12), transparent 25%),
    var(--lab-bg);
}

.magnet-hero {
  background:
    radial-gradient(circle at 18% 22%, rgba(250, 204, 21, .18), transparent 24%),
    radial-gradient(circle at 82% 10%, rgba(37, 99, 235, .18), transparent 28%),
    linear-gradient(135deg, #eff6ff 0%, #fff 46%, #fef2f2 100%);
  border-bottom: 1px solid var(--lab-border);
  padding: clamp(1.25rem, 3vw, 2.2rem) 0;
}

.magnet-hero-grid {
  align-items: center;
  display: grid;
  gap: 1rem;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 320px);
}

.magnet-back-link {
  color: var(--lab-primary);
  display: inline-flex;
  font-weight: 900;
  margin-bottom: .7rem;
  text-decoration: none;
}

.magnet-hero h1 {
  color: var(--lab-text);
  font-size: clamp(2rem, 4.8vw, 3.5rem);
  font-weight: 900;
  line-height: 1.15;
  margin: 0;
}

.magnet-hero p {
  color: var(--lab-muted);
  font-size: clamp(1rem, 2vw, 1.18rem);
  font-weight: 800;
  line-height: 1.9;
  margin: .65rem 0 0;
  max-width: 760px;
}

.magnet-brand-icon {
  background: linear-gradient(135deg, #ef4444, #2563eb);
}

.magnet-status-card,
.magnet-workbench,
.magnet-notes {
  background: rgba(255, 255, 255, .94);
  border: 1px solid var(--lab-border);
  border-radius: 24px;
  box-shadow: var(--lab-shadow);
}

.magnet-status-card {
  align-items: center;
  display: grid;
  gap: .35rem .75rem;
  grid-template-columns: auto 1fr;
  padding: .95rem;
}

.magnet-status-dot {
  background: #2563eb;
  border-radius: 999px;
  box-shadow: 0 0 0 8px rgba(37, 99, 235, .14);
  grid-row: span 2;
  height: 18px;
  width: 18px;
}

.magnet-status-dot.is-active {
  background: #22c55e;
  box-shadow: 0 0 0 8px rgba(34, 197, 94, .16);
}

.magnet-status-card strong {
  color: var(--lab-text);
  font-size: 1.08rem;
  font-weight: 900;
}

.magnet-status-card small {
  color: var(--lab-muted);
  font-weight: 800;
  line-height: 1.6;
}

.magnet-main {
  padding: clamp(.9rem, 2.4vw, 1.5rem) 0;
}

.magnet-message-bar {
  background: linear-gradient(135deg, rgba(37, 99, 235, .1), rgba(239, 68, 68, .08));
  border: 1px solid rgba(37, 99, 235, .14);
  border-radius: 18px;
  color: var(--lab-primary);
  font-weight: 900;
  line-height: 1.8;
  margin-bottom: .65rem;
  padding: .65rem .85rem;
  text-align: center;
}

.magnet-message-bar.success {
  background: rgba(34, 197, 94, .12);
  border-color: rgba(34, 197, 94, .28);
  color: #15803d;
}

.magnet-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-bottom: .65rem;
}

.magnet-tool-button {
  align-items: center;
  background: rgba(255, 255, 255, .92);
  border: 1px solid rgba(37, 99, 235, .16);
  border-radius: 14px;
  box-shadow: 0 10px 22px rgba(15, 23, 42, .08);
  color: var(--lab-text);
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  font-weight: 900;
  min-height: 42px;
  padding: .48rem .8rem;
}

.magnet-strength {
  align-items: center;
  background: rgba(255, 255, 255, .92);
  border: 1px solid rgba(37, 99, 235, .16);
  border-radius: 14px;
  box-shadow: 0 10px 22px rgba(15, 23, 42, .08);
  display: inline-flex;
  flex-wrap: wrap;
  gap: .35rem;
  min-height: 42px;
  padding: .34rem .45rem;
}

.magnet-strength span {
  color: var(--lab-muted);
  font-size: .88rem;
  font-weight: 900;
  padding: 0 .35rem;
}

.magnet-strength button {
  background: rgba(37, 99, 235, .08);
  border: 1px solid transparent;
  border-radius: 999px;
  color: var(--lab-primary);
  cursor: pointer;
  font: inherit;
  font-size: .88rem;
  font-weight: 900;
  min-height: 32px;
  padding: .28rem .65rem;
}

.magnet-strength button.is-active,
.magnet-tool-button.is-active {
  background: linear-gradient(135deg, #2563eb, #16a34a);
  color: #fff;
}

.magnet-tool-button.help-tool {
  color: var(--lab-primary);
}

.magnet-layout {
  display: grid;
  gap: .75rem;
  grid-template-columns: minmax(0, 1fr) 280px;
}

.magnet-workbench {
  background:
    linear-gradient(180deg, rgba(219, 234, 254, .9), rgba(248, 250, 252, .96) 44%, rgba(226, 232, 240, .98) 45%, rgba(241, 245, 249, .98));
  height: min(62vh, 560px);
  min-height: 430px;
  overflow: hidden;
  position: relative;
  touch-action: none;
}

.table-surface {
  background:
    linear-gradient(90deg, rgba(148, 163, 184, .16) 1px, transparent 1px),
    linear-gradient(180deg, rgba(148, 163, 184, .16) 1px, transparent 1px),
    linear-gradient(180deg, rgba(226, 232, 240, .62), rgba(203, 213, 225, .62));
  background-size: 34px 34px, 34px 34px, auto;
  bottom: 0;
  height: 58%;
  left: 0;
  position: absolute;
  right: 0;
}

.field-rings {
  border: 2px dashed rgba(37, 99, 235, .2);
  border-radius: 999px;
  height: 300px;
  left: 50%;
  opacity: .65;
  pointer-events: none;
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 300px;
  z-index: 4;
}

.field-rings.is-hidden {
  display: none;
}

.field-rings::before,
.field-rings::after {
  border: inherit;
  border-radius: inherit;
  content: "";
  inset: 42px;
  position: absolute;
}

.field-rings::after {
  inset: 86px;
}

.u-magnet {
  background: transparent;
  border: 0;
  cursor: grab;
  height: 108px;
  left: 50%;
  padding: 0;
  position: absolute;
  top: 34%;
  transform: translate(-50%, -50%);
  touch-action: none;
  width: 128px;
  z-index: 10;
}

.u-magnet:active {
  cursor: grabbing;
}

.magnet-pole {
  align-items: end;
  border-radius: 22px 22px 12px 12px;
  box-shadow: inset 0 -8px 0 rgba(0, 0, 0, .14), 0 12px 20px rgba(15, 23, 42, .16);
  color: #fff;
  display: flex;
  font-weight: 900;
  height: 92px;
  justify-content: center;
  padding-bottom: .45rem;
  position: absolute;
  top: 12px;
  width: 38px;
}

.magnet-pole.north {
  background: linear-gradient(180deg, #fb7185, #dc2626);
  right: 18px;
}

.magnet-pole.south {
  background: linear-gradient(180deg, #60a5fa, #2563eb);
  left: 18px;
}

.magnet-bridge {
  border: 18px solid #475569;
  border-bottom: 0;
  border-radius: 60px 60px 0 0;
  height: 62px;
  left: 50%;
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  width: 112px;
}

.objects-layer {
  inset: 0;
  position: absolute;
  z-index: 5;
}

.magnet-object {
  align-items: center;
  display: flex;
  flex-direction: column;
  gap: .12rem;
  height: 62px;
  justify-content: center;
  left: 0;
  pointer-events: none;
  position: absolute;
  top: 0;
  transform: translate(-50%, -50%);
  width: 74px;
  will-change: transform;
}

.magnet-object svg {
  filter: drop-shadow(0 8px 8px rgba(15, 23, 42, .16));
  height: 40px;
  overflow: visible;
  width: 54px;
}

.magnet-object small {
  background: rgba(255, 255, 255, .84);
  border: 1px solid rgba(148, 163, 184, .22);
  border-radius: 999px;
  color: #0f172a;
  font-size: .72rem;
  font-weight: 900;
  line-height: 1;
  padding: .22rem .42rem;
  white-space: nowrap;
}

.magnet-object.is-pulling {
  animation: magnetShake .18s linear infinite;
}

.magnet-object.is-attached svg {
  filter: drop-shadow(0 0 8px rgba(37, 99, 235, .28));
}

.magnet-object.is-observed:not(.is-metal) svg {
  opacity: .72;
}

@keyframes magnetShake {
  0%, 100% { margin-right: 0; }
  33% { margin-right: -2px; }
  66% { margin-right: 2px; }
}

.magnet-notes {
  max-height: min(62vh, 560px);
  overflow: auto;
  padding: .85rem;
}

.magnet-notes h2 {
  color: var(--lab-text);
  font-size: 1.1rem;
  font-weight: 900;
  margin: 0 0 .75rem;
}

.magnet-counter {
  align-items: center;
  background: rgba(34, 197, 94, .1);
  border: 1px solid rgba(34, 197, 94, .16);
  border-radius: 16px;
  display: flex;
  justify-content: space-between;
  margin-bottom: .55rem;
  padding: .65rem;
}

.magnet-counter.muted {
  background: rgba(148, 163, 184, .12);
  border-color: rgba(148, 163, 184, .2);
}

.magnet-counter span,
.magnet-counter strong {
  font-weight: 900;
}

.magnet-notes ul {
  display: grid;
  gap: .5rem;
  list-style: none;
  margin: .75rem 0 0;
  padding: 0;
}

.magnet-notes li {
  background: rgba(37, 99, 235, .08);
  border: 1px solid rgba(37, 99, 235, .13);
  border-radius: 14px;
  color: var(--lab-text);
  font-weight: 800;
  line-height: 1.7;
  padding: .55rem;
}

.magnet-observation,
.magnet-conclusion {
  background: rgba(248, 250, 252, .85);
  border: 1px solid rgba(148, 163, 184, .18);
  border-radius: 16px;
  margin-top: .75rem;
  padding: .7rem;
}

.magnet-observation h3 {
  color: var(--lab-text);
  font-size: 1rem;
  font-weight: 900;
  margin: 0 0 .55rem;
}

.magnet-observation div + div {
  margin-top: .55rem;
}

.magnet-observation strong {
  color: var(--lab-primary);
  display: block;
  font-size: .9rem;
  font-weight: 900;
  margin-bottom: .25rem;
}

.magnet-observation p,
.magnet-conclusion {
  color: var(--lab-muted);
  font-size: .92rem;
  font-weight: 800;
  line-height: 1.7;
  margin: 0;
}

.magnet-conclusion {
  color: var(--lab-text);
}

.lab-theme-dark .magnet-hero {
  background:
    radial-gradient(circle at 18% 22%, rgba(250, 204, 21, .12), transparent 24%),
    radial-gradient(circle at 82% 10%, rgba(96, 165, 250, .16), transparent 28%),
    linear-gradient(135deg, #08111f 0%, #0f172a 55%, #1f1720 100%);
}

.lab-theme-dark .magnet-status-card,
.lab-theme-dark .magnet-workbench,
.lab-theme-dark .magnet-notes,
.lab-theme-dark .magnet-tool-button,
.lab-theme-dark .magnet-strength,
.lab-theme-dark .magnet-observation,
.lab-theme-dark .magnet-conclusion {
  background: rgba(17, 24, 39, .94);
  border-color: rgba(148, 163, 184, .18);
  color: #f8fafc;
}

.lab-theme-dark .magnet-workbench {
  background:
    linear-gradient(180deg, rgba(15, 37, 71, .95), rgba(15, 23, 42, .96) 44%, rgba(30, 41, 59, .98) 45%, rgba(15, 23, 42, .98));
}

.lab-theme-dark .table-surface {
  background:
    linear-gradient(90deg, rgba(148, 163, 184, .1) 1px, transparent 1px),
    linear-gradient(180deg, rgba(148, 163, 184, .1) 1px, transparent 1px),
    linear-gradient(180deg, rgba(30, 41, 59, .72), rgba(15, 23, 42, .8));
}

.lab-theme-dark .magnet-object small {
  background: rgba(15, 23, 42, .82);
  border-color: rgba(148, 163, 184, .2);
  color: #f8fafc;
}

@media (max-width: 980px) {
  .magnet-hero-grid,
  .magnet-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .magnet-page .lab-header {
    gap: .45rem;
    padding-block: .55rem;
  }

  .magnet-page .lab-brand {
    font-size: .95rem;
  }

  .magnet-page .lab-brand-icon {
    border-radius: 12px;
    font-size: 1rem;
    height: 34px;
    width: 34px;
  }

  .magnet-page .lab-nav {
    gap: .4rem;
  }

  .magnet-page .lab-nav a,
  .magnet-page .lab-theme-toggle {
    font-size: .82rem;
    min-height: 34px;
    padding: .35rem .55rem;
  }

  .magnet-hero {
    padding: .55rem 0;
  }

  .magnet-hero-grid {
    display: block;
  }

  .magnet-back-link,
  .magnet-hero .lab-kicker,
  .magnet-hero p,
  .magnet-status-card {
    display: none;
  }

  .magnet-hero h1 {
    font-size: 1.65rem;
    text-align: center;
  }

  .magnet-main {
    padding-top: .55rem;
  }

  .magnet-message-bar {
    border-radius: 14px;
    font-size: .9rem;
    line-height: 1.55;
    margin-bottom: .45rem;
    padding: .5rem .65rem;
  }

  .magnet-toolbar {
    display: grid;
    gap: .42rem;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-bottom: .5rem;
  }

  .magnet-strength {
    display: grid;
    gap: .28rem;
    grid-column: 1 / -1;
    grid-template-columns: auto repeat(3, minmax(0, 1fr));
    min-height: 38px;
    padding: .28rem;
    width: 100%;
  }

  .magnet-strength span {
    align-self: center;
    font-size: .78rem;
    padding: 0 .2rem;
    white-space: nowrap;
  }

  .magnet-strength button {
    font-size: .78rem;
    min-height: 30px;
    padding: .2rem .35rem;
  }

  .magnet-tool-button {
    border-radius: 13px;
    font-size: .82rem;
    justify-content: center;
    min-height: 38px;
    padding: .35rem .25rem;
    width: 100%;
  }

  .magnet-workbench {
    background:
      radial-gradient(circle at 50% 48%, rgba(37, 99, 235, .14), transparent 28%),
      radial-gradient(circle at 50% 48%, rgba(239, 68, 68, .09), transparent 44%),
      linear-gradient(180deg, rgba(219, 234, 254, .95), rgba(248, 250, 252, .96));
    height: min(68vh, 540px);
    min-height: 460px;
  }

  .table-surface {
    height: 100%;
    opacity: .34;
  }

  .field-rings {
    height: 250px;
    width: 250px;
  }

  .u-magnet {
    height: 86px;
    width: 104px;
  }

  .magnet-pole {
    height: 72px;
    width: 32px;
  }

  .magnet-bridge {
    height: 50px;
    width: 92px;
  }

  .magnet-object {
    height: 42px;
    width: 48px;
  }

  .magnet-object svg {
    height: 34px;
    width: 44px;
  }

  .magnet-object small {
    display: none;
  }

  .lab-theme-dark .magnet-workbench {
    background:
      radial-gradient(circle at 50% 48%, rgba(96, 165, 250, .16), transparent 28%),
      radial-gradient(circle at 50% 48%, rgba(248, 113, 113, .1), transparent 44%),
      linear-gradient(180deg, rgba(15, 37, 71, .95), rgba(15, 23, 42, .98));
  }
}
