:root{--ink:#293128;--green:#536b43;--green-dark:#35472f;--green-soft:#edf1e6;--red:#a44636;--gold:#b78b4d;--paper:#faf9f1;--panel:rgba(255,255,250,.96);--line:#dedfd3;--muted:#656b60;--shadow:0 16px 48px rgba(39,53,35,.12);font-family:'Be Vietnam Pro','Segoe UI',sans-serif;color:var(--ink);background:#ece9d9 center top/cover fixed no-repeat;background-image:url('/background.jpg');background-image:image-set(url('/background.avif') type('image/avif'),url('/background.webp') type('image/webp'),url('/background.jpg') type('image/jpeg'));font-size:14px;line-height:1.6}
*{box-sizing:border-box}html{scroll-padding-top:110px;scrollbar-color:#788c55 #eeeddf}body{margin:0;min-height:100vh;background:linear-gradient(180deg,rgba(250,249,241,.18),rgba(248,247,238,.82) 42%,rgba(248,247,238,.96))}button,input,textarea,select{font:inherit;color:inherit}button,a{cursor:pointer}a{color:inherit;text-decoration:none}button{border:1px solid var(--line);border-radius:10px;background:#fff;padding:11px 16px;font-weight:600;transition:transform .2s ease,border-color .2s ease,box-shadow .2s ease,background .2s ease}button:hover:not(:disabled){transform:translateY(-2px);border-color:#9eab8f;box-shadow:0 7px 18px rgba(48,65,41,.12)}button:disabled{opacity:.48;cursor:not-allowed}.primary{background:var(--red);border-color:var(--red);color:#fff;display:flex;align-items:center;justify-content:center;gap:14px}.primary:hover:not(:disabled){background:#913d30;border-color:#913d30}.primary span{font-size:18px}.top{position:sticky;top:0;z-index:20;display:grid;grid-template-columns:auto 1fr auto;align-items:center;gap:28px;min-height:92px;padding:16px max(24px,calc((100vw - 1240px)/2));background:rgba(250,249,241,.94);border-top:3px solid #3c403a;border-bottom:1px solid rgba(164,70,54,.28);backdrop-filter:blur(14px);box-shadow:0 5px 22px rgba(48,61,42,.08)}.brand{display:flex;align-items:center;gap:12px}.brand img{width:43px;height:43px}.brand strong{display:block;font-size:25px;line-height:1.2;font-weight:700;color:#35432d}.brand-dot{color:var(--red)}.brand small{display:block;margin-top:5px;color:#676a61;font-size:12px;letter-spacing:1.7px}.masthead{text-align:center;color:#5e6f4b;font:500 21px 'Noto Serif',serif;letter-spacing:.04em}.masthead:before,.masthead:after{content:'';display:inline-block;width:42px;height:1px;margin:0 16px 6px;background:#9aaa86}.top nav{display:flex;align-items:center;gap:10px}.top nav a{padding:10px 13px;border-radius:9px;color:#50594b;font-size:12px}.top nav a:hover{background:rgba(237,241,230,.9);color:var(--green-dark)}.nav-account{border:1px solid var(--line);background:#fffdf8}main{width:min(1240px,calc(100% - 40px));margin:0 auto;padding:28px 0 80px}.hero{position:relative;display:grid;grid-template-columns:minmax(0,1fr);gap:18px 30px;padding:24px 34px 20px;border:1px solid rgba(222,223,211,.95);border-radius:18px 18px 0 0;background:#faf9f1;box-shadow:var(--shadow);overflow:hidden}.hero:after{content:'譯';position:absolute;right:3%;bottom:-85px;color:rgba(83,107,67,.045);font:700 250px 'Noto Serif',serif;pointer-events:none}.eyebrow{margin:0 0 9px;color:var(--red);font-size:12px;font-weight:700;letter-spacing:.19em}.hero h1{margin:0;color:#283127;font:600 clamp(24px,2.6vw,34px)/1.3 'Noto Serif',serif;letter-spacing:-.035em}.hero h1 em{color:var(--green);font-style:normal}.hero-copy>p:last-child{max-width:760px;margin:10px 0 0;color:#646c60;line-height:1.85}.account-status{grid-column:1/-1;position:relative;z-index:1;margin-top:2px;padding:11px 14px;border-left:3px solid #869b72;background:rgba(237,241,230,.72);color:#526449;font-size:12px}.account-status a{color:var(--red);font-weight:700;text-decoration:underline;text-underline-offset:3px}.workflow{display:grid;grid-template-columns:repeat(3,1fr);gap:0;margin:0 0 22px;padding:0 24px;list-style:none;border:1px solid var(--line);border-top:0;border-radius:0 0 14px 14px;background:rgba(255,255,250,.95);box-shadow:0 9px 24px rgba(39,53,35,.07)}.workflow li{display:flex;align-items:center;gap:12px;padding:12px 22px;border-right:1px solid #e7e7de}.workflow li:last-child{border:0}.workflow li>span{display:grid;place-items:center;width:29px;height:29px;border:1px solid #d8ddcf;border-radius:50%;color:#636c5b;font-size:12px}.workflow li.active>span{background:var(--red);border-color:var(--red);color:#fff}.workflow strong,.workflow small{display:block}.workflow strong{font-size:12px}.workflow small{margin-top:2px;color:#686a64;font-size:12px}.workspace{display:grid;grid-template-columns:minmax(0,1.35fr) minmax(340px,.8fr);gap:22px}.panel{border:1px solid rgba(218,220,207,.98);border-radius:14px;background:var(--panel);box-shadow:0 10px 32px rgba(38,52,35,.07);overflow:hidden}.source-panel,.controls{padding:26px}.panel-head{display:flex;align-items:center;gap:14px;margin:-2px 0 23px}.panel-head h2{margin:0;font-size:20px;line-height:1.35}.panel-head .eyebrow{margin-bottom:2px}.step-number{display:grid;place-items:center;width:42px;height:42px;flex:0 0 42px;border-radius:12px;background:#f2ede4;color:#856338;font:600 13px 'Noto Serif',serif}.file-picker{display:grid;grid-template-columns:52px 1fr auto;align-items:center;gap:16px;min-height:116px;padding:20px;border:1px dashed #aab59c;border-radius:13px;background:linear-gradient(135deg,#fbfcf7,#f4f6ee);cursor:pointer;transition:border-color .2s ease,box-shadow .2s ease,background .2s ease}.file-picker:hover{border-color:#778e62;background:#f3f7ec;box-shadow:inset 0 0 0 1px rgba(119,142,98,.15)}.upload-icon{display:grid;place-items:center;width:52px;height:52px;border:1px solid #d8ded0;border-radius:13px;background:#fff;color:var(--green);font-size:26px}.upload-copy strong,.upload-copy small{display:block}.upload-copy strong{font-size:14px}.upload-copy small{margin-top:5px;color:#666a5f;font-size:12px}.format-tags{display:flex;flex-wrap:wrap;justify-content:flex-end;gap:5px;max-width:135px}.format-tags i{padding:3px 6px;border:1px solid #dfe2d7;border-radius:4px;background:#fff;color:#666b60;font-size:12px;font-style:normal;letter-spacing:.05em}.file-picker input{position:absolute;width:1px;height:1px;opacity:0;pointer-events:none}.file-picker:has(input:focus-visible){outline:3px solid #536b43;outline-offset:3px}.hint{margin:8px 0;color:var(--muted);font-size:12px;line-height:1.75}.status-note{min-height:22px;margin:13px 2px}.field-heading{display:flex;align-items:end;justify-content:space-between;gap:20px;margin:18px 0 8px}.field-heading label,.controls>label,.control-group>label{font-size:12px;font-weight:700}.metrics{display:flex;gap:14px;color:#666b60;font-size:12px}.panel textarea,.panel input,.panel select{width:100%;margin-top:8px;padding:12px 13px;border:1px solid #d9dbd1;border-radius:9px;background:#fff;color:#30372e;outline:none}.panel textarea:hover,.panel input:hover,.panel select:hover{border-color:#aab59c}.panel textarea:focus,.panel input:focus,.panel select:focus{border-color:#758f5e;box-shadow:0 0 0 4px rgba(117,143,94,.12)}#source{min-height:440px;resize:vertical;font:15px/1.85 'Noto Serif',serif}#glossary{min-height:118px;resize:vertical;line-height:1.7}.pdf-range{margin:14px 0;padding:14px;border:1px solid #dce1d4;border-radius:10px;background:#f5f7f0}.pdf-range label{font-size:12px;font-weight:700}.controls{align-self:start}.control-group{padding:16px;border:1px solid #e0e3d8;border-radius:11px;background:#fafbf7}.required{float:right;padding:2px 7px;border-radius:10px;background:#f4e7e3;color:#a14838;font-size:12px;letter-spacing:.06em;text-transform:uppercase}.key-line{display:flex;gap:7px}.key-line input{min-width:0}.key-line button{margin-top:8px;padding-inline:13px}.backup-keys:empty{display:none}.add-key{display:block;margin:8px 0 2px;padding-inline:13px}.add-key[hidden]{display:none}.key-status{padding-left:10px;border-left:3px solid #8fa27b}.privacy-note{margin:12px 0 0;padding-top:11px;border-top:1px solid #e4e6de;color:#666b61;font-size:12px;line-height:1.7}.control-grid{display:grid;grid-template-columns:1fr 1fr;gap:11px;margin-top:18px}.control-grid label{font-size:12px;font-weight:700;color:#626b5c}.controls>label{display:block;margin-top:17px}.controls>label small{float:right;color:#676a64;font-size:12px;font-weight:500}.actions{display:flex;flex-wrap:wrap;gap:8px;margin-top:20px}.actions .primary{flex:1;min-height:46px}.progress-box{display:flex;align-items:flex-start;gap:10px;margin-top:14px;padding:12px 13px;border:1px solid #e3e6da;border-radius:10px;background:#f8f9f4}.progress-mark{color:var(--gold)}
.growth{display:flex;align-items:center;gap:6px;flex:0 0 auto;margin:-4px 2px -4px -4px}.growth[hidden]{display:none}.progress-box.growing .progress-mark{display:none}.progress-box.growing{align-items:center}
.growth-tree{width:58px;height:58px;overflow:visible}.growth-tree [data-grow]{--t:0;transition:transform .9s cubic-bezier(.2,.7,.2,1),opacity .9s ease,stroke-dashoffset .9s ease}
.g-soil{fill:#ddd1b2}.g-seed{fill:#9b7a4e;opacity:calc(1 - var(--t))}.g-sprout{fill:#7fa25a;stroke:#5f7f45;stroke-width:.6;transform-box:fill-box;transform-origin:50% 100%;transform:scale(var(--t));opacity:calc(var(--t) * var(--f,1))}
.g-trunk{fill:#7b5b3b;transform-box:fill-box;transform-origin:50% 100%;transform:scaleY(var(--t))}.g-branch{fill:none;stroke:#7b5b3b;stroke-width:1.8;stroke-linecap:round;stroke-dasharray:1;stroke-dashoffset:calc(1 - var(--t));opacity:var(--t)}
.g-leaf{transform-box:fill-box;transform-origin:50% 50%;transform:scale(var(--t));opacity:var(--t)}.g-leaf-a{fill:#6f904f}.g-leaf-b{fill:#86a865}.g-leaf-c{fill:#536b43}
.g-flower{fill:#ef9fb4;stroke:#fff;stroke-width:.7;transform-box:fill-box;transform-origin:50% 50%;transform:scale(var(--t));opacity:var(--t)}
.g-crown{transform-box:fill-box;transform-origin:50% 100%}.growth.running .g-crown{animation:growth-sway 3.4s ease-in-out infinite}@keyframes growth-sway{0%,100%{transform:rotate(-1.6deg)}50%{transform:rotate(1.6deg)}}
.growth-percent{min-width:3.1em;color:var(--green-dark);font-size:19px;font-weight:800;font-variant-numeric:tabular-nums;line-height:1}.growth.done .growth-percent{color:var(--red)}#progress{min-height:21px;margin:0;color:#53674b;font-size:12px;line-height:1.75}#progress.error{width:100%;color:#9c382f}.usage{display:grid;grid-template-columns:auto 1fr;gap:0 12px;align-items:center;margin-top:12px;padding:13px 15px;border-radius:10px;background:#303c31;color:#f4f2e8}.usage strong{grid-row:1/3;font:600 28px 'Noto Serif',serif;color:#d8bd82}.usage span{font-size:12px}.usage small{color:#b9c1b5;font-size:12px}.result{margin-top:22px;padding:26px}.result-head{display:grid;grid-template-columns:42px 1fr auto}.result-head button{align-self:center}.result-head .hint{margin:3px 0 0}#translation{min-height:390px;resize:vertical;padding:28px;background:#fbf5e8;font:17px/2 'Noto Serif',serif}.warnings{display:none;margin:14px 0 0;padding:13px 15px;border:1px solid #ecd6ab;border-radius:9px;background:#fff8e9;color:#876333;font-size:12px;white-space:pre-wrap}.warnings:not(:empty){display:block}.evaluation{margin-top:22px;border-top:1px solid #e0e1d8}.evaluation summary{display:flex;align-items:center;justify-content:space-between;gap:20px;padding:18px 4px 2px;cursor:pointer}.evaluation summary span{font-weight:700}.evaluation summary small{color:#666a63;font-size:12px}.evaluation-body{padding:20px 0 2px}.evaluation-body>label{font-size:12px;font-weight:700}.evaluation #reference{min-height:180px;resize:vertical}.evaluation-result{display:grid;gap:4px;margin-top:14px;padding:14px;border-radius:9px;background:#f0f4eb;color:#40553c}.evaluation-result:empty{display:none}.evaluation-result strong{font-size:17px}.evaluation-result small{color:#636c5f}footer:not(.site-footer){padding:24px;text-align:center;border-top:1px solid rgba(218,220,207,.85);background:rgba(250,249,241,.9);color:#656a5f;font-size:12px;letter-spacing:.06em}footer:not(.site-footer) span{margin:0 7px;color:var(--red)}#api-key[aria-invalid=true]{border-color:#b64a3b;box-shadow:0 0 0 4px rgba(182,74,59,.12)}
@supports selector(::-webkit-scrollbar){::-webkit-scrollbar{width:14px;height:14px}::-webkit-scrollbar-track{background:#eeeddf;border-left:1px solid #d8ddc7}::-webkit-scrollbar-thumb{min-height:50px;border:3px solid #eeeddf;border-radius:12px;background:repeating-linear-gradient(to bottom,transparent 0 29px,#445e34 29px 31px,#b3c48a 31px 33px,transparent 33px 62px),linear-gradient(to right,#546c3e,#9eaf73 45%,#738a50 75%,#506b3b);background-clip:padding-box}}
@media(max-width:950px){.top{grid-template-columns:auto 1fr}.masthead{display:none}.workspace{grid-template-columns:1fr}.controls{align-self:auto}.hero{grid-template-columns:1fr}.workflow{padding:0}.workflow li{padding:15px}.result-head{grid-template-columns:42px 1fr}.result-head button{grid-column:1/-1;margin-top:12px}.result-actions{grid-column:1/-1;flex-wrap:wrap;margin-top:12px}}
@media(max-width:680px){main{width:min(100% - 20px,1240px);padding-top:24px}.top{min-height:78px;padding:12px 16px;gap:10px}.brand img{width:38px}.brand strong{font-size:21px}.brand small{letter-spacing:1px}.top nav{margin-left:auto}.top nav a{padding:8px;font-size:12px}.top nav a:first-child{display:none}.hero{padding:27px 22px}.hero h1{font-size:32px}.workflow{grid-template-columns:1fr}.workflow li{display:none}.workflow li.active{display:flex;border:0}.source-panel,.controls,.result{padding:20px 16px}.file-picker{grid-template-columns:44px 1fr;padding:16px}.upload-icon{width:44px;height:44px}.format-tags{grid-column:1/-1;justify-content:flex-start;max-width:none}.field-heading{align-items:flex-start;flex-direction:column;gap:5px}.metrics{width:100%;justify-content:space-between}.control-grid{grid-template-columns:1fr}.result-head{grid-template-columns:38px 1fr}.step-number{width:38px;height:38px;flex-basis:38px}#source{min-height:350px}#translation{min-height:350px;padding:20px;font-size:16px}.evaluation summary{align-items:flex-start;flex-direction:column;gap:2px}}
@media(prefers-reduced-motion:reduce){*,*:before,*:after{scroll-behavior:auto!important;transition:none!important;animation:none!important}button:hover{transform:none!important}}
.workflow li.done>span{border-color:#7c9168;background:#e8eee0;color:#516843}.workflow li.done strong{color:#52654a}
.translation-parts{display:grid;gap:12px;margin:4px 0 18px}.translation-part{border:1px solid #e0e1d7;border-radius:11px;background:#fff;overflow:hidden}.translation-part summary{display:flex;align-items:center;justify-content:space-between;gap:20px;padding:14px 16px;cursor:pointer;list-style:none}.translation-part summary::-webkit-details-marker{display:none}.translation-part summary span{font-size:12px;font-weight:700}.translation-part summary small{padding:3px 8px;border-radius:999px;background:#f1f2eb;color:#666a61;font-size:12px}.translation-part.working{border-color:#cbae76;box-shadow:0 0 0 3px rgba(183,139,77,.1)}.translation-part.working summary{background:#fff9ec}.translation-part.working summary small{background:#f6e9cf;color:#856431}.translation-part.done{border-color:#ccd8c1}.translation-part.done summary{background:#f5f8f1}.translation-part.done summary small{background:#e3edda;color:#526c45}.translation-part.failed{border-color:#e3b7ae}.translation-part.failed summary{background:#fff3f0}.translation-part.failed summary small{background:#f7ded8;color:#9c493b}.translation-part-text{padding:20px 22px;border-top:1px solid #e5e6dd;background:#fcfaf3;font:16px/1.95 'Noto Serif',serif;white-space:pre-wrap;overflow-wrap:anywhere}.translation-part.queued:not([open]) .translation-part-text{color:#676b63}.combined-output{margin-top:18px;border:1px solid #e0e1d8;border-radius:11px;background:#fafbf7;overflow:hidden}.combined-output>summary{display:flex;align-items:center;justify-content:space-between;gap:20px;padding:14px 16px;cursor:pointer}.combined-output>summary span{font-size:12px;font-weight:700}.combined-output>summary small{color:#676b63;font-size:12px}.combined-output #translation{display:block;margin:0;border:0;border-top:1px solid #e0e1d8;border-radius:0;box-shadow:none}
@media(max-width:680px){.translation-part summary,.combined-output>summary{align-items:flex-start;flex-direction:column;gap:5px}.translation-part-text{padding:17px 15px;font-size:15px}}
.result-actions{display:flex;align-items:center;gap:8px}.download-menu{position:relative}.download-list{position:absolute;top:calc(100% + 6px);right:0;z-index:30;display:flex;flex-direction:column;gap:6px;min-width:220px;padding:8px;border:1px solid var(--line);border-radius:12px;background:#fff;box-shadow:0 12px 28px rgba(48,65,41,.16)}.download-list[hidden]{display:none}.result-head .download-list button{width:100%;margin:0;text-align:left;white-space:nowrap}.source-figures{margin:4px 0 20px;padding:18px;border:1px solid #dce1d4;border-radius:12px;background:linear-gradient(135deg,#f7f8f1,#fffdf8)}.source-figures-head{display:flex;align-items:end;justify-content:space-between;gap:24px;margin-bottom:14px}.source-figures-head h3{margin:0;color:#34422f;font:600 18px 'Noto Serif',serif}.source-figures-head .eyebrow{margin-bottom:3px}.source-figures-head small{max-width:380px;color:#656c60;font-size:12px;text-align:right}.source-figure-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(170px,1fr));gap:12px}.source-figure-grid figure{margin:0;padding:7px;border:1px solid #dfe2d7;border-radius:10px;background:#fff;box-shadow:0 5px 16px rgba(44,58,39,.06)}.source-figure-grid img{display:block;width:100%;aspect-ratio:3/4;object-fit:contain;border-radius:6px;background:#f3f1e8}.source-figure-grid figcaption{padding:7px 3px 2px;color:#5e6d55;font-size:12px;font-weight:700}.source-figure-grid figure:hover{border-color:#93a582;box-shadow:0 9px 22px rgba(44,58,39,.11);transform:translateY(-2px)}.source-figure-grid figure{transition:transform .18s ease,box-shadow .18s ease,border-color .18s ease}
@media(max-width:950px){.download-list{right:auto;left:0}}
@media(max-width:680px){.result-actions{grid-column:1/-1;flex-wrap:wrap;margin-top:12px}.source-figures-head{align-items:flex-start;flex-direction:column;gap:5px}.source-figures-head small{text-align:left}.source-figure-grid{grid-template-columns:repeat(2,minmax(0,1fr))}}
.pdf-range small{display:block;margin-top:8px;color:#616d57;font-size:12px;line-height:1.7}
.file-picker{position:relative}.file-picker input[type=file]{width:1px;height:1px;margin:0;padding:0;border:0;clip-path:inset(50%)}
.source-figures>summary{cursor:pointer;color:#40583a;font-size:12px;font-weight:700}.source-figures[open]>.source-figures-head{margin-top:12px}
.workspace>*,.hero>*,.result-head>*{min-width:0}.translation-pair.has-original{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);align-items:start}.part-originals{min-width:0;padding:18px;background:#edf0e6;border-top:1px solid #e5e6dd}.aligned-original{margin:0 0 18px}.aligned-original:last-child{margin-bottom:0}.page-canvas{position:relative;background:#fff;border:1px solid #d4dacc;border-radius:6px;overflow:hidden}.page-canvas img{display:block;width:100%;height:auto}.aligned-original figcaption{margin-top:9px;color:#4c6342;font-size:12px;font-weight:700}.region-description{min-height:2.8em;margin:7px 0 0;color:#616d59;font-size:12px;line-height:1.6;overflow-wrap:anywhere}
.page-canvas .ocr-region{position:absolute;min-width:0;min-height:0;padding:0;border:1px solid transparent;border-radius:1px;background:transparent;box-shadow:none;transform:none;transition:background .12s,border-color .12s}.page-canvas .ocr-region:hover,.page-canvas .ocr-region:focus-visible{border-color:#688c4c;background:rgba(147,179,112,.16);outline:2px solid rgba(104,140,76,.25);z-index:1}.translation-pair.has-original>.translation-part-text{min-width:0;border-left:1px solid #e0e5d7;align-self:stretch}.translation-pair.has-original>.translation-part-text{font-size:15px;line-height:1.9}
@media(max-width:760px){.translation-pair.has-original{grid-template-columns:1fr}.translation-pair.has-original>.translation-part-text{border-left:0}.part-originals{padding:14px}.page-canvas{max-width:480px;margin:auto}}
.translation-part>summary:before{content:'⌄';color:#606e54;font-size:16px;transform:rotate(-90deg);transition:transform .15s}.translation-part[open]>summary:before{transform:rotate(0)}.translation-part>summary span{flex:1}.translation-part>summary{gap:12px;padding:16px 20px}.part-toolbar{display:flex;align-items:center;justify-content:space-between;gap:14px;padding:13px 24px;border-top:1px solid #e3e7da;background:#fffef9}.reading-label{font-size:12px;font-weight:700;letter-spacing:.12em;color:#626c59}.compare-toggle{padding:7px 12px;font-size:12px;background:#f7f9f1;border-color:#dce2d3}.compare-toggle[aria-expanded=true]{background:#edf2e5;color:#405c32;border-color:#a8b99a}.translation-pair.has-original{display:block}.translation-pair>.part-originals{display:none}.translation-pair.has-original>.translation-part-text{border-left:0;font-size:16px}.translation-part-text{padding:30px 40px;background:#fffdf7;white-space:normal;border-top:1px solid #edf0e5}.translation-pair.comparing{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1.12fr);align-items:start}.translation-pair.comparing>.part-originals{display:block}.translation-pair.comparing>.translation-part-text{padding:26px 28px;border-left:1px solid #e0e5d7}.translation-pair.comparing .translation-document{font-size:15px}.translation-part.done{box-shadow:0 3px 12px rgba(39,53,35,.035)}.translation-part.done>summary{background:#f1f5eb}.translation-part .part-toolbar button:focus-visible{outline:3px solid #536b43;outline-offset:3px}
@media(max-width:760px){.translation-pair.comparing{grid-template-columns:1fr}.translation-pair.comparing>.translation-part-text{border-left:0;padding:22px 18px}.translation-part-text{padding:24px 20px}.part-toolbar{padding:12px 18px}.translation-document{font-size:15px!important}.translation-figures{gap:16px;padding:16px 10px}.translation-part>summary{flex-direction:row;align-items:center;padding:14px 16px}.translation-part>summary span{font-size:12px}.reading-label{font-size:12px;letter-spacing:.05em}.compare-toggle{font-size:12px;padding:7px 9px}}
.study-history{margin:0 0 22px;padding:22px 24px;border:1px solid #d9dfd1;border-radius:14px;background:linear-gradient(135deg,#f5f7ef,#fffdf8);box-shadow:0 8px 24px rgba(38,52,35,.05)}.history-head{display:flex;align-items:end;justify-content:space-between;gap:24px;margin-bottom:14px}.history-head h2{margin:0;font:600 20px/1.35 'Noto Serif',serif}.history-head .eyebrow{margin:0 0 3px}.history-head>small{max-width:430px;color:#646b5e;font-size:12px;line-height:1.6;text-align:right}.history-list{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px}.history-empty{grid-column:1/-1;margin:0;padding:13px 15px;border:1px dashed #ccd4c3;border-radius:9px;color:#656c5e;font-size:12px;text-align:center}.history-card{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:8px 12px;padding:14px;border:1px solid #dfe3d8;border-radius:10px;background:#fff}.history-card-main{min-width:0;border:0;background:none;padding:0;text-align:left;color:inherit;cursor:pointer}.history-card-main strong,.history-card-main span,.history-card-main small{display:block}.history-card-main strong{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font:600 14px/1.45 'Noto Serif',serif}.history-card-main span{margin-top:4px;color:#5e6f52;font-size:12px}.history-card-main small{margin-top:5px;color:#666a62;font-size:12px}.history-card-main:focus-visible{outline:3px solid #536b43;outline-offset:4px;border-radius:3px}.history-library{align-self:start;padding:5px 8px;border:1px solid #d9e0d2;border-radius:7px;background:#f3f6ee;color:#526a47;font-size:12px;text-decoration:none}.history-card.is-active{border-color:#8da37a;box-shadow:0 0 0 3px rgba(117,143,94,.11)}
@media(max-width:950px){.history-list{grid-template-columns:repeat(2,minmax(0,1fr))}}
@media(max-width:680px){.study-history{padding:18px 16px}.history-head{align-items:flex-start;flex-direction:column;gap:4px}.history-head>small{text-align:left}.history-list{grid-template-columns:1fr}}
.pdf-layout-option{display:flex;align-items:start;gap:9px;padding:12px 14px;border:1px solid #dce2d3;border-radius:9px;background:#f5f8ef;font-size:12px}.panel .pdf-layout-option input{width:16px;height:16px;margin:2px 0;flex:none}.pdf-layout-option small{display:block;margin-top:4px;color:#656c5e;font-size:12px}.pdf-dual-viewer{margin:14px 0 24px;border:1px solid #d6ddcc;border-radius:12px;overflow:hidden;background:#edf0e6}.pdf-viewer-toolbar{display:flex;justify-content:space-between;align-items:center;gap:14px;padding:16px 18px;background:#f9fbf5;border-bottom:1px solid #d6ddcc}.pdf-viewer-toolbar strong,.pdf-viewer-toolbar small{display:block}.pdf-viewer-toolbar strong{font-size:13px}.pdf-viewer-toolbar small{margin-top:4px;font-size:12px;color:#656c5e}.pdf-page-controls{display:flex;align-items:center;gap:8px}.pdf-page-controls span{font-size:12px;white-space:nowrap}.pdf-page-controls select{width:auto;margin:0;padding:7px;font-size:12px}.pdf-viewer-grid{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:1px;background:#d3dcc8}.pdf-viewer-grid>section{min-width:0;background:#e8eddf}.pdf-viewer-grid h3{margin:0;padding:10px 16px;font-size:12px;background:#f4f7ef}.pdf-viewer-grid h3 small{float:right;font-size:12px;font-weight:400;color:#5f6e55}.pdf-viewer-scroll{height:680px;overflow:auto;overscroll-behavior:contain;padding:14px;scrollbar-gutter:stable}.pdf-page-frame{position:relative;flex:none;margin:0 auto;box-shadow:0 2px 9px #0002;overflow:hidden;background:white}.pdf-page-frame>.pdf-paper,.pdf-page-frame>img,.pdf-page-frame>canvas{position:absolute;left:0;top:0;max-width:none}.pdf-layout-notice{padding:12px 18px;margin:0;background:#f5f7ef;color:#5d6f51;font-size:12px}.pdf-dual-viewer[hidden]{display:none}
@media(max-width:680px){.pdf-viewer-toolbar{align-items:start;flex-direction:column;padding:12px}.pdf-page-controls{flex-wrap:wrap}.pdf-viewer-grid{grid-template-columns:1fr}.pdf-viewer-scroll{height:520px}.pdf-viewer-grid>section+section{border-top:1px solid #ccd6be}.result-actions{flex-wrap:wrap}}
.pdf-block-editor{background:#fffdf7;border-top:1px solid #d9e0d1;padding:14px 18px}.pdf-block-editor summary{font-size:12px;font-weight:700;cursor:pointer}.pdf-block-editor>div{padding-top:12px}.pdf-block-editor label{display:block;font-size:12px;font-weight:600}.pdf-block-editor [data-pdf-edit-source]{padding:10px 12px;background:#f0f3e9;font-size:12px;line-height:1.7;white-space:pre-wrap}.pdf-block-editor textarea{font:14px/1.8 'Times New Roman',serif;resize:vertical}.pdf-block-editor small{display:block;margin:8px 0;color:#656c5e;font-size:12px;line-height:1.7}
.content-title-field{margin-bottom:22px}.content-title-field>label{font-size:12px;font-weight:700}.content-title-line{display:flex;align-items:start;gap:8px}.content-title-line input{min-width:0}.content-title-line button{flex:none;margin-top:8px;white-space:nowrap}.content-title-line button[hidden]{display:none}#content-title[aria-invalid=true]{border-color:#b64a3b;box-shadow:0 0 0 4px rgba(182,74,59,.12)}.history-card{grid-template-columns:minmax(0,1fr);align-content:start}.history-card-main strong{display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;white-space:normal;overflow-wrap:anywhere}.history-card-main .history-source{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:12px;color:#656c60}.history-card-main time{display:block;margin-top:6px;color:#666a62;font-size:12px}.history-library{justify-self:start}.history-card-main:hover:not(:disabled){transform:none;box-shadow:none;background:none}
.library-match{margin:4px 2px 14px;padding:13px 15px;border:1px solid #c9d6b8;border-left:3px solid var(--green);border-radius:10px;background:#f1f6ea;color:#40553c;font-size:12px;line-height:1.7}.library-match p{margin:0 0 4px}.library-match-actions{display:flex;flex-wrap:wrap;gap:8px;margin-top:10px}.library-match-actions a{padding:9px 14px;border-radius:9px;background:var(--green);color:#fff;font-weight:700}.library-match-actions button{padding:8px 14px}
.library-match.layout-refresh{border-color:#e3cfa9;border-left-color:#d9a441;background:#fff8ea;color:#4d4130}

.study-history>summary{list-style:none;cursor:pointer;margin-bottom:0}.study-history>summary::-webkit-details-marker{display:none}.study-history>summary h2:before{content:'▸';display:inline-block;margin-right:8px;color:var(--green);transition:transform .2s ease}.study-history[open]>summary h2:before{transform:rotate(90deg)}.study-history[open]>summary{margin-bottom:14px}.study-history{padding-block:16px}.history-count{color:#5f6758;font:500 13px 'Be Vietnam Pro',sans-serif}
/* backwards, not both: a transform kept after the animation would hold the phone's fixed action bar inside the panel. */
@keyframes study-in{from{opacity:0;transform:translateY(10px)}to{opacity:1;transform:none}}
@media (prefers-reduced-motion:no-preference){main>*{animation:study-in .4s cubic-bezier(.2,.7,.2,1) backwards}main>*:nth-child(2){animation-delay:.05s}main>*:nth-child(3){animation-delay:.1s}main>*:nth-child(n+4){animation-delay:.15s}}
.book-target{margin-top:12px;padding-top:12px;border-top:1px solid #dce1d4}
.book-target>label{display:block;font-size:12px;font-weight:700}
.book-hint{margin:8px 0 0;color:#4f5d46;font-size:12px;line-height:1.7}
.book-hint:empty{display:none}
.book-next{margin-top:8px;padding:8px 12px;border-color:#c9d6b8;background:#f1f6ea;color:#40553c;font-size:12px}
.book-replace{display:flex;align-items:flex-start;gap:8px;margin-top:8px;font-size:12px;line-height:1.6}
.panel .book-replace input{width:18px;height:18px;margin:2px 0 0;padding:0;flex:none;accent-color:var(--green)}
.book-next[hidden],.book-replace[hidden],.study-books[hidden]{display:none}
.study-books{margin:0 0 14px}
.study-books h3{margin:0 0 8px;color:#3c4a35;font:600 14px/1.4 'Noto Serif',serif}
/* One column whatever its rows hold: an auto track would grow to a row's unwrapped part list and widen a phone page. */
.study-books-list{display:grid;grid-template-columns:minmax(0,1fr);gap:8px}
.study-book{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:12px 14px;border:1px solid #dfe3d8;border-left:3px solid var(--green);border-radius:10px;background:#fbfcf8}
.study-book>div:first-child{min-width:0}
.study-book strong{display:block;font:600 14px/1.45 'Noto Serif',serif;overflow-wrap:anywhere}
.study-book small{display:block;margin-top:3px;overflow:hidden;color:#5f6758;font-size:12px;text-overflow:ellipsis;white-space:nowrap}
.study-book-actions{display:flex;flex:none;flex-wrap:wrap;gap:8px}
.study-book-actions button,.study-book-actions a{padding:8px 12px;font-size:12px}
.study-book-actions a{border:1px solid #d9e0d2;border-radius:10px;background:#f3f6ee;color:#526a47;font-weight:600;text-decoration:none}
.history-actions{display:flex;flex-direction:column;align-items:flex-end;gap:6px}
.history-merge{padding:5px 8px;font-size:12px;font-weight:600}
.history-card-main .history-book{margin-top:5px;overflow:hidden;color:var(--green);font-size:12px;text-overflow:ellipsis;white-space:nowrap}
.book-dialog{width:min(520px,calc(100vw - 32px));max-height:calc(100dvh - 32px);padding:0;border:1px solid var(--line);border-radius:14px;background:#fffefa;color:var(--ink);box-shadow:var(--shadow)}
.book-dialog::backdrop{background:rgba(32,40,28,.45)}
.book-dialog form{display:flex;flex-direction:column;gap:10px;padding:20px}
.book-dialog h2{margin:0;font:600 18px/1.4 'Noto Serif',serif;overflow-wrap:anywhere}
.book-dialog label{font-size:12px;font-weight:700}
.book-dialog input,.book-dialog select{width:100%;padding:11px 12px;border:1px solid #d9dbd1;border-radius:9px;background:#fff}
.book-dialog .hint{margin:0}
.book-dialog .hint:empty{display:none}
.book-order{display:grid;gap:6px;max-height:50dvh;margin:0;padding:0;overflow:auto;list-style:none;counter-reset:part}
.book-order li{display:grid;grid-template-columns:auto minmax(0,1fr) 44px 44px;align-items:center;gap:8px;padding:8px 10px;border:1px solid #e1e4da;border-radius:9px;background:#fff;counter-increment:part}
.book-order li:before{content:counter(part) '.';color:#5f6758;font-size:12px;font-weight:700}
.book-order strong,.book-order small{display:block;overflow-wrap:anywhere}
.book-order strong{font-size:13px}
.book-order small{color:#656c60;font-size:12px}
.book-order button{min-height:44px;padding:0;font-size:16px}
.book-dialog-actions{display:flex;justify-content:flex-end;gap:8px;margin-top:4px}
.book-dialog-actions button{min-height:44px}
.book-dialog-secondary{min-height:44px}
@media(max-width:680px){.study-book{flex-direction:column;align-items:stretch}.study-book-actions>*{flex:1;text-align:center}.history-actions{flex-direction:row;flex-wrap:wrap;align-items:center;justify-content:flex-start}.book-dialog form{padding:16px}.book-dialog-actions>*{flex:1}}
.book-dialog input:focus,.book-dialog select:focus{border-color:#758f5e;outline:none;box-shadow:0 0 0 4px rgba(117,143,94,.12)}
.book-dialog h2:focus{outline:none}
.book-dialog .book-overlap{color:var(--red)}
.pdf-range .book-replace{font-weight:500}
.cover-choice{display:flex;align-items:flex-start;gap:12px;margin-top:12px;padding-top:12px;border-top:1px solid #dce1d4}
.cover-choice[hidden],.cover-thumb[hidden],.cover-translate[hidden],#cover-none-group[hidden],#cover-change-group[hidden]{display:none}
.cover-thumb{flex:none;width:54px;height:auto;max-height:84px;object-fit:contain;border:1px solid #cfd6c4;border-radius:4px;background:#fff;box-shadow:0 3px 8px rgba(39,53,35,.14)}
.cover-choice-body{flex:1;min-width:0}
.cover-line{display:flex;flex-wrap:wrap;align-items:center;gap:0 6px;margin:0;font-size:13px;line-height:1.5}
.cover-line strong{color:#34422f}
.cover-line>span{display:inline-flex;align-items:center;gap:6px}
.cover-sep{color:#8a9180}
.panel .cover-link{min-height:44px;padding:0 2px;border:0;border-radius:4px;background:none;color:var(--green-dark);font-size:13px;font-weight:700;text-decoration:underline;text-underline-offset:3px}
.panel .cover-link:hover:not(:disabled){transform:none;box-shadow:none;color:var(--red)}
.cover-note{margin:0;color:#5f6758;font-size:12px;line-height:1.6}
.cover-note:empty{display:none}
.pdf-range .cover-translate{display:flex;align-items:center;gap:8px;min-height:44px;font-weight:500}
.pdf-range .cover-translate[hidden]{display:none}
.panel .cover-translate input{width:18px;height:18px;margin:0;padding:0;flex:none;accent-color:var(--green)}
.cover-preview{display:grid;justify-items:center;gap:6px;margin:0}
.cover-preview img{max-width:min(220px,60vw);max-height:40dvh;min-height:60px;border:1px solid #d9dbd1;border-radius:6px;background:#fff;object-fit:contain}
.cover-preview figcaption{color:#5f6758;font-size:12px}
.source-lookup{margin:0;padding:3px 10px;font-size:12px;font-weight:600;border-radius:8px;background:#f7f9f1;border-color:#dce2d3}.pdf-page-frame>.pdf-original-page{position:absolute;left:0;top:0;max-width:none}.pdf-original-page>img{display:block;width:100%;height:100%}.pdf-original-page>.pdf-source-region{position:absolute;min-width:0;min-height:0;margin:0;padding:0;border:1px solid transparent;border-radius:1px;background:transparent;box-shadow:none;transform:none;transition:background .12s,border-color .12s}.pdf-original-page>.pdf-source-region:is(:hover,:focus-visible,[aria-pressed=true]){transform:none;box-shadow:none;border-color:#688c4c;background:rgba(147,179,112,.16);outline:2px solid rgba(104,140,76,.25);z-index:1}
.book-mode{display:grid;grid-template-columns:1fr 1fr;gap:8px;min-width:0;margin:14px 0 0;padding:0;border:0}
.book-mode[hidden],.whole-book[hidden],.whole-book-read[hidden]{display:none}
.book-mode legend{margin:0 0 6px;padding:0;font-size:12px;font-weight:700}
.book-mode label{display:flex;align-items:flex-start;gap:9px;min-height:44px;padding:11px 12px;border:1px solid #dce2d3;border-radius:10px;background:#fff;font-size:12px;cursor:pointer}
.panel .book-mode input{width:18px;height:18px;margin:1px 0 0;padding:0;flex:none;accent-color:var(--red);box-shadow:none}
.book-mode strong,.book-mode small{display:block}.book-mode strong{font-size:13px}.book-mode small{margin-top:2px;color:#5f6758;font-size:12px;line-height:1.5}
.book-mode label:has(input:checked){border-color:#a8b99a;background:#f1f6ea;box-shadow:inset 0 0 0 1px #a8b99a}
.book-mode label:has(input:disabled){cursor:not-allowed;opacity:.6}
.book-mode label:has(input:focus-visible){outline:3px solid #536b43;outline-offset:2px}
.book-mode-note{grid-column:1/-1;margin:0;color:#5f6758;font-size:12px;line-height:1.6}.book-mode-note:empty{display:none}
#range-fields[hidden]+.cover-choice{margin-top:0;padding-top:0;border-top:0}
.whole-book{min-width:0;margin:14px 0;padding:16px;border:1px solid #dce1d4;border-radius:12px;background:#f5f7f0}
.whole-book h3{margin:0;color:#34422f;font:600 16px/1.4 'Noto Serif',serif}
.whole-book-summary{margin:3px 0 0;color:#5f6758;font-size:12px;overflow-wrap:anywhere}
.whole-book-range{display:block;margin-top:12px;font-size:12px;font-weight:700}.whole-book-range small{color:#5f6758;font-weight:500}
.whole-book-estimate{margin-top:12px;padding:12px 14px;border:1px solid #e0e3d8;border-radius:10px;background:#fff;font-size:12px;line-height:1.7}
.whole-book-estimate p{margin:4px 0 0}.whole-book-estimate .estimate-head{margin:0}.whole-book-estimate .estimate-head small{color:#7a6435;font-weight:600}
.whole-book-estimate ul{margin:4px 0 0;padding-left:18px}.whole-book-estimate .estimate-total{font-weight:700;color:#34422f}.whole-book-estimate .hint{margin:6px 0 0;line-height:1.6}
.whole-book-count{display:flex;flex-wrap:wrap;align-items:baseline;justify-content:space-between;gap:2px 12px;margin:14px 0 4px;color:#5f6758;font-size:12px}
.whole-book-count strong{color:#34422f;font-size:14px}
.whole-book-note{margin:0 0 8px;color:#5f6758;font-size:12px}.whole-book-note:empty{display:none}
.page-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(12px,1fr));gap:3px;max-height:240px;padding:10px;overflow:auto;border:1px solid #e0e3d8;border-radius:10px;background:#fff}
.page-cell,.page-legend li:before{display:block;aspect-ratio:3/4;border-radius:2px;background:#e3e5dc}
.page-grid [data-state=working],.page-legend [data-state=working]:before{background:#d9a441}
.page-grid [data-state=working]{animation:page-working 1.4s ease-in-out infinite}
.page-grid [data-state=done],.page-legend [data-state=done]:before{background:#6f8f55}
.page-grid [data-state=nopdf],.page-legend [data-state=nopdf]:before{background:repeating-linear-gradient(135deg,#6f8f55 0 3px,#e0b052 3px 6px)}
.page-legend li[hidden]{display:none}
.page-grid [data-state=blank],.page-legend [data-state=blank]:before{background:#fff;box-shadow:inset 0 0 0 1px #c3cab8}
.page-grid [data-state=untranslated],.page-legend [data-state=untranslated]:before{background:repeating-linear-gradient(135deg,#fff 0 2px,#e0b052 2px 4px);box-shadow:inset 0 0 0 1px #c3cab8}
.page-grid [data-state=cover],.page-legend [data-state=cover]:before{background:#9b7a45}
.page-grid [data-state=skipped],.page-legend [data-state=skipped]:before{background:repeating-linear-gradient(135deg,#e3e5dc 0 2px,#fff 2px 4px)}
.page-grid [data-state=failed],.page-legend [data-state=failed]:before{background:var(--red)}
@keyframes page-working{50%{opacity:.4}}
.page-legend{display:flex;flex-wrap:wrap;gap:4px 12px;margin:8px 0 0;padding:0;list-style:none;color:#5f6758;font-size:12px}
.page-legend li{display:flex;align-items:center;gap:5px}.page-legend li:before{content:'';width:10px}
.whole-book-status{margin:10px 0 0;padding:9px 12px;border-left:3px solid #8fa27b;background:#fff;color:#40553c;font-size:12px;line-height:1.7}.whole-book-status:empty{display:none}
.whole-book-read{display:inline-block;margin-top:10px;padding:9px 13px;border:1px solid #d9e0d2;border-radius:10px;background:#f3f6ee;color:#526a47;font-size:12px;font-weight:600}
.study-book .book-job-progress{color:#40553c;white-space:normal}
.book-job-parts{margin-top:6px;font-size:12px}.book-job-parts summary{color:#526a47;font-weight:600;cursor:pointer}
.book-job-parts ul{display:grid;gap:4px;margin:6px 0 0;padding:0;list-style:none}
.book-job-parts li{display:flex;align-items:center;gap:6px}
.book-job-parts button{padding:6px 10px;font-size:12px}.book-job-parts li>button:first-child{flex:1;min-width:0;font-weight:500;text-align:left;overflow-wrap:anywhere}
.history-delete{padding:5px 8px;color:#9c382f;font-size:12px;font-weight:600}
@media(max-width:680px){.book-mode{grid-template-columns:1fr}.whole-book{padding:14px 12px}.book-job-parts button{min-height:44px}.history-delete{min-height:44px;padding:5px 12px}}
@media(max-width:600px){:root{background-image:url('/background-phone.jpg');background-image:image-set(url('/background-phone.avif') type('image/avif'),url('/background-phone.webp') type('image/webp'),url('/background-phone.jpg') type('image/jpeg'))}}
/* Keyboard focus: one visible ring everywhere (3px #536b43 on the light page). */
:where(a,button,input,select,textarea,summary,[tabindex]):focus-visible{outline:3px solid #536b43;outline-offset:2px}
.panel :is(textarea,input,select):focus-visible,.book-dialog :is(input,select):focus-visible{outline:3px solid #536b43;outline-offset:1px}
.page-canvas .ocr-region:focus-visible,.pdf-original-page>.pdf-source-region:focus-visible{outline:3px solid #536b43;outline-offset:0}
main:focus{outline:none}
.skip-link{position:absolute;left:12px;top:-80px;z-index:60;padding:12px 16px;border-radius:8px;background:#35472f;color:#fff;font-weight:700;text-decoration:underline}
.skip-link:focus,.skip-link:focus-visible{top:12px;outline:3px solid #f0b3a3;outline-offset:2px}
.visually-hidden{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip-path:inset(50%);white-space:nowrap;border:0}
/* Signed out, or the session could not be checked: a card replaces the form, which could not be used anyway. */
body:is([data-session=out],[data-session=error]) :is(.workflow,.workspace,.result,.study-history){display:none}
body:not([data-session=in]) main{min-height:100vh}
body:is([data-session=out],[data-session=error]) .hero{border-radius:18px}
body:is([data-session=out],[data-session=error]) .account-status{display:none}
.session-card[hidden]{display:none}
.session-card{margin:22px 0;padding:26px 30px;border:1px solid var(--line);border-left:4px solid var(--red);border-radius:14px;background:var(--panel);box-shadow:0 10px 32px rgba(38,52,35,.07)}
.session-card h2{margin:0 0 8px;color:#283127;font:600 22px/1.35 'Noto Serif',serif}
.session-card p{max-width:720px;margin:0 0 16px;color:#4f5849;line-height:1.75}
.session-card-actions{display:flex;flex-wrap:wrap;align-items:center;gap:10px 18px}
.session-card-actions a.primary{display:inline-flex;min-height:46px;padding:11px 20px;border-radius:10px;font-weight:700}
.session-card-actions a:not(.primary){display:inline-flex;align-items:center;min-height:44px;color:#3f5a34;font-weight:600;text-decoration:underline;text-underline-offset:3px}
/* Contract 8: a load that failed says so where the content belongs, with Thử lại (or a sign-in link). */
.load-error{grid-column:1/-1;display:grid;justify-items:start;gap:6px;padding:14px 16px;border:1px solid #e3b7ae;border-left:3px solid var(--red);border-radius:10px;background:#fff6f3;color:#5b2a21;font-size:13px;line-height:1.6}
.load-error p{margin:0}.load-error .load-error-title{font-weight:700;color:#7d2f23}
.load-error-action{display:inline-flex;align-items:center;min-height:44px;margin-top:4px;padding:10px 16px;border:1px solid #c98a7d;border-radius:10px;background:#fff;color:#7d2f23;font-weight:700;text-decoration:none}
#progress a,.save-warning a{color:var(--red);font-weight:700;text-decoration:underline;text-underline-offset:3px}
/* Gemini key: where to get one, in three steps, and what it costs. */
.key-help{margin-top:10px;padding-top:10px;border-top:1px dashed #d9ddd0;color:#4f5849;font-size:12px;line-height:1.65}
.key-help-link{display:inline-flex;align-items:center;min-height:32px;color:#3f5a34;font-weight:700;text-decoration:underline;text-underline-offset:3px}
.key-help-link:hover{color:var(--red)}
.key-help ol{margin:4px 0 6px;padding-left:20px}.key-help li{margin:1px 0}.key-help p{margin:0;color:#5b6155}
/* The labels' floating "Bắt buộc" tag stays inside its label, so the field under it gets the full row. */
.content-title-field>label,.key-group>label{display:flow-root}
.content-title-line input,.key-line input{flex:1 1 auto;width:auto}
#glossary-hint{margin:6px 0 0}
.advanced-settings{margin-top:18px;border:1px solid #e0e3d8;border-radius:11px;background:#fafbf7}
.advanced-settings>summary{display:flex;flex-wrap:wrap;align-items:baseline;gap:4px 10px;min-height:44px;padding:12px 14px;cursor:pointer;font-size:13px;font-weight:700}
.advanced-settings>summary small{color:#5f6758;font-size:12px;font-weight:500}
.advanced-body{padding:0 14px 14px}.advanced-body>label{display:block;font-size:12px;font-weight:700}
.usage-detail{margin:12px 0 0;color:#4f5849;font-size:12px;line-height:1.6}
/* The run controls: the main action fills its row; Dừng appears only while a run is going. */
.run-bar .actions{display:grid;gap:8px;margin-top:20px}.run-bar .actions .primary{width:100%}
.run-bar #stop[hidden]{display:none}
.save-warning{margin:16px 0 0;padding:10px 12px;border:1px solid #e3b7ae;border-left:3px solid var(--red);border-radius:9px;background:#fff6f3;color:#7d2f23;font-size:12px;font-weight:600;line-height:1.6}
.save-warning[hidden]{display:none}
.run-bar-status{display:none}
.ocr-download{margin:0 2px 14px;padding:14px 15px;border:1px solid #ecd6ab;border-left:3px solid var(--gold);border-radius:10px;background:#fff8e9;color:#5d4520;font-size:12px;line-height:1.7}
.ocr-download[hidden]{display:none}.ocr-download p{margin:0 0 6px}
.ocr-download-actions{display:flex;flex-wrap:wrap;gap:8px;margin-top:10px}
.ocr-download-actions button{min-height:44px}
/* A picked PDF fills the source box itself; until then the empty box is hidden. */
.source-panel.is-pdf:has(#source:placeholder-shown) :is(.field-heading,#source,#source-lookup-hint){display:none}
@media(max-width:680px){
 html{scroll-padding-bottom:calc(var(--run-bar-height,108px) + 12px)}
 .result-head .result-actions button{min-height:44px}
 :is(.source-lookup,.history-library,.history-merge,.compare-toggle,.book-next,.whole-book-read,.library-match-actions a,.library-match-actions button,.study-book-actions button,.study-book-actions a,.key-help-link,#check-gemini-model,#save-title,#clear-key,#add-key,.backup-keys button,#evaluate){min-height:44px}
 :is(.history-library,.library-match-actions a,.study-book-actions a,.whole-book-read){display:inline-flex;align-items:center;justify-content:center}
 .pdf-page-controls :is(button,select){min-width:44px;min-height:44px}
 .panel select{min-height:44px}
 :is(.combined-output,.translation-part,.source-figures,.pdf-block-editor,.book-job-parts)>summary,.evaluation summary{min-height:44px}
 .book-job-parts summary{display:flex;align-items:center}
 .metrics{flex-wrap:wrap;align-items:center}
 /* While there is something to translate (or a run to stop), the action stays at the bottom of the screen. It never
    moves while the student taps (that would make the tap miss), and scroll-padding-bottom keeps a focused field above it. */
 .run-bar.is-floating{position:fixed;left:0;right:0;bottom:0;z-index:40;padding:10px 16px calc(10px + env(safe-area-inset-bottom,0px));border-top:1px solid #d9dfd1;background:rgba(250,249,241,.97);box-shadow:0 -6px 18px rgba(39,53,35,.12)}
 .run-bar.is-floating .actions{margin-top:0}
 .run-bar.is-floating .save-warning{margin:0 0 8px}
 .run-bar.is-floating .run-bar-status:not(:empty){display:-webkit-box;margin:0 0 8px;overflow:hidden;color:#4a5444;font-size:12px;line-height:1.5;-webkit-box-orient:vertical;-webkit-line-clamp:2}
 .run-bar.is-floating .run-bar-status.error{color:#7d2f23;font-weight:600}
 .run-bar.is-floating .save-warning:not([hidden])~.run-bar-status{display:none}
 body:has(.run-bar.is-floating){padding-bottom:calc(var(--run-bar-height,84px) + 12px)}
 .session-card{padding:20px 18px}
 /* A fitted page needs no tall empty box under it; a zoomed one still scrolls inside. */
 .pdf-viewer-scroll{height:auto;max-height:min(520px,75vh)}
}
/* "Cách dịch" counts in every run (text, kept layout, whole book): what the chosen mode does spans the row under both fields. */
.control-grid .mode-hint{grid-column:1/-1;margin:-4px 0 0;line-height:1.6}
/* A save refused because another tab saved since offers to open the newest copy. */
.save-warning .save-warning-action{margin:6px 0 0;padding:6px 12px;border-color:#c98a7d;color:#7d2f23;font-size:12px}
@media(max-width:680px){.save-warning .save-warning-action{min-height:44px}}
/* Older sessions come a page at a time under the cards ("Xem thêm bản cũ hơn"); the Gemini terms note sits with the key help. */
.history-more{grid-column:1/-1;display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:8px 12px;padding:12px 15px;border:1px dashed #ccd4c3;border-radius:9px}
.history-more p{flex:1 1 260px;margin:0;color:#656c5e;font-size:12px}
.history-more .history-more-error{flex-basis:100%;color:#7d2f23;font-weight:600}
.history-more button,.history-more a{min-height:44px;padding:8px 14px;font-size:12px}
.history-more button[aria-disabled=true]{cursor:progress;opacity:.7}
.key-help .key-terms{margin-top:6px}
.key-help .key-terms a{color:#3f5a34;font-weight:600;text-decoration:underline;text-underline-offset:3px}
/* "Sách của tôi": a long title or part list wraps (two lines of parts at most) instead of widening a phone's page. */
.study-book .study-book-parts{display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;white-space:normal;overflow-wrap:anywhere}
.study-book .book-job-progress{overflow-wrap:anywhere}
/* The address to open in Chrome or Safari when a browser inside another app would drop the download. */
.book-dialog .in-app-copy{display:flex;flex-wrap:wrap;align-items:center;gap:8px;font-size:12px}
.book-dialog .in-app-copy button{min-height:44px}
/* A block the export found longer than its box, until it is saved again. */
.pdf-dual-viewer [data-block-id].is-overflow{outline:2px solid #b64a3b;background:#fff8f5}
/* browser-check.js: the notice a browser older than iOS/Safari 15.4 gets at the top of the page. */
.browser-notice{max-width:640px;margin:24px auto;padding:24px 28px;border:1px solid #e7c8c0;border-left:4px solid #a03c32;border-radius:12px;background:#fff8f5;color:#3b2f2a;line-height:1.7}
.browser-notice h1{margin:0 0 8px;font-size:22px}
.browser-notice p{margin:0}
.browser-notice button{min-height:44px;margin-top:14px}
@media(max-width:680px){.browser-notice{margin:16px;padding:18px}}
