:root {
  --bg: #0f1419;
  --panel: #182028;
  --line: #2a3a48;
  --text: #e8eef4;
  --muted: #8fa3b5;
  --accent: #3db8a0;
  --accent-dim: #2a8f7c;
  --warn: #e6b35a;
  --font: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(ellipse 80% 50% at 10% -10%, #1a3a36 0%, transparent 55%),
    radial-gradient(ellipse 60% 40% at 100% 0%, #243048 0%, transparent 50%),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
}

.top {
  padding: 1.25rem 1.5rem 0.5rem;
  border-bottom: 1px solid var(--line);
}
.top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.nav-auth {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}
.nav-user {
  font-size: 0.85rem;
  color: var(--muted);
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lang-wrap {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  color: var(--muted);
}
.lang-select {
  background: #0c1116;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.35rem 0.5rem;
  font: inherit;
  font-size: 0.85rem;
}
.profile-legal {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 18px;
  margin: 10px 0 4px;
  font-size: 0.9rem;
}
.profile-legal a { color: var(--accent); }
.password-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  margin-top: 12px;
}
.password-panel summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.9rem;
}
.ok-msg { color: var(--accent); font-size: 0.85rem; min-height: 1.1em; }
.auth-tos { margin-top: 0.75rem; align-items: flex-start; }
.auth-tos a { color: var(--accent); }
.brand {
  font-size: 1.35rem;
  font-weight: 650;
  letter-spacing: 0.02em;
}
.brand span { color: var(--accent); }
.tag { margin: 0.35rem 0 0; color: var(--muted); font-size: 0.92rem; }
.check-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-top: 0.85rem;
  font-size: 0.85rem;
  color: var(--muted);
  cursor: pointer;
}
.check-row input { width: auto; }

