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

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
}

body {
  font-family: system-ui, "Segoe UI", sans-serif;
  background: #0c0f14;
  color: #e8eaef;
}

/* ——— Shell: panouri lipite, retractabile, canvas pe mijloc ——— */
.shell {
  --drawer-left-w: min(300px, 36vw);
  --drawer-right-w: min(320px, 38vw);
  --edge-w: 36px;
  display: flex;
  flex-direction: row;
  align-items: stretch;
  width: 100%;
  max-width: 100%;
  height: 100%;
  min-height: 100vh;
  min-height: 100dvh;
}

.edge {
  flex: 0 0 var(--edge-w);
  min-width: var(--edge-w);
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #141922 0%, #0c1018 100%);
  border: solid #252b36;
  border-width: 0 1px;
  z-index: 5;
}

.edge--left {
  border-left: none;
  order: 0;
}

.edge--right {
  border-right: none;
  order: 4;
}

.edge__toggle {
  width: 100%;
  min-height: 72px;
  margin: 0;
  padding: 0.35rem;
  border: none;
  background: transparent;
  color: #8eb4d4;
  cursor: pointer;
  border-radius: 6px;
  font-size: 1.15rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}

.edge__toggle:hover {
  background: rgba(90, 140, 200, 0.15);
  color: #c8dde8;
}

.edge__toggle:focus-visible {
  outline: 2px solid #5b9fd4;
  outline-offset: 2px;
}

.edge__icon--expand {
  display: none;
}

.shell.shell--left-collapsed .edge--left .edge__icon--collapse {
  display: none;
}

.shell.shell--left-collapsed .edge--left .edge__icon--expand {
  display: inline;
}

.shell.shell--right-collapsed .edge--right .edge__icon--collapse {
  display: none;
}

.shell.shell--right-collapsed .edge--right .edge__icon--expand {
  display: inline;
}

.drawer {
  flex: 0 0 auto;
  width: var(--drawer-left-w);
  max-width: var(--drawer-left-w);
  min-width: 0;
  overflow: hidden;
  transition: width 0.28s ease, max-width 0.28s ease, opacity 0.2s ease;
  border: solid #252b36;
  border-width: 0 1px 0 0;
  z-index: 6;
  position: relative;
}

.drawer--left {
  order: 1;
}

.drawer--right {
  order: 3;
  width: var(--drawer-right-w);
  max-width: var(--drawer-right-w);
  border-width: 0 0 0 1px;
}

.shell.shell--left-collapsed .drawer--left {
  width: 0;
  max-width: 0;
  opacity: 0;
  pointer-events: none;
  border-width: 0;
}

.shell.shell--right-collapsed .drawer--right {
  width: 0;
  max-width: 0;
  opacity: 0;
  pointer-events: none;
  border-width: 0;
}

.drawer__scroll {
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.85rem 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y pinch-zoom;
}

.drawer--right .drawer__scroll {
  gap: 1rem;
}

.main-fill {
  order: 2;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 0.65rem 0.75rem 0.75rem;
  position: relative;
  z-index: 1;
}

.header {
  flex: 0 0 auto;
  margin-bottom: 0.65rem;
}

.header h1 {
  margin: 0 0 0.2rem;
  font-size: clamp(1.1rem, 2.2vw, 1.35rem);
  font-weight: 600;
  letter-spacing: -0.02em;
}

.tagline {
  margin: 0;
  font-size: 0.88rem;
  color: #8b93a3;
}

.stage {
  flex: 1 1 auto;
  width: 100%;
  min-height: 200px;
  min-width: 0;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid #252b36;
  background: #12161d;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
  transition: transform 0.05s linear;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: stretch;
}

/* Umple exact #stage — fără object-fit: contain (lasă benzi goale pe lateral) */
#canvas {
  display: block;
  flex: 1 1 auto;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  align-self: stretch;
}

.panel {
  background: #151a22;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
}

.panel--left,
.panel--right {
  border-radius: 0;
  padding: 0;
}

.info-card {
  padding: 0.75rem 0.85rem;
  background: #0e1218;
  border-radius: 10px;
  border: 1px solid #222a36;
  flex-shrink: 0;
}

