* {
  box-sizing: border-box;
}

html {
  height: 100%;
}

body {
  height: 96%;
  font-family: arial, helvetica, sans-serif;
  font-size: 12px;
  margin: 0;
  background: #fff;
}

#wrapper {
  position: relative;
  min-width: 200px;
  min-height: 300px;
  width: 98%;
  height: 98%;
  margin: auto;
  padding: 0;
  box-shadow: 0 0 25px rgba(159, 159, 159, 0.8);
}

#header {
  position: absolute;
  top: 0;
  width: 100%;
  min-height: 85px;
  margin: auto;
  padding: 0;
}

#user-input {
  width: auto;
  height: auto;
  margin: auto;
  padding: 5px;
  padding-top: 25px;
  padding-right: 280px;
}

#content-main {
  position: absolute;
  top: 90px;
  bottom: 50px;
  width: 100%;
  padding: 1px;
}

#plot {
  position: absolute;
  top: 8px;
  bottom: 0;
  left: 0;
  width: 70%;
  overflow: hidden;
}

#sidebar {
  position: absolute;
  top: 0;
  bottom: 0;
  right: 0;
  width: 29%;
  display: flex;
  flex-direction: column;
  border-left: 1px solid #eee;
}

#descriptor-panel {
  flex: 2;
  overflow-y: auto;
  padding: 8px 12px;
  border-bottom: 1px solid #eee;
}

#footer {
  position: absolute;
  bottom: 0;
  width: 100%;
  height: 50px;
  border-top: 1px solid #eee;
  background: #fff;
}

#content-info {
  width: auto;
  padding: 10px;
  float: left;
  overflow: hidden;
}

#content-source {
  width: auto;
  padding: 10px;
  float: right;
  overflow: hidden;
  display: flex;
  align-items: center;
  gap: 10px;
}

#content-source a {
  font-size: 14px;
  font-weight: normal;
  color: #53b2c8;
  text-decoration: none;
}

#options-btn {
  width: 30px;
  height: 30px;
  border: 1px solid #d4d9dd;
  border-radius: 8px;
  background: #fff;
  color: #4f6972;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    transform 0.15s ease;
}

#options-btn:hover {
  background: #f2f8fa;
  border-color: #a9cfd7;
  transform: translateY(-1px);
}

#options-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 34, 41, 0.22);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 300;
}

#options-overlay[hidden] {
  display: none;
}

#options-modal {
  width: min(340px, calc(100vw - 32px));
  max-height: min(640px, calc(100vh - 48px));
  background: #fff;
  border: 1px solid #d8e2e6;
  border-radius: 16px;
  box-shadow: 0 18px 50px rgba(31, 52, 61, 0.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.options-header {
  padding: 16px 18px 12px;
  border-bottom: 1px solid #ecf1f3;
  background: linear-gradient(180deg, #fbfdfe 0%, #f5fafc 100%);
}

.options-header h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: #26414a;
}

.options-body {
  padding: 12px 18px 16px;
  overflow: auto;
}

.options-section + .options-section {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid #dfe8eb;
}

.options-section h3 {
  margin: 0 0 9px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #5b7a84;
}

.option-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 8px 0;
  border-top: 1px solid #f1f4f6;
  color: #31464e;
  font-size: 13px;
}

.options-section .option-row:first-of-type {
  border-top: 0;
}

.option-row input[type='number'] {
  width: 88px;
  padding: 6px 8px;
  border: 1px solid #ced8dc;
  border-radius: 8px;
  font-size: 13px;
  color: #233841;
  background: #fff;
}

.option-row input[type='number']:focus {
  outline: none;
  border-color: #7db7c4;
  box-shadow: 0 0 0 3px rgba(83, 178, 200, 0.14);
}

.option-toggle input[type='checkbox'] {
  width: 18px;
  height: 18px;
  accent-color: #53b2c8;
}

.options-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 18px 18px;
  border-top: 1px solid #ecf1f3;
  background: #fbfcfd;
}

.options-actions button {
  min-width: 78px;
  padding: 8px 14px;
  border-radius: 9px;
  border: 1px solid #ccd8dc;
  background: #fff;
  color: #35515b;
  font-size: 13px;
  cursor: pointer;
  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    transform 0.15s ease;
}

