.matter-page {
  background: #f8fafc;
}

.matter-topbar .matter-brand-icon {
  font-size: .8rem;
  font-weight: 900;
  letter-spacing: -.02em;
}

.matter-hero {
  background:
    radial-gradient(circle at 12% 18%, rgba(96, 165, 250, .24), transparent 28%),
    radial-gradient(circle at 84% 18%, rgba(34, 197, 94, .2), transparent 30%),
    linear-gradient(135deg, #eff6ff 0%, #fff 48%, #f0fdf4 100%);
  padding: clamp(2rem, 5vw, 4rem) 0;
}

.matter-hero-grid {
  align-items: center;
  display: grid;
  gap: 1.25rem;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 360px);
}

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

.matter-hero h1 {
  color: #0f172a;
  font-size: clamp(2.1rem, 5vw, 4rem);
  font-weight: 900;
  line-height: 1.18;
  margin: 0;
}

.matter-hero p {
  color: #475569;
  font-size: 1.08rem;
  font-weight: 800;
  line-height: 1.9;
  margin: .8rem 0 0;
}

.matter-status-card {
  background: rgba(255, 255, 255, .9);
  border: 1px solid rgba(37, 99, 235, .14);
  border-radius: 24px;
  box-shadow: 0 22px 55px rgba(15, 23, 42, .1);
  display: grid;
  gap: .45rem;
  padding: 1.2rem;
}

