/* 文本翻译 on the workspace system. Colours, type, shape and motion come from the --ws-* tokens
   (workspace-tokens.css); the heading, card, buttons, fields, switch and menu are the ws-* components
   (workspace-ui.css), which load just before this file. What is left here is particular to this page:
   the frame, the two-pane translation card, the 朗读 menus, the status line and the footnote.
   It replaces what brand-workspace-v44.css and workspace-refinement-v1.css did on /text.
   Every rule hangs off body.app-page.text-page. workspace-ui.css rounds every button and field to
   --r-control with !important, so that variable is set locally instead of fighting it.
   product-v10.css styles a few of these elements by ID (#text-status), so the matching rules here
   carry the ID too. */

/* ---------- Frame ---------- */
/* The legacy palette remap, the 1560px frame and the header's 开始翻译 stepping aside on desktop are shared
   (workspace-ui.css); the one solid-blue button on this page is 翻译. */
body.app-page.text-page .app-main{padding:24px clamp(16px,2.5vw,32px) 32px}

/* Icons are masks, so they follow the text colour in both themes. */
body.app-page.text-page .tx-i{display:inline-block;flex:none;width:18px;height:18px;background:currentColor;-webkit-mask:var(--i) center/contain no-repeat;mask:var(--i) center/contain no-repeat}
body.app-page.text-page .tx-sr{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}

/* ---------- Heading: 字号 and 专注阅读 on the right ---------- */
body.app-page.text-page .tx-size{display:inline-flex;align-items:center;gap:8px;margin:0;color:var(--ws-text-2);font-size:13px;white-space:nowrap}
body.app-page.text-page .tx-size .ws-select{width:auto;margin:0;font-size:13px}
/* reading-view-v1.js rewrites this button's text (专注阅读 / 退出专注), so the icon is drawn on the button
   itself and the words stay its accessible name without taking space. */
body.app-page.text-page .tx-focus{font-size:0}
body.app-page.text-page .tx-focus::before{content:"";width:18px;height:18px;background:currentColor;-webkit-mask:url(/vendor/lucide/book-open.svg) center/contain no-repeat;mask:url(/vendor/lucide/book-open.svg) center/contain no-repeat}

/* ---------- The card: languages on top, then source and translation side by side ---------- */
body.app-page.text-page .tx-card{position:relative;overflow:visible}
body.app-page.text-page .tx-bar{display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:8px 16px;padding:10px 14px 10px 12px;border-bottom:.5px solid var(--ws-line)}
body.app-page.text-page .tx-langs{display:flex;align-items:center;gap:4px;min-width:0}
body.app-page.text-page .tx-lang{display:block;min-width:0;margin:0}
body.app-page.text-page .tx-lang .ws-select{width:min(190px,34vw);margin:0}
body.app-page.text-page .tx-auto{margin-left:auto;color:var(--ws-text-2);white-space:nowrap}

body.app-page.text-page .tx-panes{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr)}
body.app-page.text-page .tx-pane{position:relative;display:flex;flex-direction:column;min-width:0}
body.app-page.text-page .tx-pane--source{border-radius:0 0 0 var(--ws-radius-card)}
body.app-page.text-page .tx-pane--target{border-left:.5px solid var(--ws-line);border-radius:0 0 var(--ws-radius-card) 0;background:var(--ws-surface-2)}
/* The text areas have no frame of their own. Their focus cue is a solid --ws-accent-text ring (over 3:1 on
   --ws-surface and --ws-surface-2 in both themes), drawn inset because the card's hairline sits right outside.
   The textarea draws it itself; where :has() works, the pane draws it instead, so it follows the pane's corners.
   A browser without :has() drops both :has() rules and keeps the textarea's own ring. */