.options-actions button:hover {
  background: #f3f8fa;
  border-color: #9fc8d1;
  transform: translateY(-1px);
}

#options-apply-btn {
  background: #53b2c8;
  border-color: #53b2c8;
  color: #fff;
}

#options-apply-btn:hover {
  background: #469db2;
  border-color: #469db2;
}

.group {
  position: relative;
  margin-bottom: 5px;
}

.examples {
  color: #999;
  margin: 0;
  padding-left: 15px;
  font-size: 12px;
  font-weight: normal;
  font-family: 'Lucida Sans Unicode', sans-serif;
}

.examples a {
  color: #53b2c8;
  font-weight: bold;
  text-decoration: none;
  cursor: pointer;
}

.examples a:hover {
  text-decoration: underline;
}

.group input {
  width: 100%;
  font-size: 16px;
  padding: 10px 10px 10px 5px;
  display: block;
  border: none;
  border-bottom: 1px solid #757575;
  background: transparent;
}

.group input:focus {
  outline: none;
}

.group input:focus ~ label,
.group input:valid ~ label {
  top: -15px;
  font-size: 13px;
  color: #5264ae;
}

.group label {
  color: #999;
  font-size: 16px;
  font-weight: normal;
  position: absolute;
  pointer-events: none;
  left: 5px;
  top: 10px;
  transition: 0.2s ease all;
}

.group .bar {
  position: relative;
  display: block;
  width: 100%;
}

.group .bar::before,
.group .bar::after {
  content: '';
  height: 2px;
  width: 0;
  bottom: 0;
  position: absolute;
  background: #5264ae;
  transition: 0.2s ease all;
}

.group .bar::before {
  left: 50%;
}
.group .bar::after {
  right: 50%;
}

.group input:focus ~ .bar::before,
.group input:focus ~ .bar::after {
  width: 50%;
}

.group .highlight {
  position: absolute;
  height: 60%;
  width: 100px;
  top: 25%;
  left: 0;
  pointer-events: none;
  opacity: 0.5;
}

.group input:focus ~ .highlight {
  animation: inputHighlighter 0.3s ease;
}

@keyframes inputHighlighter {
  from {
    background: #5264ae;
  }
  to {
    width: 0;
    background: transparent;
  }
}

.svg-plot {
  width: 100%;
  height: 100%;
  display: block;
}

#plot,
#plot * {
  -webkit-user-select: none;
  user-select: none;
}

/* ── Tooltip ─────────────────────────────────────────────────────────── */

div.tooltip {
  position: fixed;
  text-align: left;
  width: auto;
  min-width: 120px;
  height: auto;
  padding: 6px 10px 8px;
  font-size: 12px;
  font-family: 'Lucida Sans Unicode', sans-serif;
  background: white;
  border: 1px solid #bbb;
  border-radius: 6px;
  box-shadow: 2px 3px 8px rgba(0, 0, 0, 0.15);
  pointer-events: none;
  z-index: 100;
}
div.tooltip .tt-head {
  font-size: 17px;
  font-weight: bold;
  margin-bottom: 5px;
  border-bottom: 1px solid #eee;
  padding-bottom: 3px;
}
div.tooltip table {
  border-collapse: collapse;
  width: 100%;
}
div.tooltip td {
  padding: 1px 0;
  vertical-align: top;
}
div.tooltip td:first-child {
  color: #888;
  padding-right: 10px;
  white-space: nowrap;
}

/* ── Force-layout bond lines ─────────────────────────────────────────── */

.link {
  stroke: #696969;
  stroke-linecap: round;
}

/* ── 2D-structure bond lines ─────────────────────────────────────────── */

.bond {
  stroke: #111;
  stroke-linecap: round;
  fill: none;
}

.bond-dashed {
  stroke-dasharray: 5, 3;
}

.atom-bg {
  fill: none;
  stroke: none;
}

.atom-label {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 14px;
  font-weight: bold;
  text-anchor: middle;
  pointer-events: none;
  user-select: none;
}

