html[data-locale="zh-Hant"] body {
  --font-sans: "PowerLab Times", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei UI", "Microsoft JhengHei", sans-serif;
  --ui-font: "PowerLab Times", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei UI", "Microsoft JhengHei", sans-serif;
  --sim-font: "PowerLab Times", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei UI", "Microsoft JhengHei", sans-serif;
}

html[data-locale="zh-Hant"] body:is(.student-dashboard, .role-studio) {
  --studio-font: "PowerLab Times", "Noto Serif TC", "Songti TC", PMingLiU, serif;
}

html[data-locale="en-US"] :where(
  .classroom-nav-link,
  .dashboard-reference-settings,
  .dashboard-account-detail,
  .studio-workspace-heading,
  .role-studio-nav-link
) {
  min-width: 0;
}

html[data-locale="en-US"] :where(
  .classroom-nav-link > span:last-child,
  .dashboard-reference-settings-label,
  .role-studio-nav-link > span:last-child
) {
  overflow-wrap: normal;
  white-space: normal;
}

html[data-locale="en-US"] :where(.simulink-flow-steps, .fault-steps) {
  gap: 6px;
}

html[data-locale="en-US"] :where(
  .simulink-flow-steps button,
  .fault-steps > button
) {
  gap: 6px;
  min-width: 0;
  font-size: 16px;
  line-height: 1.1;
  text-align: left;
  white-space: nowrap;
}

html[data-locale="en-US"] .simulink-source-card h3 {
  line-height: 1.15;
}

/* At wide desktop sizes, the short title may use the empty area above the
   artwork. Body copy keeps a measured narrow column with a real gap before
   the artwork, so neither text block intersects the illustration. */
@media (min-width: 1180px) {
  html[data-locale="en-US"] body.student-simulink-realtime .simulink-source-card > div,
  html[data-locale="en-US"] body.student-simulink-realtime .simulink-source-card[data-source-card="manual"] > div {
    grid-column: 2 / 4;
    width: 100%;
    max-width: none;
  }

  html[data-locale="en-US"] body.student-simulink-realtime .simulink-source-card h3 {
    width: max-content;
    max-width: 100%;
    white-space: nowrap;
  }

  html[data-locale="en-US"] body.student-simulink-realtime .simulink-source-card p {
    max-width: 268px;
  }

  html[data-locale="en-US"] body.student-simulink-realtime .simulink-source-card[data-source-card="manual"] p {
    max-width: 216px;
  }
}

@media (max-width: 1179px) {
  html[data-locale="en-US"] .simulink-source-card h3 {
    white-space: normal;
  }
}

html[data-locale="en-US"] .substation-tour-panel {
  width: min(280px, calc(100vw - 40px));
}

html[data-locale="en-US"] .substation-tour-list span {
  display: -webkit-box;
  min-height: 2.3em;
  overflow: hidden;
  white-space: normal;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

html[data-locale="en-US"] :where(
  .phase26-resource-card h3,
  .phase26-category-card h3,
  .digital-twin-card h3,
  .role-studio-metric span
) {
  overflow-wrap: break-word;
  white-space: normal;
}

@media (max-width: 430px) {
  html[data-locale="en-US"] .capability-strip {
    grid-template-columns: 1fr;
  }

  html[data-locale="en-US"] .form-actions {
    align-items: stretch;
    flex-wrap: wrap;
  }
}

@media (max-width: 767px) {
  html[data-locale="en-US"] body.power-monitor .map-health {
    max-width: 160px;
  }

  html[data-locale="en-US"] body.power-monitor .phase41-locate-node {
    width: 118px !important;
    min-width: 118px !important;
  }
}

@media (max-width: 420px) {
  html[data-locale="en-US"] body.role-studio .teacher-workspace-summary {
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
  }
}

@media (min-width: 768px) {
  html[data-locale="en-US"] .motor-pid-mode-switch {
    width: 298px;
    flex-basis: 298px;
  }

  html[data-locale="en-US"] :where(
    .motor-pid-mode-switch button,
    .pid-signal-tabs button,
    .pid-comparison-tabs button
  ) {
    min-height: 0;
    white-space: nowrap;
  }

  html[data-locale="en-US"] .pid-comparison-tabs {
    width: 252px;
  }
}

/* Phase 122: English-only space allocation. Simplified Chinese remains the
   visual authority, so this block must not change the shared type scale. */
html[data-locale="en-US"] .student-dashboard .dashboard-learning-route > header > strong {
  min-width: max-content;
  flex-shrink: 0;
  white-space: nowrap;
}

html[data-locale="en-US"] body.admin-role-studio .admin-model-row > div > :where(strong, small) {
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
}

html[data-locale="en-US"] body.admin-role-studio .admin-capability-provenance {
  grid-template-columns: minmax(0, 1fr);
}

html[data-locale="en-US"] body.admin-role-studio .admin-capability-provenance div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(110px, 1fr);
}

