:root {
  --bg: #000000;
  --surface: #141414;
  --accent: #c9a96e;
  --text-primary: #f0ece4;
  --text-secondary: #7a7370;
  --border: #2a2825;
  --scene-pad-x: clamp(1.5rem, 5.5vw, 3.25rem);
  --scene-max: min(92vw, 52rem);
}

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

html {
  font-size: 18px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.55;
  overflow-x: hidden;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Logo salone: layer fisso, mai touch, respira sul nero (solo CSS, file originale) */
.mirror-decoration {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.salon-logo-heart-wrap {
  position: relative;
  width: min(52vmin, 400px);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.75s ease, transform 0.75s ease;
}

.salon-logo-heart {
  width: 100%;
  max-width: min(52vmin, 400px);
  height: auto;
  display: block;
  object-fit: contain;
  border: none;
  border-radius: 0;
  padding: 0;
  margin: 0;
  background: transparent;
  box-shadow: none;
  filter: invert(1);
  mix-blend-mode: lighten;
  transform-origin: center;
  animation: salon-logo-breathe 4.6s ease-in-out infinite;
  will-change: transform, opacity;
}

@keyframes salon-logo-breathe {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.82;
  }
  50% {
    transform: scale(1.06);
    opacity: 1;
  }
}

@keyframes salon-logo-breathe-active {
  0%,
  100% {
    transform: scale(0.94);
    opacity: 0.28;
  }
  50% {
    transform: scale(1.02);
    opacity: 0.42;
  }
}

.app-shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: space-between;
  padding: clamp(1.25rem, 4vh, 2rem) var(--scene-pad-x) clamp(0.75rem, 2.5vh, 1.5rem);
  transition: opacity 0.6s ease;
}

.app-shell.is-busy .mirror-stage {
  opacity: 0.92;
  transition: opacity 0.45s ease;
}

.app-shell.is-busy .salon-logo-heart {
  animation-duration: 2.3s;
}

/* Standby: logo protagonista */
.app-shell.ui-standby .salon-logo-heart-wrap {
  opacity: 1;
}

.app-shell.ui-standby .salon-logo-heart {
  animation: salon-logo-breathe 4.6s ease-in-out infinite;
}

/* Standby: niente fascia scura da pannello messaggi / overlay (gradienti ::before) */
.app-shell.ui-standby .dialogue-block {
  display: none !important;
}

.app-shell.ui-standby .messages::before {
  content: none !important;
}

.app-shell.ui-standby .scene-actions::before {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.app-shell.ui-standby .btn-primary#startBtn {
  min-height: 2.75rem;
  padding: 0.6rem 1.35rem;
  font-size: 0.82rem;
  letter-spacing: 0.09em;
  border-width: 1px;
  background: rgba(201, 169, 110, 0.14);
}

/* Guida / conversazione / professional: logo presente, più discreto */
.app-shell.ui-guiding .salon-logo-heart,
.app-shell.ui-speaking .salon-logo-heart,
.app-shell.ui-professional .salon-logo-heart {
  animation: salon-logo-breathe-active 3.5s ease-in-out infinite;
}

.app-shell.ui-guiding .salon-logo-heart-wrap,
.app-shell.ui-speaking .salon-logo-heart-wrap,
.app-shell.ui-professional .salon-logo-heart-wrap {
  opacity: 0.92;
}

/* Proposal: logo quasi assente */
.app-shell.ui-proposal .salon-logo-heart-wrap {
  opacity: 0.2;
}

.app-shell.ui-proposal .salon-logo-heart {
  animation: none;
  transform: scale(0.88);
  opacity: 0.35;
}

/* Scena: griglia verticale, non colonna form */
.mirror-stage.ambient-scene {
  width: var(--scene-max);
  max-width: 100%;
  margin: 0 auto;
  flex: 1 1 auto;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-height: 0;
  min-height: min(100dvh - 6rem, 100%);
  align-content: stretch;
  gap: 0;
  padding: 0;
  background: transparent;
}

.stage-header {
  flex-shrink: 0;
  text-align: center;
  padding: 0 0.25rem clamp(0.5rem, 2vh, 1rem);
  z-index: 2;
  position: relative;
}

.eyebrow {
  color: rgba(201, 169, 110, 0.55);
  letter-spacing: 0.48em;
  font-size: 0.58rem;
  font-weight: 500;
  text-transform: uppercase;
  margin: 0 0 0.45rem;
}

.stage-title {
  margin: 0;
  font-size: clamp(0.95rem, 2.4vw, 1.15rem);
  font-weight: 400;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  line-height: 1.35;
  color: rgba(240, 236, 228, 0.72);
}

/* Dialogo: fascia nobile sotto il centro dello specchio */
.dialogue-block {
  position: relative;
  z-index: 2;
  min-height: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding-top: min(36vh, 22rem);
  margin-top: clamp(-8vh, -4rem, -2rem);
}

.messages {
  position: relative;
  z-index: 1;
  flex: 1 1 auto;
  min-height: min(12rem, 26vh);
  max-height: min(34vh, 480px);
  overflow-y: auto;
  overflow-x: hidden;
  border: none;
  background: transparent;
  border-radius: 0;
  padding: clamp(1rem, 2.8vh, 1.75rem) clamp(0.25rem, 1.5vw, 0.5rem);
  margin: 0;
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
  transition:
    min-height 0.55s ease,
    max-height 0.55s ease,
    padding 0.55s ease;
}

.messages::-webkit-scrollbar {
  width: 3px;
}

