:root {
  color-scheme: light;
  --bg: #f5efe4;
  --bg-soft: #fbf7ef;
  --surface: #fffdf8;
  --surface-2: #f2e4cf;
  --ink: #2b2117;
  --muted: #6d5b49;
  --line: #d7bea1;
  --line-strong: #9a6a37;
  --amber: #c87d30;
  --amber-dark: #7a481c;
  --teal: #188b84;
  --teal-dark: #075e5b;
  --magenta: #bd4e9a;
  --blue: #1267b2;
  --green: #0f9e74;
  --gold: #d7ac18;
  --danger: #9d2b2b;
  --shadow: 0 18px 42px rgba(78, 52, 24, 0.14);
  --radius: 8px;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.35) 1px, transparent 1px),
    linear-gradient(rgba(255, 255, 255, 0.28) 1px, transparent 1px),
    var(--bg);
  background-size: 32px 32px;
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.5;
}

button,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 14px clamp(16px, 3vw, 34px);
  background: linear-gradient(135deg, #2f2319, #17120e);
  border-bottom: 1px solid #5d452c;
  box-shadow: 0 10px 28px rgba(42, 28, 16, 0.18);
  backdrop-filter: blur(10px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: #fff0c9;
  text-decoration: none;
  min-width: 260px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 2px solid var(--amber-dark);
  background: linear-gradient(135deg, var(--amber), #edc87c);
  color: #fff9eb;
  border-radius: var(--radius);
  font-weight: 850;
  letter-spacing: 0;
}

.brand strong {
  display: block;
  font-size: 1.15rem;
  line-height: 1.15;
}

.brand small {
  display: block;
  color: #d5c1a5;
  font-size: 0.78rem;
  line-height: 1.25;
  margin-top: 2px;
}

.tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
}

.tab {
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: #ead8bc;
  padding: 8px 11px;
  font-size: 0.9rem;
  font-weight: 700;
}

.tab:hover,
.tab:focus-visible {
  border-color: #6b5136;
  color: #fff6df;
  outline: none;
}

.tab.is-active {
  background: #fff8ea;
  color: var(--ink);
}

main {
  padding: clamp(16px, 3vw, 34px);
}

.tab-panel {
  display: none;
}

.tab-panel.is-active {
  display: block;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(280px, 1.15fr) minmax(250px, 0.9fr) minmax(280px, 1fr) minmax(300px, 1fr);
  gap: 14px;
  align-items: stretch;
  min-width: 0;
}

.lab-panel,
.bench-panel,
.results-panel,
.content-panel {
  background: rgba(255, 253, 248, 0.92);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.lab-panel,
.bench-panel,
.results-panel {
  padding: clamp(16px, 2.1vw, 24px);
  min-width: 0;
}

.lab-panel {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 140px);
}

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

.synthesis-panel h1,
.lab-panel h2 {
  font-size: clamp(1.35rem, 1.8vw, 1.95rem);
}

.lab-panel .panel-heading p {
  font-size: 0.92rem;
}

.content-panel {
  max-width: 1120px;
  margin: 0 auto;
  padding: clamp(20px, 4vw, 44px);
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 16px;
  margin-bottom: 18px;
}

.panel-heading.compact {
  margin-bottom: 12px;
}

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

h1 {
  font-size: clamp(1.7rem, 2.5vw, 2.45rem);
  line-height: 1.1;
  margin-bottom: 8px;
}

h2 {
  font-size: 1.18rem;
  line-height: 1.2;
  margin-bottom: 8px;
}

h3 {
  font-size: 0.92rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--amber-dark);
  margin-bottom: 10px;
}

.panel-heading p,
.content-panel > p {
  color: var(--muted);
  max-width: 760px;
  margin-bottom: 0;
}

