/* Shared study canvas, consuming MOST roles. Only the reusable Study Display
   role is new; navigation, buttons and helper text retain their shared presets. */
body.study-active .app-shell {grid-template-columns:minmax(0,1fr);padding-bottom:0;}
body.study-active :is(.sidebar,.topbar,.mobile-app-header) {display:none!important;}
body.study-active .main {min-width:0;padding:0;}
body.study-active #workspace {padding:24px 32px calc(24px + env(safe-area-inset-bottom,0px))!important;min-height:100dvh;}
body #workspace .study-workspace {width:min(880px,100%);margin:auto;display:grid;gap:18px;color:var(--most-ink,#17365e);min-width:0;}
body #workspace .study-workspace [hidden] {display:none!important;}
body #workspace .study-header {display:flex;gap:12px;align-items:center;}
body #workspace .study-header img {margin-left:auto;flex:none;}
body #workspace .study-canvas-tools {display:flex;gap:8px;margin-left:8px;}
body #workspace .study-canvas-tools button {width:44px;flex:none;padding:8px;font:var(--type-section-title);}
body #workspace .study-session-note {color:var(--most-helper);}
body #workspace .study-title {margin:0;overflow-wrap:anywhere;}
body #workspace .study-mode-tabs {display:grid;grid-template-columns:repeat(3,minmax(0,1fr));padding:5px;gap:5px;background:#e5effc;border:1px solid #d7e4f6;border-radius:16px;}
body #workspace .study-mode-tabs button {min-width:0;min-height:54px;border:0;border-radius:11px;background:transparent;color:#42536b;padding:8px 12px;font:var(--type-nav-primary);}
body #workspace .study-mode-tabs button.active {background:#fff;color:var(--most-primary,#1556bd);box-shadow:0 3px 10px #17365e12;}
body #workspace .study-mode-tabs :is(.ml-bi-label,.ml-bi-ru,.ml-bi-de) {display:block;text-align:center;}
body #workspace .study-mode-tabs .ml-bi-de {font:var(--type-nav-secondary);margin-top:3px;}
body #workspace .study-progress {display:flex;align-items:center;gap:16px;}
body #workspace .study-progress > span {white-space:nowrap;font-variant-numeric:tabular-nums;}
body #workspace .study-progress progress {flex:1;min-width:0;height:6px;border:0;border-radius:6px;overflow:hidden;background:#dbe7f7;accent-color:var(--most-primary,#1556bd);}
body #workspace .study-progress progress::-webkit-progress-bar {background:#dbe7f7;}
body #workspace .study-progress progress::-webkit-progress-value {background:var(--most-primary,#1556bd);border-radius:6px;}
body #workspace .study-progress progress::-moz-progress-bar {background:var(--most-primary,#1556bd);}
body #workspace .study-content {min-width:0;}
body #workspace .study-display {display:block;font:var(--type-study-display);letter-spacing:var(--tracking-title);overflow-wrap:anywhere;color:var(--most-ink);margin:0;}
/* Speaker controls sit outside the card's pointer/flip target. Speech is always
   explicit; the rate preference is confined to this signed-in document. */