.messages::-webkit-scrollbar-track {
  background: transparent;
}

.messages::-webkit-scrollbar-thumb {
  background: rgba(42, 40, 37, 0.35);
  border-radius: 3px;
}

.messages::before {
  content: '';
  position: absolute;
  z-index: -1;
  left: 50%;
  top: 42%;
  transform: translate(-50%, -50%);
  width: 155%;
  height: 145%;
  background: radial-gradient(
    ellipse 78% 68% at 50% 48%,
    rgba(0, 0, 0, 0.88) 0%,
    rgba(0, 0, 0, 0.45) 52%,
    transparent 78%
  );
  pointer-events: none;
}

.app-shell.ui-proposal .dialogue-block {
  padding-top: min(28vh, 18rem);
  margin-top: clamp(-6vh, -3rem, -1rem);
}

.app-shell.ui-proposal .messages {
  min-height: min(22rem, 48vh);
  max-height: min(56vh, 780px);
  padding-top: clamp(1.75rem, 5vh, 2.75rem);
  padding-bottom: clamp(1.75rem, 5vh, 2.75rem);
  padding-left: clamp(0.5rem, 2vw, 1rem);
  padding-right: clamp(0.5rem, 2vw, 1rem);
}

.app-shell.ui-proposal .messages::before {
  width: 175%;
  height: 160%;
  background: radial-gradient(
    ellipse 82% 75% at 50% 45%,
    rgba(0, 0, 0, 0.92) 0%,
    rgba(0, 0, 0, 0.52) 48%,
    transparent 76%
  );
}

/* Un solo blocco controlli attivo: stack centrale + reset fuori cluster */
.dynamic-control-stack {
  width: 100%;
  max-width: 36rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(1rem, 2.5vh, 1.5rem);
  min-height: 0;
}

.dynamic-control-stack > [hidden] {
  display: none !important;
}

.flow-options-slot {
  margin: 0;
}

/* Azioni: cluster in basso, wrap, non lista verticale */
.scene-actions {
  position: relative;
  z-index: 3;
  flex-shrink: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(0.65rem, 2vh, 1rem);
  padding: clamp(1rem, 3vh, 1.75rem) 0 clamp(0.25rem, 1vh, 0.75rem);
}

.scene-actions::before {
  content: '';
  position: absolute;
  z-index: -1;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: 130%;
  height: 120%;
  background: radial-gradient(
    ellipse 100% 80% at 50% 100%,
    rgba(0, 0, 0, 0.42) 0%,
    transparent 65%
  );
  pointer-events: none;
}