.lab-illustration {
  position: relative;
  min-height: 236px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background:
    linear-gradient(#7db2c9 0 56%, #ded0bc 56% 58%, #51463b 58% 100%);
  overflow: hidden;
  margin-bottom: 18px;
}

.translation-visual,
.sequencer-visual {
  position: relative;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: linear-gradient(#8fc2d2 0 46%, #e9dfce 46% 49%, #53463a 49% 100%);
  overflow: hidden;
  margin-bottom: 16px;
}

.translation-visual {
  display: grid;
  place-items: center;
  min-height: 210px;
  padding: 12px;
  background: #fff;
}

.translation-visual img {
  display: block;
  width: min(100%, 280px);
  height: auto;
  object-fit: contain;
}

.incubation-badge {
  position: absolute;
  right: 10px;
  bottom: 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fffaf0;
  color: var(--amber-dark);
  padding: 6px 9px;
  font-size: 0.78rem;
  font-weight: 900;
}

.protein-panel.is-translating .translation-visual img {
  animation: incubate-pulse 1.2s ease-in-out 2;
}

.translation-controls {
  display: grid;
  gap: 10px;
  margin-top: auto;
}

#translation-status {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0;
}

.sequencer-visual {
  display: grid;
  place-items: center;
  min-height: 156px;
  padding: 10px;
  background: #fffaf0;
  overflow: hidden;
}

.sequencer-visual img {
  display: block;
  width: 100%;
  max-height: 178px;
  object-fit: contain;
}

.analysis-panel.is-analyzing .sequencer-visual img {
  animation: analyzer-check 0.9s ease-in-out 2;
}

@keyframes button-press {
  0% { transform: translateY(0); }
  45% { transform: translateY(2px); filter: brightness(0.95); }
  100% { transform: translateY(0); }
}

@keyframes synth-progress {
  0% { transform: scaleX(0); opacity: 0.3; }
  60% { opacity: 1; }
  100% { transform: scaleX(1); opacity: 0; }
}

@keyframes incubate-pulse {
  0%, 100% { transform: scale(1); filter: saturate(1); }
  50% { transform: scale(1.015); filter: saturate(1.12); }
}

@keyframes analyzer-check {
  0%, 100% { transform: scale(1); filter: saturate(1); }
  50% { transform: scale(1.015); filter: saturate(1.12); }
}

.shelf {
  position: absolute;
  left: 5%;
  top: 16%;
  width: 38%;
  height: 28%;
  border-bottom: 12px solid #8d5928;
  border-left: 10px solid #6b3f1a;
  display: flex;
  align-items: end;
  justify-content: space-around;
  padding: 0 12px 8px;
}

.shelf::before {
  content: "";
  position: absolute;
  top: 0;
  left: -10px;
  right: -8px;
  height: 12px;
  background: #a96e34;
}

.bottle {
  position: relative;
  width: 42px;
  height: 58px;
  border: 3px solid #d9e3e3;
  border-radius: 12px 12px 16px 16px;
  background: linear-gradient(transparent 0 24%, currentColor 25% 100%);
  color: var(--green);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.2);
}

.bottle::before {
  content: "";
  position: absolute;
  top: -16px;
  left: 12px;
  width: 14px;
  height: 18px;
  background: #333;
  border-radius: 4px 4px 0 0;
}

.bottle span {
  position: absolute;
  inset: auto 0 7px;
  color: #fff;
  text-align: center;
  font-weight: 850;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.35);
}

.bottle-g {
  color: #18a9c2;
}

.bottle-c {
  color: var(--blue);
}

.bottle-u {
  color: var(--magenta);
}

.instrument {
  position: absolute;
  left: 10%;
  bottom: 9%;
  width: 40%;
  height: 38%;
  border: 2px solid #26221d;
  background: #74716c;
}

