* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --secondary: #6b7280;
  --danger: #dc2626;
  --success: #16a34a;
  --warning: #f59e0b;
  --bg: #f8fafc;
  --bg-light: #ffffff;
  --surface: #eff6ff;
  --border: #e5e7eb;
  --text: #0f172a;
  --muted: #64748b;
  --card: #ffffff;
  --shadow: rgba(15, 23, 42, 0.12);
}

html,
body {
  width: 100%;
  min-height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: radial-gradient(circle at top left, rgba(96, 165, 250, 0.16), transparent 28%),
    radial-gradient(circle at bottom right, rgba(52, 211, 153, 0.12), transparent 28%),
    linear-gradient(135deg, #0f172a 0%, #1e293b 44%, #334155 100%);
  color: var(--text);
  min-height: 100vh;
}

html {
  scroll-behavior: smooth;
}

button,
input,
select {
  font: inherit;
}

.hidden {
  display: none !important;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.92);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
}

.modal-content {
  background: var(--bg-light);
  border-radius: 24px;
  padding: 32px;
  max-width: 520px;
  width: min(92%, 520px);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.2);
}

.modal-header {
  text-align: center;
  margin-bottom: 24px;
}

.beaker-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.modal-header h1 {
  font-size: 28px;
  font-weight: 800;
  margin-bottom: 12px;
}

.modal-header p {
  color: var(--muted);
  line-height: 1.7;
}

.safety-alert {
  background: #fef3c7;
  border: 1px solid #fcd34d;
  border-radius: 16px;
  padding: 18px;
  display: flex;
  gap: 16px;
  margin-bottom: 24px;
  align-items: center;
}

.warning-icon {
  font-size: 24px;
}

.alert-title {
  font-weight: 700;
  color: #92400e;
  margin-bottom: 4px;
}

.alert-title,
.safety-alert p {
  font-size: 14px;
  line-height: 1.6;
}

/* Buttons */
.btn {
  border: none;
  border-radius: 12px;
  cursor: pointer;
  padding: 12px 20px;
  font-weight: 700;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.12);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  color: white;
  width: 100%;
}

.btn-secondary {
  background: var(--bg-light);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-sm {
  padding: 10px 16px;
  font-size: 0.95rem;
}

/* Layout */
.container {
  width: min(1200px, 100%);
  margin: 0 auto;
  padding: 24px 20px 40px;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  background: var(--bg-light);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 20px 24px;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
  margin-bottom: 24px;
}

.header-left {
  display: flex;
  gap: 16px;
  align-items: center;
}

.header-icon {
  width: 48px;
  height: 48px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  background: #eff6ff;
  color: var(--primary);
  font-size: 24px;
}

.app-title {
  font-size: 1.75rem;
  font-weight: 800;
}

.app-subtitle {
  font-size: 0.95rem;
  color: var(--muted);
}

.header-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.main-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 24px;
  align-items: start;
}

.sidebar {
  background: var(--bg-light);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 24px;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
}

.panel {
  display: grid;
  gap: 20px;
}

.panel-header h2 {
  font-size: 1.25rem;
  font-weight: 800;
}

.control-group {
  display: grid;
  gap: 10px;
}

.control-label {
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.toggle-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.cell-type-btn {
  background: var(--bg-light);
  border: 1px solid var(--border);
  padding: 14px 16px;
  border-radius: 16px;
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.cell-type-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary-dark);
}

.cell-type-btn:hover {
  border-color: var(--primary);
}

.control-meta {
  display: flex;
  justify-content: flex-end;
  font-weight: 700;
  color: var(--primary-dark);
}

input[type='range'] {
  width: 100%;
  accent-color: var(--primary);
  height: 10px;
}

input[type='range']::-webkit-slider-runnable-track {
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(90deg, #3b82f6 0%, #93c5fd 100%);
}

input[type='range']::-webkit-slider-thumb {
  height: 20px;
  width: 20px;
  border-radius: 50%;
  background: white;
  border: 3px solid var(--primary);
  margin-top: -5px;
}

input[type='range']::-moz-range-track {
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(90deg, #3b82f6 0%, #93c5fd 100%);
}

input[type='range']::-moz-range-thumb {
  height: 20px;
  width: 20px;
  border-radius: 50%;
  background: white;
  border: 3px solid var(--primary);
}

.range-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--muted);
}

