/* SPDX-License-Identifier: AGPL-3.0-or-later AND CC-BY-NC-SA-4.0 */
:root {
  --bg: #EEF3F8;
  --surface: #FFFFFF;
  --surface-alt: #F8FAFC;
  --border: #CBD5E1;
  --border-soft: #E2E8F0;
  --ink: #0F172A;
  --ink-muted: #475569;
  --accent: #0284C7;
  --accent-dark: #0369A1;
  --accent-soft: #E0F2FE;
  --emerald: #059669;
  --amber: #F59E0B;
  --header-bg: #0F172A;
  --header-ink: #F8FAFC;
  --radius: 12px;
  --shadow: 0 2px 10px rgba(15, 23, 42, 0.06);
  --font-sans: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", "Cascadia Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --tap: 40px; /* alçada mínima dels botons (en px de disseny; l'escala els fa créixer a la pissarra) */

  /* Escala uniforme calculada per app.js */
  --z: 1;
}

* {
  box-sizing: border-box;
}

html {
  zoom: var(--z);
  font-size: 15px;
}

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.35;
}

body {
  overflow: hidden;
}

html.apilat body {
  overflow: auto;
}

.hidden {
  display: none !important;
}

.ic {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

button, select, input {
  font-family: inherit;
}

button:focus-visible, select:focus-visible, input:focus-visible, .obj-card:focus-visible {
  outline: 3px solid #F59E0B;
  outline-offset: 2px;
}

/* Shell: ocupa exactament la finestra (dividida per l'escala) */
.app-shell {
  display: flex;
  flex-direction: column;
  height: calc(100vh / var(--z));
  min-height: 640px;
}

html.apilat .app-shell {
  height: auto;
  min-height: 0;
}

/* ===================== Barra superior ===================== */
.topbar {
  background: var(--header-bg);
  color: var(--header-ink);
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  flex-shrink: 0;
  border-bottom: 1px solid #1E293B;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-ic {
  width: 28px;
  height: 28px;
  color: #38BDF8;
}

.brand-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.brand-sub {
  margin: 0;
  font-size: 0.8rem;
  color: #94A3B8;
}

.topbar-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.liquid-picker {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #1E293B;
  min-height: var(--tap);
  padding: 0 10px;
  border-radius: 9px;
  border: 1px solid #334155;
}

.ctrl-label {
  font-size: 0.87rem;
  font-weight: 600;
  color: #CBD5E1;
}

.liquid-picker select {
  background: transparent;
  color: #F8FAFC;
  border: none;
  font-weight: 700;
  font-size: 0.93rem;
  min-height: calc(var(--tap) - 2px);
  cursor: pointer;
  outline: none;
}

.liquid-picker select option {
  background: #0F172A;
  color: #F8FAFC;
}

.custom-liquid-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #1E293B;
  min-height: var(--tap);
  padding: 0 10px;
  border-radius: 9px;
  border: 1px solid #0284C7;
}

.custom-liquid-wrap input[type="range"] {
  width: 120px;
  accent-color: #38BDF8;
}

.mono-pill {
  font-family: var(--font-mono);
  font-size: 0.87rem;
  font-weight: 700;
  color: #38BDF8;
}

.toggle-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.btn-toggle, .btn-action, .btn-ajuda {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: var(--tap);
  padding: 0 13px;
  border-radius: 9px;
  border: 1px solid #334155;
  background: #1E293B;
  color: #E2E8F0;
  font-size: 0.9rem;
  font-weight: 650;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  touch-action: manipulation;
}

.btn-toggle:hover, .btn-action:hover {
  background: #334155;
  color: #FFFFFF;
}

.btn-toggle.active {
  background: #0284C7;
  border-color: #38BDF8;
  color: #FFFFFF;
}

#btn-calculs.active {
  background: #B45309;
  border-color: #FBBF24;
}

