:root {
  --green: #27ae60;
  --green-deep: #145a32;
  --green-soft: #d5f5e3;
  --mint: #ebfff4;
  --ink: #10251a;
  --muted: #547062;
  --panel: rgba(255, 255, 255, 0.72);
  --panel-strong: rgba(255, 255, 255, 0.86);
  --border: rgba(255, 255, 255, 0.55);
  --shadow: 0 18px 55px rgba(20, 90, 50, 0.18);
  --radius: 28px;
  --radius-sm: 18px;
  --danger: #b42318;
  --success: #1e8449;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  scroll-behavior: smooth;
}

body {
  min-height: 100%;
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 10%, rgba(39, 174, 96, 0.32), transparent 28rem),
    radial-gradient(circle at 90% 15%, rgba(213, 245, 227, 0.8), transparent 22rem),
    linear-gradient(135deg, #eefbf3 0%, #d8f4e4 42%, #f9fffb 100%);
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(39, 174, 96, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(39, 174, 96, 0.08) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(to bottom, rgba(0,0,0,0.7), transparent 85%);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 18px 0 40px;
}

.glass-panel,
.glass-card {
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.hero {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 18px;
  align-items: center;
  padding: clamp(20px, 4vw, 42px);
  border-radius: 34px;
  overflow: hidden;
  position: relative;
}

.hero::after {
  content: "";
  position: absolute;
  right: -70px;
  bottom: -70px;
  width: 260px;
  height: 260px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(39,174,96,0.3), transparent 70%);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--green-deep);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  font-size: clamp(2.1rem, 7vw, 4.8rem);
  line-height: 0.96;
  letter-spacing: -0.06em;
  margin-bottom: 14px;
}

h2 {
  font-size: clamp(1.55rem, 4vw, 2.45rem);
  line-height: 1.02;
  letter-spacing: -0.04em;
  margin-bottom: 10px;
}

h3 {
  font-size: 1.18rem;
  margin-bottom: 12px;
}

.hero-text,
.section-heading p,
.note-card li,
.lab-card p,
.dictionary-list p,
.viewer-tip {
  color: var(--muted);
  line-height: 1.55;
}

.hero-text {
  max-width: 780px;
  font-size: 1.05rem;
  margin: 0;
}