.status-card {
  background: #ffffff;
  border-radius: 24px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.06);
}

.status-card-info {
  background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
  border-color: rgba(59, 130, 246, 0.18);
}

.status-label {
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.status-value {
  font-size: 1rem;
  font-weight: 700;
}

.panel-note {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 18px;
  color: var(--muted);
  line-height: 1.7;
}

.workspace {
  background: var(--bg-light);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 32px;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
}

.workspace-inner {
  display: grid;
  gap: 24px;
}

.workspace-header h2 {
  font-size: 1.5rem;
  font-weight: 800;
}

.workspace-header p {
  color: var(--muted);
}

.cell-display {
  background: radial-gradient(circle at 20% 25%, rgba(59, 130, 246, 0.18), transparent 32%),
    radial-gradient(circle at 80% 75%, rgba(16, 185, 129, 0.18), transparent 28%),
    linear-gradient(180deg, #eef2ff 0%, #ffffff 100%);
  border-radius: 32px;
  min-height: 380px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(59, 130, 246, 0.16);
  position: relative;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.12);
}

.cell-display::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 35%, rgba(255, 255, 255, 0.35), transparent 38%);
  pointer-events: none;
}

.cell-svg {
  width: 240px;
  height: 240px;
  transition: transform 0.25s ease;
}

.cell-svg circle,
.cell-svg rect {
  transition: transform 0.25s ease, fill 0.25s ease, stroke 0.25s ease, opacity 0.25s ease;
  stroke-width: 3px;
}

.cell-svg rect {
  shape-rendering: geometricPrecision;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.stat-box {
  background: var(--bg-light);
  border-radius: 22px;
  padding: 18px;
  border: 1px solid var(--border);
  text-align: center;
}

.stat-label {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
}

.stat-value {
  font-size: 1.15rem;
  font-weight: 800;
}

.content-section {
  margin-top: 28px;
  background: var(--bg-light);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 32px;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
}

.section-heading h2 {
  font-size: 1.8rem;
  font-weight: 800;
  margin-bottom: 10px;
}

.section-heading p {
  color: var(--muted);
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
  margin-top: 24px;
}

.feature-card {
  background: var(--bg-light);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 24px;
  text-align: center;
}

.feature-card h3 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 16px;
}

.feature-visual {
  width: 90px;
  height: 90px;
  margin: 0 auto 20px;
  border-radius: 50%;
  background: #eff6ff;
  display: grid;
  place-items: center;
  border: 1px solid #bfdbfe;
}

.feature-visual span {
  font-size: 1.6rem;
}

.feature-visual-center {
  background: #f8fafc;
}

.feature-visual-outward {
  background: #fef2f2;
}

.feature-visual-inward {
  background: #dcfce7;
}

.feature-card p {
  color: var(--muted);
  line-height: 1.75;
}

.quiz-card {
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 28px;
  padding: 28px;
  min-height: 340px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.08);
}

.quiz-progress {
  display: grid;
  gap: 10px;
}

.quiz-progress-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 700;
}

.quiz-progress-bar {
  height: 10px;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
}

.quiz-progress-bar > div {
  height: 100%;
  background: linear-gradient(90deg, #2563eb 0%, #38bdf8 100%);
  transition: width 0.25s ease;
}

.quiz-question-title {
  font-size: 1.45rem;
  line-height: 1.3;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 14px;
}

.options-list {
  display: grid;
  gap: 12px;
}

.quiz-explanation-text {
  color: #334155;
  line-height: 1.8;
}

.quiz-explanation-label {
  font-weight: 700;
  color: #1d4ed8;
}

.text-blue-600 {
  color: #2563eb !important;
}

.text-red-600 {
  color: #dc2626 !important;
}

.text-green-600 {
  color: #16a34a !important;
}

.tonic-hypotonic {
  box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.12), 0 24px 40px rgba(37, 99, 235, 0.12);
}

.tonic-isotonic {
  box-shadow: inset 0 0 0 1px rgba(5, 150, 105, 0.14), 0 24px 40px rgba(134, 239, 172, 0.14);
}