.modal {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0;
  background: var(--panel);
  color: var(--text);
  max-width: min(560px, 94vw);
  max-height: min(92vh, 760px);
  overflow: auto;
}
.modal::backdrop { background: rgba(4, 8, 12, 0.72); }
.modal-inner { padding: 1.1rem 1.2rem 1.25rem; }
.modal-inner.wide { max-width: min(820px, 96vw); width: 820px; }
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
}
.modal h2 { margin: 0 0 0.75rem; font-size: 1.1rem; }
.modal h3 {
  margin: 1rem 0 0.5rem;
  font-size: 0.9rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
[hidden],
.hidden { display: none !important; }
.auth-tabs { display: flex; gap: 0.35rem; margin-bottom: 0.85rem; flex-wrap: wrap; }
.auth-tabs .active { border-color: var(--accent); color: var(--accent); }
.auth-field {
  display: block;
  margin-top: 0.65rem;
  font-size: 0.8rem;
  color: var(--muted);
}
.auth-field input { margin-top: 0.3rem; }
.captcha-row,
.code-row {
  display: flex;
  gap: 0.45rem;
  align-items: stretch;
  margin-top: 0.3rem;
}
.captcha-row input,
.code-row input {
  flex: 1;
  min-width: 0;
  width: auto;
  margin-top: 0;
}
.captcha-btn {
  flex: 0 0 128px;
  height: 42px;
  padding: 0;
  border-radius: 8px;
  background: #eaf4f2;
  overflow: hidden;
}
.captcha-img {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 128px;
  height: 42px;
  font-size: 12px;
  color: #5a736e;
  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: 0.75rem 0 0; font-size: 0.8rem; }
.error { color: #e88; font-size: 0.85rem; min-height: 1.1em; }
.muted { color: var(--muted); font-size: 0.85rem; }
.profile-user { font-weight: 650; margin-top: 0.25rem; }
.hist-table .smi-cell {
  font-family: var(--mono);
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hist-actions { display: flex; gap: 0.35rem; }

.layout {
  display: grid;
  grid-template-columns: minmax(260px, 340px) 1fr;
  gap: 1rem;
  padding: 1rem 1.5rem 2rem;
  max-width: 1200px;
  margin: 0 auto;
}
.panel {
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1rem 1.1rem;
}
.panel.grow { min-height: 320px; }
.panel.full { grid-column: 1 / -1; }
.panel h2 {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.mol-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 160px;
  margin: 0 0 0.85rem;
  padding: 0.5rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #f7fafc;
  color: #334;
  overflow: hidden;
}
.mol-preview.empty {
  background: color-mix(in srgb, var(--panel) 70%, #0c1116);
  color: var(--muted);
  border-style: dashed;
  font-size: 0.85rem;
  text-align: center;
  padding: 1rem 0.75rem;
}
.mol-preview img {
  display: block;
  width: 220px;
  height: 160px;
  max-width: 100%;
  object-fit: contain;
}

label { display: block; font-size: 0.8rem; color: var(--muted); margin-bottom: 0.35rem; }
input, select {
  width: 100%;
  padding: 0.55rem 0.65rem;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #0c1116;
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.9rem;
}
.row { margin-top: 0.85rem; }
.actions { display: flex; gap: 0.5rem; }
button {
  border: 1px solid var(--line);
  background: #121a22;
  color: var(--text);
  border-radius: 6px;
  padding: 0.5rem 0.9rem;
  cursor: pointer;
  font: inherit;
}
button.primary {
  background: var(--accent-dim);
  border-color: var(--accent);
  font-weight: 600;
}
button.secondary { background: transparent; }
button:hover { filter: brightness(1.08); }
button:disabled { opacity: 0.55; cursor: not-allowed; }
.status { min-height: 1.2em; font-size: 0.85rem; color: var(--muted); margin: 0.75rem 0 0; }
.status.error { color: #e88; }
.disclaimer { font-size: 0.75rem; color: var(--warn); margin: 0.5rem 0 0; line-height: 1.35; }

#chart {
  width: 100%;
  height: 300px;
  background: #0c1116;
  border-radius: 6px;
  border: 1px solid var(--line);
}
.meta {
  margin-top: 0.65rem;
  font-size: 0.85rem;
  color: var(--muted);
  font-family: var(--mono);
}

.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.frag-struct-cell {
  width: 132px;
  vertical-align: middle;
}
.frag-struct-img {
  display: block;
  width: 120px;
  height: 90px;
  object-fit: contain;
  background: #f7fafc;
  border: 1px solid var(--line);
  border-radius: 6px;
}
.frag-struct-empty {
  color: var(--muted);
}
th, td {
  text-align: left;
  padding: 0.4rem 0.55rem;
  border-bottom: 1px solid var(--line);
}
th { color: var(--muted); font-weight: 560; }
#frag-table td:nth-child(1),
#frag-table td:nth-child(3),
#iso-table td:nth-child(1),
#iso-table td:nth-child(2) {
  font-family: var(--mono);
}

@media (max-width: 800px) {
  .layout { grid-template-columns: 1fr; padding: 0.75rem; }
}

.top h1 {
  margin: 0.45rem 0 0;
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.page { display: none; }
.page.active { display: block; }

.page-draw {
  min-height: 100vh;
  padding: 1rem 1.25rem 2rem;
}
.draw-wrap { max-width: 1200px; margin: 0 auto; }
.draw-topbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.35rem;
}
.draw-topbar h1 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 600;
}
.draw-sub {
  margin: 0 0 0.85rem;
  color: var(--muted);
  font-size: 0.9rem;
}
.draw-panel { padding: 0.75rem; }
.draw-actions { margin-top: 0.75rem; }

.ketcher-stage {
  position: relative;
  height: min(68vh, 640px);
  min-height: 420px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}
#ketcher-frame {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  background: #fff;
}
.ketcher-loading {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  padding: 1.25rem;
  background: color-mix(in srgb, var(--panel) 96%, #fff 4%);
}
.ketcher-loading.hidden { display: none; }
.ketcher-loading__title { margin: 0; font-weight: 650; color: var(--text); }
.ketcher-loading__pct {
  margin: 0;
  font-family: var(--mono);
  color: var(--accent);
  font-size: 0.95rem;
}
.ketcher-loading__detail {
  margin: 0;
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
}
.ketcher-loading__detail:empty { display: none; }
.ketcher-progress {
  width: min(320px, 70vw);
  height: 8px;
  border-radius: 999px;
  background: #243040;
  overflow: hidden;
}
.ketcher-progress__bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-dim), var(--accent));
  transition: width 0.15s ease;
}
.ketcher-progress--indeterminate .ketcher-progress__bar {
  width: 35%;
  animation: ketcher-indeterminate 1.1s ease-in-out infinite;
}
@keyframes ketcher-indeterminate {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(320%); }
}

@media (max-width: 800px) {
  .ketcher-stage { min-height: 360px; height: 58vh; }
}