.hero-badge {
  width: min(28vw, 142px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  text-align: center;
  border-radius: 34px;
  background: linear-gradient(145deg, rgba(39,174,96,0.96), rgba(20,90,50,0.92));
  color: white;
  box-shadow: 0 18px 42px rgba(20, 90, 50, 0.28);
  position: relative;
  z-index: 1;
}

.hero-badge span {
  display: block;
  font-size: clamp(2rem, 7vw, 3.6rem);
  font-weight: 900;
  line-height: 0.9;
}

.hero-badge small {
  display: block;
  max-width: 86px;
  margin: 5px auto 0;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.tab-bar {
  position: sticky;
  top: 10px;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 14px 0 18px;
  padding: 8px;
  border-radius: 999px;
}

.tab-btn {
  border: 0;
  border-radius: 999px;
  padding: 13px 12px;
  color: var(--green-deep);
  background: transparent;
  font-weight: 850;
  transition: transform 160ms ease, background 160ms ease, color 160ms ease;
}

.tab-btn:active {
  transform: scale(0.97);
}

.tab-btn.active {
  color: white;
  background: linear-gradient(135deg, var(--green), var(--green-deep));
  box-shadow: 0 10px 28px rgba(39, 174, 96, 0.28);
}

.tab-view {
  display: none;
}

.tab-view.active {
  display: block;
  animation: rise 250ms ease both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.section-heading {
  padding: 12px 4px 10px;
}

.section-heading.compact {
  padding: 0;
  margin-bottom: 16px;
}

.section-heading p {
  max-width: 850px;
  margin-bottom: 0;
}

.content-grid,
.lab-grid,
.molecule-grid,
.diagram-grid {
  display: grid;
  gap: 16px;
}

.content-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.glass-card {
  border-radius: var(--radius);
  padding: clamp(18px, 3vw, 28px);
}

.note-card {
  min-height: 100%;
}

.clean-list {
  margin: 0;
  padding-left: 1.1rem;
}

.clean-list li + li {
  margin-top: 10px;
}

.interactive-zone,
.diagram-section,
.dictionary,
.quiz-shell,
.practical-template {
  margin-top: 18px;
}

.molecule-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  perspective: 1000px;
}

.flip-card {
  min-height: 235px;
  padding: 0;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  perspective: 1000px;
  text-align: left;
}

.flip-inner {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  min-height: 235px;
  transform-style: preserve-3d;
  transition: transform 550ms cubic-bezier(.2,.85,.2,1);
}

.flip-card.is-flipped .flip-inner {
  transform: rotateY(180deg);
}

.flip-face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 22px;
  border-radius: var(--radius);
  backface-visibility: hidden;
  background: var(--panel-strong);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.flip-face.front {
  justify-content: center;
  align-items: flex-start;
}

.flip-face.back {
  transform: rotateY(180deg);
  justify-content: center;
}

.flip-face strong {
  font-size: 1.06rem;
}

.flip-face small,
.flip-face span {
  color: var(--muted);
  line-height: 1.45;
}

.molecule-icon {
  display: block;
  width: 72px;
  height: 72px;
  border-radius: 23px;
  margin-bottom: 12px;
  background: linear-gradient(145deg, rgba(39,174,96,.2), rgba(39,174,96,.72));
  position: relative;
}

.molecule-icon::before,
.molecule-icon::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  background: white;
  opacity: 0.8;
}

.molecule-icon::before {
  width: 20px;
  height: 20px;
  left: 14px;
  top: 18px;
}

.molecule-icon::after {
  width: 29px;
  height: 29px;
  right: 12px;
  bottom: 13px;
}

.molecule-icon.lipid {
  border-radius: 50% 50% 22px 22px;
}

.molecule-icon.protein {
  transform: rotate(8deg);
}

.molecule-icon.nucleic {
  border-radius: 999px;
}

.diagram-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.diagram-card {
  border: 1px solid rgba(39, 174, 96, 0.2);
  border-radius: 22px;
  padding: 14px;
  background: rgba(255,255,255,0.58);
  text-align: left;
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.diagram-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 38px rgba(20,90,50,.16);
}

.diagram-thumb {
  display: grid;
  place-items: center;
  height: 160px;
  border-radius: 18px;
  background: rgba(235,255,244,0.9);
  overflow: hidden;
  margin-bottom: 12px;
}

.diagram-thumb svg,
.diagram-canvas svg {
  width: 100%;
  height: 100%;
  max-height: 68vh;
}

.diagram-card strong {
  display: block;
  color: var(--ink);
}

.diagram-card small {
  color: var(--muted);
}

.dictionary .search-label,
.quiz-toolbar label {
  display: block;
  font-weight: 850;
  margin-bottom: 7px;
}

.search-input,
.quiz-toolbar select,
.quiz-form input {
  width: 100%;
  min-height: 48px;
  border: 1px solid rgba(20, 90, 50, 0.16);
  border-radius: 16px;
  padding: 11px 13px;
  color: var(--ink);
  background: rgba(255,255,255,0.82);
  outline: none;
}

.search-input:focus,
.quiz-form input:focus,
.quiz-toolbar select:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 4px rgba(39, 174, 96, 0.12);
}

.dictionary-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.term-card {
  padding: 16px;
  border: 1px solid rgba(39, 174, 96, 0.16);
  border-radius: 18px;
  background: rgba(255,255,255,0.65);
}

.term-card h3 {
  margin-bottom: 5px;
}

.term-card p {
  margin-bottom: 8px;
}

.term-tag {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green-deep);
  font-size: 0.78rem;
  font-weight: 850;
}

.lab-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.lab-card {
  position: relative;
  overflow: hidden;
}