.matter-status-dot {
  background: linear-gradient(135deg, #60a5fa, #2563eb);
  border-radius: 20px;
  box-shadow: 0 14px 30px rgba(37, 99, 235, .22);
  height: 72px;
  width: 72px;
}

.matter-status-card strong {
  color: #0f172a;
  font-size: 1.35rem;
  font-weight: 900;
}

.matter-status-card small {
  color: #64748b;
  font-size: .98rem;
  font-weight: 800;
  line-height: 1.7;
}

.matter-main {
  padding: clamp(1.3rem, 3vw, 2.2rem) 0 3rem;
}

.matter-message-bar {
  background: linear-gradient(135deg, rgba(37, 99, 235, .1), rgba(34, 197, 94, .1));
  border: 1px solid rgba(37, 99, 235, .14);
  border-radius: 18px;
  color: #1d4ed8;
  font-weight: 900;
  line-height: 1.7;
  margin-bottom: 1rem;
  padding: .85rem 1rem;
  text-align: center;
}

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

.matter-layout {
  align-items: start;
  display: grid;
  gap: 1rem;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
}

.matter-lab-card,
.matter-notes section {
  background: rgba(255, 255, 255, .94);
  border: 1px solid rgba(148, 163, 184, .22);
  border-radius: 24px;
  box-shadow: 0 18px 42px rgba(15, 23, 42, .08);
}

.matter-lab-card {
  display: grid;
  gap: 1rem;
  padding: 1rem;
}

.matter-toolbar {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: .55rem;
  justify-content: center;
}

.matter-state-buttons {
  background: #f1f5f9;
  border: 1px solid rgba(148, 163, 184, .18);
  border-radius: 999px;
  display: inline-flex;
  gap: .25rem;
  padding: .25rem;
}

.matter-state-buttons button,
.matter-tool-button,
.matter-quiz button {
  border: 0;
  cursor: pointer;
  font: inherit;
  font-weight: 900;
}

.matter-state-buttons button {
  background: transparent;
  border-radius: 999px;
  color: #64748b;
  min-height: 42px;
  padding: .45rem .85rem;
}

.matter-state-buttons button.is-active {
  background: #fff;
  box-shadow: 0 8px 18px rgba(15, 23, 42, .08);
  color: var(--lab-primary);
}

.matter-tool-button {
  align-items: center;
  background: #fff;
  border: 1px solid rgba(37, 99, 235, .14);
  border-radius: 999px;
  color: #1e293b;
  display: inline-flex;
  gap: .45rem;
  min-height: 44px;
  padding: .55rem .85rem;
}

.matter-tool-button:hover,
.matter-tool-button:focus,
.matter-quiz button:hover,
.matter-quiz button:focus {
  box-shadow: 0 12px 24px rgba(37, 99, 235, .14);
  outline: none;
  transform: translateY(-1px);
}

.matter-tool-button span {
  border-radius: 50%;
  height: 12px;
  width: 12px;
}

.matter-tool-button.cool span {
  background: #60a5fa;
}

.matter-tool-button.heat span {
  background: #f97316;
}

.matter-stage {
  align-items: stretch;
  display: grid;
  gap: .8rem;
  grid-template-columns: minmax(0, 1fr) 58px;
}

.matter-container-frame {
  background:
    linear-gradient(90deg, rgba(37, 99, 235, .055) 1px, transparent 1px),
    linear-gradient(180deg, rgba(37, 99, 235, .055) 1px, transparent 1px),
    linear-gradient(180deg, #f8fbff, #eef7ff);
  background-size: 28px 28px, 28px 28px, auto;
  border: 4px solid rgba(37, 99, 235, .2);
  border-radius: 28px;
  min-height: min(58vh, 470px);
  overflow: hidden;
  position: relative;
}

.matter-canvas {
  display: block;
  height: 100%;
  inset: 0;
  position: absolute;
  width: 100%;
  z-index: 4;
}

.matter-ice-shape,
.matter-liquid-shape,
.matter-steam-cloud {
  inset: auto 8% 8%;
  opacity: 0;
  pointer-events: none;
  position: absolute;
  transition: opacity .3s ease, transform .3s ease;
}

.matter-ice-shape {
  background:
    linear-gradient(135deg, rgba(191, 219, 254, .95), rgba(37, 99, 235, .16));
  border: 2px solid rgba(37, 99, 235, .22);
  border-radius: 24px;
  bottom: 18%;
  height: 42%;
  left: 23%;
  right: 23%;
  transform: rotate(-1deg);
}

.matter-liquid-shape {
  background:
    radial-gradient(circle at 30% 20%, rgba(255, 255, 255, .46), transparent 22%),
    linear-gradient(180deg, rgba(96, 165, 250, .72), rgba(37, 99, 235, .48));
  border-radius: 46% 54% 24px 24px;
  bottom: 7%;
  height: 43%;
  left: 8%;
  right: 8%;
}

.matter-steam-cloud {
  background:
    radial-gradient(circle at 20% 55%, rgba(226, 232, 240, .8), transparent 24%),
    radial-gradient(circle at 48% 35%, rgba(226, 232, 240, .75), transparent 28%),
    radial-gradient(circle at 74% 58%, rgba(226, 232, 240, .72), transparent 24%);
  bottom: 18%;
  height: 64%;
  left: 7%;
  right: 7%;
  transform: translateY(10px);
}

.matter-state-solid .matter-ice-shape,
.matter-state-liquid .matter-liquid-shape,
.matter-state-gas .matter-steam-cloud {
  opacity: 1;
  transform: translateY(0);
}

.matter-state-badge {
  background: rgba(15, 23, 42, .82);
  border-radius: 999px;
  color: #fff;
  font-size: .9rem;
  font-weight: 900;
  inset-inline-start: 1rem;
  padding: .45rem .8rem;
  position: absolute;
  top: 1rem;
  z-index: 8;
}

.matter-thermometer {
  align-items: center;
  background: #fff;
  border: 1px solid rgba(148, 163, 184, .22);
  border-radius: 22px;
  box-shadow: 0 16px 34px rgba(15, 23, 42, .07);
  display: grid;
  gap: .5rem;
  justify-items: center;
  padding: .65rem .35rem;
}

.matter-thermometer span {
  color: #64748b;
  font-size: .78rem;
  font-weight: 900;
  writing-mode: vertical-rl;
}

.matter-thermometer div {
  background: #e2e8f0;
  border-radius: 999px;
  height: 240px;
  overflow: hidden;
  position: relative;
  width: 18px;
}

.matter-thermometer i {
  background: linear-gradient(180deg, #ef4444, #f97316, #60a5fa);
  border-radius: inherit;
  bottom: 0;
  height: 25%;
  left: 0;
  position: absolute;
  right: 0;
  transition: height .28s ease;
}

.matter-notes {
  display: grid;
  gap: 1rem;
}

.matter-notes section {
  padding: 1rem;
}

.matter-notes h2 {
  color: #0f172a;
  font-size: 1.1rem;
  font-weight: 900;
  margin: 0 0 .65rem;
}

.matter-notes p,
.matter-notes dd {
  color: #475569;
  font-weight: 800;
  line-height: 1.8;
  margin: 0;
}

.matter-facts dl {
  display: grid;
  gap: .6rem;
  margin: 0;
}

.matter-facts div {
  background: #f8fafc;
  border: 1px solid rgba(148, 163, 184, .16);
  border-radius: 16px;
  padding: .7rem;
}

.matter-facts dt {
  color: var(--lab-primary);
  font-size: .82rem;
  font-weight: 900;
  margin-bottom: .2rem;
}

.matter-quiz div {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin: .75rem 0;
}

.matter-quiz button {
  background: rgba(37, 99, 235, .08);
  border-radius: 999px;
  color: var(--lab-primary);
  min-height: 42px;
  padding: .45rem .85rem;
}

.matter-quiz button.is-correct {
  background: rgba(34, 197, 94, .16);
  color: #15803d;
}

.matter-quiz button.is-wrong {
  background: rgba(239, 68, 68, .14);
  color: #b91c1c;
}

.matter-quiz strong {
  color: #64748b;
  display: block;
  font-weight: 900;
}

.lab-theme-dark.matter-page {
  background: #08111f;
}

.lab-theme-dark .matter-hero {
  background:
    radial-gradient(circle at 12% 18%, rgba(96, 165, 250, .14), transparent 28%),
    radial-gradient(circle at 84% 18%, rgba(34, 197, 94, .12), transparent 30%),
    linear-gradient(135deg, #08111f 0%, #0f172a 55%, #10231d 100%);
}

.lab-theme-dark .matter-hero h1,
.lab-theme-dark .matter-status-card strong,
.lab-theme-dark .matter-notes h2 {
  color: #f8fafc;
}

.lab-theme-dark .matter-hero p,
.lab-theme-dark .matter-status-card small,
.lab-theme-dark .matter-notes p,
.lab-theme-dark .matter-notes dd {
  color: #cbd5e1;
}

.lab-theme-dark .matter-status-card,
.lab-theme-dark .matter-lab-card,
.lab-theme-dark .matter-notes section,
.lab-theme-dark .matter-thermometer {
  background: rgba(17, 24, 39, .94);
  border-color: rgba(148, 163, 184, .18);
  box-shadow: 0 18px 42px rgba(0, 0, 0, .24);
}

.lab-theme-dark .matter-container-frame {
  background:
    linear-gradient(90deg, rgba(96, 165, 250, .08) 1px, transparent 1px),
    linear-gradient(180deg, rgba(96, 165, 250, .08) 1px, transparent 1px),
    linear-gradient(180deg, #0f172a, #101f35);
  border-color: rgba(96, 165, 250, .2);
}

.lab-theme-dark .matter-state-buttons,
.lab-theme-dark .matter-tool-button,
.lab-theme-dark .matter-facts div,
.lab-theme-dark .matter-quiz button {
  background: rgba(15, 23, 42, .78);
  border-color: rgba(148, 163, 184, .2);
  color: #dbeafe;
}

.lab-theme-dark .matter-state-buttons button {
  color: #cbd5e1;
}

.lab-theme-dark .matter-state-buttons button.is-active {
  background: #1e293b;
  color: #bfdbfe;
}

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

  .matter-stage {
    grid-template-columns: 1fr;
  }

  .matter-thermometer {
    grid-template-columns: auto 1fr auto;
  }

  .matter-thermometer span {
    writing-mode: horizontal-tb;
  }

  .matter-thermometer div {
    height: 16px;
    width: 100%;
  }

  .matter-thermometer i {
    height: 100%;
    width: 25%;
  }
}

@media (max-width: 620px) {
  .matter-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .matter-state-buttons,
  .matter-tool-button {
    justify-content: center;
    width: 100%;
  }

  .matter-stage {
    gap: .65rem;
  }

  .matter-container-frame {
    min-height: 360px;
  }

  .matter-quiz div {
    display: grid;
    grid-template-columns: 1fr;
  }
}