body #workspace .pronunciation {min-width:0;max-width:100%;}
body #workspace .pronunciation-controls {display:flex;align-items:center;gap:6px;}
body #workspace .pronunciation-play {display:grid;place-items:center;flex:none;width:44px;min-height:44px;padding:8px;border:1px solid #c4d7ee;border-radius:12px;background:#f4f8ff;color:var(--most-primary);cursor:pointer;}
body #workspace .pronunciation-play:hover {background:#e8f1ff;border-color:#9dbadd;}
body #workspace .pronunciation-play:focus-visible,body #workspace .pronunciation-rate:focus-visible {outline:3px solid #1556bd;outline-offset:3px;}
body #workspace select.pronunciation-rate {width:76px;min-width:0;min-height:44px;padding:8px 4px;font:var(--type-meta);border:1px solid #c4d7ee;border-radius:10px;background:#f8fbff;color:var(--most-ink);}
body #workspace .pronunciation-status {display:block;margin:6px 0;color:var(--most-helper);overflow-wrap:anywhere;}
body #workspace .pronunciation-status:empty {display:none;}
body #workspace .study-card-pronunciation {position:absolute;top:calc(var(--card-gutter-y) + 12px);right:calc(var(--card-gutter-x) + 14px);z-index:2;}
body #workspace .study-card-scene:is(.dragging,.rated-known,.rated-unknown) + .study-card-pronunciation {visibility:hidden;}
body #workspace .study-card .ml-type-label {padding-right:130px;min-height:32px;max-width:100%;box-sizing:border-box;text-align:left;}
body #workspace .study-source {margin:0;text-align:center;color:var(--most-helper);}
body #workspace .study-question-head > .pronunciation {max-width:60%;}
body #workspace .vocabulary-workspace .v3-word-main {grid-template-columns:minmax(0,1fr) auto;column-gap:16px;}
body #workspace .vocabulary-workspace .v3-word-main > * {grid-column:1/-1;}
body #workspace .vocabulary-workspace .v3-word-main > strong {grid-column:1;grid-row:2;align-self:center;}
body #workspace .vocabulary-workspace .v3-word-main > .vocab-pronunciation {grid-column:2;grid-row:2;width:126px;}
@media (max-width:480px) {body #workspace .vocabulary-workspace .v3-word-main > strong {grid-column:1/-1;} body #workspace .vocabulary-workspace .v3-word-main > .vocab-pronunciation {grid-column:1/-1;grid-row:auto;}}
/* The stationary stack is decorative. Gutters contain the soft shadow while
   the viewport still clips the departing swipe, without horizontal overflow. */
body #workspace .study-card-viewport {--card-min-height:320px;--card-padding-y:28px;--card-padding-x:32px;--card-gutter-x:24px;--card-gutter-y:24px;--card-gutter-bottom:30px;position:relative;isolation:isolate;padding:var(--card-gutter-y) var(--card-gutter-x) var(--card-gutter-bottom);overflow:hidden;margin:calc(-1 * var(--card-gutter-y)) calc(-1 * var(--card-gutter-x)) calc(-1 * var(--card-gutter-bottom));}
body #workspace .study-card-viewport::before {content:"";position:absolute;z-index:0;pointer-events:none;inset:calc(var(--card-gutter-y) + 7px) calc(var(--card-gutter-x) + 8px) calc(var(--card-gutter-bottom) - 7px);border:1px solid #c5d4e8;border-radius:24px;background:#e8eff9;box-shadow:0 2px 4px #17365e0a;}
body #workspace .study-card-scene {position:relative;z-index:1;min-width:0;min-height:var(--card-min-height);cursor:pointer;border:1px solid #b5c9e3;border-radius:24px;background:linear-gradient(155deg,#fff 45%,#f7faff 100%);box-shadow:0 2px 4px -1px #17365e14,0 12px 20px -9px #17365e29,0 22px 32px -20px #17365e33;touch-action:pan-y;transform:translateX(var(--drag-x,0px)) rotate(var(--drag-angle,0deg));transition:transform .28s cubic-bezier(.22,.61,.36,1),opacity .28s ease,background .18s ease,border-color .18s ease;animation:study-card-arrive .32s cubic-bezier(.22,.61,.36,1);}
@keyframes study-card-arrive {from {opacity:0;transform:translateY(16px) scale(.98);}to {opacity:1;transform:translateY(0) scale(1);}}
body #workspace .study-card {display:block;position:static;transform:none;width:100%;height:auto;min-height:var(--card-min-height);padding:var(--card-padding-y) var(--card-padding-x);border:0;box-shadow:none;background:transparent;user-select:none;}
body #workspace .study-card,body #workspace .study-card * {-webkit-user-select:none;user-select:none;-webkit-user-drag:none;}
body #workspace .study-card > div {display:flex;min-height:calc(var(--card-min-height) - 2 * var(--card-padding-y));flex-direction:column;align-items:center;justify-content:center;gap:18px;text-align:center;}
body #workspace .study-card .ml-type-label {color:var(--most-helper);}
body #workspace .study-card .study-flip-hint {color:var(--most-helper);width:100%;border-top:1px solid #e0e8f3;margin-top:8px;padding-top:14px;}
body #workspace .study-card .study-display {margin:0;}
body #workspace .study-card #cardFront > .ml-type-label {position:absolute;top:var(--card-padding-y);left:var(--card-padding-x);}
body #workspace .study-card #cardBack > .ml-type-label {align-self:flex-start;}
body #workspace .study-card #cardFront .study-flip-hint {position:absolute;bottom:22px;left:var(--card-padding-x);right:var(--card-padding-x);width:auto;margin:0;}
body #workspace .study-forms {margin:0;color:var(--most-helper);}
body #workspace .study-example {border-left:3px solid #b9d4f9;padding:0 0 0 16px;text-align:left;width:100%;}
body #workspace .study-example p {margin:4px 0;}
body #workspace .study-example .ml-type-body-small {color:var(--most-helper);}
body #workspace .study-swipe-label {position:absolute;top:18px;right:18px;border:2px solid currentColor;border-radius:8px;padding:5px 10px;font:var(--type-label);opacity:0;}
body #workspace .study-card-scene.dragging {transition:none;animation:none;}
body #workspace .study-card-scene:is(.rated-known,.rated-unknown) {animation:study-rating-confirm .4s ease both;pointer-events:none;transform:none;}
@keyframes study-rating-confirm {0%,75% {opacity:1;transform:scale(1);}100% {opacity:0;transform:translateY(-8px) scale(.985);}}
body #workspace .study-card-scene:is(.rated-known,.rated-unknown) .study-card {visibility:hidden;}
body #workspace .study-card-scene:is(.rated-known,.rated-unknown) .study-swipe-label {inset:0;border:0;padding:24px;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:12px;font:var(--type-section-title);}
body #workspace .study-card-scene:is(.rated-known,.rated-unknown) .study-swipe-label > span {font:var(--type-hero-title);}
body #workspace .study-card-scene:is(.drag-known,.rated-known) {background:#ecf8f0;border-color:#33835a;color:#19633e;}
body #workspace .study-card-scene:is(.drag-unknown,.rated-unknown) {background:#fff0f0;border-color:#bc5151;color:#9d3030;}
body #workspace .study-card-scene:is(.drag-known,.rated-known,.drag-unknown,.rated-unknown) .study-swipe-label {opacity:1;}
body #workspace .study-rating {display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:14px;margin-top:16px;}
body #workspace .study-rating button {min-height:60px;border-radius:14px;padding:10px 16px;font:var(--type-button);display:flex;align-items:center;justify-content:center;gap:12px;}
body #workspace .study-rating .ml-bi-label {display:grid;}
body #workspace .study-unknown {background:#fff;border:1px solid #e9bcbc;color:#963636;}
body #workspace .study-known {background:#eaf7ee;border:1px solid #9cccaf;color:#19633e;}
body #workspace .study-rating button .ml-bi-de {color:inherit;}
body #workspace .study-hint {text-align:center;color:var(--most-helper);margin:12px 0;}
body #workspace .study-touch-hint {display:block;}
body #workspace .study-footer {display:flex;align-items:center;justify-content:space-between;gap:10px;flex-wrap:wrap;color:var(--most-helper);}
body #workspace :is(.study-setup,.study-question,.study-result,.study-settings) {background:#fff;border:1px solid #d5e2f4;border-radius:22px;padding:28px 32px;min-width:0;}
body #workspace .study-setup > h2 {margin:12px 0;}
body #workspace .study-setup > p {color:var(--most-helper);margin:0 0 22px;}
body #workspace .study-setup form {display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:20px 16px;}
body #workspace .study-setup label {display:grid;gap:8px;min-width:0;}
body #workspace .study-setup form > :is(p,button) {grid-column:1/-1;margin:0;}
body #workspace .study-setup > button {margin-top:16px;}
body #workspace .study-workspace :is(input,select) {border:1px solid #c4d7ee;border-radius:10px;padding:12px;min-height:48px;min-width:0;width:100%;background:#f8fbff;color:var(--most-ink);}
body #workspace .study-question-head {display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:22px;}
body #workspace .study-question .study-display {margin:0 0 14px;}
body #workspace .study-task {color:var(--most-helper);margin:0 0 26px;}
body #workspace .study-options {display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;}
body #workspace .study-option {display:flex;gap:12px;align-items:center;text-align:left;min-height:64px;padding:14px 16px;border:1px solid #c4d7ee;border-radius:12px;background:#fff;color:var(--most-ink);font:var(--type-body);overflow-wrap:anywhere;}
body #workspace .study-option > :first-child {display:grid;place-items:center;border-radius:50%;background:#eef3fa;min-width:26px;min-height:26px;}
body #workspace .study-option:hover:not(:disabled) {border-color:var(--most-primary);background:#f1f7ff;}
body #workspace .study-option.correct {background:#ecf8f0;border-color:#33835a;color:#19633e;}
body #workspace .study-option.wrong {background:#fff0f0;border-color:#bc5151;color:#9d3030;}
body #workspace .study-option:disabled {opacity:1;cursor:default;}
body #workspace .study-typing {display:grid;gap:10px;}
body #workspace .study-feedback:not(:empty) {border-radius:12px;padding:18px;margin-top:22px;border:1px solid #c4d7ee;background:#f4f8ff;}
body #workspace .study-feedback.success {border-color:#9cccaf;background:#edf8f1;color:#19633e;}
body #workspace .study-feedback.error {border-color:#e9bcbc;background:#fff3f3;color:#963636;}
body #workspace .study-feedback.learn-answer-celebrate {animation:learn-answer-confirm .3s ease-out;}
@keyframes learn-answer-confirm {from {transform:translateY(3px);box-shadow:0 0 0 3px #33835a24;} to {transform:none;box-shadow:0 0 0 0 #33835a00;}}
body #workspace .study-feedback > strong {font:var(--type-subsection-title);}
body #workspace .study-feedback p {margin:8px 0;}
body #workspace .study-question-actions {display:flex;justify-content:flex-end;margin-top:20px;}
body #workspace .learn-progress {display:grid;gap:10px;min-width:0;}
body #workspace .learn-progress p {margin:0;}
body #workspace .learn-segments {display:grid;grid-template-columns:repeat(var(--learn-segments),minmax(0,1fr));gap:6px;}
body #workspace .learn-segment {display:grid;place-items:center;min-height:28px;border-radius:8px;background:#e4eaf2;color:var(--most-helper);font:var(--type-meta);}
body #workspace .learn-segment.complete {background:var(--most-primary);color:#fff;}
body #workspace .learn-segment.active {background:#e6f0ff;color:var(--most-primary);border-bottom:3px solid var(--most-primary);}
body #workspace .learn-stages {display:flex;gap:8px;flex-wrap:wrap;align-items:center;color:var(--most-helper);}
body #workspace .learn-stages .current {color:var(--most-primary);font-weight:700;}
body #workspace .study-result {display:grid;gap:18px;}
body #workspace .study-result h2,body #workspace .study-result p {margin:0;}
body #workspace .study-result-symbol {display:grid;place-items:center;width:52px;height:52px;border-radius:16px;background:#eaf3ff;color:var(--most-primary);font:var(--type-hero-title);}
body #workspace .study-stats {display:flex;gap:12px;flex-wrap:wrap;}
body #workspace .study-stats > div {background:#f1f6ff;padding:18px;border-radius:14px;flex:1;min-width:120px;display:grid;gap:6px;}
body #workspace .study-stats strong {font:var(--type-section-title);}
body #workspace .study-stats span {font:var(--type-body-small);color:var(--most-helper);}
body #workspace .study-result-actions {display:flex;gap:12px;flex-wrap:wrap;}
body #workspace .study-mistakes {display:grid;gap:12px;margin:0;padding-left:24px;}
body #workspace .study-mistakes li {padding:14px;background:#f8fbff;border-radius:12px;overflow-wrap:anywhere;}
body #workspace .study-mistakes strong {font:var(--type-subsection-title);}
body #workspace .study-settings {margin-top:16px;}
body #workspace .study-settings-dialog {width:min(600px,calc(100% - 32px));max-height:calc(100dvh - 32px);overflow-y:auto;border:1px solid #d5e2f4;border-radius:22px;padding:24px;color:var(--most-ink);background:#fff;}
body #workspace .study-settings-dialog::backdrop {background:#12264466;}
body #workspace .study-settings-dialog header {display:flex;align-items:center;justify-content:space-between;gap:16px;}
body #workspace .study-settings-dialog form {display:grid;gap:16px;margin:16px 0;}
body #workspace .study-settings-dialog label {display:grid;gap:8px;}
body #workspace .study-settings-dialog .study-check {display:flex;align-items:center;}
body #workspace .study-settings-dialog input[type=checkbox] {width:20px;min-height:20px;flex:none;}
body #workspace .study-settings-actions {display:grid;gap:10px;margin:16px 0;}
body #workspace .study-settings-dialog details {padding:16px 0;border-block:1px solid #d5e2f4;margin-bottom:20px;}
body #workspace .study-material-actions {display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;}
body #workspace .study-settings-dialog p {font:var(--type-body-small);}
body #workspace .study-workspace :is(button,[role=button],input,select):focus-visible {outline:3px solid #1556bd;outline-offset:3px;}
body #workspace .study-workspace button {min-height:44px;}
body.study-expanded #workspace {padding:0!important;}
body.study-expanded #workspace .study-workspace {width:100%;min-height:100dvh;padding:76px 24px 28px;background:#edf4ff;display:flex;flex-direction:column;justify-content:center;gap:0;--study-focus-height:clamp(280px,60dvh,580px);}
body.study-expanded #workspace .study-content {width:min(1040px,100%);margin:0 auto;}
body.study-expanded #workspace .study-workspace > :is(.study-title,.study-mode-tabs,.study-progress) {display:none;}
body.study-expanded #workspace .study-header > :is(.study-exit,img) {display:none;}
body.study-expanded #workspace .study-header {position:absolute;top:16px;right:16px;z-index:3;}
body.study-expanded #workspace .study-card-viewport {--card-min-height:var(--study-focus-height);}
body.study-expanded #workspace .study-rating {display:grid;margin-top:18px;}
body.study-expanded #workspace :is(.study-hint,.study-footer,.study-flip-hint) {display:none;}
body.study-expanded #workspace .study-card .ml-type-label {display:none;}
body #workspace .vocab-order {display:flex;gap:4px;justify-content:flex-end;}
body #workspace .vocab-order button {min-width:44px;min-height:44px;}
body #workspace .vocab-editor-workspace {width:min(1040px,100%);margin:auto;display:grid;gap:20px;color:var(--most-ink);min-width:0;}
body #workspace .vocab-editor-workspace h1 {margin:0;}
body #workspace :is(.vocab-editor-header,.vocab-editor-actions,.vocab-editor-row header) {display:flex;align-items:center;gap:12px;flex-wrap:wrap;}
body #workspace .vocab-editor-header {position:sticky;top:0;z-index:2;padding:12px 0;background:var(--most-background,#f2f7ff);}
body #workspace .vocab-editor-header .primary {margin-left:auto;}
body #workspace :is(.vocab-editor-meta,.vocab-editor-row,.vocab-editor-paste,.vocab-editor-notice) {padding:24px;border:1px solid #d5e2f4;border-radius:18px;background:#fff;min-width:0;}
body #workspace .vocab-editor-meta {display:grid;gap:16px;}
body #workspace .vocab-editor-workspace label {display:grid;gap:8px;font:var(--type-label);min-width:0;}
body #workspace .vocab-editor-workspace :is(input,textarea) {width:100%;min-width:0;min-height:48px;padding:12px;border:1px solid #c4d7ee;border-radius:10px;background:#f8fbff;color:var(--most-ink);font:var(--type-body);}
body #workspace .vocab-editor-workspace textarea {resize:vertical;}
body #workspace .vocab-editor-workspace [readonly] {background:#f3f6fa;}
body #workspace .vocab-editor-rows {display:grid;gap:16px;}
body #workspace .vocab-editor-row {display:grid;gap:18px;}
body #workspace .vocab-editor-row-actions {display:flex;gap:8px;align-items:center;margin-left:auto;}
body #workspace .vocab-editor-row-actions button {min-height:44px;min-width:44px;}
body #workspace .vocab-editor-pair {display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:16px;}
body #workspace .vocab-editor-row details .vocab-editor-pair {margin-top:16px;}
body #workspace .vocab-editor-row summary {font:var(--type-body-small);color:var(--most-helper);cursor:pointer;}
body #workspace .vocab-editor-paste [role=status] ol {padding:0;list-style:none;max-height:300px;overflow:auto;}
body #workspace .vocab-editor-paste [role=status] li {display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:16px;padding:10px 0;border-bottom:1px solid #d5e2f4;overflow-wrap:anywhere;}
body #workspace .vocab-editor-workspace [hidden] {display:none!important;}
body #workspace .vocab-editor-workspace :is(button,input,textarea):focus-visible {outline:3px solid #1556bd;outline-offset:3px;}
@media(max-width:760px) {
 body.study-active #workspace {padding:12px 16px calc(20px + env(safe-area-inset-bottom,0px))!important;}
 body #workspace .study-workspace {gap:14px;}
 body #workspace .study-card-viewport {--card-min-height:clamp(290px,40dvh,390px);--card-padding-y:24px;--card-padding-x:22px;--card-gutter-x:16px;--card-gutter-y:20px;--card-gutter-bottom:26px;}
 body #workspace .study-header {gap:8px;}
 body #workspace .study-session-note {display:none;}
 body #workspace .study-mode-tabs button {padding:8px 4px;}
 body #workspace .study-card-scene {border-radius:20px;box-shadow:0 1px 3px #17365e0f,0 8px 16px -7px #17365e29,0 16px 24px -14px #17365e2e;}
 body #workspace .study-card-viewport::before {border-radius:20px;}
 body #workspace .study-rating {gap:10px;margin-top:14px;}
 body #workspace .study-footer #flashFullscreen {display:none;}
 body #workspace :is(.study-setup,.study-question,.study-result) {padding:22px 18px;border-radius:18px;}
 body #workspace .study-options,body #workspace .study-setup form {grid-template-columns:minmax(0,1fr);}
 body #workspace .study-question-head {margin-bottom:18px;}
 body #workspace .study-task {margin-bottom:20px;}
 body #workspace .study-result-actions {flex-direction:column;}
 body #workspace .study-question-actions button {width:100%;}
 body #workspace .study-settings-dialog {padding:20px 16px;}
 body #workspace .study-material-actions {grid-template-columns:minmax(0,1fr);}
 body #workspace .vocab-editor-pair {grid-template-columns:minmax(0,1fr);}
 body #workspace :is(.vocab-editor-meta,.vocab-editor-row,.vocab-editor-paste,.vocab-editor-notice) {padding:18px 14px;}
 body #workspace .vocab-editor-header {gap:8px;}
 body #workspace .vocab-editor-header button {flex:1;}
}
@media(prefers-reduced-motion:reduce) {
 body #workspace .study-feedback.learn-answer-celebrate {animation:none;}
 body #workspace .study-card-scene {transition:none;animation:none;}
 body #workspace .study-card-scene:is(.rated-known,.rated-unknown) {animation:none;transform:none;opacity:1;}
 body #workspace .study-workspace * {scroll-behavior:auto;}
}
/* Manual Learn completion stays within the existing canvas on narrow screens. */
body #workspace .study-header:has(.study-stop){flex-wrap:wrap}
body #workspace #stopLearnNow{width:auto;min-height:44px;padding:8px 12px;font:var(--type-button-secondary)}
@media(max-width:600px){body #workspace .study-header:has(.study-stop) .study-canvas-tools{margin-left:auto;flex-wrap:wrap;justify-content:flex-end}}
