/* The demo is a separate application view in the same standalone document. */
.y-app[hidden], .y-app [hidden] { display: none !important; }
body[data-demo-view="app"] > :is(.site-header, .skip, #main, #contatti) { display: none; }
.y-app {
  --y-bg: #080d17;
  --y-card: #101a2b;
  --y-edge: #26364f;
  --y-ink: #edf4ff;
  --y-calm: #9fb0c9;
  --y-accent: #a7c7ff;
  --y-blue: #548cf2;
  --y-header-size: 70px;
  min-height: 100vh;
  background: var(--y-bg);
  color: var(--y-ink);
}
.y-top {
  position: sticky; inset-block-start: 0; z-index: 4; min-height: var(--y-header-size);
  padding: .8rem clamp(1rem, 3vw, 2rem); display: flex; align-items: center; gap: 1.05rem;
  background: #0a111e; border-bottom: 1px solid var(--y-edge);
}
.y-top .brand { letter-spacing: .13em; }
.y-context { color: var(--y-calm); border-left: 1px solid var(--y-edge); padding-left: 1.05rem; font-size: 1rem; }
.y-top-actions { margin-left: auto; display: flex; align-items: center; flex-wrap: wrap; gap: .75rem; }
.y-label { color: var(--y-accent); font-size: .9rem; }
.y-button {
  min-height: 38px; display: inline-flex; align-items: center; justify-content: center;
  font: inherit; font-size: 1rem; font-weight: 610; line-height: 1.2;
  padding: .58rem .82rem; gap: .5rem; border-radius: 7px; cursor: pointer; white-space: nowrap;
}
.y-primary { border: 1px solid #c0d8ff; background: #d3e2ff; color: #0a1427; }
.y-primary:hover { background: #f0f5ff; }
.y-subtle { border: 1px solid var(--y-edge); background: #0c1525; color: var(--y-ink); }
.y-subtle:hover { border-color: #537198; background: #192941; }
.y-layout {
  display: grid; grid-template-columns: minmax(166px, .75fr) minmax(0, 3fr) minmax(300px, 1.45fr);
  grid-template-areas: "rail work assistant"; max-width: 1680px; margin-inline: auto; align-items: start;
}
.y-rail {
  grid-area: rail; position: sticky; top: var(--y-header-size); padding: 1.2rem .72rem;
  min-height: calc(100dvh - var(--y-header-size)); display: flex; flex-direction: column; gap: 1rem;
  border-right: 1px solid var(--y-edge);
}
.y-nav { display: grid; gap: .25rem; }
.y-nav button {
  min-height: 45px; display: flex; align-items: center; gap: .66rem; text-align: left;
  border: 1px solid transparent; border-radius: 8px; padding: .58rem .65rem;
  color: var(--y-calm); background: transparent; cursor: pointer; font-size: 1rem;
}
.y-nav button:hover { color: var(--y-ink); background: #142037; }
.y-nav button[aria-current="page"] { color: var(--y-ink); background: #172945; border-color: #30476c; }
.y-nav .icon { width: 1.07rem; height: 1.07rem; color: var(--y-accent); }
.y-reset { margin-top: auto; }
.y-workspace { grid-area: work; min-width: 0; padding: clamp(1.05rem,3vw,2.25rem); }
.y-workspace-header { display: flex; justify-content: space-between; align-items: end; gap: .8rem; margin-bottom: 1.25rem; }
.y-eyebrow { color: var(--y-accent); font-size: .85rem; font-weight: 670; letter-spacing: .14em; }
.y-workspace h1 { margin-top: .38rem; font-size: clamp(2rem,4vw,3.55rem); font-weight: 610; line-height: 1.02; letter-spacing: -.052em; }
.y-mode { min-width: max-content; display: flex; padding: 3px; border: 1px solid var(--y-edge); background: #0c1524; border-radius: 9px; }
.y-mode button { background: transparent; color: var(--y-calm); border: 0; border-radius: 6px; padding: .49rem .56rem; cursor: pointer; font-size: .94rem; }
.y-mode button[aria-pressed="true"] { color: var(--y-ink); background: #243959; }
.y-notice { color: var(--y-accent); font-size: .97rem; }
.y-notice:not(:empty) { border-left: 2px solid #648ec9; background: #14233b; padding: .47rem .71rem; margin-bottom: .85rem; border-radius: 2px 6px 6px 2px; }
.y-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: .78rem; }
.y-stack { display: grid; gap: .78rem; }
.y-card {
  min-width: 0; border: 1px solid var(--y-edge); border-radius: 12px;
  padding: 1.05rem; background: linear-gradient(140deg, #121e33, #101929 84%);
}
.y-card-header { display: flex; justify-content: space-between; align-items: start; gap: .65rem; }
.y-card h2, .y-card h3 { font-weight: 610; font-size: 1rem; line-height: 1.35; letter-spacing: -.017em; }
.y-card .icon, .y-assistant .icon { color: var(--y-accent); }
.y-value { margin-top: .53rem; font-size: clamp(1.58rem,3vw,2.36rem); font-variant-numeric: tabular-nums; letter-spacing: -.052em; line-height: 1.1; font-weight: 550; overflow-wrap: anywhere; }
.y-copy { margin-top: .55rem; font-size: 1rem; color: var(--y-calm); }
.y-card-button {
  text-align: left; width: 100%; color: inherit; cursor: pointer; appearance: none; font: inherit;
}
.y-card-button:hover { border-color: #6384b7; background: #172640; }
.y-action-row { margin-top: .65rem; display: flex; flex-wrap: wrap; gap: .5rem; }
.y-action-row .y-button { white-space: normal; text-align: center; }
.y-device { padding: .95rem 1rem; }
.y-device.is-selected { border-color: #30476c; }
.y-device input[type="range"] { width: 100%; margin-top: 1.08rem; margin-bottom: .1rem; accent-color: var(--y-blue); cursor: pointer; }
.y-device output { font-variant-numeric: tabular-nums; }
.y-field { display: grid; gap: .42rem; color: var(--y-calm); font-size: 1rem; min-width: 0; }
.y-field select, .y-input input {
  min-width: 0; border: 1px solid var(--y-edge); border-radius: 7px; background: #0b1424;
  color: var(--y-ink); outline-offset: 3px; font: inherit; padding: .55rem .63rem;
}
.y-field select { min-height: 42px; }
.y-two-fields { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: .7rem; margin-top: .8rem; }
.y-gauge { height: 6px; margin-top: .9rem; background: #293951; border-radius: 8px; overflow: hidden; }
.y-gauge progress { display: block; width: 100%; height: 100%; appearance: none; border: 0; background: none; color: #78a7f4; }
.y-gauge progress::-webkit-progress-bar { background: #293951; }
.y-gauge progress::-webkit-progress-value { background: #78a7f4; }
.y-gauge progress::-moz-progress-bar { background: #78a7f4; }
.y-bridge-map { margin-top: .75rem; overflow: hidden; border: 1px solid var(--y-edge); border-radius: 9px; }
.y-bridge-map .map { min-height: clamp(230px, 28vw, 355px); }
.y-card-status { font-variant-numeric: tabular-nums; color: var(--y-accent); font-size: 1rem; }
.y-log-list { margin: .72rem 0 0; padding-left: 0; list-style: none; }
.y-log-list li { display: grid; grid-template-columns: 61px 1fr; gap: .66rem; padding: .6rem 0; border-top: 1px solid var(--y-edge); font-size: 1rem; }
.y-log-list time { color: var(--y-accent); font-variant-numeric: tabular-nums; }
.y-assistant {
  grid-area: assistant; position: sticky; top: var(--y-header-size); padding: 1.25rem .95rem 1rem;
  min-height: calc(100dvh - var(--y-header-size)); min-width: 0; background: #0b1423; border-left: 1px solid var(--y-edge);
  display: flex; flex-direction: column; gap: .85rem;
}
.y-assistant-header { display: flex; align-items: center; justify-content: space-between; gap: .48rem; }
.y-assistant-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .35rem; }
.y-assistant-actions .y-button { padding-inline: .5rem; }
.y-assistant-header h2 { font-size: 1.43rem; margin-top: .28rem; letter-spacing: -.034em; }
.y-voice-toggle { padding: .46rem; min-width: 38px; border: 1px solid var(--y-edge); background: #121f34; }
.y-voice-toggle[aria-pressed="false"] { opacity: .63; }
.y-voice-toggle:disabled { display: none; }
.y-talk { text-align: center; padding: 1rem .25rem .15rem; }
.y-mic {
  --ring: #88acf5;
  position: relative; display: grid; place-items: center; margin-inline: auto;
  width: 106px; height: 106px; border-radius: 50%; border: 1px solid var(--ring);
  color: #ecf4ff; background: radial-gradient(circle at 50% 23%, #597db8 0%, #274b84 78%);
  box-shadow: 0 0 0 9px #132442, inset 0 5px 16px #91b9ff40, 0 12px 32px #070d18;
  cursor: pointer; transition: background .2s, box-shadow .2s;
}
.y-mic:hover { box-shadow: 0 0 0 10px #203c66, inset 0 5px 16px #91b9ff60, 0 12px 32px #070d18; }
.y-mic .icon { color: #f4f8ff; width: 45px; height: 45px; stroke-width: 1.28; }
.y-mic[aria-pressed="true"] { --ring:#ecc6ca; background: radial-gradient(circle at 50% 23%, #bc7183, #673c5a 84%); box-shadow: 0 0 0 10px #40304a; }
.y-mic-caption { margin-top: .95rem; min-height: 1.6em; color: var(--y-ink); font-size: 1.05rem; font-weight: 630; }
.y-voice-note { color: var(--y-calm); font-size: .89rem; margin-top: .22rem; }
.y-chat {
  display: flex; flex-direction: column; gap: .55rem; padding: .65rem .02rem;
  min-height: 127px; max-height: min(31vh,278px); overflow: auto; overscroll-behavior: contain;
}
.y-message {
  max-width: 95%; padding: .57rem .66rem; border-radius: 8px; font-size: 1rem; line-height: 1.48;
  background: #172740; border: 1px solid #273c5c; overflow-wrap: anywhere;
}
.y-message[data-role="user"] { align-self: flex-end; color: #e8f0ff; background: #203756; }
.y-message span { display: block; color: var(--y-accent); font-size: .79rem; font-weight: 660; margin-bottom: .13rem; }
.y-suggestions, .y-confirm { display: flex; flex-wrap: wrap; gap: .38rem; }
.y-chip { color: #d7e5ff; font: inherit; font-size: .89rem; background: transparent; border: 1px solid var(--y-edge); border-radius: 7px; padding: .32rem .48rem; cursor: pointer; min-height: 32px; text-align: left; }
.y-chip:hover { background: #1b2c47; }
.y-input { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: .42rem; margin-top: auto; }
.y-input input { min-height: 42px; font-size: 1rem; }
.y-dialog { width: min(510px, calc(100% - 2rem)); max-height: calc(100vh - 2rem); overflow: auto; color: var(--y-ink); background: #101a2b; border: 1px solid var(--y-edge); border-radius: 12px; padding: 1.2rem; }
.y-dialog::backdrop { background: #03070dcc; }
.y-dialog-head { display: flex; align-items: start; justify-content: space-between; gap: .6rem; }
.y-dialog h2 { font-size: 1.9rem; margin-top: .4rem; }
.y-document { margin-top: .85rem; }
.y-document div { border-top: 1px solid var(--y-edge); padding: .65rem 0; }
.y-document dt { color: var(--y-accent); font-weight: 610; }
.y-document dd { color: var(--y-calm); }
.y-sr { position: absolute; width: 1px; height: 1px; clip-path: inset(50%); overflow: hidden; white-space: nowrap; }

/* Voice interaction uses the same color and shape language as the console. */
.y-voice-steps {
  display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: .3rem;
  margin: 0; padding: 0; list-style: none; text-align: center;
}
.y-voice-steps li {
  border: 1px solid var(--y-edge); border-radius: 6px;
  padding: .34rem .15rem; color: var(--y-calm); font-size: clamp(.78rem,1.22vw,.85rem);
  line-height: 1.3; overflow-wrap: anywhere;
}
.y-voice-steps li.is-current {
  background: #1c344f; border-color: #527cb0; color: var(--y-ink); font-weight: 650;
}
.y-assistant[data-voice-state="listening"] .y-voice-steps li.is-current {
  background: #40304a; border-color: #673c5a; color: #ecc6ca;
}
.y-transcript {
  padding: .42rem .6rem; border-inline-start: 2px solid #587daf; border-radius: 0 6px 6px 0;
  background: #101f35; min-width: 0; color: var(--y-calm); font-size: .95rem;
}
#y-transcript-text {
  margin: .1rem 0 0; color: var(--y-ink); line-height: 1.4; overflow-wrap: anywhere;
}
.y-assistant[data-voice-state="processing"] .y-mic { --ring:#a7c7ff; }
.y-assistant[data-voice-state="error"] .y-mic-caption { color: #ecc6ca; }
.y-voice-toggle:focus-visible, .y-mic:focus-visible, .y-input input:focus-visible, .y-field select:focus-visible {
  outline: 2px solid #b4cfff; outline-offset: 3px;
}
.y-card-name { font-weight: 610; font-size: 1rem; line-height: 1.35; letter-spacing: -.017em; }
.y-card > .y-value, .y-card > .y-copy { display: block; }

/* Touch targets stay generous without changing the desktop console geometry. */
@media (max-width: 1190px), (pointer: coarse) {
  .y-app { --y-header-size: 4.5rem; }
  .y-button, .y-mode button, .y-chip, .y-field select, .y-input input,
  .y-device input[type="range"] { min-height: 44px; }
  .y-voice-toggle { min-width: 44px; }
  .y-input input { font-size: 1rem; }
  .y-mode { min-width: 0; width: max-content; max-width: 100%; flex-wrap: wrap; }
}

/* Tablet portrait moves the categories above the side-by-side panels. */
@media (max-width: 1190px) {
  .y-layout {
    grid-template-columns: minmax(0,1fr) minmax(278px,.56fr);
    grid-template-areas: "rail rail" "work assistant";
  }
  .y-rail {
    position: static; min-width: 0; min-height: 0; flex-direction: row; align-items: center;
    padding: .44rem .78rem; border-right: 0; border-bottom: 1px solid var(--y-edge);
  }
  .y-nav { display: flex; flex: 1; min-width: 0; overflow-x: auto; padding: .16rem .25rem .22rem; gap: .28rem; }
  .y-nav button { white-space: nowrap; min-height: 44px; flex: 0 0 auto; padding: .43rem .62rem; }
  .y-reset { margin: 0; flex: 0 0 auto; }
  .y-workspace-header { align-items: flex-start; flex-wrap: wrap; }
}

/* A taller landscape tablet can keep the three-panel helm view. */
@media (min-width: 960px) and (max-width: 1190px) and (min-height: 560px) and (orientation: landscape) {
  .y-layout {
    grid-template-columns: minmax(136px,.68fr) minmax(0,2.65fr) minmax(281px,1.4fr);
    grid-template-areas: "rail work assistant";
  }
  .y-rail {
    position: sticky; top: var(--y-header-size); min-height: calc(100dvh - var(--y-header-size));
    flex-direction: column; align-items: stretch; padding: 1rem .5rem;
    border-right: 1px solid var(--y-edge); border-bottom: 0;
  }
  .y-nav { display: grid; flex: 0 0 auto; overflow: visible; padding: 0; }
  .y-nav button { white-space: normal; }
  .y-reset { margin-top: auto; }
}

/* The narrow layout keeps a voice dock visible beneath the scrollable plancia. */
@media (max-width: 669px) {
  .y-app { --y-header-size: 3.65rem; }
  .y-top {
    position: relative; gap: .5rem; padding: .4rem max(.7rem, env(safe-area-inset-right)) .4rem max(.7rem, env(safe-area-inset-left));
  }
  .y-top .brand { min-width: 0; font-size: .78rem; gap: .4rem; letter-spacing: .085em; }
  .y-top .brand-mark { width: 1.54rem; height: 1.54rem; }
  .y-context, .y-top .y-label { display: none; }
  .y-top-actions { gap: .4rem; flex: 0 0 auto; }
  .y-top-actions .y-button { font-size: .9rem; padding-inline: .62rem; }
  .y-layout {
    grid-template-columns: minmax(0,1fr);
    grid-template-areas: "rail" "work" "assistant";
    grid-template-rows: auto minmax(12rem,1fr) auto;
    block-size: calc(100dvh - var(--y-header-size));
    min-block-size: 30rem; align-items: stretch;
  }
  .y-rail { padding: .28rem .4rem; gap: .32rem; }
  .y-reset { margin-right: .18rem; font-size: .85rem; padding-inline: .44rem; }
  .y-workspace { overflow-y: auto; padding: .78rem .88rem; }
  .y-workspace-header { margin-bottom: .79rem; }
  .y-workspace-header h1 { font-size: clamp(1.67rem,6.1vw,2.5rem); }
  .y-card { padding: .74rem; }
  .y-grid, .y-stack { gap: .52rem; }
  .y-assistant {
    position: static; min-height: 0; min-block-size: 0; max-block-size: min(52dvh,25rem); overflow-y: auto;
    border-left: 0; border-top: 1px solid var(--y-edge); padding: .55rem .78rem max(.57rem,env(safe-area-inset-bottom)); gap: .34rem;
  }
  .y-assistant-header h2 { font-size: 1.22rem; }
  .y-assistant-header .y-eyebrow { font-size: .78rem; }
  .y-talk {
    display: grid; grid-template-columns: 72px minmax(0,1fr); align-items: center;
    column-gap: .82rem; padding: .4rem .24rem .35rem; text-align: left;
  }
  .y-mic { grid-area: 1 / 1 / 3 / 2; width: 64px; height: 64px; box-shadow: 0 0 0 5px #132442; }
  .y-mic[aria-pressed="true"] { box-shadow: 0 0 0 5px #40304a; }
  .y-mic .icon { width: 29px; height: 29px; }
  .y-mic-caption { grid-column: 2; margin: 0; align-self: end; min-height: 0; }
  .y-voice-note { grid-column: 2; margin-top: .11rem; align-self: start; line-height: 1.35; }
  .y-talk > :is(.y-voice-steps, .y-transcript) { grid-column: 1 / -1; margin-top: .3rem; }
  .y-assistant #y-transcript-text { max-block-size: 3.2em; overflow-y: auto; }
  .y-chat { min-height: 0; max-height: 5rem; padding: .15rem .02rem; overscroll-behavior: auto; }
  .y-suggestions { flex-wrap: nowrap; overflow-x: auto; padding: .12rem .19rem; }
  .y-suggestions .y-chip { flex: 0 0 auto; }
  .y-input { margin-top: 0; }
}

@media (max-width: 350px) {
  .y-grid, .y-two-fields { grid-template-columns: minmax(0,1fr); }
}

/* A short landscape phone shows the workspace and voice side by side. */
@media (min-width: 540px) and (max-width: 1190px) and (max-height: 510px) and (orientation: landscape) {
  .y-app { --y-header-size: 3.6rem; }
  .y-top { position: relative; padding-block: .35rem; }
  .y-layout {
    grid-template-columns: minmax(0,1fr) minmax(220px,.74fr);
    grid-template-areas: "rail rail" "work assistant";
    grid-template-rows: auto auto; block-size: auto; min-block-size: 0; align-items: start;
  }
  .y-rail { padding-block: .24rem; }
  .y-workspace { padding: .65rem .82rem; overflow: visible; }
  .y-workspace-header { align-items: center; gap: .55rem; margin-bottom: .65rem; }
  .y-workspace-header h1 { font-size: clamp(1.5rem,4vw,2.2rem); }
  .y-card { padding: .72rem; }
  .y-grid, .y-stack { gap: .52rem; }
  .y-assistant {
    position: sticky; top: .25rem; min-height: 0; max-block-size: none; overflow: visible;
    padding: .57rem .7rem; gap: .34rem; border-top: 0; border-left: 1px solid var(--y-edge);
  }
  .y-assistant-header h2 { font-size: 1.22rem; }
  .y-talk {
    display: grid; grid-template-columns: 68px minmax(0,1fr); align-items: center;
    column-gap: .62rem; padding: .24rem .18rem .34rem; text-align: left;
  }
  .y-mic { grid-area: 1 / 1 / 3 / 2; width: 60px; height: 60px; box-shadow: 0 0 0 4px #132442; }
  .y-mic[aria-pressed="true"] { box-shadow: 0 0 0 4px #40304a; }
  .y-mic .icon { width: 27px; height: 27px; }
  .y-mic-caption { grid-column: 2; margin: 0; align-self: end; min-height: 0; }
  .y-voice-note { grid-column: 2; align-self: start; margin-top: .12rem; line-height: 1.3; }
  .y-talk > :is(.y-voice-steps, .y-transcript) { grid-column: 1 / -1; margin-top: .3rem; }
  .y-assistant #y-transcript-text { max-block-size: 3.2em; overflow-y: auto; }
  .y-chat { min-height: 0; max-height: 5rem; padding: .12rem .02rem; overscroll-behavior: auto; }
  .y-input { margin-top: 0; }
  .y-suggestions { display: none; }
  .y-bridge-map .map { min-height: 200px; }
}

@media (max-height: 360px) and (orientation: landscape) {
  .y-assistant { position: static; }
}

@media (prefers-reduced-motion: reduce) {
  .y-mic { transition: none; }
}