.instrument-top {
  height: 38%;
  background: linear-gradient(160deg, #b6b4af, #7e7d78);
  border-bottom: 2px solid #26221d;
  display: flex;
  align-items: center;
  gap: 18px;
  padding-left: 24px;
}

.instrument-top span {
  width: 16px;
  height: 16px;
  border: 3px solid #3f3d39;
  border-radius: 50%;
  background: #d8d3ca;
}

.instrument-screen {
  margin: 17px auto;
  width: 68%;
  background: #d6c9e4;
  border: 1px solid #59506d;
  color: #2e2840;
  font-family: var(--mono);
  font-size: 0.82rem;
  padding: 6px;
  text-align: center;
}

.tube-rack {
  position: absolute;
  right: 25%;
  bottom: 12%;
  display: flex;
  gap: 8px;
  padding: 12px 10px 8px;
  background: #4d4741;
  border: 2px solid #25211d;
}

.tube {
  width: 28px;
  height: 82px;
  border: 3px solid #e9f1f0;
  border-radius: 0 0 13px 13px;
  background: linear-gradient(transparent 0 16%, var(--teal) 16% 100%);
}

.tube-gold {
  background: linear-gradient(transparent 0 16%, var(--gold) 16% 100%);
}

.tube-magenta {
  background: linear-gradient(transparent 0 16%, var(--magenta) 16% 100%);
}

.sequencer {
  position: absolute;
  right: 4%;
  top: 18%;
  width: 128px;
  height: 124px;
  display: grid;
  place-items: center;
  background: #e9e1d4;
  border: 2px solid #2d2821;
  border-radius: 50%;
  color: var(--amber-dark);
  font-weight: 850;
  text-align: center;
  line-height: 1.2;
}

.builder {
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.bottle-image-fieldset {
  border: 0;
  padding: 0;
  margin: 0;
}

.bottle-image-control {
  position: relative;
  max-width: 430px;
  margin: 0 auto;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.bottle-image-control img {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: auto;
}

.image-select,
.image-make-rna,
.bottle-liquid {
  position: absolute;
}

.bottle-liquid {
  z-index: 2;
  top: 51.4%;
  width: 16.7%;
  height: 25.6%;
  border-radius: 8px 8px 22px 22px;
  opacity: 0;
  background: transparent;
  mix-blend-mode: multiply;
  pointer-events: none;
  transition: opacity 160ms ease, background-color 160ms ease;
}

.bottle-liquid[data-base="A"] {
  opacity: 0.72;
  background: var(--green);
}

.bottle-liquid[data-base="G"] {
  opacity: 0.7;
  background: #18a9c2;
}

.bottle-liquid[data-base="C"] {
  opacity: 0.72;
  background: var(--blue);
}

.bottle-liquid[data-base="U"] {
  opacity: 0.7;
  background: var(--magenta);
}

.liquid-1 {
  left: 5.55%;
}

.liquid-2 {
  left: 29.85%;
}

.liquid-3 {
  left: 54.15%;
}

.liquid-4 {
  left: 78.55%;
}

.image-select {
  z-index: 3;
  top: 72.8%;
  width: 14.2%;
  height: 8%;
}

.image-select select {
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 2px 6px;
  border: 1px solid #6e6a64;
  border-radius: 7px;
  background: #f7f7f7;
  color: #191512;
  font-size: clamp(0.82rem, 1.35vw, 0.96rem);
  font-weight: 700;
}

.bottle-select-1 {
  left: 7.9%;
}

.bottle-select-2 {
  left: 32.3%;
}

.bottle-select-3 {
  left: 56.7%;
}

.bottle-select-4 {
  left: 81%;
}

.image-make-rna {
  z-index: 3;
  left: 25.3%;
  top: 86.4%;
  width: 49.4%;
  height: 9.8%;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: transparent;
  font-size: clamp(1rem, 1.9vw, 1.18rem);
  font-weight: 850;
  box-shadow: none;
}

.synthesis-panel.is-synthesizing .image-make-rna {
  animation: button-press 0.5s ease;
}

.image-make-rna:focus-visible {
  outline: 3px solid var(--teal);
  outline-offset: 2px;
}

.synthesis-panel.is-synthesizing .bottle-image-control::after {
  content: "";
  position: absolute;
  left: 26%;
  right: 26%;
  bottom: 4%;
  height: 5px;
  border-radius: 999px;
  background: var(--teal);
  animation: synth-progress 0.9s ease-in-out 1;
}

fieldset {
  border: 0;
  padding: 0;
  margin: 0;
}

legend {
  color: var(--amber-dark);
  font-weight: 850;
  margin-bottom: 10px;
}

.bottle-controls {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.synthesis-panel .bottle-controls {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

label span {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  margin-bottom: 5px;
}

select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
}

select {
  min-height: 42px;
  min-width: 0;
  padding: 8px 10px;
  font-weight: 750;
}

textarea {
  resize: vertical;
  min-height: 74px;
  padding: 10px 12px;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.primary-button,
.secondary-button,
.ghost-button,
.icon-button {
  min-height: 40px;
  border-radius: var(--radius);
  font-weight: 850;
}

.primary-button {
  border: 1px solid var(--amber-dark);
  background: var(--amber);
  color: #fff9ec;
  padding: 9px 14px;
}

.primary-button.accent {
  border-color: var(--teal-dark);
  background: var(--teal);
}

.secondary-button,
.ghost-button {
  border: 1px solid var(--line);
  background: #fffaf0;
  color: var(--amber-dark);
  padding: 8px 12px;
}

.secondary-button.small {
  min-height: 34px;
  padding: 6px 10px;
  font-size: 0.85rem;
}

.primary-button:disabled,
.secondary-button:disabled,
.ghost-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.ghost-button {
  background: transparent;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  min-height: 34px;
  border: 1px solid var(--line);
  background: #fffaf0;
  color: var(--danger);
  font-size: 1.3rem;
}

.primary-button:hover,
.secondary-button:hover,
.ghost-button:hover,
.icon-button:hover {
  filter: brightness(0.97);
  transform: translateY(-1px);
}

.primary-button:disabled:hover,
.secondary-button:disabled:hover,
.ghost-button:disabled:hover {
  filter: none;
  transform: none;
}

.rna-readout {
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fffaf0;
  padding: 14px;
}

.readout-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.readout-heading h2 {
  margin-bottom: 0;
}

#repeat-label {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.88rem;
}

.readout-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.rna-strip {
  display: flex;
  gap: 4px;
  min-height: 42px;
  overflow: hidden;
  padding: 6px;
  background: #352820;
  border-radius: var(--radius);
}

.base-chip {
  flex: 0 0 34px;
  display: grid;
  place-items: center;
  height: 30px;
  border-radius: 5px;
  color: #fff;
  font-family: var(--mono);
  font-weight: 900;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.18);
}

.base-A {
  background: var(--green);
}

.base-G {
  background: #18a9c2;
}

.base-C {
  background: var(--blue);
}

.base-U {
  background: var(--magenta);
}

.readout-text {
  margin: 9px 0 0;
  color: var(--muted);
  font-family: var(--mono);
  overflow-wrap: anywhere;
}

.result-box {
  min-height: 132px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 14px;
  margin-bottom: 16px;
}

.analysis-actions {
  display: flex;
  justify-content: flex-end;
}

.empty-state {
  color: var(--muted);
  margin: 0;
}

.peptide-list {
  display: grid;
  gap: 10px;
  margin: 0;
}

.peptide {
  border-left: 5px solid var(--teal);
  padding: 8px 10px;
  background: #f3fbf8;
}

.peptide.stop {
  border-left-color: var(--danger);
  background: #fff4f0;
}

.peptide strong {
  display: block;
  margin-bottom: 3px;
}

.peptide code {
  font-family: var(--mono);
  color: var(--amber-dark);
  font-size: 0.92em;
}

.notebook-heading,
.notebook-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.notebook-panel .notebook {
  display: flex;
  flex: 1;
  min-height: 0;
  flex-direction: column;
}

.history {
  display: grid;
  gap: 10px;
  max-height: none;
  flex: 1;
  overflow: auto;
  margin-top: 12px;
  padding-right: 4px;
}

.history-item {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fffaf0;
  padding: 10px;
}

.history-item header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
  color: var(--amber-dark);
  font-weight: 850;
  margin-bottom: 4px;
}

.history-item time {
  font-size: 0.86rem;
}

.history-item p {
  margin: 4px 0 0;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.history-item code {
  font-family: var(--mono);
  color: var(--ink);
  white-space: normal;
}

.assignment-list {
  display: grid;
  gap: 12px;
  margin-top: 22px;
}

.assignment-item {
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.assignment-item h2 {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.assignment-number {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--ink);
  color: #fff8ea;
  font-size: 0.9rem;
}

.example-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.load-sequence {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fffaf0;
  color: var(--teal-dark);
  padding: 6px 9px;
  font-family: var(--mono);
  font-weight: 850;
}

.text-columns,
.help-grid,
.glossary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
  margin-top: 22px;
}

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

.text-columns article,
.help-grid article,
.glossary-card {
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.glossary-card dt {
  color: var(--amber-dark);
  font-weight: 850;
}

.glossary-card dd {
  margin: 5px 0 0;
  color: var(--muted);
}

.credits-list {
  display: grid;
  gap: 10px;
  max-width: 620px;
  margin: 22px 0;
  padding: 0;
  list-style: none;
}

.credits-list li {
  display: grid;
  grid-template-columns: minmax(150px, 0.42fr) minmax(0, 1fr);
  gap: 10px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.credits-list span,
.credits-note {
  color: var(--muted);
}

.credits-note {
  max-width: 760px;
}

@media (max-width: 1180px) {
  .topbar {
    align-items: start;
    flex-direction: column;
  }

  .tabs {
    width: 100%;
  }

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

@media (max-width: 720px) {
  main {
    padding: 12px;
  }

  .topbar {
    gap: 12px;
    overflow: hidden;
    position: static;
  }

  .tabs {
    flex-wrap: wrap;
    overflow: visible;
  }

  .tab {
    padding: 8px 10px;
  }

  .brand {
    min-width: 0;
  }

  .brand small {
    display: none;
  }

  .bottle-controls,
  .text-columns,
  .help-grid,
  .glossary-grid {
    grid-template-columns: 1fr;
  }

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

  .lab-panel {
    min-height: auto;
  }

  .lab-illustration {
    min-height: 190px;
  }

  .sequencer {
    right: 3%;
    width: 98px;
    height: 98px;
    font-size: 0.8rem;
  }

  .tube-rack {
    display: none;
  }

  .instrument {
    width: 52%;
  }

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

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