.lab-icon {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  margin-bottom: 12px;
  background: linear-gradient(135deg, var(--green), var(--green-deep));
  color: white;
  font-weight: 900;
}

.lab-card p {
  margin-bottom: 9px;
}

.step-list {
  margin: 0;
  padding-left: 1.25rem;
}

.step-list li + li {
  margin-top: 10px;
}

.quiz-toolbar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 16px;
}

.quiz-toolbar label {
  grid-column: 1 / -1;
  margin: 0;
}

.quiz-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.meta-pill {
  display: inline-flex;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(39,174,96,.12);
  color: var(--green-deep);
  font-weight: 850;
  font-size: 0.86rem;
}

.quiz-form {
  display: grid;
  gap: 12px;
}

.question-card {
  padding: 16px;
  border-radius: 20px;
  background: rgba(255,255,255,.66);
  border: 1px solid rgba(39,174,96,.16);
}

.question-card label {
  display: block;
  line-height: 1.5;
  margin-bottom: 10px;
}

.question-card .result {
  min-height: 22px;
  margin-top: 7px;
  font-weight: 850;
}

.result.correct {
  color: var(--success);
}

.result.wrong {
  color: var(--danger);
}

.quiz-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px;
}

.primary-btn,
.secondary-btn,
.icon-btn {
  border: 0;
  border-radius: 999px;
  min-height: 46px;
  padding: 0 18px;
  font-weight: 900;
}

.primary-btn {
  color: white;
  background: linear-gradient(135deg, var(--green), var(--green-deep));
  box-shadow: 0 12px 28px rgba(39,174,96,.24);
}

.secondary-btn {
  color: var(--green-deep);
  background: rgba(255,255,255,.78);
  border: 1px solid rgba(39,174,96,.18);
}

.quiz-feedback {
  margin-top: 14px;
  font-weight: 850;
  line-height: 1.45;
}

.diagram-dialog {
  width: min(940px, calc(100% - 22px));
  border: 1px solid var(--border);
  border-radius: 28px;
  padding: 16px;
  background: rgba(247, 255, 250, 0.94);
  color: var(--ink);
  box-shadow: 0 25px 80px rgba(0,0,0,.25);
}

.diagram-dialog::backdrop {
  background: rgba(5, 20, 12, 0.58);
  backdrop-filter: blur(8px);
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.dialog-head h2 {
  margin-bottom: 0;
}

.icon-btn {
  width: 46px;
  padding: 0;
  font-size: 2rem;
  line-height: 1;
  color: var(--green-deep);
  background: rgba(255,255,255,.88);
}

.diagram-canvas {
  height: min(68vh, 620px);
  overflow: auto;
  border-radius: 20px;
  background: white;
  border: 1px solid rgba(39,174,96,.14);
  padding: 10px;
}

.viewer-tip {
  margin: 12px 3px 0;
  font-size: 0.9rem;
}

@media (max-width: 980px) {
  .content-grid,
  .dictionary-list {
    grid-template-columns: 1fr;
  }

  .molecule-grid,
  .lab-grid,
  .diagram-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  .app-shell {
    width: min(100% - 20px, 620px);
    padding-top: 10px;
  }

  .hero {
    grid-template-columns: 1fr;
    border-radius: 26px;
  }

  .hero-badge {
    width: 112px;
    aspect-ratio: 1;
  }

  .tab-bar {
    top: 6px;
  }

  .tab-btn {
    padding: 12px 8px;
    font-size: 0.9rem;
  }

  .molecule-grid,
  .lab-grid,
  .diagram-grid {
    grid-template-columns: 1fr;
  }

  .flip-card,
  .flip-inner {
    min-height: 218px;
  }

  .diagram-thumb {
    height: 180px;
  }

  .quiz-toolbar {
    grid-template-columns: 1fr;
  }

  .quiz-actions button {
    flex: 1 1 160px;
  }

  .diagram-dialog {
    padding: 12px;
  }

  .diagram-canvas {
    height: 65vh;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
