:root {
  --bg: #e8f2ef;
  --bg2: #f7fbfa;
  --ink: #0b2f2b;
  --muted: #5a736e;
  --teal: #0a5c54;
  --teal-deep: #064039;
  --accent: #1a8a7a;
  --line: #c5d8d3;
  --danger: #b42318;
  --card: #ffffff;
  --shadow: 0 18px 50px rgba(6, 64, 57, 0.12);
  --radius: 16px;
  font-family: "IBM Plex Sans", "Source Han Sans SC", "PingFang SC", "Noto Sans SC", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 10% -10%, #cfe8e2 0%, transparent 55%),
    radial-gradient(900px 420px at 100% 0%, #d9efe8 0%, transparent 50%),
    linear-gradient(180deg, var(--bg), var(--bg2) 40%, #f4f8f7);
}

.hidden { display: none !important; }

.top {
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(10px);
  background: rgba(247, 251, 250, 0.88);
  border-bottom: 1px solid var(--line);
}
.top__inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand { display: flex; gap: 12px; align-items: center; }
.brand__mark {
  width: 42px; height: 42px; border-radius: 12px;
  display: grid; place-items: center;
  background: linear-gradient(145deg, var(--teal), var(--teal-deep));
  color: #fff; font-weight: 700; letter-spacing: 0.02em;
}
.brand__name { font-weight: 700; font-size: 1.05rem; }
.brand__sub { color: var(--muted); font-size: 0.78rem; }
.top__right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.user-label { color: var(--muted); font-size: 0.85rem; }

.health-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  white-space: nowrap;
}
.health-badge::before {
  content: "";
  width: 8px; height: 8px; border-radius: 50%;
  background: #9aa;
}
.health-badge--ok { color: #146c2e; background: #d8f3dc; border-color: #b7e4c7; }
.health-badge--ok::before { background: #2d9a4a; }
.health-badge--warn { color: #7a5b00; background: #fff3cd; border-color: #ffe08a; }
.health-badge--warn::before { background: #e0a800; }
.health-badge--unknown::before { background: #9aa; }

.lang-switch {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.lang-switch__label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
}
.lang-select {
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 10px;
  background:
    #fff
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%230a5c54' d='M1.1 1.2 6 6.1l4.9-4.9 1.1 1.1L6 8.2 0 2.3z'/%3E%3C/svg%3E")
    no-repeat right 0.65rem center;
  color: var(--ink);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.2;
  padding: 0.38rem 1.85rem 0.38rem 0.7rem;
  min-width: 7.5rem;
  cursor: pointer;
}
.lang-select:hover,
.lang-select:focus {
  border-color: var(--teal);
  outline: none;
}

.main { max-width: 1100px; margin: 0 auto; padding: 28px 20px 64px; }

.hero {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 4px);
  box-shadow: var(--shadow);
  padding: 28px 24px 22px;
}
.hero h1 {
  margin: 0 0 8px;
  font-family: "IBM Plex Serif", "Source Han Serif SC", "Songti SC", serif;
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  letter-spacing: -0.02em;
}
.hero__desc { margin: 0 0 18px; color: var(--muted); line-height: 1.55; max-width: 62ch; }

.field-label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--muted);
}

.search-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}
.opts {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 14px 18px;
  align-items: center;
}
.opt { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 0.9rem; }
.opt select {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 6px 10px;
  background: #fff;
  color: var(--ink);
}
.opt--check { gap: 6px; }

.input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 1rem;
  background: #fff;
  color: var(--ink);
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
.input--area {
  resize: vertical;
  min-height: 4.5rem;
  line-height: 1.45;
}
.input:focus { outline: 2px solid rgba(10, 92, 84, 0.25); border-color: var(--teal); }

.examples {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 12px;
}
.examples__label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  margin-right: 2px;
}

.btn {
  border: 0;
  border-radius: 12px;
  padding: 11px 16px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  font-family: inherit;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn--primary { background: var(--teal); color: #fff; }
.btn--primary:hover:not(:disabled) { background: var(--teal-deep); }
.btn--secondary { background: #e2f0ec; color: var(--teal-deep); }
.btn--ghost { background: transparent; color: var(--teal); border: 1px solid transparent; }
.btn--ghost:hover { border-color: var(--line); background: #fff; }
.btn--block { width: 100%; }

.status { min-height: 1.2em; margin: 12px 0 0; color: var(--ink); font-weight: 560; }
.status-tip { margin: 6px 0 0; line-height: 1.45; }
.status--countdown { color: var(--accent, #1a6bb5); }
.modal__panel--wide {
  max-width: 960px;
  width: min(960px, 96vw);
}
.modal__panel--profile {
  display: flex;
  flex-direction: column;
  max-width: min(1360px, 98vw);
  width: min(1360px, 98vw);
  max-height: min(92vh, 920px);
  overflow: hidden;
  padding-bottom: 0;
}
.modal__panel--profile > .modal__bar {
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 2;
  background: #fff;
  padding-bottom: 12px;
  margin-bottom: 0;
  border-bottom: 1px solid var(--line);
}
.profile-modal__body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 14px 2px 20px;
}
.profile-account {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}
.profile-account__info { min-width: 0; }
.profile-user { margin: 0 0 4px; font-weight: 600; }
.profile-password {
  margin-bottom: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0 14px;
  background: #fbfefe;
}
.profile-password > summary {
  cursor: pointer;
  padding: 10px 0;
  font-weight: 500;
  list-style: none;
}
.profile-password > summary::-webkit-details-marker { display: none; }
.profile-password > summary::after {
  content: '▾';
  float: right;
  color: var(--muted);
}
.profile-password[open] > summary::after { content: '▴'; }
.profile-password__form { padding-bottom: 12px; }
.profile-password__actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.profile-section-title {
  margin: 16px 0 6px;
  font-size: 1.05rem;
}
.membership {
  margin: 4px 0 12px;
}
.membership__quota {
  margin: 0 0 10px;
}
.membership__plans {
  display: block;
  margin-bottom: 10px;
}
.membership__plans-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
}
.membership__interval {
  display: inline-flex;
  gap: 6px;
  margin: 0 0 12px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f0f5fa;
}
.membership-interval-btn.is-on {
  background: var(--accent, #1a6bb5);
  color: #fff;
  border-color: transparent;
}
.membership-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  background: #f7fafc;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 140px;
}
.membership-card--current {
  border-color: var(--accent, #1a6bb5);
  box-shadow: inset 0 0 0 1px rgba(26, 107, 181, 0.25);
}
.membership-card__name {
  margin: 0;
  font-weight: 650;
  font-size: 1rem;
}
.membership-card__price {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--ink);
}
.membership-card__cycle {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted);
}
.membership-card__limits {
  margin: 0;
  flex: 1;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.35;
}
.membership-card .btn {
  width: 100%;
  margin-top: auto;
}
.membership__paypal {
  min-height: 45px;
  margin: 4px 0 8px;
}
.membership__paypal.hidden { display: none; }
.history-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin: -6px 0 14px;
  padding: 10px 12px;
  border-radius: 12px;
  background: #eef7f4;
  border: 1px solid var(--line);
}
.history-banner strong { margin-right: 8px; }
.history-banner__actions { display: flex; gap: 8px; flex-wrap: wrap; }
.table-wrap {
  overflow: auto;
  max-height: min(42vh, 360px);
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-bottom: 8px;
}
.history-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.history-table th,
.history-table td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.history-table th { color: var(--muted); font-weight: 560; }
.history-table tbody tr { cursor: pointer; }
.history-table tbody tr:hover { background: #f3f8f6; }
.history-table .smiles-cell {
  min-width: 280px;
  max-width: min(40rem, 52vw);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.82rem;
  line-height: 1.4;
}
.history-table th:last-child,
.history-table td.history-actions {
  position: sticky;
  right: 0;
  z-index: 2;
  text-align: right;
  white-space: nowrap;
  width: 1%;
  min-width: 9.5rem;
  vertical-align: middle;
  background: #fff;
  box-shadow: -6px 0 8px -6px rgba(20, 40, 30, 0.18);
  display: table-cell;
}
.history-table tbody tr:hover td.history-actions {
  background: #f3f8f6;
}
.history-table .history-actions__btns {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}
.history-table .btn-view,
.history-table .btn-delete {
  display: inline-block;
  font-size: 0.82rem;
  padding: 4px 10px;
  flex: 0 0 auto;
}
.history-table .btn-delete {
  color: #9b2c2c;
}
.history-table .btn-delete:hover {
  background: #fde8e8;
  color: #7a1f1f;
}
.error { margin: 8px 0 0; color: var(--danger); }

.result {
  margin-top: 22px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}
.result.is-history {
  outline: 2px solid rgba(26, 138, 122, 0.35);
  outline-offset: 2px;
}
.result__head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}
.result__head h2 { margin: 0 0 6px; font-size: 1.35rem; }
.muted { color: var(--muted); font-size: 0.9rem; }
.badge {
  display: inline-block;
  margin-top: 8px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #e2f0ec;
  color: var(--teal-deep);
  font-size: 0.78rem;
  font-weight: 700;
}
.badge--cache { background: #fff3cd; color: #7a5b00; }
.struct {
  width: 160px; height: 120px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  overflow: hidden;
  flex-shrink: 0;
}
.struct img { width: 100%; height: 100%; object-fit: contain; }

.route-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 18px 0 14px;
}
.chip {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 7px 12px;
  cursor: pointer;
  font-size: 0.88rem;
  font-family: inherit;
  color: var(--ink);
}
.chip--on { background: var(--teal); color: #fff; border-color: var(--teal); }
.chip[data-smiles] {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.78rem;
}

.route-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-bottom: 14px;
  font-size: 0.88rem;
  color: var(--muted);
}
.route-meta strong { color: var(--ink); font-weight: 600; }
.route-note {
  margin: 0 0 16px;
  padding: 10px 12px;
  border-radius: 12px;
  background: #eef7f4;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.step-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 12px;
  background: #fbfcfc;
}
.step-card__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.step-card__head h3 {
  margin: 0;
  font-size: 1rem;
}
.step-mols {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.mol-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.mol-thumb {
  width: 120px;
  height: 90px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  overflow: hidden;
}
.mol-thumb img { width: 100%; height: 100%; object-fit: contain; }
.mol-plus {
  font-size: 1.25rem;
  color: var(--ink);
  font-weight: 700;
  padding: 0 2px;
  line-height: 1;
  user-select: none;
}
.mol-arrow {
  font-size: 1.4rem;
  color: var(--teal);
  font-weight: 700;
  padding: 0 4px;
}
.step-conds {
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.5;
  margin: 0 0 8px;
}
.step-conds dt {
  display: inline;
  font-weight: 600;
  color: var(--ink);
}
.step-conds dd {
  display: inline;
  margin: 0 12px 0 4px;
}
.named {
  margin: 10px 0 8px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #f7f5ff;
  border: 1px solid #e4dff7;
}
.named__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}
.named__k {
  font-size: 0.78rem;
  color: #6b6280;
}
.named__name {
  font-size: 0.95rem;
  font-weight: 700;
  color: #3b2f63;
}
.named__en {
  font-size: 0.8rem;
  color: #6b6280;
}
.named__summary,
.named__mech,
.named__step {
  display: block;
  font-size: 0.86rem;
  line-height: 1.55;
  color: #2c2640;
  margin-top: 4px;
}
.named__steps { margin-top: 6px; }
.named__caveat {
  display: block;
  margin-top: 6px;
  font-size: 0.8rem;
  color: #6b6280;
  line-height: 1.45;
}
.named__more {
  display: inline-block;
  margin-top: 8px;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  font-size: 0.86rem;
  font-weight: 650;
  color: #3b2f63;
  text-decoration: underline;
  cursor: pointer;
}
.named__more:hover { color: #231a45; }
.named-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 650;
  background: #ebe6f8;
  color: #4c3d78;
}
.named-badge--cred {
  background: #eef2ff;
  color: #3730a3;
}
.modal__panel--mechanism {
  max-width: 640px;
  width: min(640px, 94vw);
  max-height: min(88vh, 820px);
  overflow: auto;
}
.mech-en { margin: 0 0 8px; }
.mech-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.mech-summary {
  margin: 0 0 14px;
  font-size: 0.95rem;
  line-height: 1.55;
  color: var(--ink);
}
.mech-h {
  margin: 14px 0 6px;
  font-size: 1rem;
  color: #3b2f63;
}
.mech-body {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.6;
  color: #2c2640;
  white-space: pre-wrap;
}
.mech-steps {
  margin: 0;
  padding-left: 1.2rem;
  font-size: 0.9rem;
  line-height: 1.55;
  color: #2c2640;
}
.mech-steps li { margin: 4px 0; }
.mech-caveat {
  margin: 14px 0 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: #fff8e8;
  border: 1px solid #f0e0b8;
  font-size: 0.86rem;
  line-height: 1.5;
  color: #6b5a2e;
}
.mech-wiki { margin-top: 12px; }
.evidence-block { margin-top: 10px; }
.evidence-h {
  margin: 0 0 6px;
  font-size: 0.85rem;
  font-weight: 650;
  color: var(--muted, #5c5670);
}
.evidence-list {
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 6px;
}
.evidence-list a {
  color: var(--teal);
  word-break: break-all;
}
.evidence-list li {
  font-size: 0.82rem;
  color: var(--muted);
  padding: 6px 8px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--line);
}

.disclaimer {
  margin-top: 16px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.5;
}
.actions { margin-top: 14px; display: flex; gap: 10px; flex-wrap: wrap; }

.modal {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(8, 30, 28, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.modal__panel {
  width: min(420px, 100%);
  background: #fff;
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 16px;
  margin: auto;
}
.login-gate__msg {
  margin: 8px 0 16px;
  color: var(--ink);
  line-height: 1.55;
  font-size: 0.95rem;
}
.login-gate__actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}
.modal--wide .modal__panel--ketcher {
  width: min(1100px, 100%);
  height: min(88vh, 820px);
  display: flex;
  flex-direction: column;
  padding: 12px;
}
.modal__bar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin-bottom: 10px;
}
.auth-tabs { display: flex; gap: 8px; margin-bottom: 12px; }
.form { display: grid; gap: 10px; }
.form label { display: grid; gap: 4px; font-size: 0.88rem; color: var(--muted); }
.form .input { font-family: inherit; }
.captcha-row, .code-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.captcha-input, .code-input { flex: 1; min-width: 0; }
.captcha-btn {
  flex: 0 0 128px;
  height: 42px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eaf4f2;
  cursor: pointer;
  overflow: hidden;
}
.captcha-img {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 128px;
  height: 42px;
  font-size: 12px;
  color: var(--muted);
  user-select: none;
}
.captcha-img svg,
.captcha-img img {
  width: 128px;
  height: 42px;
  display: block;
}
.code-btn {
  flex: 0 0 auto;
  white-space: nowrap;
  min-width: 7.5rem;
}
.tip { margin: 10px 0 0; font-size: 0.8rem; }
.ketcher-stage {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 420px;
}
#ketcherFrame {
  flex: 1;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  min-height: 420px;
}
.ketcher-loading {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 24px;
  border-radius: 12px;
  background: rgba(247, 250, 249, 0.96);
  border: 1px solid var(--line);
}
.ketcher-loading.hidden { display: none; }
.ketcher-loading__title {
  margin: 0;
  font-weight: 600;
  color: var(--ink);
}
.ketcher-loading__pct {
  margin: 0;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--teal);
}
.ketcher-loading__detail { margin: 0; text-align: center; }
.ketcher-progress {
  width: min(360px, 86%);
  height: 10px;
  border-radius: 999px;
  background: #e2eeea;
  overflow: hidden;
}
.ketcher-progress__bar {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--teal-deep, #0a5c54));
  transition: width 0.18s ease-out;
}
.ketcher-progress--indeterminate .ketcher-progress__bar {
  width: 36% !important;
  animation: ketcher-indeterminate 1.1s ease-in-out infinite;
}
@keyframes ketcher-indeterminate {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(320%); }
}

@media (max-width: 780px) {
  .result__head { flex-direction: column; }
  .struct { width: 100%; height: 160px; }
  .mol-thumb { width: 100px; height: 76px; }
  .top__inner { flex-direction: column; align-items: flex-start; }
}