.atom-charge-text,
.charge-label-text {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 9px;
  font-weight: bold;
  pointer-events: none;
  user-select: none;
}

.atom-charge-ring,
.charge-label-ring {
  pointer-events: none;
}

.atom-hit {
  fill: transparent;
  stroke: none;
  cursor: default;
}

/* ── Sidebar ─────────────────────────────────────────────────────────── */

#descriptor-table,
#pc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

#descriptor-table th,
#pc-table th {
  text-align: left;
  color: #555;
  font-size: 13px;
  font-weight: 600;
  border-bottom: 1px solid #ddd;
  padding: 4px 2px;
}

#descriptor-table td,
#pc-table td {
  padding: 3px 2px;
  border-bottom: 1px solid #f0f0f0;
  color: #333;
}

#descriptor-table td:last-child,
#pc-table td:last-child {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: #555;
}

#pc-table tr[data-highlight] {
  cursor: pointer;
}

#pc-table tr.pc-hover td {
  background: rgba(245, 224, 94, 0.22);
}

#descriptor-tabs {
  display: flex;
  border-bottom: 1px solid #ddd;
  margin-top: 6px;
  margin-bottom: 4px;
  gap: 2px;
}

.desc-tab {
  flex: 1;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  padding: 4px 4px;
  font-size: 11px;
  font-weight: 600;
  color: #999;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.desc-tab.active {
  color: #333;
  border-bottom-color: #333;
}

.desc-tab:hover:not(.active) {
  color: #555;
}

#smarts-panel {
  flex: 1;
  overflow-y: auto;
  padding: 6px 12px 8px;
}

#smarts-tabs {
  display: flex;
  border-bottom: 1px solid #ddd;
  margin-top: 0;
  margin-bottom: 6px;
  gap: 2px;
}

.smarts-tab {
  flex: 1;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  padding: 4px 4px;
  font-size: 11px;
  font-weight: 600;
  color: #999;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.smarts-tab.active {
  color: #333;
  border-bottom-color: #333;
}

.smarts-tab:hover:not(.active) {
  color: #555;
}

.smarts-tab-panel {
  min-height: 0;
}

#fg-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

#fg-table td {
  padding: 2px 4px;
  border-bottom: 1px solid #f0f0f0;
  color: #333;
}

#fg-table td:last-child {
  text-align: right;
  color: #777;
  white-space: nowrap;
}

#fg-table tr {
  cursor: pointer;
}

#fg-table tr:hover td {
  background: #f0f0f0;
}

#fg-table tr.fg-active td {
  background: rgba(80, 160, 40, 0.15);
}

#reaction-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

#resonance-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

#reaction-table td {
  padding: 6px 4px;
  border-bottom: 1px solid #f0f0f0;
  color: #333;
  vertical-align: top;
}

#resonance-table td {
  padding: 6px 4px;
  border-bottom: 1px solid #f0f0f0;
  color: #333;
  vertical-align: top;
}

#reaction-table td:last-child {
  width: 34px;
  text-align: right;
  white-space: nowrap;
}

#resonance-table td:last-child {
  width: 34px;
  text-align: right;
  white-space: nowrap;
}

#reaction-table tr:hover td {
  background: #f7f7f7;
}

#resonance-table tr.resonance-clickable:hover td {
  background: #f7f7f7;
}

#reaction-table tr {
  cursor: pointer;
}

#resonance-table tr.resonance-clickable {
  cursor: pointer;
}

#reaction-table tr.reaction-active td {
  background: rgba(80, 160, 40, 0.15);
}

#resonance-table tr.resonance-active td {
  background: rgba(0, 0, 0, 0.06);
}

.reaction-name {
  font-weight: 400;
  color: #333;
  margin-bottom: 2px;
}

.reaction-count {
  color: #666;
  font-variant-numeric: tabular-nums;
}

.reaction-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}

.reaction-site-label {
  color: #666;
  font-size: 11px;
  min-width: 28px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.reaction-nav-btn {
  width: 22px;
  height: 22px;
  border: 1px solid #ccc;
  border-radius: 11px;
  background: #fff;
  color: #555;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.reaction-nav-btn:hover {
  background: #f0f0f0;
  color: #333;
}

#molecularFormula {
  font-size: 14px;
  font-weight: bold;
  color: #333;
  display: inline-block;
}

