/* Language controls share a stable order in every locale. */
.language-switch{direction:ltr;max-width:100%}
.language-switch button{white-space:nowrap;flex:0 0 auto}
#learned-count,.result-number,.study-range-label output{direction:ltr;unicode-bidi:isolate}
html[dir="rtl"] .result-number{text-align:right}
.language-switch button[lang="ar"]{font-family:Tahoma,"Segoe UI",Arial,sans-serif;font-size:13px;letter-spacing:0;min-width:46px}
.topbar>*{min-width:0}
.content-language-note{display:flex;align-items:flex-start;gap:9px;margin:0 0 20px;padding:12px 15px;background:#edf3fb;border:1px solid #dce5f3;border-radius:8px;font-size:13px;line-height:1.7;color:#526d92}
.content-language-note svg{flex:0 0 17px;width:17px;height:17px;margin-top:3px}
.content-language-note p{margin:0}
[lang="en"][dir="ltr"]{unicode-bidi:isolate;text-align:start}
.course-heading>div,.card-body,.card-footer>span,.footer-copy{min-width:0}
.course-heading h1,.card-body h2{overflow-wrap:break-word}
.study-quick>div{flex-wrap:wrap;justify-content:flex-end}
.study-quick>span{min-width:0}

/* Mirror the reading layout, never the model or its projected coordinates. */
html[dir="rtl"]{font-family:Tahoma,"Segoe UI",Arial,sans-serif}
html[dir="rtl"] :is(h1,h2,h3,.eyebrow,.detail-label,.practice-eyebrow,.brand-product,.card-tag,.viewer-title,.study-chip){letter-spacing:0}
html[dir="rtl"] .sidebar{left:auto;right:0;border-right:0;border-left:1px solid var(--line)}
html[dir="rtl"] .main{margin-left:0;margin-right:var(--side)}
html[dir="rtl"] :is(.brand,.nav-button,.part-button,.task-option,.equipment-card,.breadcrumb-home,.study-zones button){text-align:start}
html[dir="rtl"] .nav-button.active:before{left:auto;right:18px}
html[dir="rtl"] .brand-wordmark,
html[dir="rtl"] .brand-compact,
html[dir="rtl"] .mobile-brand{direction:ltr}
html[dir="rtl"] .part-button svg{margin-left:0;margin-right:auto}
html[dir="rtl"] .catalog-search input{padding-left:15px;padding-right:42px}
html[dir="rtl"] .catalog-search svg{left:auto;right:14px}
html[dir="rtl"] .card-image .card-tag{left:auto;right:18px}
html[dir="rtl"] .card-study-badge{right:auto;left:12px}
html[dir="rtl"] :is(.dialog ul,.quiz-answer-list,.specification-sources ul){padding-left:0;padding-right:20px}
html[dir="rtl"] .study-disclaimer{border-left:0;border-right:2px solid #a5c6b9;padding-left:0;padding-right:11px}
html[dir="rtl"] .toast{left:calc(50% - var(--side)/2)}
html[dir="rtl"] svg[data-icon="arrow"],
html[dir="rtl"] svg[data-icon="chevron"]{transform:scaleX(-1)}

/* The renderer positions markers and point cards using physical left/top. */
.viewer,.markers,.marker,.point-info,.study-range{direction:ltr}
html[dir="rtl"] :is(.viewer-title,.viewer-hint,.model-badge,.model-loading,.model-error){direction:rtl;unicode-bidi:isolate}
html[dir="rtl"] .viewer-title{font-family:Tahoma,"Segoe UI",Arial,sans-serif}
html[dir="rtl"] .viewer-hint{max-width:calc(100% - 36px);line-height:1.6}
html[dir="rtl"] .point-info[dir="rtl"]{direction:rtl;text-align:right}
html[dir="rtl"] .view-presets button{letter-spacing:0}

@media(max-width:950px){
  html[dir="rtl"] .nav-button.active:before{right:0}
  html[dir="rtl"] .mobile-brand{margin-left:8px;margin-right:0}
  html[dir="rtl"] .card-image .card-tag{right:12px}
  .breadcrumb{display:none}
}
@media(max-width:720px){
  html[dir="rtl"] .sidebar{box-shadow:-20px 0 40px #0002}
  html[dir="rtl"] .mobile-brand{margin-right:0;margin-left:auto}
  html[dir="rtl"] .top-actions{margin-left:0;margin-right:auto}
  html[dir="rtl"] .toast{left:50%}
  .card-footer{flex-wrap:wrap}
}
@media(max-width:600px){
  /* A dedicated second row prevents the four languages squeezing the logo. */
  .topbar{display:grid;grid-template-columns:34px minmax(0,1fr);grid-template-rows:34px 40px;gap:8px 12px;height:106px;padding:12px 16px}
  .mobile-menu{grid-column:1;grid-row:1}
  .mobile-brand{grid-column:2;grid-row:1;justify-self:start;margin:0}
  .mobile-brand img{width:132px;max-width:100%}
  .top-actions{grid-column:1/-1;grid-row:2;justify-content:flex-end;width:100%;margin:0}
  .language-switch{padding:3px;gap:4px}
  .language-switch button{padding:6px 10px;min-width:36px;min-height:32px}
  .language-switch button[lang="ar"]{min-width:48px}
  .sidebar{top:106px}
  html[dir="rtl"] .mobile-brand,
  html[dir="rtl"] .top-actions{margin:0}
  .content-language-note{font-size:12px;margin-bottom:17px;padding:11px 13px}
  .study-quick{align-items:flex-start}
  .study-quick>div{max-width:75%}
  .study-quick button{white-space:normal}
  .course-tab{max-width:100%}
}
@media(max-width:370px){
  .parts-list,.task-options{grid-template-columns:minmax(0,1fr)}
  .study-modes button{font-size:12px}
  .study-quick>div{max-width:70%}
  .study-quick button{padding:7px}
  .view-presets button{padding:8px 6px;font-size:10px}
}
