/* FLOW "next" layout (D356 prototype). Presentation only.
   Every rule is scoped to html[data-flow-layout="next"], so the classic layout is untouched
   (tests/interface-next.test.mjs pins this). Colours: 4U orange #F7941D · teal #4ECDC4 · violet #5E3B6F.
   Wash-and-hole, edge frame and logo shadow reuse the 4U BAG overlay v1.5 recipe. */

html[data-flow-layout="next"] {
  --nx-teal: 78,205,196; --nx-orange: 247,148,29; --nx-violet: 94,59,111;
  --nx-c: var(--nx-violet); --nx-wash: .80; --nx-dock-h: 158px; --nx-level: 0;
}
html[data-flow-layout="next"][data-nx-state="recording"] { --nx-c: var(--nx-teal); --nx-wash: .80; }
html[data-flow-layout="next"][data-nx-state="paused"] { --nx-c: var(--nx-violet); --nx-wash: .80; }
html[data-flow-layout="next"][data-nx-alert="on"] { --nx-c: var(--nx-orange); --nx-wash: .75; }

/* ── Clean screen: marketing copy and the approval frame leave the signed-in app ── */
html[data-flow-layout="next"] body { padding-bottom: calc(var(--nx-dock-h) + 28px + env(safe-area-inset-bottom)); }
html[data-flow-layout="next"] .hero-copy,
html[data-flow-layout="next"] .state-board,
html[data-flow-layout="next"] .brand small,
html[data-flow-layout="next"] .top-actions .ui-language,
html[data-flow-layout="next"] .top-actions a[href="/sobre"],
html[data-flow-layout="next"] footer .layout-switch { display: none; }
html[data-flow-layout="next"] .hero { display: block; min-height: 0; padding: 0; }
html[data-flow-layout="next"] .topbar { height: 60px; min-height: 0; padding: 0; gap: 10px; flex-wrap: nowrap; }
html[data-flow-layout="next"] .brand strong { white-space: nowrap; }
html[data-flow-layout="next"] .top-actions { width: auto; margin-left: auto; }
html[data-flow-layout="next"] .brand-logo { display: grid; flex-basis: 46px; width: 46px; height: 38px; }
html[data-flow-layout="next"] .brand { gap: 10px; }
html[data-flow-layout="next"] .connection-button { width: auto; min-height: 40px; }
html[data-flow-layout="next"] .workspace { margin-bottom: 24px; }
html[data-flow-layout="next"] footer { height: 56px; }
html[data-flow-layout="next"] .toast { z-index: 60; bottom: calc(var(--nx-dock-h) + 24px + env(safe-area-inset-bottom)); }