.controls,
.mode-box,
.composer-block .input-row,
.photo-box {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 1.35rem;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.controls-slot {
  margin: 0;
}

.btn-reset-outside {
  align-self: center;
  margin-top: 0.15rem;
  min-height: 2.65rem;
  padding: 0.5rem 1.15rem;
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  font-weight: 500;
  opacity: 0.72;
  border-color: rgba(122, 115, 112, 0.28);
  background: transparent;
}

.btn-reset-outside:not(:disabled):hover {
  opacity: 0.95;
  border-color: rgba(201, 169, 110, 0.32);
}

.mode-box {
  margin: 0;
}

.composer-block {
  position: relative;
  z-index: 3;
  width: 100%;
  max-width: 36rem;
  padding: 0 0.25rem;
  transition:
    opacity 0.55s ease,
    max-height 0.55s ease,
    margin 0.55s ease,
    padding 0.55s ease;
}

.composer-block::before {
  display: none;
}

/* Visibilità controllata da syncView / hidden — niente duplicati per stato UI */

.input-row {
  width: 100%;
}

.msg {
  max-width: 100%;
  padding: 0.9rem 0.85rem;
  margin-bottom: 0.9rem;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.58;
  font-size: 1rem;
  font-weight: 400;
  border-radius: 0.2rem;
  transition: opacity 0.5s ease, transform 0.5s ease;
  animation: msg-in 0.55s ease forwards;
}

@keyframes msg-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.msg:last-child {
  margin-bottom: 0;
}

.msg.assistant {
  background: rgba(12, 12, 12, 0.35);
  border: none;
  border-bottom: 1px solid rgba(201, 169, 110, 0.18);
  color: var(--text-primary);
  margin-right: auto;
}

.app-shell.ui-proposal .msg.assistant {
  font-size: clamp(1.05rem, 2.5vw, 1.2rem);
  font-weight: 400;
  letter-spacing: 0.02em;
  line-height: 1.68;
  padding: 1.1rem 1rem 1.35rem;
  border-bottom-color: rgba(201, 169, 110, 0.32);
  max-width: 100%;
}

.app-shell[data-flow-state="HOME_ROUTINE"] .home-routine-scroll-hint {
  display: block;
  text-align: center;
  font-size: 0.82rem;
  letter-spacing: 0.06em;
  opacity: 0.58;
  margin-top: 1rem;
  padding-bottom: 0.85rem;
  color: rgba(240, 236, 228, 0.72);
}

/* HOME_ROUTINE — card prodotti (solo questo stato; scroll orizzontale compatto) */
.app-shell[data-flow-state="HOME_ROUTINE"] .routine-product-cards {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
  margin-top: 1rem;
  max-width: 520px;
  margin-left: auto;
  margin-right: auto;
  overflow-x: hidden;
  overflow-y: hidden;
  padding-bottom: 0.35rem;
}

.app-shell:not([data-flow-state="HOME_ROUTINE"]) .routine-product-cards {
  display: none;
}

.app-shell[data-flow-state="HOME_ROUTINE"] .routine-product-card {
  flex: 1 1 clamp(170px, 44vw, 232px);
  max-width: 232px;
  min-width: 170px;
  background: rgba(8, 8, 8, 0.45);
  border: 1px solid rgba(201, 169, 110, 0.22);
  border-radius: 10px;
  padding: 0.65rem 0.7rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

@media (max-width: 560px) {
  .app-shell[data-flow-state="HOME_ROUTINE"] .routine-product-card {
    flex-basis: min(90vw, 232px);
    min-width: 0;
  }
}

.app-shell[data-flow-state="HOME_ROUTINE"] .routine-product-image-wrap {
  height: 104px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
  width: 100%;
}

.app-shell[data-flow-state="HOME_ROUTINE"] .routine-product-image {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
}

.app-shell[data-flow-state="HOME_ROUTINE"] .routine-product-meta {
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
  min-width: 0;
  font-size: 0.82rem;
  line-height: 1.38;
  color: rgba(240, 236, 228, 0.88);
}

.app-shell[data-flow-state="HOME_ROUTINE"] .routine-product-phase {
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(201, 169, 110, 0.82);
}

.app-shell[data-flow-state="HOME_ROUTINE"] .routine-product-brandrow {
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  color: rgba(240, 236, 228, 0.55);
}

.app-shell[data-flow-state="HOME_ROUTINE"] .routine-product-name {
  font-size: 0.88rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--text-primary);
}

.app-shell[data-flow-state="HOME_ROUTINE"] .routine-product-benefit {
  font-size: 0.78rem;
  color: rgba(240, 236, 228, 0.72);
}

.app-shell[data-flow-state="HOME_ROUTINE"] .routine-product-howto {
  font-size: 0.72rem;
  color: rgba(240, 236, 228, 0.58);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.app-shell[data-flow-state="HOME_ROUTINE"] .routine-product-price {
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  color: rgba(201, 169, 110, 0.95);
  margin-top: 0.15rem;
}

/* CONSULTATION_SUMMARY — scheda premium strutturata (senza card prodotto/immagini) */
.app-shell[data-flow-state="CONSULTATION_SUMMARY"] .msg.assistant {
  width: min(760px, 100%);
  max-width: 100%;
  padding: 0.75rem 0.75rem 0.95rem;
  border-bottom-color: rgba(201, 169, 110, 0.28);
}

.app-shell[data-flow-state="CONSULTATION_SUMMARY"] .consultation-summary-card {
  background: rgba(10, 10, 10, 0.62);
  border: 1px solid rgba(201, 169, 110, 0.24);
  border-radius: 12px;
  padding: clamp(0.95rem, 1.8vw, 1.3rem) clamp(0.9rem, 2.1vw, 1.4rem);
  width: min(680px, 100%);
  max-width: 100%;
  margin: 0 auto;
  max-height: min(62vh, 720px);
  overflow-y: auto;
  overflow-x: hidden;
}

.app-shell[data-flow-state="CONSULTATION_SUMMARY"] .consultation-summary-title {
  margin: 0;
  text-align: center;
  font-size: clamp(1.3rem, 2.4vw, 1.9rem);
  font-weight: 500;
  letter-spacing: 0.04em;
  color: rgba(247, 241, 231, 0.98);
}

.app-shell[data-flow-state="CONSULTATION_SUMMARY"] .consultation-summary-subtitle {
  margin: 0.42rem 0 0.9rem;
  text-align: center;
  font-size: clamp(0.86rem, 1.4vw, 1rem);
  color: rgba(240, 236, 228, 0.72);
}

.app-shell[data-flow-state="CONSULTATION_SUMMARY"] .consultation-summary-section {
  padding-top: 0.68rem;
  margin-top: 0.68rem;
  border-top: 1px solid rgba(201, 169, 110, 0.18);
}

.app-shell[data-flow-state="CONSULTATION_SUMMARY"] .consultation-summary-section-title {
  margin: 0;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: rgba(201, 169, 110, 0.9);
}

.app-shell[data-flow-state="CONSULTATION_SUMMARY"] .consultation-summary-items {
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.4rem;
}

.app-shell[data-flow-state="CONSULTATION_SUMMARY"] .consultation-summary-item {
  margin: 0;
  padding: 0.22rem 0;
  font-size: clamp(0.9rem, 1.2vw, 1.02rem);
  line-height: 1.45;
  color: rgba(247, 241, 231, 0.92);
  border-bottom: 1px solid rgba(201, 169, 110, 0.1);
}

.app-shell[data-flow-state="CONSULTATION_SUMMARY"] .consultation-summary-item:last-child {
  border-bottom: 0;
}

body:has(.app-shell[data-flow-state="CONSULTATION_SUMMARY"]) .mirror-decoration {
  opacity: 0.05;
}

body:has(.app-shell[data-flow-state="CONSULTATION_SUMMARY"]) .salon-logo-heart-wrap {
  opacity: 0.06;
}

@media (min-width: 1025px) {
  .app-shell.ui-guiding .dialogue-block,
  .app-shell.ui-speaking .dialogue-block {
    padding-top: min(8vh, 4rem);
    margin-top: 0;
  }

  .app-shell.ui-guiding .messages,
  .app-shell.ui-speaking .messages {
    max-height: min(28vh, 380px);
  }

  body:has(.app-shell[data-flow-state="PROPOSAL_SALON"]) .mirror-decoration,
  body:has(.app-shell[data-flow-state="HOME_ROUTINE"]) .mirror-decoration,
  body:has(.app-shell[data-flow-state="CONSULTATION_SUMMARY"]) .mirror-decoration {
    align-items: flex-start;
    justify-content: flex-end;
    padding: 1rem 1.5rem 0 0;
  }

  body:has(.app-shell[data-flow-state="CONSULTATION_SUMMARY"]) .mirror-decoration {
    opacity: 1;
  }

  body:has(.app-shell[data-flow-state="PROPOSAL_SALON"]) .salon-logo-heart-wrap,
  body:has(.app-shell[data-flow-state="HOME_ROUTINE"]) .salon-logo-heart-wrap {
    width: min(18vmin, 90px);
    opacity: 0.72;
  }

  body:has(.app-shell[data-flow-state="CONSULTATION_SUMMARY"]) .salon-logo-heart-wrap {
    width: min(20vmin, 110px);
    opacity: 0.8;
  }

  body:has(.app-shell[data-flow-state="CONSULTATION_SUMMARY"]) .salon-logo-heart {
    filter: invert(1) brightness(1.25);
  }

  .app-shell[data-flow-state="PROPOSAL_SALON"] .dialogue-block,
  .app-shell[data-flow-state="HOME_ROUTINE"] .dialogue-block,
  .app-shell[data-flow-state="CONSULTATION_SUMMARY"] .dialogue-block {
    padding-top: min(2vh, 1rem);
    margin-top: 0;
  }

  .app-shell[data-flow-state="PROPOSAL_SALON"] .messages,
  .app-shell[data-flow-state="HOME_ROUTINE"] .messages,
  .app-shell[data-flow-state="CONSULTATION_SUMMARY"] .messages {
    max-height: min(72vh, 900px);
    overflow-y: auto;
  }

  .app-shell[data-flow-state="CONSULTATION_SUMMARY"] .consultation-summary-card {
    max-height: none;
    overflow-y: visible;
  }
}

.msg.user {
  margin-left: auto;
  background: rgba(20, 20, 20, 0.28);
  border: none;
  border-bottom: 1px solid rgba(122, 115, 112, 0.32);
  color: var(--text-primary);
  max-width: 94%;
}

.msg.system {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 0.86rem;
  letter-spacing: 0.06em;
  padding-left: 0.15rem;
  padding-right: 0.15rem;
}

/* CTA: touch ≥60px, pesi diversi */
.btn {
  min-height: 3.75rem;
  min-width: 3.75rem;
  border-radius: 999px;
  border: 1px solid rgba(201, 169, 110, 0.28);
  padding: 0.95rem 1.75rem;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  cursor: pointer;
  color: var(--text-primary);
  background: rgba(0, 0, 0, 0.35);
  transition:
    opacity 0.45s ease,
    border-color 0.45s ease,
    background 0.45s ease,
    transform 0.35s ease;
}

.btn:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

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

.app-shell:not(.ui-professional) .flow-options-slot button.btn:active:not(:disabled) {
  background-color: #ffffff !important;
  color: #000000 !important;
  transform: scale(0.98);
  transition:
    background-color 0.1s ease,
    color 0.1s ease,
    transform 0.1s ease;
}

.btn-primary {
  background: rgba(201, 169, 110, 0.12);
  border-color: rgba(201, 169, 110, 0.45);
  color: var(--text-primary);
}

.btn-primary:not(:disabled):hover {
  border-color: rgba(201, 169, 110, 0.62);
  background: rgba(201, 169, 110, 0.18);
}

.btn-secondary,
.btn-mode {
  background: rgba(0, 0, 0, 0.2);
  border-color: rgba(122, 115, 112, 0.38);
  color: rgba(240, 236, 228, 0.88);
  font-weight: 500;
}

.btn-secondary:not(:disabled):hover,
.btn-mode:not(:disabled):hover {
  border-color: rgba(201, 169, 110, 0.38);
  background: rgba(20, 20, 20, 0.45);
}

.btn-send {
  flex: 0 0 auto;
  min-width: 6.5rem;
  background: rgba(201, 169, 110, 0.1);
}

textarea#textInput {
  resize: none;
  overflow-y: hidden;
  line-height: 1.35;
  white-space: pre-wrap;
}

#textInput {
  flex: 1 1 14rem;
  min-height: 3.75rem;
  min-width: 12rem;
  border-radius: 999px;
  border: 1px solid rgba(122, 115, 112, 0.35);
  background: rgba(0, 0, 0, 0.4);
  color: var(--text-primary);
  padding: 0.95rem 1.35rem;
  max-height: 3.75rem;
  font-family: inherit;
  font-size: 1rem;
  letter-spacing: 0.03em;
  transition: border-color 0.45s ease, background 0.45s ease;
}