.btn-ajuda {
  background: #FBBF24;
  border-color: #FCD34D;
  color: #0F172A;
  font-weight: 800;
}

.btn-ajuda:hover {
  background: #FCD34D;
}

/* ===================== Espai de treball ===================== */
.workspace {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 10px;
  padding: 10px 14px;
}

/* Catàleg d'objectes */
.catalog-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.cat-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 8px;
  background: var(--surface-alt);
  border-bottom: 1px solid var(--border);
}

.cat-tab {
  min-height: 34px;
  padding: 0 8px;
  border-radius: 7px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-muted);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
}

.cat-tab:hover {
  background: #E2E8F0;
  color: var(--ink);
}

.cat-tab.active {
  background: var(--accent);
  color: #FFFFFF;
}

.cat-grid {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 8px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  align-content: start;
}

.obj-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 6px;
  border-radius: 10px;
  border: 1.5px solid var(--border-soft);
  background: var(--surface-alt);
  color: var(--ink);
  cursor: grab;
  text-align: center;
  font: inherit;
  transition: transform 0.12s, border-color 0.12s, background 0.12s;
  user-select: none;
  -webkit-user-select: none;
  touch-action: pan-y;
}

.obj-card:hover {
  border-color: #7DD3FC;
  background: #F0F9FF;
  transform: translateY(-1px);
}

.obj-card.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 2px rgba(2, 132, 199, 0.2);
}

.obj-card:active {
  cursor: grabbing;
}

.obj-card svg {
  width: 54px;
  height: 43px;
  pointer-events: none;
}

.obj-card-name {
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1.15;
}

/* Panell personalitzat */
.custom-obj-panel {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.field-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.field-row label {
  font-size: 0.87rem;
  font-weight: 700;
  color: var(--ink-muted);
}

.field-row select {
  flex: 1;
  min-height: 38px;
  padding: 0 8px;
  border-radius: 7px;
  border: 1px solid var(--border);
  font-weight: 600;
}

.slider-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.slider-head {
  display: flex;
  justify-content: space-between;
  font-size: 0.87rem;
  font-weight: 700;
}

.mono-val {
  font-family: var(--font-mono);
  color: var(--accent-dark);
}

input[type="range"] {
  accent-color: var(--accent);
  height: 30px;
  cursor: pointer;
  touch-action: pan-y;
}

.slider-block input[type="range"] {
  width: 100%;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 0 16px;
  border: none;
  border-radius: 9px;
  background: var(--accent);
  color: #FFFFFF;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
}

.btn-primary:hover {
  background: var(--accent-dark);
}

.btn-link {
  min-height: var(--tap);
  padding: 0 10px;
  border: none;
  background: transparent;
  color: var(--ink-muted);
  font-weight: 700;
  font-size: 0.87rem;
  text-decoration: underline;
  cursor: pointer;
}

.full-w {
  width: 100%;
}

/* Objecte seleccionat */
.selected-box {
  padding: 9px 10px;
  border-top: 1px solid var(--border);
  background: #F1F5F9;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.selected-info {
  display: flex;
  align-items: center;
  gap: 9px;
}

.selected-thumb {
  width: 46px;
  height: 40px;
  border-radius: 7px;
  background: #FFFFFF;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.selected-thumb svg {
  width: 40px;
  height: 33px;
}

.selected-name {
  font-size: 0.93rem;
  font-weight: 800;
}

.selected-desc {
  font-size: 0.8rem;
  color: var(--ink-muted);
}

.quick-send {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
}

.btn-send {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 46px;
  padding: 3px 2px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #FFFFFF;
  color: var(--ink);
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
}

.btn-send:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.btn-send.accent {
  background: var(--accent);
  border-color: var(--accent);
  color: #FFFFFF;
}

.btn-send.accent:hover {
  background: var(--accent-dark);
}

/* ===================== Instruments ===================== */
.bench-area {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
}

.instruments-grid {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 1fr 1.3fr;
  gap: 10px;
}

.station-card {
  position: relative;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.station-card.drag-over {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(2, 132, 199, 0.3);
  background: #F0F9FF;
}

.station-head {
  padding: 7px 8px 7px 12px;
  background: var(--surface-alt);
  border-bottom: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.station-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 800;
  color: var(--ink);
}

.station-hint {
  margin: 0;
  font-size: 0.8rem;
  color: var(--ink-muted);
}

.btn-info {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--tap);
  height: var(--tap);
  flex-shrink: 0;
  border-radius: 50%;
  border: 1.5px solid #FCD34D;
  background: #FFFBEB;
  color: #B45309;
  cursor: pointer;
  touch-action: manipulation;
}

.btn-info .ic {
  width: 22px;
  height: 22px;
}

.btn-info:hover {
  background: #FEF3C7;
}

.btn-mini, .select-mini, .pill-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: var(--tap);
  padding: 0 11px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #FFFFFF;
  color: var(--ink);
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  touch-action: manipulation;
}