body.app-page.text-page .tx-pane:has(.tx-text:focus-visible){box-shadow:inset 0 0 0 2px var(--ws-accent-text)}
body.app-page.text-page .tx-text{--r-control:0;display:block;flex:1 1 auto;box-sizing:border-box;width:100%;height:clamp(240px,calc(100dvh - 380px),640px);min-height:0;max-height:none;margin:0;padding:16px 18px 8px;border:0;border-radius:0;background:transparent;box-shadow:none;color:var(--ws-text);font-family:var(--ws-font);font-size:18px;font-weight:400;line-height:1.7;resize:none;overflow:auto}
body.app-page.text-page .tx-text:focus{outline:none;box-shadow:none}
body.app-page.text-page .tx-text:focus-visible{outline:none;box-shadow:inset 0 0 0 2px var(--ws-accent-text)}
body.app-page.text-page .tx-pane:has(.tx-text:focus-visible) .tx-text:focus-visible{box-shadow:none}
body.app-page.text-page .tx-text::placeholder{color:var(--ws-text-3);opacity:1}
body.app-page.text-page[data-reading-size=normal] .tx-text{font-size:15px}
body.app-page.text-page[data-reading-size=xlarge] .tx-text{font-size:24px;line-height:1.6}

/* While the translation is written, faint lines take its place. */
body.app-page.text-page #text-output[aria-busy=true]{color:transparent;background:
 linear-gradient(var(--ws-line),var(--ws-line)) 18px 22px/calc(100% - 36px) 10px no-repeat,
 linear-gradient(var(--ws-line),var(--ws-line)) 18px 46px/calc(88% - 36px) 10px no-repeat,
 linear-gradient(var(--ws-line),var(--ws-line)) 18px 70px/calc(62% - 36px) 10px no-repeat;
 animation:tx-pulse 1.4s ease-in-out infinite}
body.app-page.text-page #text-output[aria-busy=true]::placeholder{color:transparent}
body.app-page.text-page .text-result-panel[aria-busy=true]::after{content:none}
@keyframes tx-pulse{50%{opacity:.5}}

/* Foot of each pane: icon buttons on the left; count and 翻译, or the state, on the right. */
body.app-page.text-page .tx-foot{display:flex;align-items:center;gap:2px;min-height:50px;padding:6px 10px 10px}
body.app-page.text-page .tx-foot .tx-i{width:17px;height:17px}
/* Copied: the icon is a tick for 2.5 seconds (text-product-v10.js). The base rule draws var(--i) through the mask
   shorthand and the icon is set inline, so the tick replaces the mask image itself. */