#molecularWeight {
  font-size: 13px;
  color: #777;
  display: inline-block;
  margin-left: 10px;
}

/* ── Plot overlay controls ───────────────────────────────────────────── */

#toggle-controls {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 10;
}

#toggle-btn {
  height: 30px;
  padding: 0 12px;
  border: 1px solid #ccc;
  border-radius: 15px;
  background: #fff;
  cursor: pointer;
  font-size: 12px;
  font-family: arial, helvetica, sans-serif;
  color: #555;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
  transition:
    background 0.15s,
    color 0.15s;
  white-space: nowrap;
}

#toggle-btn:hover {
  background: #f0f0f0;
  color: #333;
}

#undo-controls {
  position: absolute;
  top: 48px;
  right: 10px;
  z-index: 10;
  display: flex;
  gap: 4px;
}

#undo-btn,
#redo-btn {
  width: 32px;
  height: 32px;
  border: 1px solid #ccc;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
  transition:
    background 0.15s,
    color 0.15s,
    border-color 0.15s,
    opacity 0.15s;
  padding: 0;
  color: #555;
}

#undo-btn:hover:not(:disabled),
#redo-btn:hover:not(:disabled) {
  background: #f0f0f0;
  color: #333;
}

#undo-btn:disabled,
#redo-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

#atom-selector {
  position: absolute;
  top: 88px;
  right: 10px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

#atom-selector button {
  width: 32px;
  height: 32px;
  border: 1px solid #ccc;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
  transition:
    background 0.15s,
    border-color 0.15s;
  padding: 0;
  font-size: 13px;
  font-weight: bold;
}

#atom-selector button:hover {
  background: #f0f0f0;
}

#elem-btn-C {
  color: #333333;
}
#elem-btn-C.active {
  background: #e8e8e8;
  border-color: #333333;
}
#elem-btn-N {
  color: #3050f8;
}
#elem-btn-N.active {
  background: #e6eaff;
  border-color: #3050f8;
}
#elem-btn-O {
  color: #ff0d0d;
}
#elem-btn-O.active {
  background: #ffe8e8;
  border-color: #ff0d0d;
}
#elem-btn-S {
  color: #c8a000;
}
#elem-btn-S.active {
  background: #fdf8d8;
  border-color: #c8a000;
}
#elem-btn-P {
  color: #ff8000;
}
#elem-btn-P.active {
  background: #fff0e0;
  border-color: #ff8000;
}
#elem-btn-F {
  color: #6ab52a;
}
#elem-btn-F.active {
  background: #f2fce4;
  border-color: #6ab52a;
}
#elem-btn-Cl {
  color: #18b018;
}
#elem-btn-Cl.active {
  background: #e0fce0;
  border-color: #18b018;
}
#elem-btn-Br {
  color: #a62929;
}
#elem-btn-Br.active {
  background: #fce8e8;
  border-color: #a62929;
}
#elem-btn-I {
  color: #940094;
}
#elem-btn-I.active {
  background: #f8e0f8;
  border-color: #940094;
}

#rotate-controls {
  position: absolute;
  bottom: 10px;
  right: 10px;
  display: flex;
  gap: 4px;
  z-index: 10;
}

#force-controls {
  position: absolute;
  bottom: 10px;
  right: 10px;
  display: none;
  z-index: 10;
  gap: 4px;
}

#label-toggle,
#copy-force-svg-btn,
#copy-force-png-btn {
  height: 32px;
  padding: 0 12px;
  border: 1px solid #ccc;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  font-size: 12px;
  font-family: arial, helvetica, sans-serif;
  transition: background 0.15s;
}

#label-toggle:hover,
#copy-force-svg-btn:hover,
#copy-force-png-btn:hover {
  background: #f0f0f0;
}

#label-toggle.active {
  background: #5090f0;
  color: #fff;
  border-color: #3060c0;
}

#label-toggle.active:hover {
  background: #4080e0;
}