.btn-mini .ic {
  width: 17px;
  height: 17px;
}

.btn-mini:hover, .pill-btn:hover {
  background: #F1F5F9;
}

.btn-mini-toggle.active, .pill-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #FFFFFF;
}

.mode-pills {
  display: inline-flex;
  background: #E2E8F0;
  padding: 3px;
  border-radius: 9px;
  gap: 3px;
  flex: 1;
  min-width: 0;
}

.mode-pills .pill-btn {
  flex: 1;
  border: none;
  background: transparent;
  min-height: calc(var(--tap) - 6px);
  padding: 0 8px;
}

.mode-pills .pill-btn.active {
  background: var(--accent);
  color: #FFFFFF;
}

.station-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px 6px;
  background: linear-gradient(180deg, #FFFFFF 0%, #F8FAFC 82%, #E2E8F0 100%);
}

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

.station-foot {
  padding: 7px 10px;
  background: var(--surface-alt);
  border-top: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.foot-row {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.87rem;
  font-weight: 600;
  min-width: 0;
}

.foot-row input[type="range"] {
  flex: 1;
  min-width: 60px;
}

.range-label {
  white-space: nowrap;
}

.range-wrap {
  position: relative;
  flex: 1;
  min-width: 60px;
  display: flex;
}

.range-wrap input[type="range"] {
  width: 100%;
}

/* Marca groga: fins on s'enfonsa sol un objecte que sura */
.range-limit {
  position: absolute;
  top: 3px;
  bottom: 3px;
  width: 4px;
  margin-left: -2px;
  border-radius: 2px;
  background: var(--amber);
  box-shadow: 0 0 0 2px #FFFFFF;
  pointer-events: none;
}

.preset-imm {
  display: flex;
  gap: 4px;
}

.preset-imm .btn-mini {
  padding: 0 8px;
}

.status-note {
  flex: 1;
  font-size: 0.87rem;
  color: var(--ink-muted);
}

/* Col·locar un objecte tocant l'instrument */
.station-card.can-drop {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.25);
  animation: parpelleja 1.4s ease-in-out infinite;
}

.station-card.can-drop .station-stage {
  cursor: copy;
}

.station-card.can-drop .station-stage::after {
  content: attr(data-colocar);
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  max-width: calc(100% - 20px);
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--accent);
  color: #FFFFFF;
  font-size: 0.87rem;
  font-weight: 800;
  text-align: center;
  box-shadow: 0 6px 18px rgba(2, 132, 199, 0.35);
  pointer-events: none;
}

@keyframes parpelleja {
  0%, 100% { box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.18); }
  50% { box-shadow: 0 0 0 6px rgba(2, 132, 199, 0.4); }
}

/* Objecte arrossegat */
.drag-ghost {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 100;
  width: 74px;
  height: 60px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.92);
  border: 2px solid var(--accent);
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.28);
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.drag-ghost svg {
  width: 62px;
  height: 50px;
}