body.app-page.text-page .ws-icon-btn.is-copied{color:var(--ws-success)}
body.app-page.text-page .is-copied .tx-i{-webkit-mask-image:url(/vendor/lucide/check.svg);mask-image:url(/vendor/lucide/check.svg)}
body.app-page.text-page .tx-count{margin-left:auto;padding:0 8px;color:var(--ws-text-2);font-size:12px;font-variant-numeric:tabular-nums;white-space:nowrap}
/* 翻译 and 停止 swap in place at one width; polish.css sizes #text-submit by ID, so this rule names the IDs too. */
body.app-page.text-page :is(#text-submit,#text-stop).tx-go{margin-left:6px;min-width:7.5em}
body.app-page.text-page .tx-go .tx-i{width:13px;height:13px}
body.app-page.text-page .tx-kbd{margin:0 0 0 2px;padding:0;border:0;background:none;color:inherit;font-family:var(--ws-font);font-size:12px;font-weight:400;line-height:1;opacity:.8}
body.app-page.text-page .tx-meta{display:flex;align-items:center;gap:6px;min-width:0;margin-left:auto;padding:0 6px;overflow:hidden;color:var(--ws-text-2);font-size:12px;white-space:nowrap;text-overflow:ellipsis}

/* 朗读: the button opens a small menu above it with read, stop and speed. While reading, the button turns blue. */
body.app-page.text-page .tx-read{position:relative;display:inline-flex}
body.app-page.text-page .tx-read:has([id$="-read-stop"]:not(:disabled))>.ws-icon-btn{color:var(--ws-accent-text)}
body.app-page.text-page .tx-read-menu{position:absolute;z-index:30;bottom:calc(100% + 6px);left:0;min-width:230px}
body.app-page.text-page .tx-read-menu .tx-i{width:16px;height:16px;color:var(--ws-text-2)}
body.app-page.text-page .tx-read-menu>button:disabled{opacity:.45;cursor:not-allowed}
body.app-page.text-page .tx-rate{display:flex;align-items:center;justify-content:space-between;gap:12px;margin:0;padding:2px 2px 2px 10px;color:var(--ws-text);font-size:14px;white-space:nowrap}
body.app-page.text-page .tx-rate .ws-select{width:auto;height:30px;min-height:30px;margin:0;font-size:13px}
body.app-page.text-page .tx-read-status{margin:0;padding:6px 10px 2px;color:var(--ws-text-2);font-size:12px;line-height:1.5}
body.app-page.text-page .tx-read-status:empty{display:none}

/* ---------- Under the card: the status line, then one line of notes ---------- */
body.app-page.text-page #text-status{min-height:1.5em;margin:10px 2px 0;color:var(--ws-text-2);font-size:13px;line-height:1.5}
body.app-page.text-page #text-status[data-error=true]{color:var(--ws-danger)}
body.app-page.text-page .text-footnote{margin:2px 2px 0;color:var(--ws-text-2);font-size:12px;line-height:1.5}

/* ---------- 专注阅读: header, sidebar and title step aside; the text areas take the height ---------- */
body.app-page.text-page.reading-focus .app-main{padding:16px clamp(16px,2.5vw,32px) 24px}
body.app-page.text-page.reading-focus .tx-head__text{display:none}
/* product-v10.css hides .page-heading in focus mode; here the heading keeps its tools, so 退出专注 stays in reach. */
body.app-page.text-page.reading-focus .tx-head{display:flex;justify-content:flex-end}
body.app-page.text-page.reading-focus .tx-text{height:calc(100dvh - 250px);min-height:240px}

/* ---------- Phones: the panes stack ---------- */
/* A tablet held upright has height to spare: the two panes drop the 640px cap and fill it. */
@media (orientation:portrait) and (min-width:768px){
 body.app-page.text-page .tx-text{height:max(240px,calc(100dvh - 380px))}
}
@media(max-width:767px){
 body.app-page.text-page .app-main{padding:16px 16px calc(24px + env(safe-area-inset-bottom))}
 /* Touch target: the speed picker in the 朗读 menu. */
 body.app-page.text-page .tx-rate .ws-select{height:44px;min-height:44px}
 body.app-page.text-page .tx-bar{padding:10px}
 body.app-page.text-page .tx-langs{flex:1 1 100%}
 body.app-page.text-page .tx-lang{flex:1}
 body.app-page.text-page .tx-lang .ws-select{width:100%}
 body.app-page.text-page .tx-panes{grid-template-columns:minmax(0,1fr)}
 body.app-page.text-page .tx-pane--source{border-radius:0}
 body.app-page.text-page .tx-pane--target{border-left:0;border-top:.5px solid var(--ws-line);border-radius:0 0 var(--ws-radius-card) var(--ws-radius-card)}
 body.app-page.text-page .tx-text{height:clamp(180px,32dvh,280px);padding:14px 14px 6px}
 /* With 44px buttons and a long character count the row can outgrow a phone: then 翻译 takes the next line, at the right. */
 body.app-page.text-page .tx-foot{flex-wrap:wrap;justify-content:flex-end;row-gap:4px;padding:6px 8px 8px}
 body.app-page.text-page .tx-kbd{display:none}
 body.app-page.text-page.reading-focus .tx-text{height:clamp(200px,38dvh,360px)}
}

/* ---------- Reduced motion: everything switches instantly ---------- */
@media(prefers-reduced-motion:reduce){
 body.app-page.text-page #text-output[aria-busy=true]{transition:none;animation:none}
}
