/* fit-u.css: final build, area phone behaviour, dialogs, tap targets, polish (builder U). Loaded after fit.css (concept A). */

/* ---------- U6. the voice chip: no press-and-hold any more, so a swipe that starts on it scrolls the page (owner) ------ */
#who { touch-action: manipulation; }

/* ---------- U3. nothing behind an open menu or dialog scrolls, chains or pulls to refresh ---------- */
html:has(.g-bar.menu-open), html:has(dialog[open]) { overscroll-behavior: none; }
body:has(.g-bar.menu-open), body:has(dialog[open]) { overscroll-behavior: none; }
.g-bar.menu-open::after { touch-action: none; }  /* (the dimmed page under the menu: a tap closes it, a swipe does nothing) */
dialog::backdrop { touch-action: none; }

/* ---------- dialogs open with a move, never a fade (the owner's last word on motion): same paths, no opacity ---------- */
@keyframes fitPopIn { from { transform: translateY(6px) scale(.98); } }
@keyframes fitNewsIn { from { transform: translateY(18px) scale(.95); } }
@keyframes fitNewsOut { to { transform: translateY(8px) scale(.97); } }
.dlg[open]:not(.news), #vpDlg[open] { animation-name: fitPopIn; }
.dlg.news[open] { animation-name: fitNewsIn; }
.dlg.news.out { animation-name: fitNewsOut; }
.dlg[open]::backdrop, .dlg.news[open]::backdrop, .dlg.news.out::backdrop { animation: none; }
.tpop.g-tpop.in { animation-name: fitPopIn, tpblip; }
/* phones and landscape phones: the voice picker comes up from the bottom edge like every other sheet */
@media (max-width: 640px), (pointer: coarse) and (max-height: 500px) {
  #vpDlg.sheet[open] { animation: fitSheet .3s var(--g-ease) both; }
}
@media (prefers-reduced-motion: reduce) { #vpDlg[open], .tpop.g-tpop.in { animation: none !important; } }

/* ---------- U6. Settings is a gear (the sun read as light / dark) -- the icon itself is in index.html ---------- */
.g-bar .setbtn svg { stroke-width: 1.7; }

/* ---------- U4. fingertip targets without a bigger look: transparent borders / negative margins ---------- */
/* phones and landscape phones (under the 80 % zoom: 50 page px = 40 on the screen) */
@media (pointer: coarse) and (max-width: 560px), (pointer: coarse) and (max-height: 500px) and (orientation: landscape) {
  .vp-search { height: 52px; }
  .vp-search input { height: 100%; }
  .vp-tabs button { min-width: 52px; }
  .vp-tabs select { height: 52px; }
  .vpick .vp-foot a { min-height: 52px; }
  .g-composer .g-lang { min-height: 52px; }
  .g-cread #scriptLang { height: 52px; border: 7px solid transparent; background-clip: padding-box; box-shadow: inset 0 0 0 1px var(--g-line); margin: -7px 0; }
  .g-sets .g-srand .auto { border-width: 17px; margin: -17px -17px -17px 0; }
  .g-voices .filters button { min-width: 52px; }
  #v-voices .g-voices .voicelist button.v { padding-top: 8px; padding-bottom: 8px; margin-top: -8px; margin-bottom: -8px; }
  .g-vrec .rec { width: 58px; height: 58px; border: 9px solid transparent; background-clip: padding-box; margin: -9px; }
}
/* tablets (touch, no zoom: 44 px) */
@media (pointer: coarse) and (min-width: 561px) and (min-height: 501px) {
  .g-voices .filters { column-gap: 2px; }
  .g-voices .filters button { height: 46px; border: 5px solid transparent; background-clip: padding-box; box-shadow: inset 0 0 0 1px var(--g-line); margin: -5px 0; }
  .g-voices .filters button[aria-pressed="true"] { border-color: transparent; box-shadow: none; }
  .g-sm { min-height: 44px; }
  .sitefoot a { min-width: 44px; justify-content: center; }
  .g-cread #scriptLang { height: 44px; border: 3px solid transparent; background-clip: padding-box; box-shadow: inset 0 0 0 1px var(--g-line); margin: -3px 0; }
}
/* the Sound tab's model radios: the whole card is the target; the dot gets a fingertip-size (invisible) ring too */
@media (pointer: coarse) {
  .g-model input[type="radio"] { -webkit-appearance: none; appearance: none; box-sizing: border-box; width: 52px; height: 52px; margin: -18px; flex: none;
    border: 18px solid transparent; border-radius: 50%; background: var(--g-card) padding-box; box-shadow: inset 0 0 0 1.5px #8a8a93; cursor: pointer; }
  .g-model input[type="radio"]:checked { box-shadow: inset 0 0 0 5px var(--ink); }
  .g-model input[type="radio"]:focus-visible { outline: 2px solid var(--red); outline-offset: -16px; }
}

/* ---------- U5. the footer on phones, landscape phones and narrow windows: tight rows, no link left alone on a line
   (balanced lines of atomic links: "What's new  Check a clip / Withdraw my recordings  Privacy  Terms"); each link is a
   finger-size target (padding + negative margin: the words sit where they would anyway). Fold modes keep their own line. */
@media (max-width: 900px), (pointer: coarse) and (max-height: 500px) and (orientation: landscape) {
  html:not([data-fold]) .sitefoot { display: block; text-wrap: balance; }
  html:not([data-fold]) .sitefoot > span { display: block; line-height: 1.45; padding: 2px 0 6px; }
  html:not([data-fold]) .sitefoot > a, html:not([data-fold]) .sitefoot .seolinks a { display: inline-block; min-height: 0; white-space: nowrap; vertical-align: top; line-height: 28px; }
  html:not([data-fold]) .sitefoot > a { padding: 0 10px; margin: 0 10px 0 -10px; }
  html:not([data-fold]) .sitefoot .seolinks { display: block; text-wrap: balance; margin: 6px 0 0; }
  html:not([data-fold]) .sitefoot .seolinks a { padding: 0 12px; margin: 0 4px 0 -12px; }
}
@media (pointer: coarse) and (max-width: 900px) {
  html:not([data-fold]) .sitefoot > a, html:not([data-fold]) .sitefoot .seolinks a { line-height: 44px; }
  html:not([data-fold]) .sitefoot .seolinks { margin-top: 0; }
}
@media (pointer: coarse) and (max-width: 560px), (pointer: coarse) and (max-height: 500px) and (orientation: landscape) {
  html:not([data-fold]) .sitefoot { padding-top: 18px; }
  html:not([data-fold]) .sitefoot > a, html:not([data-fold]) .sitefoot .seolinks a { line-height: 50px; }
  html:not([data-fold]) .sitefoot .seolinks a { font-size: 14px; }
}

/* ---------- the voice picker on a landscape phone: title, search and close on one row, the groups under it, so the
   list gets the height (it showed three and a half voices) ---------- */
@media (pointer: coarse) and (max-height: 500px) and (min-width: 520px) {
  #vpDlg.sheet[open] { width: min(760px, 100%); }
  #vpDlg.sheet .vp-top { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; column-gap: 16px; row-gap: 4px; padding: 8px 18px 6px; }
  #vpDlg.sheet .vp-sheethead { display: contents; }
  #vpDlg.sheet .vp-sheethead b { grid-row: 1; grid-column: 1; }
  #vpDlg.sheet .vp-search { grid-row: 1; grid-column: 2; }
  #vpDlg.sheet .vp-sheethead .dlg-x { grid-row: 1; grid-column: 3; margin: 0 -10px 0 -6px; }
  #vpDlg.sheet .vp-tabs { grid-row: 2; grid-column: 1 / -1; }
}

/* ---------- Voices on a phone: the language chips are one row you swipe (no lone "German" on a second line) ---------- */
@media (max-width: 640px) {
  #langFilter { flex-wrap: nowrap; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none; margin: 0 calc(-1 * var(--gutter));
    padding: 2px calc(var(--gutter) + 24px) 2px var(--gutter); scroll-padding: 0 var(--gutter);
    -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 40px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 40px), transparent); }
  #langFilter::-webkit-scrollbar { display: none; }
  #langFilter > button { flex: none; }
}

