*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/*déclaration des valeurs communes */

:root {
  --bg:           #CCC;
  --border:       rgba(255,255,255,0.07);
  --accent:       #0ea871;
  --accent-dim:   rgba(14,168,113,0.10);
  --accent-border:rgba(14,168,113,0.35);
  --text:         black;
  --muted:        #445566;
  --error:        #800;
  
  --panel-w:      260px;
  --panel-w-close:      20px;
  --fab-size:     40px;
}

#panel {
  --p-bg:        #f5f6f8;
  --p-bg2:       #eceef2;
  --p-border:    rgba(0,0,0,0.08);
  --p-text:      #1a2030;
  --p-muted:     #7a8899;
  --p-accent:    #0ea871;
  --p-accent-dim:rgba(14,168,113,0.10);
  --p-accent-bd: rgba(14,168,113,0.30);
}


html, body {
  width: 100%; height: 100%;
  background: var(--bg);
  overflow: hidden;
  font-family: sans-serif;
  color: var(--text);
}

#viewer {
  position: fixed;
  inset: 0;
}

/* décale le canvas si panneau visible */
body.has-panel #viewer {
  left: var(--panel-w);
}

#label {
  position: fixed;
  top: 16px;
  left: calc(var(--panel-w-close) + 16px);
  display: flex;
  align-items: baseline;

  font-family: monospace;
  font-size: 11px;
  letter-spacing: .07em;
  pointer-events: none;
  z-index: 10;
  user-select: none;
  transition: left .3s ease;
}

body.has-panel #label {
  left: calc(var(--panel-w) + 16px);
}

#label-name    {
	padding-right: 8px;
}

/* overlay pour messages et spinner de chargement */

#overlay {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  z-index: 20;
  pointer-events: none;
  transition: opacity .4s ease;
}
#overlay.hidden { opacity: 0; }

.spinner {
  width: 32px; height: 32px;
  border: 1.5px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

#overlay-msg {
  font-family: monospace;
  font-size: 11px;
  letter-spacing: .07em;
  color: var(--muted);
}
#overlay-msg.is-error { color: var(--error); }

/* boutons flottant type FAB */

#fabs {
  position: fixed;
  bottom: 20px; right: 18px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  z-index: 30;
}

.fab {
  width: var(--fab-size);
  height: var(--fab-size);
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,0.12);
  background: white;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
  color: #445566;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  position: relative;
  transition: border-color .2s, background .2s, color .2s, transform .15s, box-shadow .2s;
}
.fab:hover {
  border-color: var(--accent-border);
  background: #f0fdf8;
  color: var(--accent);
  box-shadow: 0 4px 14px rgba(0,0,0,0.18);
  transform: scale(1.07);
}
.fab:active { transform: scale(.93); }

.fab::before {
  content: attr(data-tip);
  position: absolute;
  right: calc(100% + 9px);
  white-space: nowrap;
  background: white;
  border: 1px solid rgba(0,0,0,0.10);
  border-radius: 6px;
  padding: 3px 10px;
  font-family: monospace;
  font-size: 10px;
  letter-spacing: .05em;
  color: #445566;
  box-shadow: 0 2px 6px rgba(0,0,0,0.12);
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s;
}
.fab:hover::before { opacity: 1; }

/* Panel gauche  */

#panel {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--panel-w);
  background: var(--p-bg);
  border-right: 1px solid var(--p-border);
  display: flex;
  flex-direction: column;
  z-index: 40;
  overflow: hidden;
  color: var(--p-text);
}

/* masqué en mode élève, ajouté par le script */
body.mode-view #panel { display: none; }

#panel-header {
  /*padding: 20px 18px 16px;*/
  height: 70px;
  border-bottom: 1px solid var(--p-border);
  flex-shrink: 0;
  background: var(--p-bg);
  display:flex;
  justify-content: space-between;
  align-items: center;
}

#panel-title {
  display: block;
  font-family: monospace;
  font-size: 13px;
  letter-spacing: .14em;
  color: var(--p-accent);
  text-transform: uppercase;
  margin-bottom: 3px;
  padding-left : 12px;
}

#panel-subtitle {
  font-size: 11px;
  color: var(--p-muted);
  letter-spacing: .04em;
  padding-left : 12px;
}

#panel-body {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--p-border) transparent;
}
 
.panel-section {
  padding: 12px 18px;
  border-bottom: 1px solid var(--p-border);
}
.panel-section:last-child { border-bottom: none; }

.section-label {
  font-family: monospace;
  font-size: 10px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--p-muted);
  margin-top: 6px;
  margin-bottom: 3px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* menu déroulant de molécules */

#mol-list, #mol-search {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  border: 1px solid var(--p-border);
  border-radius: 8px;
  background: white;
  color: var(--p-text);
  font-family: sans-serif;
  font-size: 13px;
  padding: 4px;
  outline: none;
}