.tonic-hypertonic {
  box-shadow: inset 0 0 0 1px rgba(220, 38, 38, 0.14), 0 24px 40px rgba(251, 191, 36, 0.12);
}

.text-base {
  font-size: 1rem;
}

.font-bold {
  font-weight: 700;
}

.flex {
  display: flex;
}

.flex-col {
  flex-direction: column;
}

.items-center {
  align-items: center;
}

.justify-center {
  justify-content: center;
}

.text-center {
  text-align: center;
}

.text-6xl {
  font-size: 3.75rem;
  line-height: 1;
}

.text-3xl {
  font-size: 2rem;
  line-height: 1.1;
}

.text-lg {
  font-size: 1.125rem;
}

.text-gray-900 {
  color: #0f172a;
}

.text-gray-600 {
  color: #475569;
}

.bg-blue-600 {
  background: #2563eb;
}

.hover\:bg-blue-700:hover {
  background: #1d4ed8;
}

.text-white {
  color: #ffffff;
}

.px-6 {
  padding-left: 1.5rem;
  padding-right: 1.5rem;
}

.py-3 {
  padding-top: 0.75rem;
  padding-bottom: 0.75rem;
}

.rounded-full {
  border-radius: 9999px;
}

.transition-colors {
  transition: color 0.2s ease, background-color 0.2s ease, border-color 0.2s ease;
}

.quiz-option-btn {
  width: 100%;
  text-align: left;
  padding: 16px 18px;
  border-radius: 18px;
  background: #f8fafc;
  border: 1px solid #e5e7eb;
  margin-bottom: 12px;
  cursor: pointer;
  transition: border-color 0.2s ease, background-color 0.2s ease, transform 0.2s ease, color 0.2s ease;
}

.quiz-option-btn:hover:not(:disabled) {
  border-color: var(--primary);
  transform: translateY(-1px);
}

.quiz-option-btn:disabled {
  opacity: 0.75;
  cursor: not-allowed;
}

.quiz-option-btn.correct {
  background-color: #dcfce7;
  border-color: #22c55e;
  color: #166534;
}

.quiz-option-btn.wrong {
  background-color: #fee2e2;
  border-color: #ef4444;
  color: #991b1b;
}

.quiz-explanation {
  margin-top: 20px;
}

.quiz-next-btn {
  margin-top: 18px;
  background: var(--primary);
  color: white;
  border: none;
  padding: 14px 20px;
  border-radius: 18px;
  cursor: pointer;
  font-weight: 700;
  transition: background-color 0.2s ease, transform 0.2s ease;
}

.quiz-next-btn:hover {
  background: #1d4ed8;
  transform: translateY(-1px);
}