/* ---------- big screens (an ultrawide or a 4K screen at 100 %): one gentle step up, so the page isn't a small island in
   the middle (the column, type and controls all grow by the same 20 %; viewport units are divided by --pz as on phones) */
@media (pointer: fine) and (min-width: 3000px) and (min-height: 1300px) {
  html { zoom: 1.2; }
  :root { --pz: 1.2; }
}

/* ---------- the home status line ("Type something for Grey to say.", "In line · ..."): right above the box it's about,
   not stranded under the last take with the free room below it (portrait phones; landscape is builder L's layout) ---------- */
@media (max-width: 640px) {
  .stage.g-home:has(> #homeTakesBox:not([hidden])) > #sayStatus:not(:empty) { margin-top: auto; }
  .stage.g-home:has(> #homeTakesBox:not([hidden])):has(> #sayStatus:not(:empty)) > .g-composer { margin-top: 0; }
}

/* ---------- small things ---------- */
.dlg-x:focus-visible { outline-color: var(--ink); }  /* (a red ring on the X read as an error) */
@media (pointer: fine) {
  .vpick .vp-foot a { min-height: 26px; display: inline-flex; align-items: center; }
  .g-sets .g-srand .auto { min-height: 26px; }
}
/* the home language select reads as a control (a chevron, like the voice chip), not as plain text */
.g-composer .g-lang, .g-composer .g-lang:hover { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5 6 7.5 9 4.5' fill='none' stroke='%236b6b73' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 12px; padding-right: 28px; }
/* Settings: a soft shade at the top / bottom edge while there's more to scroll (it cut off mid-list with no hint) */
.g-sets .sets-body { background:
    linear-gradient(var(--g-card) 30%, transparent) center top / 100% 36px no-repeat local,
    linear-gradient(transparent, var(--g-card) 70%) center bottom / 100% 36px no-repeat local,
    radial-gradient(farthest-side at 50% 0, rgba(20, 20, 23, .10), transparent) center top / 100% 12px no-repeat scroll,
    radial-gradient(farthest-side at 50% 100%, rgba(20, 20, 23, .10), transparent) center bottom / 100% 12px no-repeat scroll; }
:root[data-scheme="dark"] .g-sets .sets-body { background:
    linear-gradient(#16161a 30%, transparent) center top / 100% 36px no-repeat local,
    linear-gradient(transparent, #16161a 70%) center bottom / 100% 36px no-repeat local,
    radial-gradient(farthest-side at 50% 0, rgba(0, 0, 0, .5), transparent) center top / 100% 12px no-repeat scroll,
    radial-gradient(farthest-side at 50% 100%, rgba(0, 0, 0, .5), transparent) center bottom / 100% 12px no-repeat scroll; }
/* a mouse: the take's play button answers the pointer like download does */
@media (hover: hover) { .g-take .g-play:hover { border-color: var(--g-text3); } }
/* page subtitles: no lone word on the last line */
.g-ptitle p, .page-head .lede, .g-vhead p, .g-hero .g-sub { text-wrap: pretty; }
/* Technology: thousands read "243,755", not "243 , 755" (tabular digits gave the comma a digit's width) */
.facts .fact b { font-variant-numeric: proportional-nums lining-nums; }

/* ---------- Technology and About end with their own footer: the site footer's quiet look, not red underlined links ---------- */
html body[data-view="tech"] .sitefoot, html body[data-view="about"] .sitefoot { display: none; }  /* (as grey2: they have their own) */
main .foot.wrap { color: var(--g-text3); font-size: 13px; column-gap: 20px; row-gap: 6px; align-items: center; justify-content: flex-start; }
main .foot.wrap > span { flex: 1 1 auto; }
main .foot.wrap > span:first-child { flex: 0 1 auto; }
main .foot.wrap a, main .foot.wrap a:not([class]) { color: var(--g-text3); text-decoration: none; }
@media (hover: hover) { main .foot.wrap a:hover { color: var(--ink); } }
@media (max-width: 900px), (pointer: coarse) and (max-height: 500px) and (orientation: landscape) {
  main .foot.wrap { display: block; text-wrap: balance; }
  main .foot.wrap > span { display: block; line-height: 1.45; padding: 2px 0; }
  main .foot.wrap > span + span { padding-bottom: 6px; }
  main .foot.wrap > a { display: inline-block; white-space: nowrap; vertical-align: top; line-height: 28px; padding: 0 10px; margin: 0 10px 0 -10px; }
}
@media (pointer: coarse) and (max-width: 900px) { main .foot.wrap > a { line-height: 44px; } }
@media (pointer: coarse) and (max-width: 560px), (pointer: coarse) and (max-height: 500px) and (orientation: landscape) {
  main .foot.wrap { font-size: 15px; }
  main .foot.wrap > a { line-height: 50px; }
}
/* dark mode: a switch that is on is the light one with a dark knob (on and off were two greys with the same white knob) */
:root[data-scheme="dark"] .switch input:checked + span { background: #ececef; }
:root[data-scheme="dark"] .switch input:checked + span::after { background: #16161a; box-shadow: none; }
#v-tech .page-head .lede { margin-bottom: 24px; }  /* (the lede sat right on the stats band's top rule) */
/* the training pill in the phone menu reads at the same size as What's new and Settings beside it (it was 10 px) */
@media (pointer: coarse) and (max-width: 560px), (pointer: coarse) and (max-height: 500px) and (orientation: landscape) {
  .g-bar.menu-open .trainpill:not([hidden]), .g-bar.menu-open .trainpill b { font-size: 15px; }
  .g-bar.menu-open .trainpill:not([hidden]) { padding: 0 14px; }
}

/* ---------- Design a voice: its main action looks like one (it was a small grey link at the far right) ---------- */
.g-dth { align-items: center; gap: 12px; }
.g-dth #designPreview { display: inline-flex; align-items: center; height: 40px; padding: 0 18px; border: 0; border-radius: 999px; background: #c8241f; color: #fff;
  font: 600 15px var(--body); text-decoration: none; cursor: pointer; flex: none; }
.g-dth #designPreview:disabled { background: #e3908d; cursor: default; }
@media (hover: hover) { .g-dth #designPreview:not(:disabled):hover { background: #b01f1b; color: #fff; } }
.g-dth #designPreview:active:not(:disabled) { transform: scale(.96); }
@media (pointer: coarse) { .g-dth #designPreview { height: 48px; padding: 0 20px; font-size: 16px; } }
@media (pointer: coarse) and (max-width: 560px), (pointer: coarse) and (max-height: 500px) and (orientation: landscape) {
  .g-dth #designPreview { height: 54px; font-size: 18px; padding: 0 22px; }
  .g-dactions .link { display: inline-flex; align-items: center; min-height: 50px; padding: 0 8px; margin: 0 -8px; }
  .g-dactions { column-gap: 22px; }
}
@media (pointer: coarse) and (min-width: 561px) and (min-height: 501px) {
  .g-dactions .link { display: inline-flex; align-items: center; min-height: 44px; padding: 0 6px; margin: 0 -6px; }
}
/* the design sliders: a finger-size hit area around the same thin track and label */
@media (pointer: coarse) {
  .g-dshape .sl input[type="range"] { height: 40px; margin: -11px 0; }
  .g-dshape .sl-top label { display: inline-block; padding: 13px 0; margin: -13px 0; }
}
@media (pointer: coarse) and (max-width: 560px), (pointer: coarse) and (max-height: 500px) and (orientation: landscape) {
  .g-dshape .sl input[type="range"] { height: 50px; margin: -16px 0; }
  .g-dshape .sl-top label { padding: 18px 0; margin: -18px 0; }
}
/* the open menu on a 280 px cover screen: training, What's new and Settings still share one row */
@media (max-width: 330px) {
  .g-bar.menu-open > .g-right { gap: 2px; }
  html .g-bar.menu-open .trainpill:not([hidden]) { padding: 0 10px; gap: 6px; }
  html .g-bar.menu-open .trainpill:not([hidden]), html .g-bar.menu-open .trainpill b, .g-bar.menu-open .g-newslink, .g-bar.menu-open .g-right .setbtn { font-size: 14px; }
  .g-bar.menu-open .g-newslink { padding-left: 4px; padding-right: 4px; }
  .g-bar.menu-open .g-right .setbtn { padding: 0 4px 0 4px; gap: 6px; }
}
/* a phone sheet with a text field (Withdraw's code, Settings' private key): on iOS the keyboard only covers the page, so
   the sheet rides up by the keyboard's height (--kb from next.js; 0 where the browser resizes the page itself) */
@media (max-width: 640px) {
  html.kb dialog.dlg:not(#vpDlg)[open] { margin-bottom: var(--kb); max-height: calc(92 * var(--vh) / 100 / var(--pz) - var(--kb)); }
}