.info-card--live {
  border-color: #2a3f55;
  background: linear-gradient(145deg, #0f141c 0%, #121a24 100%);
}

.info-card__title {
  margin: 0 0 0.45rem;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #7ec8e3;
}

.info-card__text {
  margin: 0;
  font-size: 0.86rem;
  line-height: 1.5;
  color: #a8b0c0;
}

.info-card__text strong {
  color: #dce2ec;
  font-weight: 600;
}

.chart-panel {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex-shrink: 0;
}

.chart-panel__title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: #c8dde8;
  letter-spacing: -0.02em;
}

.chart-panel__caption {
  margin: 0;
  font-size: 0.8rem;
  line-height: 1.45;
  color: #7a8494;
}

.chart-wrap {
  width: 100%;
  min-height: 160px;
  height: clamp(160px, 22vh, 260px);
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid #2c3545;
  background: #0a0d12;
  flex-shrink: 0;
}

#chart-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.chart-axis-label {
  margin: 0;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #5c6575;
  text-align: right;
}

.controls--sidebar {
  margin: 0;
  padding: 1rem 1.05rem;
  background: #0e1218;
  border-radius: 10px;
  border: 1px solid #252b36;
  flex-shrink: 0;
  position: relative;
  z-index: 2;
}

.controls__heading {
  margin: 0 0 0.85rem;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #6b7a8c;
}

.temp-label {
  display: block;
  font-size: 0.9rem;
  margin-bottom: 0.45rem;
  margin-top: 0.65rem;
}

.controls--sidebar .temp-label:first-of-type,
.control-row + .temp-label {
  margin-top: 0;
}

/* Zonă de tragere mare + pan orizontal (evită conflictul cu scroll-ul pe mobil) */
.range-field {
  width: 100%;
  padding: 0.35rem 0 0.6rem;
  margin: 0 -0.15rem;
  padding-left: 0.15rem;
  padding-right: 0.15rem;
  touch-action: pan-x;
  position: relative;
  z-index: 3;
}

input[type="range"] {
  width: 100%;
  max-width: 100%;
  margin: 0;
  min-height: 2.75rem;
  cursor: pointer;
  touch-action: pan-x;
  -webkit-tap-highlight-color: transparent;
  accent-color: #5b9fd4;
  background: transparent;
  -webkit-appearance: none;
  appearance: none;
}

input[type="range"]:focus {
  outline: none;
}