html[data-locale="en-US"] body.admin-role-studio .admin-capability-provenance dd {
  width: 100%;
  max-width: none;
  text-align: right;
}

html[data-locale="en-US"] body.admin-role-studio .lesson-step-button {
  min-height: 90px;
}

html[data-locale="en-US"] body.admin-role-studio .lesson-step-button > small {
  overflow: visible;
  overflow-wrap: normal;
  text-overflow: clip;
  white-space: normal;
}

html[data-locale="en-US"] body.role-studio .role-studio-topbar {
  z-index: 30;
}

html[data-locale="en-US"] body.role-studio .account-popover-identity strong {
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
}

html[data-locale="en-US"] body.teacher-role-studio .teacher-workspace-summary {
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
}

html[data-locale="en-US"] body.phase26-groups .phase26-task-column > header {
  grid-template-columns: 20px auto max-content minmax(20px, 1fr);
}

html[data-locale="en-US"] body.phase26-groups .phase26-task-column > header > span:nth-of-type(2) {
  width: auto;
  min-width: 20px;
  padding-inline: 4px;
  border-radius: 999px;
  white-space: nowrap;
}

html[data-locale="en-US"] body.phase26-groups .group-directory-row {
  grid-template-columns: 38px minmax(0, 1fr);
  align-items: start;
}

html[data-locale="en-US"] body.phase26-groups .group-directory-row > .status-pill {
  grid-column: 2;
  justify-self: start;
}