#mol-search {
  padding: 8px;
}

.search-container {
  position: relative;
  width: 100%;
}

#search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 1px solid var(--p-border);
  border-radius: 6px;
  margin-top: 4px;
  max-height: 250px;
  overflow-y: auto;
  z-index: 100;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  list-style: none;
}

#search-results.hidden {
  display: none;
}

#search-results li {
  padding: 8px 10px;
  cursor: pointer;
  border-bottom: 1px solid #f0f0f0;
}

#search-results li:hover {
  background: var(--p-accent-dim);
}

.res-name {
  font-weight: bold;
  color: var(--p-text);
  display: block;
}

.res-formula {
  font-family: monospace;
  color: var(--p-accent);
  font-size: 11px;
}

.res-family {
  font-size: 10px;
  color: var(--p-muted);
  display: block;
  margin-top: 2px;
}

#mol-list {
  cursor: pointer;
}

#mol-list option:checked {
  background: var(--p-accent-dim);
  color: var(--p-accent);
}
#mol-list li.active .mol-name { color: var(--p-accent); }

/* éléments du formulaire */
.radio-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.radio-label, .check-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--p-text);
  cursor: pointer;
}

.radio-label input[type="radio"], input[type="checkbox"] {
  accent-color: var(--p-accent);
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  cursor: pointer;
}

#taille-slider, #baton-slider {
  width: 100%;
  accent-color: var(--p-accent);
  margin-top: 3px;
  margin-bottom: 3px;
}

.action-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  padding: 8px 12px;
  background: white;
  border: 1px solid var(--p-border);
  border-radius: 8px;
  color: var(--p-muted);
  font-family: monospace;
  font-size: 11px;
  letter-spacing: .05em;
  cursor: pointer;
  transition: border-color .2s, color .2s, background .2s;
}
.action-btn:hover {
  border-color: var(--p-accent-bd);
  color: var(--p-accent);
  background: var(--p-accent-dim);
}
.action-btn svg {
  width: 13px; height: 13px;
  fill: none; stroke: currentColor;
  stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round;
  flex-shrink: 0;
}

#link-feedback {
  margin-top: 8px;
  font-family: monospace;
  font-size: 10px;
  color: var(--p-accent);
  min-height: 14px;
}

/* fentres modales */

#modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4,7,12,.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease;
}
#modal-backdrop.open {
  opacity: 1;
  pointer-events: all;
}

#modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: clamp(24px,5vw,44px);
  max-width: 440px;
  width: 100%;
  transform: translateY(16px);
  transition: transform .28s ease;
}
#modal-backdrop.open #modal { transform: translateY(0); }

#modal header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}
.modal-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
  flex-shrink: 0;
}
#modal h2 {
  font-family: monospace;
  font-weight: 400;
  font-size: 12px;
  letter-spacing: .14em;
  color: var(--accent);
  text-transform: uppercase;
}

#modal p {
  font-size: 13px;
  line-height: 1.7;
  color: rgba(200,214,229,.75);
  margin-bottom: 12px;
}
#modal p code {
  font-family: monospace;
  font-size: .85em;
  color: var(--blue);
}

.modal-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 14px 0 22px;
}
.tag {
  font-family: monospace;
  font-size: 10px;
  letter-spacing: .05em;
  padding: 3px 10px;
  border-radius: 20px;
  border: 1px solid var(--border);
  color: var(--muted);
}
.tag.hl {
  border-color: var(--accent-border);
  color: var(--accent);
}

#btn-close-modal {
  font-family:  monospace;
  font-size: 11px;
  letter-spacing: .06em;
  padding: 7px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: none;
  color: var(--muted);
  cursor: pointer;
  transition: border-color .2s, color .2s;
}
#btn-close-modal:hover {
  border-color: var(--accent-border);
  color: var(--accent);
}

/* bouton responsive*/
#btn-menu {
	top: 0px; 
	right: 0px;
    width: var(--panel-w-close);
    height: 100%;
    border-width: thin;
    border-color: var(--accent);
    color: var(--accent);
    font-size: 12px; 
    cursor: pointer;
}

/* panel fermé pas la class .open */
  #panel {
    transform: translateX(calc(var(--panel-w-close) - var(--panel-w)));
    transition: transform .3s ease;
    box-shadow: none;
  }

  /* Panneau ouvert */
  #panel.open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,0.18);
  }

/* text area */
textarea {
  resize: none;
  width: 100%;
  font-size: 10px;
  font-family: monospace;
}

#iframe-larg, #iframe-haut {
  width: 100%;
  border: 1px solid var(--p-border);
  background: white;
  border-radius: 8px;
  color: var(--p-text);
  font-family: monospace;
  font-size: 10px;
  padding: 4px;
  outline: none;
}

}