.svg-plot.labels-hidden .atom-symbol {
  display: none;
}

#rotate-controls button,
#force-rotate-ccw,
#force-rotate-cw,
#force-flip-h,
#force-flip-v {
  width: 32px;
  height: 32px;
  border: 1px solid #ccc;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
  font-size: 17px;
  color: #555;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
  transition: background 0.15s;
  padding: 0;
}

#rotate-controls button:hover,
#force-rotate-ccw:hover,
#force-rotate-cw:hover,
#force-flip-h:hover,
#force-flip-v:hover {
  background: #f0f0f0;
  color: #333;
}

#rotate-controls #copy-svg-btn,
#rotate-controls #save-png-btn {
  font-size: 9px;
  font-weight: bold;
}

#clean-controls {
  position: absolute;
  bottom: 10px;
  left: 10px;
  display: flex;
  gap: 8px;
  align-items: center;
  z-index: 10;
}

#clean-controls button {
  width: 32px;
  height: 32px;
  border: 1px solid #ccc;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
  font-size: 16px;
  color: #555;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
  transition:
    background 0.15s,
    color 0.15s,
    border-color 0.15s;
  padding: 0;
}

#clean-controls button:hover {
  background: #f0f0f0;
  color: #333;
}

#pan-mode-btn.active,
#select-mode-btn.active {
  background: #5090f0;
  color: #fff;
  border-color: #3060c0;
}

#pan-mode-btn.active:hover,
#select-mode-btn.active:hover {
  background: #4080e0;
}

#erase-btn.active {
  background: #5090f0;
  color: #fff;
  border-color: #3070d0;
}
#erase-btn.active:hover {
  background: #4080e0;
}

#erase-cursor {
  position: fixed;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(220, 50, 50, 0.25);
  border: 2px solid rgba(200, 30, 30, 0.6);
  pointer-events: none;
  transform: translate(-50%, -50%);
  display: none;
  z-index: 9999;
}

#draw-tools {
  position: absolute;
  top: 10px;
  left: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 10;
}

#draw-tools button {
  width: 32px;
  height: 32px;
  border: 1px solid #ccc;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
  font-size: 16px;
  color: #555;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
  transition:
    background 0.15s,
    color 0.15s,
    border-color 0.15s;
  padding: 0;
}

#draw-tools button:hover {
  background: #f0f0f0;
  color: #333;
}

#draw-bond-btn.active {
  background: #5090f0;
  color: #fff;
  border-color: #3060c0;
}

#draw-bond-btn.active:hover {
  background: #4080e0;
}

#force-controls #copy-force-svg-btn,
#force-controls #copy-force-png-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 50%;
  font-size: 9px;
  font-family: -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  font-weight: bold;
  color: #555;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

#force-controls #copy-force-svg-btn:hover,
#force-controls #copy-force-png-btn:hover {
  color: #333;
}

/* ── Format toggle (SMILES / InChI) ─────────────────────────────────── */

#format-toggle {
  position: absolute;
  top: 14px;
  right: 12px;
  display: flex;
  z-index: 2;
  border: 1px solid #ccc;
  border-radius: 28px;
  overflow: hidden;
}

#format-toggle button {
  padding: 8px 18px;
  border: none;
  background: #fff;
  color: #999;
  cursor: pointer;
  font-size: 14px;
  font-family: arial, helvetica, sans-serif;
  transition:
    background 0.15s,
    color 0.15s;
}

#format-toggle button.active {
  background: #5264ae;
  color: #fff;
}

#format-toggle button:hover:not(.active) {
  background: #f0f0f0;
  color: #555;
}

#collection-picker {
  position: absolute;
  top: 58px;
  right: 12px;
  width: 240px;
  z-index: 2;
}

#collection-select {
  width: 100%;
  height: 34px;
  padding: 0 10px;
  border: 1px solid #d6d6d6;
  border-radius: 10px;
  background: #fff;
  color: #666;
  font-size: 13px;
  font-family: arial, helvetica, sans-serif;
  outline: none;
}

#collection-select:focus {
  border-color: #5264ae;
  box-shadow: 0 0 0 2px rgba(82, 100, 174, 0.08);
}