body.arrossegant, body.arrossegant * {
  cursor: grabbing !important;
}

/* ===================== Barra de resultats ===================== */
.summary-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 7px 10px;
  display: grid;
  grid-template-columns: 1.25fr repeat(6, minmax(0, 1fr));
  gap: 7px;
  flex-shrink: 0;
}

.sum-item {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  min-width: 0;
  min-height: 54px;
  padding: 4px 9px;
  border-radius: 9px;
  background: var(--surface-alt);
  border: 1px solid var(--border-soft);
}

.sum-obj {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  background: #F1F5F9;
}

.sum-thumb {
  width: 42px;
  height: 36px;
  flex-shrink: 0;
  border-radius: 7px;
  background: #FFFFFF;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
}

.sum-thumb svg {
  width: 36px;
  height: 30px;
}

.sum-obj-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.sum-nom {
  font-size: 0.9rem;
  font-weight: 800;
  line-height: 1.15;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.sum-item.highlight {
  background: #F0F9FF;
  border-color: #BAE6FD;
}

.sum-item.highlight-green {
  background: #ECFDF5;
  border-color: #A7F3D0;
}

.sum-lbl {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--ink-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.sum-val {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--ink);
  white-space: nowrap;
}

.sum-item.highlight .sum-val {
  color: var(--accent-dark);
}

.sum-item.highlight-green .sum-val {
  color: var(--emerald);
}

.sum-pista {
  font-family: var(--font-sans);
  font-size: 0.78rem;
  font-weight: 600;
  color: #64748B;
  font-style: italic;
  white-space: normal;
  line-height: 1.15;
}

.btn-revela {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1.5px dashed #B45309;
  background: #FFFBEB;
  color: #92400E;
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 800;
  cursor: pointer;
  touch-action: manipulation;
}

.btn-revela .ic {
  width: 15px;
  height: 15px;
}

.btn-revela:hover {
  background: #FEF3C7;
}

/* ===================== Mode pissarra (contrast) ===================== */
html.mode-pissarra {
  --border: #94A3B8;
  --border-soft: #CBD5E1;
  --ink-muted: #1E293B;
  --bg: #E2E8F0;
}

html.mode-pissarra .station-card,
html.mode-pissarra .catalog-panel,
html.mode-pissarra .summary-bar {
  border-width: 2px;
}

html.mode-pissarra .sum-val {
  font-size: 1.2rem;
}

html.mode-pissarra .force-vectors line:not([stroke-dasharray]) {
  stroke-width: 4.6;
}

html.mode-pissarra .felip-app-footer {
  display: none;
}

/* ===================== Peu corporatiu ===================== */
.felip-app-footer {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  padding: 5px clamp(14px, 3vw, 28px);
  border-top: 1px solid #CBD5E1;
  background: rgba(248, 250, 252, 0.96);
  color: #475569;
  font-size: 0.78rem;
  line-height: 1.25;
}

.felip-license-image-link {
  display: block;
  line-height: 0;
}

.felip-license-image {
  display: block;
  width: 76px;
  height: auto;
}

.felip-footer-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}

.felip-footer-text p {
  margin: 0;
}

.felip-footer-text a {
  color: inherit;
  font-weight: 700;
  text-decoration: none;
}

.felip-footer-text a:hover,
.felip-footer-text a:focus-visible {
  color: var(--accent-dark);
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}

/* ===================== Ajuda ===================== */
.ajuda {
  width: min(1120px, calc(94vw / var(--z)));
  max-height: calc(92vh / var(--z));
  padding: 0;
  border: none;
  border-radius: 16px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.4);
  overflow: hidden;
}

.ajuda[open] {
  display: flex;
  flex-direction: column;
}

.ajuda::backdrop {
  background: rgba(15, 23, 42, 0.55);
}

.ajuda-cap {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 12px 10px 18px;
  background: var(--header-bg);
  color: var(--header-ink);
  flex-wrap: wrap;
}

