:root {
  color-scheme: light;
  --ink: #172229;
  --muted: #647179;
  --panel: #ffffff;
  --canvas: #eef2f2;
  --line: #d8e0e0;
  --brand: #ef5b22;
  --brand-dark: #be3e0e;
  --navy: #1d2930;
  --success: #1c7a4f;
  --error: #b53a2c;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at top right, rgba(239, 91, 34, 0.12), transparent 28rem),
    var(--canvas);
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 2rem max(1.25rem, calc((100vw - 1440px) / 2));
  color: #fff;
  background: var(--navy);
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(1.7rem, 3vw, 2.6rem);
}

h2 {
  margin-bottom: 0;
  font-size: 1.35rem;
}

.eyebrow,
.step-label {
  margin-bottom: 0.35rem;
  color: #ff8758;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

main {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(22rem, 0.7fr);
  align-items: start;
  gap: 1.25rem;
  width: min(1440px, calc(100% - 2.5rem));
  margin: 1.25rem auto 3rem;
}

.panel {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  box-shadow: 0 14px 35px rgba(23, 34, 41, 0.08);
}

.editor-panel {
  display: flex;
  align-self: start;
  flex-direction: column;
  height: 778px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.2rem 1.35rem;
  border-bottom: 1px solid var(--line);
}

#ketcherFrame {
  display: block;
  flex: 0 0 690px;
  width: 100%;
  height: 690px;
  min-height: 690px;
  border: 0;
  background: #fff;
}

.controls-panel,
.results-panel {
  align-self: start;
}

.controls-panel {
  display: flex;
  flex-direction: column;
  height: 778px;
}

.control-grid {
  display: grid;
  flex: 1 1 auto;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  min-height: 0;
  overflow: auto;
  padding: 1.35rem;
}

.field {
  display: grid;
  gap: 0.45rem;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.field-wide {
  grid-column: 1 / -1;
}

.field-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.45;
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  padding: 0.65rem 0.75rem;
  border: 1px solid #bbc7c8;
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  font: inherit;
  font-weight: 500;
}

input:focus,
select:focus,
textarea:focus {
  outline: 3px solid rgba(239, 91, 34, 0.2);
  border-color: var(--brand);
}

.molfile-output,
.product-smiles {
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
}

.molfile-output {
  min-height: 250px;
  resize: vertical;
  white-space: pre;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.actions {
  padding: 0 1.35rem 1.2rem;
}

.button {
  min-height: 42px;
  padding: 0.65rem 1rem;
  border: 1px solid transparent;
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
  font-weight: 750;
}

.button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.button-primary {
  color: #fff;
  background: var(--brand);
}

.button-primary:hover {
  background: var(--brand-dark);
}

.button-secondary {
  border-color: var(--navy);
  color: #fff;
  background: var(--navy);
}

.button-quiet {
  border-color: var(--line);
  color: var(--ink);
  background: #fff;
}

.form-message {
  min-height: 1.4rem;
  margin: 0;
  padding: 0 1.35rem 1.25rem;
  color: var(--muted);
}

.form-message.success,
.response-meta.success {
  color: var(--success);
}

.form-message.error,
.response-meta.error {
  color: var(--error);
}

.status-pill {
  flex: 0 0 auto;
  padding: 0.5rem 0.8rem;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 999px;
  color: #d6dede;
  font-size: 0.8rem;
  font-weight: 750;
}

.status-pill.success {
  color: #cbf6df;
  border-color: rgba(203, 246, 223, 0.4);
}

.status-pill.error {
  color: #ffd6d0;
  border-color: rgba(255, 214, 208, 0.4);
}

.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.header-actions > * {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 10.5rem;
  min-height: 44px;
  padding: 0.55rem 0.8rem;
  text-align: center;
}

.login-page {
  min-height: 100vh;
  background:
    radial-gradient(circle at top right, rgba(239, 91, 34, 0.2), transparent 34rem),
    var(--navy);
}

.login-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  place-items: center;
  min-height: 100vh;
  width: min(100% - 2rem, 32rem);
  margin: 0 auto;
}

.login-card {
  width: 100%;
  padding: clamp(1.5rem, 5vw, 2.5rem);
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
}

.login-card h1 {
  color: var(--ink);
  font-size: clamp(1.7rem, 5vw, 2.25rem);
}

.login-intro {
  margin-bottom: 1.5rem;
  color: var(--muted);
}

.login-button {
  width: 100%;
  margin-top: 1.25rem;
}

.login-message {
  padding: 1rem 0 0;
}

.response-meta {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 750;
}

.results-panel {
  display: flex;
  flex-direction: column;
  grid-column: 1 / -1;
  height: 620px;
}

.results-panel .panel-heading {
  flex: 0 0 auto;
}

.empty-state {
  display: grid;
  flex: 1 1 auto;
  place-items: center;
  min-height: 0;
  padding: 2rem 1.35rem;
  color: var(--muted);
  text-align: center;
}

#resultsContent {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
  overflow: auto;
}

.product-grid {
  display: grid;
  flex: 1 1 auto;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 1rem;
  min-height: 0;
  overflow: auto;
  padding: 1.25rem;
}

.product-card {
  display: flex;
  min-width: 0;
  min-height: 360px;
  overflow: hidden;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 8px 22px rgba(23, 34, 41, 0.08);
}

.product-structure {
  display: grid;
  place-items: center;
  min-height: 190px;
  padding: 0.75rem;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  background: transparent;
  font-size: 0.82rem;
  text-align: center;
}

.product-structure img {
  display: block;
  width: 100%;
  height: 180px;
  object-fit: contain;
}

.product-card-body {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1rem;
}

.product-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.product-code,
.product-code:hover {
  color: #1d252d;
  font-weight: 800;
  text-decoration: none;
}

.product-metric {
  flex: 0 0 auto;
  padding: 0.3rem 0.55rem;
  border-radius: 999px;
  color: #fe5000;
  background: #e9f7f0;
  font-size: 0.75rem;
  font-weight: 800;
}

.product-smiles {
  display: block;
  margin-top: auto;
  padding: 0.65rem;
  border-radius: 8px;
  color: #34434b;
  background: #f3f6f6;
  font-size: 0.74rem;
  overflow-wrap: anywhere;
  white-space: normal;
}

a {
  color: var(--brand-dark);
}

details {
  padding: 1rem 1.35rem 1.35rem;
}

summary {
  cursor: pointer;
  font-weight: 750;
}

pre {
  max-height: 420px;
  overflow: auto;
  padding: 1rem;
  border-radius: 10px;
  color: #d8e3e4;
  background: #152027;
  font-size: 0.78rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.is-hidden {
  display: none !important;
}

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

  .editor-panel {
    height: auto;
  }

  .controls-panel {
    height: auto;
  }

  #ketcherFrame {
    flex-basis: 600px;
    height: 600px;
    min-height: 600px;
  }
}

@media (max-width: 620px) {
  .site-header,
  .panel-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .header-actions {
    width: 100%;
  }

  .header-actions > * {
    width: 100%;
  }

  main {
    width: min(100% - 1rem, 1440px);
  }

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

  .field-wide {
    grid-column: auto;
  }

  #ketcherFrame {
    flex-basis: 520px;
    height: 520px;
    min-height: 520px;
  }

  .controls-panel {
    min-height: 0;
  }

  .results-panel {
    height: 620px;
  }

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