#textInput::placeholder {
  color: var(--text-secondary);
}

#textInput:focus {
  outline: none;
  border-color: rgba(201, 169, 110, 0.48);
  background: rgba(0, 0, 0, 0.55);
}

.app-shell.ui-professional .composer-block { max-width: min(72rem, 92vw); }
.app-shell.ui-professional .composer-block .input-row { align-items: stretch; }
.app-shell.ui-professional #textInput { min-height: 8rem; max-height: 16rem; font-size: 1.08rem; border-radius: 1.25rem; padding: 0.8rem 1.6rem; }
.app-shell.ui-professional .btn-send { min-height: 5.25rem; }

.photo-box {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 1.35rem;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 36rem;
  padding-top: 0.25rem;
}

.photo-status {
  flex: 1 1 100%;
  margin: 0;
  min-height: 1.35em;
  font-size: 0.9rem;
  color: var(--text-secondary);
  text-align: center;
  letter-spacing: 0.04em;
}

.vision-debug-panel {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 40;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 0.75rem 1rem;
  max-height: 40vh;
  overflow: auto;
}

.vision-debug-panel hr {
  display: none;
}

.vision-debug-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.vision-debug-label {
  width: 100%;
  margin: 0 0 0.25rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.vision-debug-label code {
  font-size: 0.75em;
  color: var(--accent);
}

.vision-debug-output {
  width: 100%;
  max-height: 18vh;
  overflow: auto;
  margin: 0;
  padding: 0.5rem;
  font-size: 0.7rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 0.35rem;
  color: var(--text-secondary);
  scrollbar-width: thin;
}

@media (max-height: 700px) {
  .dialogue-block {
    padding-top: min(30vh, 14rem);
  }
}

/* Tablet tuning: logo in alto a destra, dialogo più alto, più spazio ai bottoni */
@media (max-width: 1024px) {
  body:has(.app-shell.ui-guiding) .mirror-decoration,
  body:has(.app-shell.ui-speaking) .mirror-decoration,
  body:has(.app-shell.ui-professional) .mirror-decoration {
    align-items: flex-start;
    justify-content: flex-end;
    padding: clamp(0.75rem, 3vh, 1.5rem) clamp(0.85rem, 4vw, 1.5rem) 0 0;
  }

  body:has(.app-shell.ui-guiding) .salon-logo-heart-wrap,
  body:has(.app-shell.ui-speaking) .salon-logo-heart-wrap,
  body:has(.app-shell.ui-professional) .salon-logo-heart-wrap {
    width: min(22vmin, 110px);
    opacity: 0.78;
  }

  .app-shell.ui-guiding .dialogue-block,
  .app-shell.ui-speaking .dialogue-block,
  .app-shell.ui-professional .dialogue-block {
    padding-top: min(18vh, 10rem);
    margin-top: clamp(-3vh, -1.5rem, -0.5rem);
  }

  .app-shell.ui-guiding .messages,
  .app-shell.ui-speaking .messages,
  .app-shell.ui-professional .messages {
    min-height: min(8rem, 16vh);
    max-height: min(26vh, 360px);
    padding-top: clamp(0.65rem, 2vh, 1rem);
    padding-bottom: clamp(0.65rem, 2vh, 1rem);
  }

  .app-shell.ui-guiding .scene-actions,
  .app-shell.ui-speaking .scene-actions,
  .app-shell.ui-professional .scene-actions {
    gap: clamp(0.45rem, 1.5vh, 0.75rem);
    padding: clamp(0.65rem, 2vh, 1rem) 0 clamp(0.1rem, 0.5vh, 0.35rem);
  }

  .app-shell.ui-guiding .controls,
  .app-shell.ui-guiding .mode-box,
  .app-shell.ui-guiding .composer-block .input-row,
  .app-shell.ui-guiding .photo-box,
  .app-shell.ui-speaking .controls,
  .app-shell.ui-speaking .mode-box,
  .app-shell.ui-speaking .composer-block .input-row,
  .app-shell.ui-speaking .photo-box,
  .app-shell.ui-professional .controls,
  .app-shell.ui-professional .mode-box,
  .app-shell.ui-professional .composer-block .input-row,
  .app-shell.ui-professional .photo-box {
    gap: 0.65rem 0.85rem;
  }

  .app-shell.ui-guiding .msg.assistant,
  .app-shell.ui-speaking .msg.assistant,
  .app-shell.ui-professional .msg.assistant {
    font-size: clamp(1.22rem, 3.6vw, 1.36rem);
    line-height: 1.6;
  }

  body:has(.app-shell.ui-proposal) .mirror-decoration {
    align-items: flex-start;
    justify-content: flex-end;
    padding: clamp(0.75rem, 3vh, 1.5rem) clamp(0.85rem, 4vw, 1.5rem) 0 0;
  }

  body:has(.app-shell.ui-proposal) .salon-logo-heart-wrap {
    width: min(22vmin, 110px);
    opacity: 0.28;
  }

  .app-shell.ui-proposal .dialogue-block {
    padding-top: min(2vh, 1rem);
    margin-top: 0;
  }

  .app-shell.ui-proposal .messages {
    max-height: min(75vh, 940px);
    padding-top: clamp(0.75rem, 2vh, 1.25rem);
    padding-bottom: clamp(0.75rem, 2vh, 1.25rem);
  }

  .app-shell.ui-proposal .msg.assistant {
    font-size: clamp(1.1rem, 3.2vw, 1.25rem);
    line-height: 1.65;
  }

  /* HOME_ROUTINE: routine scrollabile nel viewport, CTA (#flowOptions) sempre raggiungibile */
  .app-shell[data-flow-state="HOME_ROUTINE"] .mirror-stage.ambient-scene {
    max-height: calc(100dvh - 4rem);
    overflow: hidden;
  }

  .app-shell[data-flow-state="HOME_ROUTINE"] .dialogue-block {
    min-height: 0;
    overflow: hidden;
    justify-content: flex-start;
  }

  .app-shell[data-flow-state="HOME_ROUTINE"] .messages {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    overflow-y: auto;
    overflow-x: hidden;
  }

  .app-shell[data-flow-state="HOME_ROUTINE"] .scene-actions {
    flex-shrink: 0;
  }

  .app-shell[data-flow-state="HOME_ROUTINE"] .dynamic-control-stack {
    flex-shrink: 0;
  }

  .app-shell[data-flow-state="HOME_ROUTINE"] #flowOptions {
    flex-shrink: 0;
  }

  .app-shell[data-flow-state="CONSULTATION_SUMMARY"] .mirror-stage.ambient-scene {
    max-height: calc(100dvh - 4rem);
    overflow: hidden;
  }

  .app-shell[data-flow-state="CONSULTATION_SUMMARY"] .dialogue-block {
    min-height: 0;
    overflow: hidden;
    justify-content: flex-start;
    padding-top: min(3vh, 1.3rem);
    margin-top: 0;
  }

  .app-shell[data-flow-state="CONSULTATION_SUMMARY"] .messages {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    overflow-y: auto;
    overflow-x: hidden;
  }

  .app-shell[data-flow-state="CONSULTATION_SUMMARY"] .scene-actions,
  .app-shell[data-flow-state="CONSULTATION_SUMMARY"] .dynamic-control-stack,
  .app-shell[data-flow-state="CONSULTATION_SUMMARY"] #flowOptions {
    flex-shrink: 0;
  }
}