.ajuda-cap h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 1.15rem;
  font-weight: 800;
}

.ajuda-cap h2 .ic {
  color: #FBBF24;
  width: 24px;
  height: 24px;
}

.ajuda-tabs {
  display: flex;
  gap: 4px;
  flex: 1;
  flex-wrap: wrap;
}

.ajuda-tab {
  min-height: var(--tap);
  padding: 0 14px;
  border-radius: 9px;
  border: 1px solid #334155;
  background: #1E293B;
  color: #CBD5E1;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
}

.ajuda-tab.active {
  background: #FBBF24;
  border-color: #FCD34D;
  color: #0F172A;
}

.ajuda-tanca {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid #334155;
  background: #1E293B;
  color: #F8FAFC;
  cursor: pointer;
}

.ajuda-tanca .ic {
  width: 22px;
  height: 22px;
}

.ajuda-cos {
  overflow-y: auto;
  padding: 18px 20px 20px;
}

.ajuda-intro {
  margin: 0 0 14px;
  font-size: 0.95rem;
  color: var(--ink-muted);
}

.ajuda h3 {
  margin: 0 0 6px;
  font-size: 1.02rem;
  font-weight: 800;
}

.ajuda p, .ajuda li {
  font-size: 0.93rem;
  line-height: 1.45;
  text-align: justify;
}