.quiz-option-btn {
  width: 100%;
  text-align: left;
  padding: 16px 18px;
  border-radius: 18px;
  background: white;
  border: 1px solid #e5e7eb;
  margin-bottom: 12px;
  cursor: pointer;
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

.quiz-option-btn.correct {
  background-color: #dcfce7;
  border-color: #22c55e;
  color: #15803d;
}

.quiz-option-btn.wrong {
  background-color: #fee2e2;
  border-color: #ef4444;
  color: #b91c1c;
}

.quiz-option-btn:hover {
  border-color: var(--primary);
}

.quiz-explanation {
  margin-top: 20px;
}

.quiz-next-btn {
  margin-top: 18px;
  background: var(--primary);
  color: white;
  border: none;
  padding: 14px 20px;
  border-radius: 18px;
  cursor: pointer;
  font-weight: 700;
}

.footer {
  text-align: center;
  color: rgba(255, 255, 255, 0.8);
  margin-top: 32px;
  font-size: 0.95rem;
}

.footer p {
  margin: 0;
}

@media (max-width: 960px) {
  .main-layout {
    grid-template-columns: 1fr;
  }

  .status-grid,
  .feature-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .container {
    padding: 20px 16px 32px;
  }

  .header,
  .sidebar,
  .workspace,
  .content-section,
  .quiz-card {
    padding: 20px;
  }

  .workspace-header h2,
  .section-heading h2 {
    font-size: 1.35rem;
  }
}

@media (max-width: 1080px) {
  .main-layout {
    grid-template-columns: 1fr;
  }

  .status-grid {
    grid-template-columns: 1fr;
  }

  .feature-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .header,
  .sidebar,
  .workspace,
  .content-section,
  .quiz-card {
    border-radius: 20px;
    padding: 20px;
  }

  .header {
    flex-direction: column;
    align-items: flex-start;
  }

  .header-actions {
    width: 100%;
    justify-content: flex-start;
  }
}
.top-1\/2 { top: 50%; }
.-translate-y-1\/2 { transform: translateY(-50%); }
.-translate-y-16 { transform: translateY(-4rem); }
.translate-y-16 { transform: translateY(4rem); }
.inset-0 { top: 0; right: 0; bottom: 0; left: 0; }
.-translate-y-10 { transform: translateY(-2.5rem); }

.selection\:bg-blue-200 *::selection { background-color: #bfdbfe; }

/* Range Input Styling */
input[type="range"] {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  height: 0.5rem;
  border-radius: 0.5rem;
  background: #e2e8f0;
  outline: none;
  -webkit-slider-thumb-appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 50%;
  background: currentColor;
  cursor: pointer;
  border: 2px solid white;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

input[type="range"]::-moz-range-thumb {
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 50%;
  background: currentColor;
  cursor: pointer;
  border: 2px solid white;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Buttons */
button {
  border: none;
  cursor: pointer;
  font-family: inherit;
  background-color: transparent;
}

.cell-type-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  border: 2px solid #e2e8f0;
  font-weight: 600;
  font-size: 0.875rem;
  color: #475569;
  transition: all 0.3s ease;
}

.cell-type-btn:hover {
  border-color: #cbd5e1;
}

.cell-type-btn.active {
  border-color: #2563eb;
  background-color: #eff6ff;
  color: #1e40af;
}

.cell-type-btn.active:nth-child(2) {
  border-color: #16a34a;
  background-color: #dcfce7;
  color: #166534;
}

/* Quiz */
.quiz-option-btn {
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-radius: 0.75rem;
  border: 2px solid #e5e7eb;
  transition: all 0.2s ease;
  font-weight: 500;
  color: #374151;
  gap: 0.5rem;
}

.quiz-option-btn:not(:disabled) {
  cursor: pointer;
}

.quiz-option-btn:not(:disabled):hover {
  border-color: #60a5fa;
  background-color: rgba(239, 246, 255, 0.5);
}

.quiz-option-btn:disabled {
  cursor: default;
}

.quiz-option-btn.correct {
  border-color: #16a34a;
  background-color: #dcfce7;
  color: #166534;
}

.quiz-option-btn.incorrect {
  border-color: #f87171;
  background-color: #fef2f2;
  color: #991b1b;
}

.quiz-option-btn.unselected-disabled {
  border-color: #e5e7eb;
  opacity: 0.5;
}

.quiz-explanation {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: flex-start;
  padding: 1.25rem;
  background-color: #eff6ff;
  border-radius: 0.75rem;
}

.quiz-explanation p {
  font-size: 0.875rem;
  color: #1e40af;
  line-height: 1.625;
  font-weight: 500;
}

.quiz-next-btn {
  white-space: nowrap;
  background-color: #2563eb;
  color: white;
  padding: 0.625rem 1.5rem;
  border-radius: 0.5rem;
  font-weight: 500;
  font-size: 0.875rem;
  transition: background-color 0.2s ease;
  margin-left: auto;
}

.quiz-next-btn:hover {
  background-color: #1d4ed8;
}

/* Link */
a {
  transition: all 0.2s ease;
}

/* Grayscale */
.grayscale {
  filter: grayscale(1);
}

/* Opacity */
.opacity-50 {
  opacity: 0.5;
}

/* Space */
.space-y-3 > * + * {
  margin-top: 0.75rem;
}

.space-y-4 > * + * {
  margin-top: 1rem;
}

.space-y-8 > * + * {
  margin-top: 2rem;
}

.space-y-16 > * + * {
  margin-top: 4rem;
}

/* Font Mono */
.font-mono {
  font-family: "Monaco", "Courier New", monospace;
}

/* Flex Shrink */
.flex-shrink-0 {
  flex-shrink: 0;
}

/* Screen readers */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* Print styles */
@media print {
  .hidden {
    display: none;
  }
}