@media (min-width: 1138px) and (min-height: 640px) {
  html[data-locale="en-US"] body.teacher-role-studio .profile-chip {
    max-width: 240px;
    overflow: hidden;
  }

  html[data-locale="en-US"] body.teacher-role-studio .profile-chip strong {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  html[data-locale="en-US"] body.admin-role-studio .admin-model-row {
    grid-template-columns: 36px minmax(0, 1fr) auto;
    align-items: start;
  }

  html[data-locale="en-US"] body.admin-role-studio .admin-model-row-actions {
    grid-column: 2 / -1;
    justify-content: flex-start;
    flex-wrap: wrap;
  }
}

@media (max-width: 1137px), (max-height: 639px) {
  html[data-locale="en-US"] body.teacher-role-studio .teacher-workflow-tabs {
    grid-template-columns: repeat(4, minmax(148px, 1fr));
  }

  html[data-locale="en-US"] body.role-studio .teacher-top-actions .profile-chip.account-menu-trigger {
    width: 44px !important;
    min-width: 44px !important;
    padding: 3px !important;
    display: inline-flex !important;
    flex: 0 0 44px;
    overflow: visible;
  }

  html[data-locale="en-US"] body.role-studio .teacher-top-actions .profile-chip.account-menu-trigger::after {
    display: none;
  }

  html[data-locale="en-US"] body.admin-role-studio .admin-model-row {
    grid-template-columns: 36px minmax(0, 1fr) auto;
    align-items: start;
  }

  html[data-locale="en-US"] body.admin-role-studio .admin-model-row-actions {
    grid-column: 2 / -1;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  html[data-locale="en-US"] body.admin-role-studio .admin-model-action {
    display: inline-flex;
    align-items: center;
  }

  html[data-locale="en-US"] body.admin-role-studio .admin-dialog {
    inset: 0;
    width: 100vw;
    max-width: none;
    height: 100dvh;
    max-height: 100dvh;
    margin: 0;
    overflow-x: hidden;
    overflow-y: auto;
    border-radius: 0 !important;
  }

  html[data-locale="en-US"] body.admin-role-studio .admin-dialog > form {
    min-height: 100%;
    max-height: none;
    overflow: visible;
  }

  html[data-locale="en-US"] body.role-studio .account-menu-language-option,
  html[data-locale="en-US"] body.role-studio .account-menu-item {
    min-height: 44px;
  }
}

@media (max-width: 640px) {
  html[data-locale="en-US"] [data-auth-card] .primary-button {
    gap: 8px;
    padding-inline: 18px;
  }

  html[data-locale="en-US"] [data-auth-card] .primary-button [data-submit-label] {
    white-space: nowrap;
  }

  html[data-locale="en-US"] [data-auth-card] [data-secondary-verification-field] .field-label {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
    justify-content: stretch;
    gap: 3px;
  }

  html[data-locale="en-US"] [data-auth-card] [data-secondary-verification-field] .field-label > span {
    min-width: 0;
  }
}

@media (min-width: 768px) {
  html[data-locale="en-US"] body.student-simulink-realtime .simulink-balance-card .simulink-summary-stats {
    margin-top: 10px;
  }

  html[data-locale="en-US"] body.student-simulink-realtime .simulink-balance-card .simulink-summary-stats div {
    min-height: 35px;
  }

  html[data-locale="en-US"] body.student-simulink-realtime .simulink-balance-card .simulink-health {
    margin-block: 10px;
  }
}

@media (min-width: 768px) and (max-width: 1450px) {
  html[data-locale="en-US"] body.student-simulink-realtime .simulink-import-shell {
    display: block;
    overflow-x: hidden;
    overflow-y: auto;
  }

  html[data-locale="en-US"] body.student-simulink-realtime .simulink-import-header,
  html[data-locale="en-US"] body.student-simulink-realtime .simulink-import-footer {
    min-height: 125px;
  }

  html[data-locale="en-US"] body.student-simulink-realtime .simulink-import-main {
    min-height: max-content;
  }

  html[data-locale="en-US"] body.student-simulink-realtime .simulink-import-precheck {
    height: auto;
    min-height: max-content;
  }

  html[data-locale="en-US"] body.student-simulink-realtime .simulink-sheet-list div {
    grid-template-columns: 64px minmax(120px, 1fr) auto minmax(120px, max-content);
  }

  html[data-locale="en-US"] body.student-simulink-realtime .simulink-sheet-list span {
    min-width: 0;
    white-space: normal;
  }

  html[data-locale="en-US"] body.student-simulink-realtime .simulink-import-footer > div > small {
    position: static;
    display: block;
    margin-top: 8px;
    white-space: normal;
  }
}

@media (max-width: 767px) {
  html[data-locale="en-US"] body.student-simulink-realtime .simulink-import-shell {
    display: block;
  }

  html[data-locale="en-US"] body.student-simulink-realtime .simulink-selected-file > .simulink-change-file {
    grid-column: 2;
    grid-row: 2;
  }

  html[data-locale="en-US"] body.student-simulink-realtime .simulink-selected-file > div {
    width: 100%;
    min-width: 0;
  }

  html[data-locale="en-US"] body.student-simulink-realtime .simulink-selected-file strong {
    display: block;
    width: 100%;
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
  }

  html[data-locale="en-US"] body.student-simulink-realtime .simulink-import-main {
    min-height: max-content;
  }

  html[data-locale="en-US"] body.student-simulink-realtime .simulink-import-footer > strong {
    min-width: 0;
    white-space: normal;
  }

  html[data-locale="en-US"] body.phase26-groups .phase86-task-dialog,
  html[data-locale="en-US"] body.phase26-groups .phase86-task-dialog > form,
  html[data-locale="en-US"] body.phase26-groups .phase86-task-dialog-header,
  html[data-locale="en-US"] body.phase26-groups .phase86-task-dialog-body,
  html[data-locale="en-US"] body.phase26-groups .phase86-task-dialog-footer {
    width: 100%;
    min-width: 0;
    max-width: 100vw;
  }

  html[data-locale="en-US"] body.phase26-groups .phase86-task-dialog-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    gap: 8px 12px;
  }

  html[data-locale="en-US"] body.phase26-groups .phase86-task-dialog-header > div:first-child,
  html[data-locale="en-US"] body.phase26-groups .phase86-task-header-actions {
    grid-column: 1 / -1;
  }

  html[data-locale="en-US"] body.phase26-groups .phase86-task-eyebrow {
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
  }

  html[data-locale="en-US"] body.phase26-groups .phase86-task-dialog-header p {
    max-width: none;
  }

  html[data-locale="en-US"] body.phase26-groups .phase86-task-header-actions {
    width: 100%;
    min-width: 0;
    justify-content: flex-end;
  }

  html[data-locale="en-US"] body.phase26-groups .phase86-task-status-field {
    width: 160px;
  }

  html[data-locale="en-US"] body.phase26-groups :where(.phase86-task-cancel, .phase86-task-submit) {
    min-width: 0;
    padding-inline: 8px;
    white-space: nowrap;
  }
}

/* End Phase 122 */
