.chemlab { font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji"; color: #0f172a; }
.chemlab * { box-sizing: border-box; }
.chemlab .wrap { max-width: 1000px; margin: 1.25rem auto; padding: 1rem; border: 1px solid #e2e8f0; border-radius: 16px; background: #ffffff; box-shadow: 0 2px 20px rgba(2,6,23,0.04); }
.chemlab header { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; }
.chemlab h1 { font-size: clamp(1.25rem, 1rem + 1.5vw, 1.75rem); margin: 0; letter-spacing: 0.1px; }
.chemlab .tag { font-size: .8rem; padding: .25rem .5rem; border-radius: 999px; background: #eef2ff; color: #3730a3; border: 1px solid #c7d2fe; }

.chemlab .tabs { margin-top: 1rem; display: flex; gap: .5rem; flex-wrap: wrap; }
.chemlab .tab-btn { appearance: none; border: 1px solid #e2e8f0; background: #f8fafc; color: #0f172a; padding: .5rem .75rem; border-radius: 999px; cursor: pointer; font-size: .95rem; transition: transform .05s ease, background .2s ease, border-color .2s ease; }
.chemlab .tab-btn[aria-selected="true"] { background: #111827; color: #fff; border-color: #111827; }
.chemlab .tab-btn:active { transform: translateY(1px); }

.chemlab .panel { display: none; margin-top: 1rem; }
.chemlab .panel[aria-hidden="false"] { display: block; }

.chemlab .grid { display: flex; flex-direction: column; gap: 1rem; }
@media (min-width: 900px) { .chemlab .grid { display: flex; flex-direction: column; gap: 1rem; } }

.chemlab .card { border: 1px solid #e2e8f0; border-radius: 14px; padding: .75rem; background: #fcfcfd; }
.chemlab .card h3 { margin: .25rem 0 .5rem; font-size: 1.05rem; }
.chemlab label { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: .5rem; font-size: .9rem; margin: .5rem 0; }
.chemlab .row { display: grid; grid-template-columns: 1fr 70px; gap: .5rem; align-items: center; }
.chemlab input[type="range"] { width: 100%; }
.chemlab input[type="number"] { width: 100%; padding: .4rem .5rem; border: 1px solid #e2e8f0; border-radius: 8px; background: #fff; }
.chemlab .inline { display: inline-flex; gap: .5rem; align-items: center; }
.chemlab .switch { position: relative; width: 46px; height: 26px; display: inline-block; }
.chemlab .switch input { display: none; }
.chemlab .slider { position: absolute; inset: 0; border-radius: 999px; background:#e5e7eb; transition: .2s; }
.chemlab .slider::before { content:""; position: absolute; width: 22px; height: 22px; left: 2px; top: 2px; border-radius: 50%; background:#fff; box-shadow: 0 1px 3px rgba(0,0,0,.15); transition: .2s; }
.chemlab .switch input:checked + .slider { background:#16a34a; }
.chemlab .switch input:checked + .slider::before { transform: translateX(20px); }

.chemlab .meta { display: grid; grid-template-columns: repeat(auto-fit,minmax(160px,1fr)); gap: .5rem; }
.chemlab .pill { border: 1px dashed #cbd5e1; background:#f8fafc; border-radius: 12px; padding: .5rem .6rem; font-size: .86rem; }

.chemlab canvas { width: 100%; height: 360px; border-radius: 12px; display: block; background: #ffffff; border: 1px solid #e5e7eb; }
.chemlab .caption { font-size: .85rem; color: #475569; margin-top: .35rem; }

.chemlab .small { font-size: .82rem; color: #475569; }
.chemlab .footer { margin-top: 1rem; font-size: .8rem; color:#475569; text-align:center; }
.chemlab .kbd { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; background:#f1f5f9; border:1px solid #e2e8f0; padding: .1rem .35rem; border-radius: 6px; }
.chemlab .btn { appearance:none; border:1px solid #e2e8f0; background:#111827; color:#fff; padding:.5rem .8rem; border-radius:10px; cursor:pointer; font-size:.9rem; }
/* --- Added by ChatGPT: Force vertical stacking for blog layout --- */
.chemlab section .grid,
.chemlab .grid {
  display: flex !important;
  flex-direction: column !important;
  gap: 1rem;
}
/* Make children span full width to avoid squishing */
.chemlab .grid > * {
  width: 100%;
  max-width: 100%;
}
/* Ensure cards behave as block-level containers */
.chemlab .card {
  display: block;
}