input[type="range"]:focus-visible {
  outline: 2px solid #5b9fd4;
  outline-offset: 3px;
  border-radius: 6px;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 10px;
  border-radius: 5px;
  background: #2c3545;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 26px;
  height: 26px;
  margin-top: -8px;
  border-radius: 50%;
  background: linear-gradient(180deg, #6eb0e8 0%, #4a8fc4 100%);
  border: 2px solid #c8dde8;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

input[type="range"]::-moz-range-track {
  height: 10px;
  border-radius: 5px;
  background: #2c3545;
}

input[type="range"]::-moz-range-thumb {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: linear-gradient(180deg, #6eb0e8 0%, #4a8fc4 100%);
  border: 2px solid #c8dde8;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

.state-line {
  margin: 0.5rem 0 0.35rem;
  font-size: 0.95rem;
}

.state-line strong {
  color: #7ec8e3;
  font-weight: 600;
}

.control-row {
  margin-bottom: 0.25rem;
}

.select-input {
  width: 100%;
  padding: 0.45rem 0.6rem;
  border-radius: 8px;
  border: 1px solid #2c3545;
  background: #0e1218;
  color: #e8eaef;
  font-size: 0.95rem;
}

.pressure-line {
  margin: 0 0 0.35rem;
  font-size: 1rem;
  font-weight: 600;
  color: #9dd4a8;
}

.zero-warning {
  margin: 0.65rem 0 0;
  padding: 0.55rem 0.65rem;
  border-radius: 8px;
  background: rgba(80, 120, 180, 0.2);
  border: 1px solid rgba(120, 170, 230, 0.35);
  font-size: 0.85rem;
  color: #b8d4ff;
}

.challenge-item {
  margin: 0.5rem 0 0;
  font-size: 0.82rem;
  line-height: 1.45;
  color: #9aa3b2;
}

.challenge-item:first-of-type {
  margin-top: 0.35rem;
}

.hint {
  margin: 0;
  font-size: 0.85rem;
  line-height: 1.45;
  color: #8b93a3;
}

.info-card--aha {
  border-color: #3a5a78;
  background: linear-gradient(160deg, #101820 0%, #15202d 100%);
}

.insight-dynamic {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.55;
  color: #c5d2e5;
  transition: color 0.25s ease, transform 0.25s ease;
}

.insight-dynamic--flash {
  animation: insight-pulse 0.55s ease;
}

@keyframes insight-pulse {
  0% {
    color: #7ec8e3;
    transform: scale(1);
  }
  40% {
    color: #fff;
    transform: scale(1.01);
  }
  100% {
    color: #c5d2e5;
    transform: scale(1);
  }
}

.experiment-block {
  margin-top: 1rem;
  padding: 0.9rem 0.85rem;
  border-radius: 10px;
  border: 1px solid #2c3f55;
  background: linear-gradient(180deg, #121a26 0%, #0e141c 100%);
}

.experiment-block__title {
  margin: 0 0 0.5rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #7ec8e3;
}

.experiment-block__goal {
  margin: 0 0 0.35rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: #e8eaef;
}

.experiment-block__desc {
  margin: 0 0 0.75rem;
  font-size: 0.8rem;
  line-height: 1.45;
  color: #8b96a8;
}

.experiment-block__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 0.55rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  font-family: inherit;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}

.btn:active {
  transform: scale(0.98);
}

.btn--primary {
  background: linear-gradient(180deg, #4a8fc4 0%, #3a7aad 100%);
  color: #fff;
  border-color: #5a9fd4;
}

.btn--primary:hover {
  background: linear-gradient(180deg, #5a9fd4 0%, #4a8fc4 100%);
}

.btn--ghost {
  background: transparent;
  color: #9eb4cc;
  border-color: #3a4a5e;
}

.btn--ghost:hover {
  background: rgba(90, 130, 180, 0.12);
  color: #c8dde8;
}

.btn--capture {
  width: 100%;
  margin-top: 0.15rem;
  background: #1a2432;
  color: #b8d4ee;
  border-color: #35475c;
  font-weight: 500;
}

.btn--capture:hover {
  background: #243044;
  border-color: #4a6280;
}

.toast-root {
  position: fixed;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  padding: 0.65rem 1.15rem;
  border-radius: 12px;
  background: linear-gradient(145deg, #1e2a3a 0%, #152030 100%);
  border: 1px solid #3d5a78;
  color: #e8f0f8;
  font-size: 0.92rem;
  font-weight: 500;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  opacity: 0;
  transform: translateY(12px) scale(0.96);
  transition: opacity 0.35s ease, transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
  max-width: min(420px, 92vw);
  text-align: center;
}

.toast--show {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.stage--absolute-zero {
  filter: brightness(0.93) saturate(0.9);
  box-shadow:
    inset 0 0 80px rgba(80, 140, 200, 0.08),
    0 8px 32px rgba(0, 0, 0, 0.35);
}

@media (max-width: 720px) {
  .shell {
    --drawer-left-w: min(280px, 85vw);
    --drawer-right-w: min(290px, 88vw);
    --edge-w: 32px;
  }

  .drawer__scroll {
    padding: 0.65rem 0.75rem 1rem;
  }

  input[type="range"] {
    min-height: 3rem;
  }

  input[type="range"]::-webkit-slider-thumb {
    width: 30px;
    height: 30px;
    margin-top: -10px;
  }

  input[type="range"]::-moz-range-thumb {
    width: 30px;
    height: 30px;
  }

  .select-input {
    min-height: 48px;
    font-size: 1rem;
  }

  .btn {
    min-height: 48px;
    padding: 0.55rem 1rem;
  }
}