@keyframes jervi-reveal {
  from {
    opacity: 0;
    transform: translateY(16px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

/* 27A-2 Tablet Luxury Redesign — FASE 1 CSS-only (tablet / iPad salone) */
@media (max-width: 1024px) {
  body:has(.app-shell[data-flow-state="HOME_ROUTINE"]),
  body:has(.app-shell[data-flow-state="CONSULTATION_SUMMARY"]) {
    background-color: #0a0a0a;
  }

  body:has(.app-shell[data-flow-state="HOME_ROUTINE"]) .mirror-decoration,
  body:has(.app-shell[data-flow-state="CONSULTATION_SUMMARY"]) .mirror-decoration {
    opacity: 0.045;
  }

  body:has(.app-shell[data-flow-state="HOME_ROUTINE"]) .salon-logo-heart-wrap,
  body:has(.app-shell[data-flow-state="CONSULTATION_SUMMARY"]) .salon-logo-heart-wrap {
    opacity: 0.42;
  }

  .app-shell[data-flow-state="HOME_ROUTINE"] .mirror-stage.ambient-scene,
  .app-shell[data-flow-state="CONSULTATION_SUMMARY"] .mirror-stage.ambient-scene {
    background: radial-gradient(
      ellipse 140% 90% at 50% 20%,
      rgba(28, 28, 28, 0.55) 0%,
      #0a0a0a 62%
    );
  }

  /* HOME_ROUTINE — boutique: card per prime, copy routine defilata */
  .app-shell.ui-proposal[data-flow-state="HOME_ROUTINE"] .messages > .msg.assistant {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
    font-size: clamp(0.76rem, 2.5vw, 0.88rem);
    line-height: 1.68;
    letter-spacing: 0.04em;
    color: rgba(168, 162, 154, 0.92);
    font-style: normal;
    padding-bottom: 0.25rem;
  }

  .app-shell[data-flow-state="HOME_ROUTINE"] .routine-product-cards {
    order: -1;
    align-self: stretch;
    display: flex;
    flex-wrap: nowrap;
    justify-content: flex-start;
    align-items: stretch;
    gap: 1rem;
    max-width: none;
    width: auto;
    margin-left: calc(-1 * clamp(0.5rem, 2vw, 1rem));
    margin-right: calc(-1 * clamp(0.5rem, 2vw, 1rem));
    margin-top: 0;
    padding: 0 clamp(0.5rem, 2vw, 1rem) 1rem;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scroll-padding-inline: clamp(0.5rem, 2vw, 1rem) 2.5rem;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }

  .app-shell[data-flow-state="HOME_ROUTINE"] .routine-product-cards::-webkit-scrollbar {
    display: none;
  }

  .app-shell[data-flow-state="HOME_ROUTINE"] .routine-product-card {
    flex: 0 0 auto;
    width: clamp(240px, 72vw, 340px);
    max-width: none;
    min-width: 0;
    scroll-snap-align: center;
    border-radius: 20px;
    padding: 1.05rem 1.1rem 1.2rem;
    background: rgba(20, 20, 20, 0.92);
    border: 1px solid rgba(212, 175, 55, 0.24);
    box-shadow: 0 18px 42px rgba(0, 0, 0, 0.38);
    gap: 0.55rem;
  }

  .app-shell[data-flow-state="HOME_ROUTINE"] .routine-product-image-wrap {
    height: 152px;
  }

  .app-shell[data-flow-state="HOME_ROUTINE"] .routine-product-meta {
    font-size: 0.9rem;
    line-height: 1.55;
    color: rgba(245, 241, 232, 0.94);
    font-style: normal;
  }

  .app-shell[data-flow-state="HOME_ROUTINE"] .routine-product-phase {
    font-size: 0.72rem;
    letter-spacing: 0.14em;
    color: rgba(212, 175, 55, 0.88);
  }

  .app-shell[data-flow-state="HOME_ROUTINE"] .routine-product-brandrow {
    font-size: 0.76rem;
    color: rgba(168, 162, 154, 0.88);
  }

  .app-shell[data-flow-state="HOME_ROUTINE"] .routine-product-name {
    font-size: 0.98rem;
    font-weight: 500;
    letter-spacing: 0.03em;
    color: #f5f1e8;
    font-style: normal;
  }

  .app-shell[data-flow-state="HOME_ROUTINE"] .routine-product-benefit {
    font-size: 0.82rem;
    line-height: 1.52;
    color: rgba(245, 241, 232, 0.78);
    font-style: normal;
  }

  .app-shell[data-flow-state="HOME_ROUTINE"] .routine-product-howto {
    font-size: 0.78rem;
    line-height: 1.48;
    color: rgba(168, 162, 154, 0.82);
    font-style: normal;
  }

  .app-shell[data-flow-state="HOME_ROUTINE"] .routine-product-price {
    font-size: 0.85rem;
    font-weight: 500;
    letter-spacing: 0.08em;
    color: #d4af37;
    margin-top: 0.35rem;
  }

  .app-shell[data-flow-state="HOME_ROUTINE"] .scene-actions {
    padding-bottom: clamp(0.35rem, 1.2vh, 0.75rem);
  }

  /* CONSULTATION_SUMMARY — Piano Salone premium */
  .app-shell[data-flow-state="CONSULTATION_SUMMARY"] .msg.assistant {
    width: 100%;
    padding-left: 0.25rem;
    padding-right: 0.25rem;
  }

  .app-shell[data-flow-state="CONSULTATION_SUMMARY"] .consultation-summary-card {
    opacity: 0;
    animation: jervi-reveal 0.5s ease forwards;
    background: rgba(20, 20, 20, 0.92);
    border: 1px solid rgba(212, 175, 55, 0.22);
    border-radius: 20px;
    box-shadow: 0 22px 48px rgba(0, 0, 0, 0.42);
    padding: clamp(1.45rem, 3.5vw, 1.85rem) clamp(1.25rem, 3.5vw, 1.65rem);
    width: min(720px, 100%);
    max-height: min(58vh, 680px);
  }

  .app-shell[data-flow-state="CONSULTATION_SUMMARY"] .consultation-summary-title {
    font-size: clamp(1.45rem, 4vw, 1.85rem);
    font-weight: 500;
    letter-spacing: 0.08em;
    color: #f5f1e8;
    font-style: normal;
  }

  .app-shell[data-flow-state="CONSULTATION_SUMMARY"] .consultation-summary-subtitle {
    font-size: clamp(0.88rem, 2.2vw, 1rem);
    line-height: 1.55;
    color: rgba(168, 162, 154, 0.95);
    margin-bottom: 1.15rem;
    font-style: normal;
  }

  .app-shell[data-flow-state="CONSULTATION_SUMMARY"] .consultation-summary-section {
    margin-top: 1.15rem;
    padding-top: 1.15rem;
    border-top: 1px solid rgba(212, 175, 55, 0.18);
  }

  .app-shell[data-flow-state="CONSULTATION_SUMMARY"] .consultation-summary-section:first-of-type {
    margin-top: 0.5rem;
    border-top: none;
    padding-top: 0.35rem;
  }

  .app-shell[data-flow-state="CONSULTATION_SUMMARY"] .consultation-summary-section-title {
    font-size: clamp(0.72rem, 1.8vw, 0.82rem);
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: rgba(212, 175, 55, 0.95);
    font-weight: 600;
    font-style: normal;
    margin-bottom: 0.35rem;
  }

  .app-shell[data-flow-state="CONSULTATION_SUMMARY"]
    .consultation-summary-section:first-of-type
    .consultation-summary-section-title {
    font-size: clamp(0.78rem, 2vw, 0.9rem);
    color: #e8c547;
    letter-spacing: 0.14em;
  }

  .app-shell[data-flow-state="CONSULTATION_SUMMARY"] .consultation-summary-items {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    margin-top: 0.65rem;
  }

  .app-shell[data-flow-state="CONSULTATION_SUMMARY"] .consultation-summary-item {
    margin: 0;
    padding: 0.78rem 1rem;
    font-size: clamp(0.94rem, 2.4vw, 1.06rem);
    line-height: 1.58;
    letter-spacing: 0.02em;
    color: #f5f5f5;
    font-style: normal;
    border: 1px solid rgba(212, 175, 55, 0.14);
    border-radius: 14px;
    background: rgba(14, 14, 14, 0.72);
  }

  .app-shell[data-flow-state="CONSULTATION_SUMMARY"] .msg.assistant:not(:has(.consultation-summary-card)) {
    font-size: clamp(0.95rem, 2.6vw, 1.08rem);
    line-height: 1.68;
    letter-spacing: 0.03em;
    color: rgba(245, 241, 232, 0.94);
    font-style: normal;
    padding: 1.25rem 0.85rem;
    background: rgba(20, 20, 20, 0.88);
    border: 1px solid rgba(212, 175, 55, 0.2);
    border-radius: 18px;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
  }

  .app-shell[data-flow-state="CONSULTATION_SUMMARY"] .scene-actions {
    padding-bottom: clamp(0.35rem, 1.2vh, 0.85rem);
  }

  .app-shell[data-flow-state="HOME_ROUTINE"] #flowOptions .btn,
  .app-shell[data-flow-state="CONSULTATION_SUMMARY"] #flowOptions .btn {
    margin-top: 0.15rem;
  }
}

/* —— 27A-3: dashboard visibile solo tablet; PC usa ancora .consultation-summary-card —— */
.summary-dashboard-tablet {
  display: none;
}

/* 27A-3 Tablet Dashboard */
@media (max-width: 1024px) {
  .app-shell[data-flow-state="CONSULTATION_SUMMARY"] .msg.assistant.has-tablet-dashboard {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    width: 100%;
    max-width: min(36rem, 100%);
    margin-left: auto;
    margin-right: auto;
    padding-left: clamp(0.35rem, 1.5vw, 0.75rem);
    padding-right: clamp(0.35rem, 1.5vw, 0.75rem);
  }

  .app-shell[data-flow-state="CONSULTATION_SUMMARY"]
    .msg.assistant.has-tablet-dashboard
    .consultation-summary-card {
    display: none;
  }

  .app-shell[data-flow-state="CONSULTATION_SUMMARY"] .msg.assistant.has-tablet-dashboard .summary-dashboard-tablet {
    display: flex;
    flex-direction: column;
    gap: clamp(1.15rem, 3vw, 1.65rem);
    width: 100%;
    max-width: min(34rem, 100%);
    margin: 0 auto;
    padding: clamp(1.1rem, 3vw, 1.5rem) clamp(0.85rem, 2.8vw, 1.25rem) clamp(1rem, 2.5vw, 1.35rem);
    transform: translateZ(0);
    opacity: 0;
    animation: jervi-reveal 0.55s ease forwards;
  }

  .summary-dashboard-hero {
    text-align: center;
    padding-bottom: 0.15rem;
  }

  .summary-dashboard-hero-title {
    margin: 0;
    font-size: clamp(1.35rem, 4.2vw, 1.85rem);
    font-weight: 500;
    letter-spacing: 0.06em;
    color: #f5f1e8;
    line-height: 1.28;
  }

  .summary-dashboard-hero-subtitle {
    margin: 0.65rem 0 0;
    font-size: clamp(0.88rem, 2.4vw, 1rem);
    line-height: 1.62;
    letter-spacing: 0.02em;
    color: rgba(168, 162, 154, 0.96);
    max-width: 28rem;
    margin-left: auto;
    margin-right: auto;
  }

  .summary-dashboard-main {
    display: flex;
    flex-direction: column;
    gap: clamp(1.1rem, 2.8vw, 1.45rem);
  }

  .summary-services-hero {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
  }

  .summary-services-hero-heading {
    margin: 0;
    font-size: clamp(0.72rem, 2vw, 0.82rem);
    font-weight: 600;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: rgba(212, 175, 55, 0.92);
    text-align: center;
  }

  .service-hero-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    padding: clamp(1.1rem, 2.8vw, 1.35rem) clamp(1rem, 2.6vw, 1.3rem);
    border-radius: 20px;
    background: rgba(20, 20, 20, 0.92);
    border: 1px solid rgba(212, 175, 55, 0.22);
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.36);
  }

  .service-hero-name {
    font-size: clamp(1.05rem, 3vw, 1.22rem);
    font-weight: 500;
    letter-spacing: 0.03em;
    color: #f5f1e8;
    line-height: 1.35;
    padding-right: 5.5rem;
  }

  .service-hero-benefit {
    margin: 0;
    font-size: clamp(0.86rem, 2.3vw, 0.95rem);
    line-height: 1.55;
    letter-spacing: 0.015em;
    color: rgba(245, 241, 232, 0.82);
  }

  .service-hero-badge {
    position: absolute;
    top: clamp(0.85rem, 2vw, 1rem);
    right: clamp(0.85rem, 2vw, 1rem);
    font-size: clamp(0.62rem, 1.6vw, 0.68rem);
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: rgba(212, 175, 55, 0.88);
    border: 1px solid rgba(212, 175, 55, 0.28);
    border-radius: 999px;
    padding: 0.28rem 0.55rem;
    background: rgba(10, 10, 10, 0.55);
  }

  .summary-insight-card {
    padding: clamp(0.95rem, 2.4vw, 1.15rem) clamp(1rem, 2.5vw, 1.2rem);
    border-radius: 16px;
    background: rgba(14, 14, 14, 0.72);
    border: 1px solid rgba(212, 175, 55, 0.14);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
  }

  .summary-insight-heading {
    margin: 0 0 0.45rem;
    font-size: clamp(0.68rem, 1.8vw, 0.76rem);
    font-weight: 600;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: rgba(168, 162, 154, 0.88);
  }

  .summary-insight-text {
    margin: 0;
    font-size: clamp(0.86rem, 2.2vw, 0.95rem);
    line-height: 1.58;
    letter-spacing: 0.02em;
    color: rgba(245, 241, 232, 0.88);
  }

  .summary-routine-pills {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
  }

  .summary-routine-heading {
    margin: 0;
    font-size: clamp(0.72rem, 2vw, 0.82rem);
    font-weight: 600;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: rgba(212, 175, 55, 0.88);
    text-align: center;
  }

  .summary-routine-pills-inner {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem 0.55rem;
  }

  .routine-pill {
    display: inline-block;
    max-width: 100%;
    padding: 0.48rem 0.85rem;
    border-radius: 999px;
    font-size: clamp(0.82rem, 2.1vw, 0.9rem);
    letter-spacing: 0.02em;
    line-height: 1.35;
    color: rgba(245, 241, 232, 0.92);
    background: rgba(18, 18, 18, 0.88);
    border: 1px solid rgba(212, 175, 55, 0.2);
  }

  .summary-dashboard-actions {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.65rem;
    padding-top: 0.25rem;
    padding-bottom: 0.15rem;
  }

  .summary-dashboard-btn-team {
    width: 100%;
    transform: translateZ(0);
    transition:
      transform 0.22s ease,
      opacity 0.22s ease,
      border-color 0.22s ease;
  }

  .summary-dashboard-btn-team:not(:disabled):active {
    transform: scale(0.98);
    opacity: 0.9;
  }
}