/* ── Stage: the 4U mark as hero (BAG placement: top centre, drop shadow) + a sign under it ── */
html[data-flow-layout="next"] .nx-stage { position: relative; z-index: 35; display: flex; flex-direction: column; align-items: center; padding: 0; pointer-events: none; }
html[data-flow-layout="next"][data-nx-work="open"] .nx-stage { display: none; }
html[data-flow-layout="next"][data-nx-sheet="open"] .nx-stage { visibility: hidden; }
html[data-flow-layout="next"] .nx-sign { max-width: min(560px, 86vw); margin: 18px 0 10px; padding: 10px 18px; border: 3px solid #4ECDC4; border-radius: 14px; background: #1a1024; color: #fff; font-size: 16px; font-weight: 700; text-align: center; box-shadow: 0 6px 24px rgba(0,0,0,.4); }
html[data-flow-layout="next"] .nx-sign[hidden] { display: none; }
html[data-flow-layout="next"][data-nx-alert="on"] .nx-sign { border-color: #F7941D; }

/* ── Edge frame (BAG: inset 6px line + 80px glow). Softer when the notes are open so text stays readable ── */
html[data-flow-layout="next"] .nx-frame { position: fixed; z-index: 29; inset: 0; pointer-events: none; opacity: 0; transition: opacity .25s ease; box-shadow: inset 0 0 0 6px rgba(var(--nx-c),.95), inset 0 0 calc(60px + var(--nx-level) * 40px) 20px rgba(var(--nx-c),.75); }
html[data-flow-layout="next"][data-nx-focus="on"] .nx-frame { opacity: 1; }
html[data-flow-layout="next"][data-nx-live="on"][data-nx-focus="off"] .nx-frame { opacity: 1; box-shadow: inset 0 0 0 3px rgba(var(--nx-c),.85), inset 0 0 48px 8px rgba(var(--nx-c),.35); }

/* ── Notes pad (D449): typed notes at the TOP of the recording screen, always visible; clear above the wash. ── */
html[data-flow-layout="next"] .nx-pad { position: relative; z-index: 35; display: block; max-width: 720px; margin: 14px auto 0; padding: 10px 12px 10px; border: 1px solid rgba(255,255,255,.14); border-radius: 18px; background: #120e1e; color: #f3eef8; font-family: system-ui, -apple-system, "Segoe UI", sans-serif; pointer-events: auto; }
html[data-flow-layout="next"][data-nx-focus="on"] .nx-pad { box-shadow: 0 0 0 4px #fff, 0 0 24px 8px rgba(255,255,255,.9); }
html[data-flow-layout="next"] .nx-pad-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 8px; }
html[data-flow-layout="next"] .nx-pad-head strong { flex: 1 1 auto; min-width: 0; font-size: 15px; line-height: 44px; letter-spacing: .01em; white-space: nowrap; }
html[data-flow-layout="next"] .nx-pad-state { order: 9; flex: 0 0 100%; color: #84cccc; font-size: 12px; }
html[data-flow-layout="next"] .nx-pad-state:empty { display: none; }
html[data-flow-layout="next"] .nx-chip { min-width: 44px; min-height: 44px; padding: 0 12px; border: 1px solid rgba(255,255,255,.18); border-radius: 999px; background: rgba(255,255,255,.05); color: #f3eef8; font: inherit; font-size: 13px; cursor: pointer; }
html[data-flow-layout="next"] .nx-chip:disabled { opacity: .4; cursor: not-allowed; }
html[data-flow-layout="next"] .nx-chip[aria-pressed="true"] { border-color: rgba(78,205,196,.6); background: rgba(78,205,196,.12); }
html[data-flow-layout="next"] .nx-chip:focus-visible,
html[data-flow-layout="next"] .nx-pad-text:focus-visible { outline: 2px solid #8af2e8; outline-offset: 2px; }
html[data-flow-layout="next"] .nx-pad-text { display: block; width: 100%; min-height: 96px; max-height: 34vh; padding: 12px; resize: vertical; border: 1px solid rgba(255,255,255,.16); border-radius: 12px; background: #0b0916; color: #f3eef8; font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; }
html[data-flow-layout="next"] .nx-pad-hint { margin: 8px 2px 0; color: #bcb4cc; font-size: 12px; line-height: 1.4; }

/* ── Dock: every recording control in one place, inside thumb reach ── */
html[data-flow-layout="next"] .nx-dock { position: fixed; z-index: 30; left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom)); margin: 0 auto; max-width: 560px; padding: 10px 12px 12px; border: 1px solid rgba(255,255,255,.14); border-radius: 22px; background: #120e1e; color: #f3eef8; box-shadow: 0 14px 40px rgba(0,0,0,.5); font-family: system-ui, -apple-system, "Segoe UI", sans-serif; touch-action: manipulation; isolation: isolate; }
/* The wash and its clear hole: one box-shadow spread around the dock (BAG: wash + 4px white ring + white glow). */
html[data-flow-layout="next"] .nx-dock::before { content: ""; position: absolute; z-index: -1; inset: -6px; border-radius: 26px; pointer-events: none; opacity: 0; transition: opacity .25s ease; box-shadow: 0 0 0 200vmax rgba(var(--nx-c), var(--nx-wash)), 0 0 0 4px #fff, 0 0 24px 8px rgba(255,255,255,.9); }
html[data-flow-layout="next"][data-nx-focus="on"] .nx-dock::before { opacity: 1; }
html[data-flow-layout="next"][data-nx-focus="on"] .app-shell { pointer-events: none; }

html[data-flow-layout="next"] .nx-status { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; min-height: 30px; padding: 0 4px 6px; }
html[data-flow-layout="next"] .nx-dot { align-self: center; flex: 0 0 10px; width: 10px; height: 10px; border-radius: 50%; background: #6f697a; }
html[data-flow-layout="next"] .nx-dock[data-state="recording"] .nx-dot { background: #F7941D; box-shadow: 0 0 0 4px rgba(247,148,29,.22); animation: nx-blink 1.4s ease-in-out infinite; }
html[data-flow-layout="next"] .nx-dock[data-state="paused"] .nx-dot { background: #4ECDC4; }
html[data-flow-layout="next"] .nx-timer { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: .02em; }
html[data-flow-layout="next"] .nx-dock[data-state="idle"] .nx-timer { display: none; }
html[data-flow-layout="next"] .nx-parts { flex: 1 1 auto; min-width: 0; overflow: hidden; color: #84cccc; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
html[data-flow-layout="next"] .nx-demo { flex: none; margin-left: auto; padding: 2px 8px; border: 1px solid #F7941D; border-radius: 999px; color: #F7941D; font-size: 11px; font-weight: 700; letter-spacing: .04em; }
html[data-flow-layout="next"] .nx-demo[hidden] { display: none; }

/* A double tap must never zoom the page on a phone (pinch zoom stays): every tappable part of the layout opts out. */
html[data-flow-layout="next"] .nx-dock *,
html[data-flow-layout="next"] .nx-pad,
html[data-flow-layout="next"] .nx-pad *,
html[data-flow-layout="next"] .nx-sheet-head * { touch-action: manipulation; }
html[data-flow-layout="next"] .nx-row { display: grid; grid-template-columns: 1fr 1fr 104px 1fr 1fr; align-items: center; justify-items: center; gap: 4px; }
html[data-flow-layout="next"] .nx-btn { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; width: 100%; max-width: 76px; min-height: 56px; padding: 6px 2px; border: 1px solid transparent; border-radius: 16px; background: transparent; color: #d9d3e1; font: inherit; font-size: 11px; line-height: 1.1; cursor: pointer; -webkit-tap-highlight-color: transparent; }
html[data-flow-layout="next"] .nx-btn svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
html[data-flow-layout="next"] .nx-btn .nx-ico-resume,
html[data-flow-layout="next"] .nx-dock[data-state="paused"] .nx-btn .nx-ico-pause { display: none; }
html[data-flow-layout="next"] .nx-dock[data-state="paused"] .nx-btn .nx-ico-resume { display: block; }
html[data-flow-layout="next"] .nx-btn:hover:not([aria-disabled="true"]) { border-color: rgba(78,205,196,.4); color: #fff; }
html[data-flow-layout="next"] .nx-btn[aria-disabled="true"] { opacity: .34; cursor: not-allowed; }
html[data-flow-layout="next"] .nx-btn[aria-pressed="true"] { border-color: rgba(78,205,196,.55); background: rgba(78,205,196,.1); color: #e6fffb; }
html[data-flow-layout="next"] .nx-btn:focus-visible,
html[data-flow-layout="next"] .nx-main:focus-visible { outline: 2px solid #8af2e8; outline-offset: 2px; }
html[data-flow-layout="next"] .nx-btn kbd,
html[data-flow-layout="next"] .nx-main kbd { display: none; }

html[data-flow-layout="next"] .nx-main { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 0; border: 0; background: transparent; color: #f3eef8; font: inherit; font-size: 12px; font-weight: 700; cursor: pointer; -webkit-tap-highlight-color: transparent; -webkit-touch-callout: none; user-select: none; }
/* The record control IS the 4U mark (Rod 12/11: "the 4U lightning ... on the recording piece"). While recording it
   pulses with the voice level the app already measures (--nx-level, 0..1): it grows, brightens and throws an orange
   glow; a halo flashes behind it. Idle = still. Paused = dimmed. A small badge says what a tap does. */
html[data-flow-layout="next"] .nx-main-disc { position: relative; display: block; width: 84px; height: 84px; }
html[data-flow-layout="next"] .nx-main:active:not([aria-disabled="true"]) .nx-main-disc { transform: scale(.96); }
html[data-flow-layout="next"] .nx-main[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
html[data-flow-layout="next"] .nx-mark { position: relative; z-index: 1; display: block; width: 100%; height: auto; filter: drop-shadow(0 4px 12px rgba(0,0,0,.5)); transition: transform 90ms linear, filter 90ms linear, opacity .3s ease; }
html[data-flow-layout="next"] .nx-halo { position: absolute; z-index: 0; inset: 0; border-radius: 50%; transform: scale(1); opacity: 0; pointer-events: none; background: radial-gradient(circle, rgba(247,148,29,.95) 0, rgba(247,148,29,.55) 38%, rgba(78,205,196,.35) 58%, transparent 72%); transition: transform 90ms linear, opacity 90ms linear; }
html[data-flow-layout="next"][data-nx-state="recording"] .nx-mark { transform: scale(calc(1 + var(--nx-level) * .16)); filter: drop-shadow(0 4px 12px rgba(0,0,0,.5)) drop-shadow(0 0 calc(6px + var(--nx-level) * 34px) rgba(247,148,29, calc(.25 + var(--nx-level) * .75))) brightness(calc(1 + var(--nx-level) * .45)); }
html[data-flow-layout="next"][data-nx-state="recording"] .nx-halo { opacity: calc(.15 + var(--nx-level) * .85); transform: scale(calc(1.2 + var(--nx-level) * .8)); }
html[data-flow-layout="next"][data-nx-state="paused"] .nx-mark { opacity: .5; filter: drop-shadow(0 4px 12px rgba(0,0,0,.5)) saturate(.45) brightness(.75); }
html[data-flow-layout="next"] .nx-main-glyph { position: absolute; z-index: 2; right: -4px; bottom: -4px; display: grid; place-items: center; width: 30px; height: 30px; border: 2px solid #120e1e; border-radius: 50%; background: #F7941D; color: #fff; font-size: 18px; font-weight: 700; line-height: 1; }
html[data-flow-layout="next"] .nx-main-glyph::after { content: ""; display: block; width: 12px; height: 12px; border-radius: 50%; background: #fff; }
html[data-flow-layout="next"] .nx-dock[data-state="recording"] .nx-main-glyph::after,
html[data-flow-layout="next"] .nx-dock[data-state="paused"] .nx-main-glyph::after { width: 11px; height: 11px; border-radius: 2px; }
html[data-flow-layout="next"] .nx-dock[data-state="ready"] .nx-main-glyph,
html[data-flow-layout="next"] .nx-dock[data-auth="out"][data-state="idle"] .nx-main-glyph { background: #5E3B6F; }
html[data-flow-layout="next"] .nx-dock[data-state="ready"] .nx-main-glyph::after { content: "+"; width: auto; height: auto; border-radius: 0; background: none; }
html[data-flow-layout="next"] .nx-dock[data-auth="out"][data-state="idle"] .nx-main-glyph::after { content: "→"; width: auto; height: auto; border-radius: 0; background: none; font-size: 16px; }

html[data-flow-layout="next"] .nx-retry { display: block; width: 100%; min-height: 48px; margin-top: 10px; border: 1px solid #F7941D; border-radius: 14px; background: rgba(247,148,29,.12); color: #ffe3bd; font: inherit; font-size: 14px; font-weight: 700; cursor: pointer; }
html[data-flow-layout="next"] .nx-retry[hidden] { display: none; }
html[data-flow-layout="next"] .nx-retry:disabled { opacity: .5; cursor: not-allowed; }
html[data-flow-layout="next"] .nx-notice { margin: 8px 4px 0; color: #f6d2b6; font-size: 12px; line-height: 1.4; }
html[data-flow-layout="next"] .nx-notice[hidden] { display: none; }

/* ── "More" sheet: the classic options block, relocated above the dock (same nodes, same handlers) ── */
html[data-flow-layout="next"] .orb-stage { position: fixed; z-index: 28; left: 10px; right: 10px; bottom: calc(var(--nx-dock-h) + 22px + env(safe-area-inset-bottom)); display: block; max-width: 560px; max-height: min(64vh, 560px); margin: 0 auto; padding: 14px 16px 18px; overflow: auto; overscroll-behavior: contain; border: 1px solid rgba(255,255,255,.14); border-radius: 22px; background: #120e1e; box-shadow: 0 14px 40px rgba(0,0,0,.55); visibility: hidden; pointer-events: none; }
html[data-flow-layout="next"][data-nx-sheet="open"] .orb-stage { visibility: visible; pointer-events: auto; }
html[data-flow-layout="next"] .orb-stage > .record-controls,
html[data-flow-layout="next"] .orb-stage #partStatus,
html[data-flow-layout="next"] .orb-stage #retryPartsButton,
html[data-flow-layout="next"] .orb-frame > .orb { display: none; }
html[data-flow-layout="next"] .orb-frame,
html[data-flow-layout="next"] .orb-frame.consent-open { position: static; width: auto; aspect-ratio: auto; margin: 0; }
html[data-flow-layout="next"] .orb-stage .consent-script { width: auto; margin-top: 12px; }
html[data-flow-layout="next"] .orb-stage > .helper { max-width: none; text-align: left; }
html[data-flow-layout="next"] .nx-sheet-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding-bottom: 12px; border-bottom: 1px solid rgba(255,255,255,.1); }
html[data-flow-layout="next"] .nx-sheet-head button,
html[data-flow-layout="next"] .nx-sheet-head a { display: inline-grid; place-items: center; min-width: 48px; min-height: 48px; padding: 0 12px; border: 1px solid rgba(255,255,255,.14); border-radius: 14px; background: rgba(255,255,255,.04); color: #f3eef8; font: inherit; font-size: 13px; text-decoration: none; cursor: pointer; }
html[data-flow-layout="next"] .nx-sheet-head .nx-flag { padding: 0; font-size: 26px; }
html[data-flow-layout="next"] .nx-sheet-head .nx-flag[aria-pressed="true"] { border-color: rgba(255,255,255,.6); background: rgba(255,255,255,.1); }
html[data-flow-layout="next"] .nx-sheet-head .nx-close { margin-left: auto; font-size: 20px; }
html[data-flow-layout="next"] .nx-keys { display: none; }
/* Must stay in view even while the sheet is closed: consent card and auto-copy lamp sit just above the dock. */
html[data-flow-layout="next"] #orbConsent { position: fixed; z-index: 38; top: auto; right: 10px; bottom: calc(var(--nx-dock-h) + 22px + env(safe-area-inset-bottom)); left: 10px; max-width: 560px; margin: 0 auto; padding: 16px 14px; border: 1px solid #df9a90; visibility: visible; pointer-events: auto; }
html[data-flow-layout="next"] #orbConsent button { min-height: 48px; padding: 0 18px; font-size: 14px; }
html[data-flow-layout="next"] #orbConsent[hidden] { display: none; }
html[data-flow-layout="next"] #copyLamp { position: fixed; z-index: 31; top: auto; left: 50%; bottom: calc(var(--nx-dock-h) + 14px + env(safe-area-inset-bottom)); max-width: 90vw; padding: 6px 12px; border-radius: 999px; background: #120e1e; visibility: visible; pointer-events: auto; }
html[data-flow-layout="next"] #copyLamp[hidden] { display: none; }
html[data-flow-layout="next"][data-nx-sheet="open"] #copyLamp { display: none; }

/* ── Desktop: keyboard hints on the dock, shortcut list in the sheet ── */
@media (hover: hover) and (pointer: fine) {
  html[data-flow-layout="next"] .nx-btn kbd,
  html[data-flow-layout="next"] .nx-main kbd { display: inline-block; min-width: 18px; padding: 1px 5px; border: 1px solid rgba(255,255,255,.22); border-radius: 5px; background: rgba(255,255,255,.06); color: #bcb4cc; font: 600 10px ui-monospace, monospace; }
  html[data-flow-layout="next"] .nx-keys { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 12px 0 0; color: #d9d3e1; font-size: 13px; }
  html[data-flow-layout="next"] .nx-keys dt { margin: 0; }
  html[data-flow-layout="next"] .nx-keys dd { margin: 0; }
  html[data-flow-layout="next"] .nx-keys kbd { padding: 2px 7px; border: 1px solid rgba(255,255,255,.22); border-radius: 5px; background: rgba(255,255,255,.06); font: 600 12px ui-monospace, monospace; }
  html[data-flow-layout="next"] { --nx-dock-h: 176px; }
}
@media (min-width: 900px) {
  html[data-flow-layout="next"] .nx-dock { bottom: 20px; }
  html[data-flow-layout="next"] .nx-pad-text { min-height: clamp(120px, 24vh, 260px); }
  html[data-flow-layout="next"] .nx-sign { font-size: 20px; padding: 14px 22px; margin: 26px 0 12px; }
}
@media (max-height: 560px) {
  html[data-flow-layout="next"] .nx-pad-text { min-height: 64px; }
  html[data-flow-layout="next"] .nx-pad-hint { display: none; }
}
@keyframes nx-blink { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) {
  html[data-flow-layout="next"] .nx-dock[data-state="recording"] .nx-dot { animation: none; }
  html[data-flow-layout="next"] .nx-frame,
  html[data-flow-layout="next"] .nx-dock::before,
  html[data-flow-layout="next"] .nx-main-disc,
  html[data-flow-layout="next"] .nx-main-glyph { transition: none; }
  /* Reduced motion: the hero never moves or flashes; it only gets brighter with the voice. */
  html[data-flow-layout="next"][data-nx-state="recording"] .nx-mark { transform: none; transition: none; filter: drop-shadow(0 4px 12px rgba(0,0,0,.5)) brightness(calc(1 + var(--nx-level) * .45)); }
  html[data-flow-layout="next"][data-nx-state="recording"] .nx-halo { opacity: 0; transform: none; transition: none; }
}
@media (forced-colors: active) {
  html[data-flow-layout="next"] .nx-frame,
  html[data-flow-layout="next"] .nx-dock::before { display: none; }
}

/* Both layouts share the sign-in dialog. Outside the flag there are exactly two rules: the footer link that offers
   the new layout, and the small support reference under a rejected sign-in. */
.layout-switch { color: inherit; text-decoration: underline; text-underline-offset: 3px; }
.account-dialog .login-reference { min-height: 0; margin: -8px 0 0; color: #8f879d; font: 11px/1.4 ui-monospace, monospace; overflow-wrap: anywhere; }
.account-dialog .login-reference:empty { display: none; }