/* Passos */
.passos {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.pas {
  position: relative;
  padding: 14px 14px 12px;
  border-radius: 14px;
  background: var(--surface-alt);
  border: 1.5px solid var(--border-soft);
}

.pas p {
  margin: 0;
  text-align: left;
}

.pas-num {
  position: absolute;
  top: -10px;
  left: -8px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.05rem;
  box-shadow: 0 3px 8px rgba(2, 132, 199, 0.35);
}

.pas-dibuix {
  height: 128px;
  margin-bottom: 10px;
  border-radius: 10px;
  background: #FFFFFF;
  border: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.pas-dibuix svg {
  width: 100%;
  height: 100%;
}

.pas-formula .formula {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2.6rem;
  font-style: italic;
  color: var(--accent-dark);
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.frac {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  font-size: 2.1rem;
  line-height: 1.05;
}

.frac span:first-child {
  border-bottom: 3px solid currentColor;
  padding: 0 10px 2px;
}

.llegenda-forces {
  margin-top: 18px;
  padding: 14px 16px;
  border-radius: 14px;
  background: #F8FAFC;
  border: 1.5px solid var(--border-soft);
}

.llegenda-forces ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 18px;
}

.llegenda-forces li {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  text-align: left;
}

.fx {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: #FFFFFF;
}

.fx-p { background: #EF4444; }
.fx-e { background: #0284C7; }
.fx-t { background: #10B981; }
.fx-n { background: #F59E0B; }

.ajuda-peu {
  margin-top: 16px;
  display: flex;
  justify-content: center;
}

/* Instruments a l'ajuda */
.inst-ajuda {
  display: grid;
  grid-template-columns: 210px 1fr;
  gap: 18px;
  align-items: center;
  padding: 12px;
  border-radius: 14px;
  border: 1.5px solid var(--border-soft);
  background: var(--surface-alt);
  transition: box-shadow 0.3s, border-color 0.3s;
}

.inst-ajuda + .inst-ajuda {
  margin-top: 12px;
}

.inst-ajuda.destacat {
  border-color: #FBBF24;
  box-shadow: 0 0 0 4px rgba(251, 191, 36, 0.35);
}

.inst-dibuix {
  height: 200px;
  border-radius: 10px;
  background: #FFFFFF;
  border: 1px solid var(--border-soft);
  padding: 4px;
}

.inst-text h3 {
  display: flex;
  align-items: center;
  gap: 8px;
}

.inst-text p {
  margin: 0 0 6px;
}

.prof-card p, .inst-text li {
  text-align: left;
}

.inst-text ul {
  margin: 0;
  padding-left: 20px;
}

/* Experiments */
.exp-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.exp-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border-radius: 14px;
  border: 1.5px solid var(--border-soft);
  background: var(--surface-alt);
}

.exp-vis {
  display: flex;
  align-items: center;
  gap: 8px;
}

.exp-vis svg {
  width: 56px;
  height: 46px;
}

.exp-liquid {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--ink-muted);
}

.exp-gota {
  width: 16px;
  height: 16px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  border: 1px solid rgba(15, 23, 42, 0.2);
}

.exp-card h3 {
  margin: 0;
}

.exp-card p {
  margin: 0;
  text-align: left;
  font-size: 0.87rem;
}

.exp-pregunta {
  font-weight: 700;
  color: var(--accent-dark);
}

.exp-card .btn-primary {
  margin-top: auto;
}

/* Professorat */
.prof-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.prof-card {
  padding: 14px;
  border-radius: 14px;
  border: 1.5px solid var(--border-soft);
  background: var(--surface-alt);
}

.prof-card p {
  margin: 0;
}

.prof-ic {
  width: 34px;
  height: 34px;
  margin-bottom: 6px;
  padding: 6px;
  border-radius: 9px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

kbd {
  display: inline-block;
  min-width: 22px;
  padding: 1px 6px;
  border-radius: 5px;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  background: #FFFFFF;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  text-align: center;
}

/* ===================== Guia ràpida ===================== */
.guia-capa {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(15, 23, 42, 0.55);
}

.guia-focus {
  position: relative;
  z-index: 81;
  box-shadow: 0 0 0 4px #FBBF24, 0 0 0 10px rgba(251, 191, 36, 0.35) !important;
}

.guia-bombolla {
  position: fixed;
  z-index: 90;
  width: 340px;
  padding: 16px 16px 12px;
  border-radius: 14px;
  background: #FFFFFF;
  border: 2px solid #FBBF24;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.4);
}

.guia-pas {
  font-size: 0.78rem;
  font-weight: 800;
  color: #B45309;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.guia-bombolla h3 {
  margin: 4px 0 6px;
  font-size: 1.08rem;
}

.guia-bombolla p {
  margin: 0 0 10px;
  font-size: 0.93rem;
  line-height: 1.45;
  color: var(--ink-muted);
}

.guia-botons {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ===================== Disposició apilada (mòbil, tauleta i pissarra vertical) ===================== */
html.apilat .workspace {
  grid-template-columns: 1fr;
}

html.apilat .cat-grid {
  max-height: 238px;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
}

html.apilat .instruments-grid {
  grid-template-columns: 1fr 1fr;
}

html.apilat .station-wide {
  grid-column: 1 / -1;
}

html.apilat .station-stage {
  height: clamp(260px, 46vh, 460px);
  flex: none;
}

html.apilat .summary-bar {
  position: sticky;
  bottom: 6px;
  z-index: 10;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

html.apilat .sum-obj {
  grid-column: span 2;
}

html.apilat .passos,
html.apilat .exp-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

html.apilat .prof-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (max-width: 620px) {
  html.apilat .instruments-grid {
    grid-template-columns: 1fr;
  }
  html.apilat .summary-bar {
    position: static;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .liquid-picker {
    width: 100%;
    min-width: 0;
  }
  .liquid-picker select {
    flex: 1;
    min-width: 0;
    width: 100%;
  }
  html.apilat .passos,
  html.apilat .exp-grid,
  html.apilat .prof-grid,
  .llegenda-forces ul {
    grid-template-columns: 1fr;
  }
  .inst-ajuda {
    grid-template-columns: 1fr;
  }
  .topbar-controls, .toggle-group {
    width: 100%;
  }
  .btn-toggle span, .btn-action span {
    display: none;
  }
  .guia-bombolla {
    width: calc(100vw - 24px);
  }
}
